aboutsummaryrefslogtreecommitdiff
path: root/test/Modules
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerDimitry Andric <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /test/Modules
parentf73d5f23a889b93d89ddef61ac0995df40286bb8 (diff)
Notes
Diffstat (limited to 'test/Modules')
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Both/a.h0
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Both/b.h1
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Both/module.map3
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Both/module.modulemap3
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h1
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/b.h1
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Modules/module.modulemap3
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Both_F.framework/module.map3
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Inferred.framework/Headers/Inferred.h0
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/a.h1
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/module.modulemap3
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Headers/a.h0
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.modulemap3
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.private.modulemap3
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/PrivateHeaders/private.h0
-rw-r--r--test/Modules/Inputs/ModuleMapLocations/module.modulemap2
-rw-r--r--test/Modules/Inputs/autolink-sub3.h1
-rw-r--r--test/Modules/Inputs/autolink-sub3.pch1
-rw-r--r--test/Modules/Inputs/c-header-bad.h4
-rw-r--r--test/Modules/Inputs/c-header.h1
-rw-r--r--test/Modules/Inputs/cxx-decls-imported.h20
-rw-r--r--test/Modules/Inputs/cxx-decls-merged.h1
-rw-r--r--test/Modules/Inputs/cxx-header.h1
-rw-r--r--test/Modules/Inputs/cxx-inline-namespace-b.h5
-rw-r--r--test/Modules/Inputs/cxx-inline-namespace.h6
-rw-r--r--test/Modules/Inputs/cxx-irgen-left.h11
-rw-r--r--test/Modules/Inputs/cxx-irgen-right.h3
-rw-r--r--test/Modules/Inputs/cxx-irgen-top.h16
-rw-r--r--test/Modules/Inputs/cxx-templates-a.h25
-rw-r--r--test/Modules/Inputs/cxx-templates-b-impl.h7
-rw-r--r--test/Modules/Inputs/cxx-templates-b.h5
-rw-r--r--test/Modules/Inputs/cxx-templates-c.h6
-rw-r--r--test/Modules/Inputs/cxx-templates-common.h27
-rw-r--r--test/Modules/Inputs/declare-use/e.h3
-rw-r--r--test/Modules/Inputs/declare-use/h.h2
-rw-r--r--test/Modules/Inputs/declare-use/i.h1
-rw-r--r--test/Modules/Inputs/declare-use/j.h14
-rw-r--r--test/Modules/Inputs/declare-use/module.map13
-rw-r--r--test/Modules/Inputs/declare-use/s.h0
-rw-r--r--test/Modules/Inputs/elsewhere/c-header-indirect.h1
-rw-r--r--test/Modules/Inputs/elsewhere/module.map1
-rw-r--r--test/Modules/Inputs/exclude-header/module.map3
-rw-r--r--test/Modules/Inputs/exclude-header/x/a.h1
-rw-r--r--test/Modules/Inputs/exclude-header/x/bad.h1
-rw-r--r--test/Modules/Inputs/exclude-header/y/b.h1
-rw-r--r--test/Modules/Inputs/include-relative/a.h1
-rw-r--r--test/Modules/Inputs/include-relative/module.map1
-rw-r--r--test/Modules/Inputs/macro-hiding/a1.h1
-rw-r--r--test/Modules/Inputs/macro-hiding/a2.h0
-rw-r--r--test/Modules/Inputs/macro-hiding/b1.h0
-rw-r--r--test/Modules/Inputs/macro-hiding/b2.h2
-rw-r--r--test/Modules/Inputs/macro-hiding/c1.h2
-rw-r--r--test/Modules/Inputs/macro-hiding/d1.h2
-rw-r--r--test/Modules/Inputs/macro-hiding/e1.h1
-rw-r--r--test/Modules/Inputs/macro-hiding/e2.h2
-rw-r--r--test/Modules/Inputs/macro-hiding/module.modulemap18
-rw-r--r--test/Modules/Inputs/macro-undef-through-pch/A.h2
-rw-r--r--test/Modules/Inputs/macro-undef-through-pch/foo.h1
-rw-r--r--test/Modules/Inputs/macro-undef-through-pch/module.map3
-rw-r--r--test/Modules/Inputs/macros_other.h7
-rw-r--r--test/Modules/Inputs/macros_right.h2
-rw-r--r--test/Modules/Inputs/macros_right_undef.h3
-rw-r--r--test/Modules/Inputs/macros_top.h8
-rw-r--r--test/Modules/Inputs/macros_top_b.h5
-rw-r--r--test/Modules/Inputs/macros_top_c.h2
-rw-r--r--test/Modules/Inputs/malformed/a1.h1
-rw-r--r--test/Modules/Inputs/malformed/a2.h1
-rw-r--r--test/Modules/Inputs/malformed/b1.h3
-rw-r--r--test/Modules/Inputs/malformed/b2.h1
-rw-r--r--test/Modules/Inputs/malformed/module.map8
-rw-r--r--test/Modules/Inputs/module.map31
-rw-r--r--test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h1
-rw-r--r--test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap4
-rw-r--r--test/Modules/Inputs/modules-with-same-name/path1/A/a.h1
-rw-r--r--test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap5
-rw-r--r--test/Modules/Inputs/modules-with-same-name/path2/A/a.h1
-rw-r--r--test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap5
-rw-r--r--test/Modules/Inputs/namespaces-left.h13
-rw-r--r--test/Modules/Inputs/namespaces-top.h4
-rw-r--r--test/Modules/Inputs/recursive1.h1
-rw-r--r--test/Modules/Inputs/recursive2.h1
-rw-r--r--test/Modules/Inputs/redecl-add-after-load-decls.h24
-rw-r--r--test/Modules/Inputs/redecl-add-after-load-top.h5
-rw-r--r--test/Modules/Inputs/redecl-add-after-load.h23
-rw-r--r--test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/AnotherModule.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/C.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h2
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap4
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h2
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap5
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h0
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap3
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap7
-rw-r--r--test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h2
-rw-r--r--test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap4
-rw-r--r--test/Modules/Inputs/require-modular-includes/NotFramework.h2
-rw-r--r--test/Modules/Inputs/require-modular-includes/NotInModule.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/module.modulemap12
-rw-r--r--test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h1
-rw-r--r--test/Modules/Inputs/require-modular-includes/umbrella/foo.h1
-rw-r--r--test/Modules/Inputs/string_names/a.h4
-rw-r--r--test/Modules/Inputs/string_names/b.h4
-rw-r--r--test/Modules/Inputs/string_names/c.h4
-rw-r--r--test/Modules/Inputs/string_names/module.map16
-rw-r--r--test/Modules/Inputs/string_names/sub.h4
-rw-r--r--test/Modules/Inputs/submodules/import-self-b.h4
-rw-r--r--test/Modules/Inputs/submodules/module.map20
-rw-r--r--test/Modules/Inputs/submodules/not_missing.h2
-rw-r--r--test/Modules/Inputs/template-specialization-visibility/a.h8
-rw-r--r--test/Modules/Inputs/template-specialization-visibility/b.h7
-rw-r--r--test/Modules/Inputs/template-specialization-visibility/c.h6
-rw-r--r--test/Modules/Inputs/template-specialization-visibility/d.h5
-rw-r--r--test/Modules/Inputs/template-specialization-visibility/e.h6
-rw-r--r--test/Modules/Inputs/template-specialization-visibility/module.map7
-rw-r--r--test/Modules/Inputs/templates-left.h27
-rw-r--r--test/Modules/Inputs/templates-right.h12
-rw-r--r--test/Modules/Inputs/templates-top.h17
-rw-r--r--test/Modules/Inputs/undefined-type-fixit/module.map9
-rw-r--r--test/Modules/Inputs/undefined-type-fixit/public1.h6
-rw-r--r--test/Modules/Inputs/undefined-type-fixit/public2.h6
-rw-r--r--test/Modules/Inputs/undefined-type-fixit/public2sub.h6
-rw-r--r--test/Modules/Inputs/unnecessary-module-map-parsing/a1.h1
-rw-r--r--test/Modules/Inputs/unnecessary-module-map-parsing/module.map3
-rw-r--r--test/Modules/Inputs/update-after-load/a.h1
-rw-r--r--test/Modules/Inputs/update-after-load/b.h2
-rw-r--r--test/Modules/Inputs/update-after-load/module.map1
-rw-r--r--test/Modules/Inputs/update-after-load/modules.timestamp0
-rw-r--r--test/Modules/Rmodule-build.m34
-rw-r--r--test/Modules/Werror-Wsystem-headers.m23
-rw-r--r--test/Modules/Werror.m75
-rw-r--r--test/Modules/auto-module-import.m6
-rw-r--r--test/Modules/autolink.m16
-rw-r--r--test/Modules/compiler_builtins_arm.m1
-rw-r--r--test/Modules/config_macros.m2
-rw-r--r--test/Modules/cxx-decls.cpp15
-rw-r--r--test/Modules/cxx-inline-namespace.cpp3
-rw-r--r--test/Modules/cxx-irgen.cpp22
-rw-r--r--test/Modules/cxx-templates.cpp54
-rw-r--r--test/Modules/declare-use.S5
-rw-r--r--test/Modules/declare-use1.cpp7
-rw-r--r--test/Modules/declare-use2.cpp4
-rw-r--r--test/Modules/declare-use3.cpp4
-rw-r--r--test/Modules/declare-use4.cpp10
-rw-r--r--test/Modules/decldef.mm43
-rw-r--r--test/Modules/dependency-dump-dependent-module.m22
-rw-r--r--test/Modules/dependency-dump.m15
-rw-r--r--test/Modules/dependency-gen-inferred-map.m8
-rw-r--r--test/Modules/dependency-gen-pch.m12
-rw-r--r--test/Modules/dependency-gen.m22
-rw-r--r--test/Modules/diag-pragma.c2
-rw-r--r--test/Modules/diamond-pch.c4
-rw-r--r--test/Modules/diamond.c2
-rw-r--r--test/Modules/exclude-header.c11
-rw-r--r--test/Modules/extern_c.cpp81
-rw-r--r--test/Modules/extern_c_bad.cpp2
-rw-r--r--test/Modules/fatal-module-loader-error.m2
-rw-r--r--test/Modules/fmodules-validate-once-per-build-session.c45
-rw-r--r--test/Modules/import-self.m11
-rw-r--r--test/Modules/include-relative.c12
-rw-r--r--test/Modules/inferred-framework-case.m7
-rw-r--r--test/Modules/irgen.c2
-rw-r--r--test/Modules/linkage-merge.cpp5
-rw-r--r--test/Modules/linkage-merge.m2
-rw-r--r--test/Modules/load-after-failure.m25
-rw-r--r--test/Modules/load_failure.c4
-rw-r--r--test/Modules/lookup.cpp4
-rw-r--r--test/Modules/lookup.m4
-rw-r--r--test/Modules/macro-hiding.cpp104
-rw-r--r--test/Modules/macro-reexport/a1.h1
-rw-r--r--test/Modules/macro-reexport/a2.h0
-rw-r--r--test/Modules/macro-reexport/b1.h0
-rw-r--r--test/Modules/macro-reexport/b2.h2
-rw-r--r--test/Modules/macro-reexport/c1.h2
-rw-r--r--test/Modules/macro-reexport/d1.h2
-rw-r--r--test/Modules/macro-reexport/d2.h1
-rw-r--r--test/Modules/macro-reexport/macro-reexport.cpp13
-rw-r--r--test/Modules/macro-reexport/module.modulemap15
-rw-r--r--test/Modules/macro-undef-through-pch.m10
-rw-r--r--test/Modules/macros.c43
-rw-r--r--test/Modules/macros2.c83
-rw-r--r--test/Modules/malformed.cpp23
-rw-r--r--test/Modules/missing-header.m13
-rw-r--r--test/Modules/missing-submodule.m7
-rw-r--r--test/Modules/module-private.cpp2
-rw-r--r--test/Modules/module_file_info.m12
-rw-r--r--test/Modules/modulemap-locations.m18
-rw-r--r--test/Modules/modules-with-same-name.m35
-rw-r--r--test/Modules/namespaces.cpp7
-rw-r--r--test/Modules/no-stale-modtime.m37
-rw-r--r--test/Modules/objc-categories.m2
-rw-r--r--test/Modules/objc_redef.m2
-rw-r--r--test/Modules/prune.m20
-rw-r--r--test/Modules/recursive.c11
-rw-r--r--test/Modules/redecl-add-after-load.cpp59
-rw-r--r--test/Modules/redecl-namespaces.mm2
-rw-r--r--test/Modules/redeclarations.m2
-rw-r--r--test/Modules/redecls/main.m6
-rw-r--r--test/Modules/renamed.m2
-rw-r--r--test/Modules/require-modular-includes.m83
-rw-r--r--test/Modules/resolution-change.m27
-rw-r--r--test/Modules/strict-decluse.cpp9
-rw-r--r--test/Modules/string_names.cpp6
-rw-r--r--test/Modules/subframework-from-intermediate-path.m5
-rw-r--r--test/Modules/submodules.cpp8
-rw-r--r--test/Modules/system_version.m6
-rw-r--r--test/Modules/template-specialization-visibility.cpp26
-rw-r--r--test/Modules/templates.mm37
-rw-r--r--test/Modules/undefined-type-fixit1.cpp12
-rw-r--r--test/Modules/unnecessary-module-map-parsing.c8
-rw-r--r--test/Modules/update-after-load.cpp8
-rw-r--r--test/Modules/validate-system-headers.m43
223 files changed, 1994 insertions, 100 deletions
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both/a.h b/test/Modules/Inputs/ModuleMapLocations/Both/a.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both/a.h
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both/b.h b/test/Modules/Inputs/ModuleMapLocations/Both/b.h
new file mode 100644
index 0000000000000..3abbd398c7e29
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both/b.h
@@ -0,0 +1 @@
+void wont_be_found1(void);
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both/module.map b/test/Modules/Inputs/ModuleMapLocations/Both/module.map
new file mode 100644
index 0000000000000..bf5aaed37ab09
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both/module.map
@@ -0,0 +1,3 @@
+module both {
+ header "b.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/Both/module.modulemap
new file mode 100644
index 0000000000000..0bfa0968c45fc
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both/module.modulemap
@@ -0,0 +1,3 @@
+module both {
+ header "a.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h
new file mode 100644
index 0000000000000..9dabfc089a154
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h
@@ -0,0 +1 @@
+void will_be_found2(void);
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/b.h b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/b.h
new file mode 100644
index 0000000000000..26169fa2f693e
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/b.h
@@ -0,0 +1 @@
+void wont_be_found2(void);
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Modules/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Modules/module.modulemap
new file mode 100644
index 0000000000000..da49ba5392f50
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Modules/module.modulemap
@@ -0,0 +1,3 @@
+framework module Both_F {
+ header "a.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/module.map b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/module.map
new file mode 100644
index 0000000000000..8fc108d3eaa76
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/module.map
@@ -0,0 +1,3 @@
+framework module Both_F {
+ header "b.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Inferred.framework/Headers/Inferred.h b/test/Modules/Inputs/ModuleMapLocations/Inferred.framework/Headers/Inferred.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Inferred.framework/Headers/Inferred.h
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/a.h b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/a.h
new file mode 100644
index 0000000000000..d571c6e4f799f
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/a.h
@@ -0,0 +1 @@
+void will_be_found1(void);
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/module.modulemap
new file mode 100644
index 0000000000000..2ac7cc52b4f3e
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/module.modulemap
@@ -0,0 +1,3 @@
+module module_modulemap {
+ header "a.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Headers/a.h b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Headers/a.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Headers/a.h
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.modulemap
new file mode 100644
index 0000000000000..400f3043e7ab3
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.modulemap
@@ -0,0 +1,3 @@
+framework module Module_ModuleMap_F {
+ header "a.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.private.modulemap b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.private.modulemap
new file mode 100644
index 0000000000000..25a469dafbe2c
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.private.modulemap
@@ -0,0 +1,3 @@
+explicit framework module Module_ModuleMap_F.Private {
+ header "private.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/PrivateHeaders/private.h b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/PrivateHeaders/private.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/PrivateHeaders/private.h
diff --git a/test/Modules/Inputs/ModuleMapLocations/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/module.modulemap
new file mode 100644
index 0000000000000..a8f5d1fbf258b
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/module.modulemap
@@ -0,0 +1,2 @@
+framework module * {
+}
diff --git a/test/Modules/Inputs/autolink-sub3.h b/test/Modules/Inputs/autolink-sub3.h
new file mode 100644
index 0000000000000..132c72976cd5d
--- /dev/null
+++ b/test/Modules/Inputs/autolink-sub3.h
@@ -0,0 +1 @@
+int autolink_sub3(void);
diff --git a/test/Modules/Inputs/autolink-sub3.pch b/test/Modules/Inputs/autolink-sub3.pch
new file mode 100644
index 0000000000000..f63b2d5b25b39
--- /dev/null
+++ b/test/Modules/Inputs/autolink-sub3.pch
@@ -0,0 +1 @@
+@import autolink.sub3;
diff --git a/test/Modules/Inputs/c-header-bad.h b/test/Modules/Inputs/c-header-bad.h
new file mode 100644
index 0000000000000..7f7cd8701ee0a
--- /dev/null
+++ b/test/Modules/Inputs/c-header-bad.h
@@ -0,0 +1,4 @@
+} // expected-error {{extraneous closing brace ('}')}}
+int not_in_extern_c;
+extern "C" { // expected-note {{to match this '{'}}
+// expected-error {{expected '}'}}
diff --git a/test/Modules/Inputs/c-header.h b/test/Modules/Inputs/c-header.h
new file mode 100644
index 0000000000000..e12f6446729d6
--- /dev/null
+++ b/test/Modules/Inputs/c-header.h
@@ -0,0 +1 @@
+int f(void);
diff --git a/test/Modules/Inputs/cxx-decls-imported.h b/test/Modules/Inputs/cxx-decls-imported.h
index b94368614dfb1..38cc00d863f2f 100644
--- a/test/Modules/Inputs/cxx-decls-imported.h
+++ b/test/Modules/Inputs/cxx-decls-imported.h
@@ -3,3 +3,23 @@ class HasFriends {
friend void friend_2(HasFriends);
void private_thing();
};
+
+struct HasNontrivialDefaultConstructor {
+ HasNontrivialDefaultConstructor() = default;
+ HasNontrivialDefaultConstructor(int n = 0);
+
+ // Ensure this class is not POD but is still trivially-copyable.
+ // This is necessary to exercise the second static_assert below,
+ // because GCC's spec for __has_trivial_constructor is absurd.
+ int m;
+private:
+ int n;
+};
+
+static_assert(!__is_trivial(HasNontrivialDefaultConstructor), "");
+static_assert(!__has_trivial_constructor(HasNontrivialDefaultConstructor), "");
+
+void *operator new[](__SIZE_TYPE__);
+
+extern int mergeUsedFlag;
+inline int getMergeUsedFlag() { return mergeUsedFlag; }
diff --git a/test/Modules/Inputs/cxx-decls-merged.h b/test/Modules/Inputs/cxx-decls-merged.h
new file mode 100644
index 0000000000000..ccc3b01548726
--- /dev/null
+++ b/test/Modules/Inputs/cxx-decls-merged.h
@@ -0,0 +1 @@
+extern int mergeUsedFlag;
diff --git a/test/Modules/Inputs/cxx-header.h b/test/Modules/Inputs/cxx-header.h
new file mode 100644
index 0000000000000..7ed7775122904
--- /dev/null
+++ b/test/Modules/Inputs/cxx-header.h
@@ -0,0 +1 @@
+int f();
diff --git a/test/Modules/Inputs/cxx-inline-namespace-b.h b/test/Modules/Inputs/cxx-inline-namespace-b.h
new file mode 100644
index 0000000000000..242a585673ae5
--- /dev/null
+++ b/test/Modules/Inputs/cxx-inline-namespace-b.h
@@ -0,0 +1,5 @@
+@import cxx_inline_namespace;
+
+struct X::Y::Z {
+ void f(struct Elaborated);
+};
diff --git a/test/Modules/Inputs/cxx-inline-namespace.h b/test/Modules/Inputs/cxx-inline-namespace.h
index 2525ad3569c05..4feb8501801eb 100644
--- a/test/Modules/Inputs/cxx-inline-namespace.h
+++ b/test/Modules/Inputs/cxx-inline-namespace.h
@@ -9,3 +9,9 @@ namespace std {
typedef int size_t;
}
}
+
+namespace X {
+ inline namespace Y {
+ struct Z;
+ }
+}
diff --git a/test/Modules/Inputs/cxx-irgen-left.h b/test/Modules/Inputs/cxx-irgen-left.h
new file mode 100644
index 0000000000000..ceb50846bbf4e
--- /dev/null
+++ b/test/Modules/Inputs/cxx-irgen-left.h
@@ -0,0 +1,11 @@
+#include "cxx-irgen-top.h"
+
+S<int> s;
+
+inline int instantiate_min() {
+ return min(1, 2);
+}
+
+inline int instantiate_CtorInit(CtorInit<int> i = CtorInit<int>()) {
+ return i.a;
+}
diff --git a/test/Modules/Inputs/cxx-irgen-right.h b/test/Modules/Inputs/cxx-irgen-right.h
new file mode 100644
index 0000000000000..4400c760f07a2
--- /dev/null
+++ b/test/Modules/Inputs/cxx-irgen-right.h
@@ -0,0 +1,3 @@
+#include "cxx-irgen-top.h"
+
+inline int h() { return S<int>::f(); }
diff --git a/test/Modules/Inputs/cxx-irgen-top.h b/test/Modules/Inputs/cxx-irgen-top.h
new file mode 100644
index 0000000000000..8753d8daa3dcd
--- /dev/null
+++ b/test/Modules/Inputs/cxx-irgen-top.h
@@ -0,0 +1,16 @@
+template<typename T> struct S {
+ __attribute__((always_inline)) static int f() { return 0; }
+ __attribute__((always_inline, visibility("hidden"))) static int g() { return 0; }
+};
+
+extern template struct S<int>;
+
+template<typename T> T min(T a, T b) { return a < b ? a : b; }
+
+extern decltype(min(1, 2)) instantiate_min_decl;
+
+template<typename T> struct CtorInit {
+ static int f() { return 0; }
+ int a;
+ CtorInit() : a(f()) {}
+};
diff --git a/test/Modules/Inputs/cxx-templates-a.h b/test/Modules/Inputs/cxx-templates-a.h
index 0b1614d3d9e68..c95dc6325e499 100644
--- a/test/Modules/Inputs/cxx-templates-a.h
+++ b/test/Modules/Inputs/cxx-templates-a.h
@@ -48,3 +48,28 @@ template<typename T> struct MergeSpecializations<T*> {
template<> struct MergeSpecializations<char> {
typedef int explicitly_specialized_in_a;
};
+
+void InstantiateWithFriend(Std::WithFriend<int> wfi) {}
+
+template<typename T> struct WithPartialSpecialization<T*> {
+ typedef int type;
+ T &f() { static T t; return t; }
+};
+typedef WithPartialSpecializationUse::type WithPartialSpecializationInstantiate;
+
+template<> struct WithExplicitSpecialization<int> {
+ int n;
+ template<typename T> T &inner_template() {
+ return n;
+ }
+};
+
+template<typename T> template<typename U>
+constexpr int Outer<T>::Inner<U>::f() { return 1; }
+static_assert(Outer<int>::Inner<int>::f() == 1, "");
+
+template<typename T> struct MergeTemplateDefinitions {
+ static constexpr int f();
+ static constexpr int g();
+};
+template<typename T> constexpr int MergeTemplateDefinitions<T>::f() { return 1; }
diff --git a/test/Modules/Inputs/cxx-templates-b-impl.h b/test/Modules/Inputs/cxx-templates-b-impl.h
index fdf4a4fbc4d4f..93d057433dd3f 100644
--- a/test/Modules/Inputs/cxx-templates-b-impl.h
+++ b/test/Modules/Inputs/cxx-templates-b-impl.h
@@ -3,3 +3,10 @@ struct DefinedInBImpl {
struct Inner {};
friend void FoundByADL(DefinedInBImpl);
};
+
+@import cxx_templates_common;
+template struct TemplateInstantiationVisibility<char[1]>;
+extern template struct TemplateInstantiationVisibility<char[2]>;
+template<> struct TemplateInstantiationVisibility<char[3]> {};
+extern TemplateInstantiationVisibility<char[4]>::type
+ TemplateInstantiationVisibility_ImplicitInstantiation;
diff --git a/test/Modules/Inputs/cxx-templates-b.h b/test/Modules/Inputs/cxx-templates-b.h
index 6cd83faf1a1bd..efd07c617e528 100644
--- a/test/Modules/Inputs/cxx-templates-b.h
+++ b/test/Modules/Inputs/cxx-templates-b.h
@@ -20,6 +20,10 @@ extern DefinedInCommon &defined_in_common;
template<int> struct MergeTemplates;
MergeTemplates<0> *merge_templates_b;
+template<typename T> template<typename U>
+constexpr int Outer<T>::Inner<U>::g() { return 2; }
+static_assert(Outer<int>::Inner<int>::g() == 2, "");
+
@import cxx_templates_b_impl;
template<typename T, typename> struct Identity { typedef T type; };
@@ -66,4 +70,5 @@ template<typename T> void UseDefinedInBImplIndirectly(T &v) {
void TriggerInstantiation() {
UseDefinedInBImpl<void>();
+ Std::f<int>();
}
diff --git a/test/Modules/Inputs/cxx-templates-c.h b/test/Modules/Inputs/cxx-templates-c.h
index 4c0fc8a4a8257..6daffadc6cede 100644
--- a/test/Modules/Inputs/cxx-templates-c.h
+++ b/test/Modules/Inputs/cxx-templates-c.h
@@ -5,3 +5,9 @@ template<typename T> struct MergeSpecializations<T[]> {
template<> struct MergeSpecializations<bool> {
typedef int explicitly_specialized_in_c;
};
+
+template<typename T> struct MergeTemplateDefinitions {
+ static constexpr int f();
+ static constexpr int g();
+};
+template<typename T> constexpr int MergeTemplateDefinitions<T>::g() { return 2; }
diff --git a/test/Modules/Inputs/cxx-templates-common.h b/test/Modules/Inputs/cxx-templates-common.h
index 40a11e20b4f0a..682ef939cec0f 100644
--- a/test/Modules/Inputs/cxx-templates-common.h
+++ b/test/Modules/Inputs/cxx-templates-common.h
@@ -9,3 +9,30 @@ struct DefinedInCommon {
template<typename T> struct CommonTemplate {
enum E { a = 1, b = 2, c = 3 };
};
+
+namespace Std {
+ template<typename T> struct WithFriend {
+ friend bool operator!=(const WithFriend &A, const WithFriend &B) { return false; }
+ };
+}
+
+namespace Std {
+ template<typename T> void f() {
+ extern T g();
+ }
+}
+
+template<typename T> struct TemplateInstantiationVisibility { typedef int type; };
+
+template<typename T> struct Outer {
+ template<typename U> struct Inner {
+ static constexpr int f();
+ static constexpr int g();
+ };
+};
+
+template<typename T> struct WithPartialSpecialization {};
+typedef WithPartialSpecialization<int*> WithPartialSpecializationUse;
+
+template<typename T> struct WithExplicitSpecialization;
+typedef WithExplicitSpecialization<int> WithExplicitSpecializationUse;
diff --git a/test/Modules/Inputs/declare-use/e.h b/test/Modules/Inputs/declare-use/e.h
index ed8d843f9a852..31247f7f9c7d6 100644
--- a/test/Modules/Inputs/declare-use/e.h
+++ b/test/Modules/Inputs/declare-use/e.h
@@ -1,6 +1,7 @@
#ifndef E_H
#define E_H
-#include "a.h"
+#define HEADER "a.h"
+#include HEADER
#include "b.h"
const int e = a*b;
#endif
diff --git a/test/Modules/Inputs/declare-use/h.h b/test/Modules/Inputs/declare-use/h.h
index df99a6dd10ae9..379e50180ca19 100644
--- a/test/Modules/Inputs/declare-use/h.h
+++ b/test/Modules/Inputs/declare-use/h.h
@@ -1,7 +1,7 @@
#ifndef H_H
#define H_H
#include "c.h"
-#include "d.h" // expected-error {{use of a module not declared used}}
+#include "d.h" // expected-error {{does not depend on a module exporting}}
#include "h1.h"
const int h1 = aux_h*c*7*d;
#endif
diff --git a/test/Modules/Inputs/declare-use/i.h b/test/Modules/Inputs/declare-use/i.h
new file mode 100644
index 0000000000000..30e7ded79b791
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/i.h
@@ -0,0 +1 @@
+int aux_i = 13;
diff --git a/test/Modules/Inputs/declare-use/j.h b/test/Modules/Inputs/declare-use/j.h
new file mode 100644
index 0000000000000..04d46a9fb2b7d
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/j.h
@@ -0,0 +1,14 @@
+#ifndef J_H
+#define J_H
+
+#define STR(x) #x
+#define HDR(x) STR(x.h)
+
+#include ALLOWED_INC
+#include HDR(a)
+
+const int j = a * a + b;
+
+// expected-no-diagnostics
+
+#endif
diff --git a/test/Modules/Inputs/declare-use/module.map b/test/Modules/Inputs/declare-use/module.map
index 774fc37760c9c..a176fb3a141fc 100644
--- a/test/Modules/Inputs/declare-use/module.map
+++ b/test/Modules/Inputs/declare-use/module.map
@@ -9,21 +9,25 @@ module XB {
module XC {
header "c.h"
use XA
+ // Intentionally doesn't use XB to show that -fdecl-use isn't transitive.
}
module XD {
header "d.h"
use XA
+ // Intentionally doesn't use XB to show that -fdecl-use isn't transitive.
}
module XE {
header "e.h"
+ header "unavailable.h"
use XA
use XB
}
module XF {
header "f.h"
+ header "unavailable.h"
use XA
use XB
}
@@ -33,11 +37,20 @@ module XG {
header "g1.h"
use XC
use XE
+ use XJ
}
module XH {
header "h.h"
header "h1.h"
+ header "s.h"
use XC
use XE
}
+
+module XJ {
+ header "j.h"
+}
+
+module XS {
+}
diff --git a/test/Modules/Inputs/declare-use/s.h b/test/Modules/Inputs/declare-use/s.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/s.h
diff --git a/test/Modules/Inputs/elsewhere/c-header-indirect.h b/test/Modules/Inputs/elsewhere/c-header-indirect.h
new file mode 100644
index 0000000000000..083c41f77c5eb
--- /dev/null
+++ b/test/Modules/Inputs/elsewhere/c-header-indirect.h
@@ -0,0 +1 @@
+#include "c-header.h"
diff --git a/test/Modules/Inputs/elsewhere/module.map b/test/Modules/Inputs/elsewhere/module.map
new file mode 100644
index 0000000000000..2c56820676aa2
--- /dev/null
+++ b/test/Modules/Inputs/elsewhere/module.map
@@ -0,0 +1 @@
+module c_library_indirect { header "c-header-indirect.h" }
diff --git a/test/Modules/Inputs/exclude-header/module.map b/test/Modules/Inputs/exclude-header/module.map
new file mode 100644
index 0000000000000..2563ef9dc9cd3
--- /dev/null
+++ b/test/Modules/Inputs/exclude-header/module.map
@@ -0,0 +1,3 @@
+module x { umbrella "x" exclude header "x/bad.h" module * {} }
+module y { umbrella "y" module * {} }
+module bad { header "x/bad.h" }
diff --git a/test/Modules/Inputs/exclude-header/x/a.h b/test/Modules/Inputs/exclude-header/x/a.h
new file mode 100644
index 0000000000000..389d285a45827
--- /dev/null
+++ b/test/Modules/Inputs/exclude-header/x/a.h
@@ -0,0 +1 @@
+typedef int a;
diff --git a/test/Modules/Inputs/exclude-header/x/bad.h b/test/Modules/Inputs/exclude-header/x/bad.h
new file mode 100644
index 0000000000000..179ef267be223
--- /dev/null
+++ b/test/Modules/Inputs/exclude-header/x/bad.h
@@ -0,0 +1 @@
+#error bad
diff --git a/test/Modules/Inputs/exclude-header/y/b.h b/test/Modules/Inputs/exclude-header/y/b.h
new file mode 100644
index 0000000000000..a16836aac77fc
--- /dev/null
+++ b/test/Modules/Inputs/exclude-header/y/b.h
@@ -0,0 +1 @@
+typedef int b;
diff --git a/test/Modules/Inputs/include-relative/a.h b/test/Modules/Inputs/include-relative/a.h
new file mode 100644
index 0000000000000..b95284b323b28
--- /dev/null
+++ b/test/Modules/Inputs/include-relative/a.h
@@ -0,0 +1 @@
+extern int n;
diff --git a/test/Modules/Inputs/include-relative/module.map b/test/Modules/Inputs/include-relative/module.map
new file mode 100644
index 0000000000000..bb00c840ce39d
--- /dev/null
+++ b/test/Modules/Inputs/include-relative/module.map
@@ -0,0 +1 @@
+module a { header "a.h" }
diff --git a/test/Modules/Inputs/macro-hiding/a1.h b/test/Modules/Inputs/macro-hiding/a1.h
new file mode 100644
index 0000000000000..b17c8eeb69ab9
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/a1.h
@@ -0,0 +1 @@
+#define assert(x)
diff --git a/test/Modules/Inputs/macro-hiding/a2.h b/test/Modules/Inputs/macro-hiding/a2.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/a2.h
diff --git a/test/Modules/Inputs/macro-hiding/b1.h b/test/Modules/Inputs/macro-hiding/b1.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/b1.h
diff --git a/test/Modules/Inputs/macro-hiding/b2.h b/test/Modules/Inputs/macro-hiding/b2.h
new file mode 100644
index 0000000000000..83918489e92eb
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/b2.h
@@ -0,0 +1,2 @@
+#include "a2.h"
+#define assert(x)
diff --git a/test/Modules/Inputs/macro-hiding/c1.h b/test/Modules/Inputs/macro-hiding/c1.h
new file mode 100644
index 0000000000000..4b78b3c273431
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/c1.h
@@ -0,0 +1,2 @@
+#include "b1.h"
+#define assert(x)
diff --git a/test/Modules/Inputs/macro-hiding/d1.h b/test/Modules/Inputs/macro-hiding/d1.h
new file mode 100644
index 0000000000000..83918489e92eb
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/d1.h
@@ -0,0 +1,2 @@
+#include "a2.h"
+#define assert(x)
diff --git a/test/Modules/Inputs/macro-hiding/e1.h b/test/Modules/Inputs/macro-hiding/e1.h
new file mode 100644
index 0000000000000..bd01708c5e32e
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/e1.h
@@ -0,0 +1 @@
+#include "a1.h"
diff --git a/test/Modules/Inputs/macro-hiding/e2.h b/test/Modules/Inputs/macro-hiding/e2.h
new file mode 100644
index 0000000000000..f3a49c70aeae0
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/e2.h
@@ -0,0 +1,2 @@
+#include "a1.h"
+inline void e1() { assert(true); }
diff --git a/test/Modules/Inputs/macro-hiding/module.modulemap b/test/Modules/Inputs/macro-hiding/module.modulemap
new file mode 100644
index 0000000000000..20632d35aebc0
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/module.modulemap
@@ -0,0 +1,18 @@
+module a {
+ module a1 { header "a1.h" export * }
+ module a2 { header "a2.h" export * }
+}
+module b {
+ module b1 { header "b1.h" export * }
+ module b2 { header "b2.h" export * }
+}
+module c {
+ module c1 { header "c1.h" export * }
+}
+module d {
+ module d1 { header "d1.h" export * }
+}
+module e {
+ module e1 { header "e1.h" export * }
+ module e2 { header "e2.h" export * }
+}
diff --git a/test/Modules/Inputs/macro-undef-through-pch/A.h b/test/Modules/Inputs/macro-undef-through-pch/A.h
new file mode 100644
index 0000000000000..6a2cc5cf6c2e3
--- /dev/null
+++ b/test/Modules/Inputs/macro-undef-through-pch/A.h
@@ -0,0 +1,2 @@
+#define AB
+#undef AB
diff --git a/test/Modules/Inputs/macro-undef-through-pch/foo.h b/test/Modules/Inputs/macro-undef-through-pch/foo.h
new file mode 100644
index 0000000000000..9d0256bdff2e4
--- /dev/null
+++ b/test/Modules/Inputs/macro-undef-through-pch/foo.h
@@ -0,0 +1 @@
+@import A;
diff --git a/test/Modules/Inputs/macro-undef-through-pch/module.map b/test/Modules/Inputs/macro-undef-through-pch/module.map
new file mode 100644
index 0000000000000..63f68ca5033a9
--- /dev/null
+++ b/test/Modules/Inputs/macro-undef-through-pch/module.map
@@ -0,0 +1,3 @@
+module A {
+ header "A.h"
+}
diff --git a/test/Modules/Inputs/macros_other.h b/test/Modules/Inputs/macros_other.h
index ea686bfc558aa..4923a7fe56aa8 100644
--- a/test/Modules/Inputs/macros_other.h
+++ b/test/Modules/Inputs/macros_other.h
@@ -1 +1,6 @@
-#define OTHER_INTEGER int
+#undef TOP_OTHER_UNDEF1
+#define TOP_OTHER_UNDEF2 42
+#define TOP_OTHER_REDEF1 1
+#define TOP_OTHER_REDEF1 3
+
+#define TOP_OTHER_DEF_RIGHT_UNDEF 4
diff --git a/test/Modules/Inputs/macros_right.h b/test/Modules/Inputs/macros_right.h
index dbbd2c3643503..a70c3501e5c9f 100644
--- a/test/Modules/Inputs/macros_right.h
+++ b/test/Modules/Inputs/macros_right.h
@@ -17,3 +17,5 @@
#define TOP_RIGHT_REDEF float
#define FN_ADD(x, y) (x+y)
+
+#undef TOP_OTHER_DEF_RIGHT_UNDEF
diff --git a/test/Modules/Inputs/macros_right_undef.h b/test/Modules/Inputs/macros_right_undef.h
index 49473e36f0cbb..15a83666a1369 100644
--- a/test/Modules/Inputs/macros_right_undef.h
+++ b/test/Modules/Inputs/macros_right_undef.h
@@ -1 +1,4 @@
#undef TOP_RIGHT_UNDEF
+
+@import macros_top;
+#undef TOP_OTHER_DEF_RIGHT_UNDEF
diff --git a/test/Modules/Inputs/macros_top.h b/test/Modules/Inputs/macros_top.h
index dd303ffee4e15..10935043e2a16 100644
--- a/test/Modules/Inputs/macros_top.h
+++ b/test/Modules/Inputs/macros_top.h
@@ -14,3 +14,11 @@
#define TOP_RIGHT_UNDEF int
+#define TOP_OTHER_UNDEF1 42
+#undef TOP_OTHER_UNDEF2
+#define TOP_OTHER_REDEF1 1
+#define TOP_OTHER_REDEF2 2
+
+#define TOP_OTHER_DEF_RIGHT_UNDEF void
+
+#define TOP_REDEF_IN_SUBMODULES 0
diff --git a/test/Modules/Inputs/macros_top_b.h b/test/Modules/Inputs/macros_top_b.h
new file mode 100644
index 0000000000000..cfee17cb58746
--- /dev/null
+++ b/test/Modules/Inputs/macros_top_b.h
@@ -0,0 +1,5 @@
+#include "macros_top.h"
+#undef TOP_REDEF_IN_SUBMODULES
+#define TOP_REDEF_IN_SUBMODULES 1
+#undef TOP_REDEF_IN_SUBMODULES
+#define TOP_REDEF_IN_SUBMODULES 2
diff --git a/test/Modules/Inputs/macros_top_c.h b/test/Modules/Inputs/macros_top_c.h
new file mode 100644
index 0000000000000..aee82462131a0
--- /dev/null
+++ b/test/Modules/Inputs/macros_top_c.h
@@ -0,0 +1,2 @@
+#include "macros_top_b.h"
+#undef TOP_REDEF_IN_SUBMODULES
diff --git a/test/Modules/Inputs/malformed/a1.h b/test/Modules/Inputs/malformed/a1.h
new file mode 100644
index 0000000000000..400b916e211dc
--- /dev/null
+++ b/test/Modules/Inputs/malformed/a1.h
@@ -0,0 +1 @@
+void f() {
diff --git a/test/Modules/Inputs/malformed/a2.h b/test/Modules/Inputs/malformed/a2.h
new file mode 100644
index 0000000000000..5c34318c2147f
--- /dev/null
+++ b/test/Modules/Inputs/malformed/a2.h
@@ -0,0 +1 @@
+}
diff --git a/test/Modules/Inputs/malformed/b1.h b/test/Modules/Inputs/malformed/b1.h
new file mode 100644
index 0000000000000..3d98bc1b55f0d
--- /dev/null
+++ b/test/Modules/Inputs/malformed/b1.h
@@ -0,0 +1,3 @@
+struct S {
+ #include "b2.h"
+};
diff --git a/test/Modules/Inputs/malformed/b2.h b/test/Modules/Inputs/malformed/b2.h
new file mode 100644
index 0000000000000..7fc5340164074
--- /dev/null
+++ b/test/Modules/Inputs/malformed/b2.h
@@ -0,0 +1 @@
+void g() {}
diff --git a/test/Modules/Inputs/malformed/module.map b/test/Modules/Inputs/malformed/module.map
new file mode 100644
index 0000000000000..5277ffa41edd0
--- /dev/null
+++ b/test/Modules/Inputs/malformed/module.map
@@ -0,0 +1,8 @@
+module malformed_a {
+ module a1 { header "a1.h" }
+ module a2 { header "a2.h" }
+}
+module malformed_b {
+ module b1 { header "b1.h" }
+ module b2 { header "b2.h" }
+}
diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map
index cf8a298ccee72..fea12015233b6 100644
--- a/test/Modules/Inputs/module.map
+++ b/test/Modules/Inputs/module.map
@@ -1,3 +1,6 @@
+module c_library [extern_c] { module inner { header "c-header.h" } }
+module cxx_library { header "cxx-header.h" requires cplusplus }
+module c_library_bad [extern_c] { header "c-header-bad.h" }
module diamond_top { header "diamond_top.h" }
module diamond_left {
header "diamond_left.h"
@@ -12,6 +15,9 @@ module diamond_bottom {
export *
}
module irgen { header "irgen.h" }
+module cxx_irgen_top { header "cxx-irgen-top.h" }
+module cxx_irgen_left { header "cxx-irgen-left.h" }
+module cxx_irgen_right { header "cxx-irgen-right.h" }
module lookup_left_objc { header "lookup_left.h" }
module lookup_right_objc { header "lookup_right.h" }
module lookup_left_cxx { header "lookup_left.hpp" }
@@ -20,6 +26,8 @@ module module_private_left { header "module_private_left.h" }
module module_private_right { header "module_private_right.h" }
module macros_top {
header "macros_top.h"
+ explicit module b { header "macros_top_b.h" }
+ explicit module c { header "macros_top_c.h" }
}
module macros_left {
header "macros_left.h"
@@ -33,6 +41,7 @@ module macros_right {
}
}
module macros { header "macros.h" }
+module macros_other { header "macros_other.h" }
module category_top { header "category_top.h" }
module category_left {
header "category_left.h"
@@ -60,6 +69,9 @@ module redeclarations_left { header "redeclarations_left.h" }
module redeclarations_right { header "redeclarations_right.h" }
module redecl_namespaces_left { header "redecl_namespaces_left.h" }
module redecl_namespaces_right { header "redecl_namespaces_right.h" }
+module redecl_add_after_load_top { header "redecl-add-after-load-top.h" }
+module redecl_add_after_load_decls { header "redecl-add-after-load-decls.h" }
+module redecl_add_after_load { header "redecl-add-after-load.h" }
module load_failure { header "load_failure.h" }
module decldef {
@@ -166,6 +178,11 @@ module autolink {
header "autolink-sub2.h"
link framework "autolink_framework"
}
+
+ explicit module sub3 {
+ header "autolink-sub3.h"
+ link "autolink_from_pch"
+ }
}
module weird_objc {
@@ -184,6 +201,10 @@ module cxx_inline_namespace {
header "cxx-inline-namespace.h"
}
+module cxx_inline_namespace_b {
+ header "cxx-inline-namespace-b.h"
+}
+
module cxx_linkage_cache {
header "cxx-linkage-cache.h"
}
@@ -217,6 +238,10 @@ module cxx_decls {
}
}
+module cxx_decls_merged {
+ header "cxx-decls-merged.h"
+}
+
module config {
header "config.h"
config_macros [exhaustive] WANT_FOO, WANT_BAR
@@ -281,3 +306,9 @@ module recursive_visibility_b {
module recursive_visibility_c {
header "recursive_visibility_c.h"
}
+module recursive1 {
+ header "recursive1.h"
+}
+module recursive2 {
+ header "recursive2.h"
+}
diff --git a/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h b/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h
new file mode 100644
index 0000000000000..9d0256bdff2e4
--- /dev/null
+++ b/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h
@@ -0,0 +1 @@
+@import A;
diff --git a/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap b/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap
new file mode 100644
index 0000000000000..b2a027b55d74d
--- /dev/null
+++ b/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap
@@ -0,0 +1,4 @@
+module DependsOnA {
+ header "DependsOnA.h"
+ export *
+}
diff --git a/test/Modules/Inputs/modules-with-same-name/path1/A/a.h b/test/Modules/Inputs/modules-with-same-name/path1/A/a.h
new file mode 100644
index 0000000000000..0086e2a2504ce
--- /dev/null
+++ b/test/Modules/Inputs/modules-with-same-name/path1/A/a.h
@@ -0,0 +1 @@
+#define FROM_PATH 1
diff --git a/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap b/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap
new file mode 100644
index 0000000000000..76c3358335fc5
--- /dev/null
+++ b/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap
@@ -0,0 +1,5 @@
+// path1. This comment keeps this file from being identical to
+// path2/A/module.modulemap.
+module A {
+ header "a.h"
+}
diff --git a/test/Modules/Inputs/modules-with-same-name/path2/A/a.h b/test/Modules/Inputs/modules-with-same-name/path2/A/a.h
new file mode 100644
index 0000000000000..184c190bcbc47
--- /dev/null
+++ b/test/Modules/Inputs/modules-with-same-name/path2/A/a.h
@@ -0,0 +1 @@
+#define FROM_PATH 2
diff --git a/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap b/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap
new file mode 100644
index 0000000000000..2ff394378e72c
--- /dev/null
+++ b/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap
@@ -0,0 +1,5 @@
+// path2. This comment keeps this file from being identical to
+// path1/A/module.modulemap.
+module A {
+ header "a.h"
+}
diff --git a/test/Modules/Inputs/namespaces-left.h b/test/Modules/Inputs/namespaces-left.h
index bd192afd2e897..787fe753fba97 100644
--- a/test/Modules/Inputs/namespaces-left.h
+++ b/test/Modules/Inputs/namespaces-left.h
@@ -1,5 +1,18 @@
+namespace RedeclAcrossImport {
+ enum E { e };
+}
+
+namespace AddAndReexportBeforeImport {
+ struct S {};
+ extern struct S t;
+}
+
@import namespaces_top;
+namespace RedeclAcrossImport {
+ E x = e;
+}
+
float &global(float);
float &global2(float);
diff --git a/test/Modules/Inputs/namespaces-top.h b/test/Modules/Inputs/namespaces-top.h
index 7aa8490eb7e18..7bf5394f55bee 100644
--- a/test/Modules/Inputs/namespaces-top.h
+++ b/test/Modules/Inputs/namespaces-top.h
@@ -17,3 +17,7 @@ namespace N13 {
int f(int);
void (*p)() = &f;
}
+
+namespace AddAndReexportBeforeImport {
+ int S;
+}
diff --git a/test/Modules/Inputs/recursive1.h b/test/Modules/Inputs/recursive1.h
new file mode 100644
index 0000000000000..8cb591739726e
--- /dev/null
+++ b/test/Modules/Inputs/recursive1.h
@@ -0,0 +1 @@
+#include "recursive2.h"
diff --git a/test/Modules/Inputs/recursive2.h b/test/Modules/Inputs/recursive2.h
new file mode 100644
index 0000000000000..d9480aa1e14af
--- /dev/null
+++ b/test/Modules/Inputs/recursive2.h
@@ -0,0 +1 @@
+#include "recursive1.h"
diff --git a/test/Modules/Inputs/redecl-add-after-load-decls.h b/test/Modules/Inputs/redecl-add-after-load-decls.h
new file mode 100644
index 0000000000000..fbe6b9387a170
--- /dev/null
+++ b/test/Modules/Inputs/redecl-add-after-load-decls.h
@@ -0,0 +1,24 @@
+typedef struct A B;
+extern const int variable;
+extern constexpr int function();
+constexpr int test(bool b) { return b ? variable : function(); }
+
+namespace N {
+ typedef struct A B;
+ extern const int variable;
+ extern constexpr int function();
+}
+typedef N::B NB;
+constexpr int N_test(bool b) { return b ? N::variable : N::function(); }
+
+@import redecl_add_after_load_top;
+typedef C::A CB;
+constexpr int C_test(bool b) { return b ? C::variable : C::function(); }
+
+struct D {
+ struct A; // expected-note {{forward}}
+ static const int variable;
+ static constexpr int function(); // expected-note {{here}}
+};
+typedef D::A DB;
+constexpr int D_test(bool b) { return b ? D::variable : D::function(); } // expected-note {{subexpression}} expected-note {{undefined}}
diff --git a/test/Modules/Inputs/redecl-add-after-load-top.h b/test/Modules/Inputs/redecl-add-after-load-top.h
new file mode 100644
index 0000000000000..638fb013cd7ed
--- /dev/null
+++ b/test/Modules/Inputs/redecl-add-after-load-top.h
@@ -0,0 +1,5 @@
+struct C {
+ struct A;
+ static const int variable;
+ static constexpr int function();
+};
diff --git a/test/Modules/Inputs/redecl-add-after-load.h b/test/Modules/Inputs/redecl-add-after-load.h
new file mode 100644
index 0000000000000..6951a76289f0f
--- /dev/null
+++ b/test/Modules/Inputs/redecl-add-after-load.h
@@ -0,0 +1,23 @@
+struct A {};
+extern const int variable = 0;
+extern constexpr int function() { return 0; }
+
+namespace N {
+ struct A {};
+ extern const int variable = 0;
+ extern constexpr int function() { return 0; }
+}
+
+@import redecl_add_after_load_top;
+struct C::A {};
+const int C::variable = 0;
+constexpr int C::function() { return 0; }
+
+struct D {
+ struct A;
+ static const int variable;
+ static constexpr int function();
+};
+struct D::A {};
+const int D::variable = 0;
+constexpr int D::function() { return 0; }
diff --git a/test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h b/test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h
new file mode 100644
index 0000000000000..fad91bdbfd0d2
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h
@@ -0,0 +1 @@
+#include "B/B.h"
diff --git a/test/Modules/Inputs/require-modular-includes/AnotherModule.h b/test/Modules/Inputs/require-modular-includes/AnotherModule.h
new file mode 100644
index 0000000000000..96913aa22acee
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/AnotherModule.h
@@ -0,0 +1 @@
+// AnotherModule.h
diff --git a/test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h b/test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h
new file mode 100644
index 0000000000000..b539dd9ba9c91
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h
@@ -0,0 +1 @@
+// AnotherModuleExcluded.h
diff --git a/test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h b/test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h
new file mode 100644
index 0000000000000..77d6ff1e5f471
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h
@@ -0,0 +1 @@
+#include "C.h"
diff --git a/test/Modules/Inputs/require-modular-includes/C.h b/test/Modules/Inputs/require-modular-includes/C.h
new file mode 100644
index 0000000000000..a0121d46b41f8
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/C.h
@@ -0,0 +1 @@
+// C.h
diff --git a/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h b/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h
new file mode 100644
index 0000000000000..0c0ce7bb560ab
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h
@@ -0,0 +1 @@
+#include "AnotherModuleExcluded.h"
diff --git a/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h b/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h
new file mode 100644
index 0000000000000..1fe5c08aceef2
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h
@@ -0,0 +1 @@
+#include "AnotherModule.h"
diff --git a/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h b/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h
new file mode 100644
index 0000000000000..a80bcc6945b73
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h
@@ -0,0 +1,2 @@
+// FromImportedModuleFail.h
+#include "NotInModule.h"
diff --git a/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h b/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h
new file mode 100644
index 0000000000000..3b2056c45494b
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h
@@ -0,0 +1 @@
+#include "FromImportedModuleOK2.h"
diff --git a/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h b/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h
new file mode 100644
index 0000000000000..775fd6e4d82a8
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h
@@ -0,0 +1 @@
+// FromImportedModuleOK2.h
diff --git a/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap b/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap
new file mode 100644
index 0000000000000..26381110d20de
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module FromImportedModuleOK {
+ header "FromImportedModuleOK.h"
+ header "FromImportedModuleOK2.h"
+}
diff --git a/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h b/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h
new file mode 100644
index 0000000000000..613cd9d68168d
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h
@@ -0,0 +1,2 @@
+// Header.h
+#include "NotInModule.h"
diff --git a/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap b/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap
new file mode 100644
index 0000000000000..c07efec72b890
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap
@@ -0,0 +1,5 @@
+framework module FromImportedSubModule {
+ module Sub {
+ header "Header.h"
+ }
+}
diff --git a/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h b/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h
diff --git a/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h b/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h
new file mode 100644
index 0000000000000..4680be4a37ae8
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h
@@ -0,0 +1 @@
+#include "Subframework/Subframework.h"
diff --git a/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap b/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap
new file mode 100644
index 0000000000000..c308ea429bd50
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap
@@ -0,0 +1,3 @@
+framework module FromNonModularSubframework {
+ header "FromNonModularSubframework.h"
+}
diff --git a/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h b/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h
new file mode 100644
index 0000000000000..c08fac0b55f47
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h
@@ -0,0 +1 @@
+// Subframework.h
diff --git a/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h b/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h
new file mode 100644
index 0000000000000..4680be4a37ae8
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h
@@ -0,0 +1 @@
+#include "Subframework/Subframework.h"
diff --git a/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap b/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap
new file mode 100644
index 0000000000000..250f05ace0d12
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap
@@ -0,0 +1,7 @@
+framework module FromSubframework {
+ umbrella header "FromSubframework.h"
+
+ framework module Subframework {
+ umbrella header "Subframework.h"
+ }
+}
diff --git a/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h b/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h
new file mode 100644
index 0000000000000..f6f891f53f31c
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h
@@ -0,0 +1,2 @@
+#include "umbrella/foo.h"
+#include "umbrella/bar/bar.h"
diff --git a/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h b/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h
new file mode 100644
index 0000000000000..f330e6c0ecd24
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h
@@ -0,0 +1 @@
+// Excluded.h
diff --git a/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h b/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h
new file mode 100644
index 0000000000000..f2ffdc327ed90
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h
@@ -0,0 +1 @@
+#include "Excluded.h"
diff --git a/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap b/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap
new file mode 100644
index 0000000000000..a1753539bd1f8
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module IncludeExcluded {
+ header "IncludeExcluded.h"
+ exclude header "Excluded.h"
+}
diff --git a/test/Modules/Inputs/require-modular-includes/NotFramework.h b/test/Modules/Inputs/require-modular-includes/NotFramework.h
new file mode 100644
index 0000000000000..3afd8fc64a020
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/NotFramework.h
@@ -0,0 +1,2 @@
+// NotFramework.h
+#import "NotInModule.h"
diff --git a/test/Modules/Inputs/require-modular-includes/NotInModule.h b/test/Modules/Inputs/require-modular-includes/NotInModule.h
new file mode 100644
index 0000000000000..c2a626cab92ec
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/NotInModule.h
@@ -0,0 +1 @@
+// NotInModule.h
diff --git a/test/Modules/Inputs/require-modular-includes/module.modulemap b/test/Modules/Inputs/require-modular-includes/module.modulemap
new file mode 100644
index 0000000000000..0ac4d5b7030da
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/module.modulemap
@@ -0,0 +1,12 @@
+module AnotherModule {
+ header "AnotherModule.h"
+ exclude header "AnotherModuleExcluded.h"
+}
+module Umbrella {
+ umbrella "umbrella"
+}
+module NotFramework {
+ header "NotFramework.h"
+}
+
+framework module * { }
diff --git a/test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h b/test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h
new file mode 100644
index 0000000000000..410aba263906e
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h
@@ -0,0 +1 @@
+// bar.h
diff --git a/test/Modules/Inputs/require-modular-includes/umbrella/foo.h b/test/Modules/Inputs/require-modular-includes/umbrella/foo.h
new file mode 100644
index 0000000000000..249664863bd2e
--- /dev/null
+++ b/test/Modules/Inputs/require-modular-includes/umbrella/foo.h
@@ -0,0 +1 @@
+// foo.h
diff --git a/test/Modules/Inputs/string_names/a.h b/test/Modules/Inputs/string_names/a.h
new file mode 100644
index 0000000000000..a36dc1b59d6f9
--- /dev/null
+++ b/test/Modules/Inputs/string_names/a.h
@@ -0,0 +1,4 @@
+#ifndef A_H
+#define A_H
+const int a = 2;
+#endif
diff --git a/test/Modules/Inputs/string_names/b.h b/test/Modules/Inputs/string_names/b.h
new file mode 100644
index 0000000000000..55daf7286801c
--- /dev/null
+++ b/test/Modules/Inputs/string_names/b.h
@@ -0,0 +1,4 @@
+#ifndef B_H
+#define B_H
+const int b = 3;
+#endif
diff --git a/test/Modules/Inputs/string_names/c.h b/test/Modules/Inputs/string_names/c.h
new file mode 100644
index 0000000000000..38c278fc87d2a
--- /dev/null
+++ b/test/Modules/Inputs/string_names/c.h
@@ -0,0 +1,4 @@
+#ifndef C_H
+#define C_H
+const int c = 2;
+#endif
diff --git a/test/Modules/Inputs/string_names/module.map b/test/Modules/Inputs/string_names/module.map
new file mode 100644
index 0000000000000..4e70eda399240
--- /dev/null
+++ b/test/Modules/Inputs/string_names/module.map
@@ -0,0 +1,16 @@
+module "my/module-a" {
+ header "a.h"
+ use "my/module-c"
+
+ module "Sub" {
+ header "sub.h"
+ }
+}
+
+module "my/module-b" {
+ header "b.h"
+}
+
+module "my/module-c" {
+ header "c.h"
+}
diff --git a/test/Modules/Inputs/string_names/sub.h b/test/Modules/Inputs/string_names/sub.h
new file mode 100644
index 0000000000000..64b9112d3e6ca
--- /dev/null
+++ b/test/Modules/Inputs/string_names/sub.h
@@ -0,0 +1,4 @@
+#ifndef SUB_H
+#define SUB_H
+const int sub = 2;
+#endif
diff --git a/test/Modules/Inputs/submodules/import-self-b.h b/test/Modules/Inputs/submodules/import-self-b.h
index f88b56d5f0829..9852094b10b9a 100644
--- a/test/Modules/Inputs/submodules/import-self-b.h
+++ b/test/Modules/Inputs/submodules/import-self-b.h
@@ -1,10 +1,12 @@
+// FIXME: This import has no effect, because the submodule isn't built yet, and
+// we don't map an @import to a #include in this case.
@import import_self.c;
#include "import-self-d.h"
// FIXME: This should not work; names from 'a' should not be visible here.
MyTypeA import_self_test_a;
-// FIXME: This should work but does not; names from 'b' are not actually visible here.
+// FIXME: This should work but does not; names from 'c' are not actually visible here.
//MyTypeC import_self_test_c;
MyTypeD import_self_test_d;
diff --git a/test/Modules/Inputs/submodules/module.map b/test/Modules/Inputs/submodules/module.map
index c91e94f47d238..1c1b76a08969e 100644
--- a/test/Modules/Inputs/submodules/module.map
+++ b/test/Modules/Inputs/submodules/module.map
@@ -10,3 +10,23 @@ module import_self {
module c { header "import-self-c.h" }
module d { header "import-self-d.h" }
}
+
+module missing_headers {
+ module missing { header "missing.h" }
+ module not_missing { header "not_missing.h" }
+}
+
+module missing_unavailable_headers {
+ module missing {
+ requires !objc
+ header "missing.h"
+ module also_missing { header "also_missing.h" }
+ }
+ module not_missing { }
+}
+
+module missing_umbrella_with_inferred_submodules {
+ umbrella header "missing_umbrella.h"
+ module * { export * }
+ export *
+}
diff --git a/test/Modules/Inputs/submodules/not_missing.h b/test/Modules/Inputs/submodules/not_missing.h
new file mode 100644
index 0000000000000..1f8d0480e5edf
--- /dev/null
+++ b/test/Modules/Inputs/submodules/not_missing.h
@@ -0,0 +1,2 @@
+void NotMissingFunction() {
+}
diff --git a/test/Modules/Inputs/template-specialization-visibility/a.h b/test/Modules/Inputs/template-specialization-visibility/a.h
new file mode 100644
index 0000000000000..e88205558726e
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/a.h
@@ -0,0 +1,8 @@
+#ifndef A_H
+#define A_H
+template<typename T> struct S;
+template<typename U> struct T {
+ struct S;
+ enum E : int;
+};
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/b.h b/test/Modules/Inputs/template-specialization-visibility/b.h
new file mode 100644
index 0000000000000..1a098262456a9
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/b.h
@@ -0,0 +1,7 @@
+#ifndef B_H
+#define B_H
+#include "a.h"
+S<int> *s1;
+T<int>::S *s2;
+T<int>::E e1;
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/c.h b/test/Modules/Inputs/template-specialization-visibility/c.h
new file mode 100644
index 0000000000000..a92fb3b4c60c1
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/c.h
@@ -0,0 +1,6 @@
+#ifndef C_H
+#define C_H
+template<typename T> struct S { int n; };
+template<typename U> struct T<U>::S { int n; };
+template<typename U> enum T<U>::E : int { e };
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/d.h b/test/Modules/Inputs/template-specialization-visibility/d.h
new file mode 100644
index 0000000000000..3048272c5f2dc
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/d.h
@@ -0,0 +1,5 @@
+#ifndef D_H
+#define D_H
+template<typename> struct S;
+template<typename> struct T;
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/e.h b/test/Modules/Inputs/template-specialization-visibility/e.h
new file mode 100644
index 0000000000000..5d6b14290471d
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/e.h
@@ -0,0 +1,6 @@
+#ifndef E_H
+#define E_H
+#include "c.h"
+template struct S<char>;
+template struct T<char>;
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/module.map b/test/Modules/Inputs/template-specialization-visibility/module.map
new file mode 100644
index 0000000000000..f0e2a0ef90223
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/module.map
@@ -0,0 +1,7 @@
+module tsv {
+ module a { header "a.h" }
+ module b { header "b.h" }
+ module c { header "c.h" }
+ module d { header "d.h" }
+ module e { header "e.h" }
+}
diff --git a/test/Modules/Inputs/templates-left.h b/test/Modules/Inputs/templates-left.h
index e76598d6bd5ca..2bd79be945848 100644
--- a/test/Modules/Inputs/templates-left.h
+++ b/test/Modules/Inputs/templates-left.h
@@ -33,3 +33,30 @@ void triggerPendingInstantiation() {
void redeclDefinitionEmit(){}
typedef Outer<int>::Inner OuterIntInner_left;
+
+int defineListDoubleLeft() {
+ List<double> ld;
+ ld.push_back(0.0);
+ return ld.size;
+}
+
+template<typename T> struct MergePatternDecl;
+
+extern template struct ExplicitInstantiation<false, false>;
+extern template struct ExplicitInstantiation<false, true>;
+extern template struct ExplicitInstantiation<true, false>;
+extern template struct ExplicitInstantiation<true, true>;
+
+void useExplicitInstantiation() {
+ ExplicitInstantiation<true, false>().f();
+ ExplicitInstantiation<true, true>().f();
+}
+
+template<typename> struct DelayUpdates;
+template<> struct DelayUpdates<int>;
+template<typename T> struct DelayUpdates<T*>;
+template<typename T> void testDelayUpdates(DelayUpdates<T> *p = 0) {}
+
+void outOfLineInlineUseLeftF(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::f);
+void outOfLineInlineUseLeftG(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::g);
+void outOfLineInlineUseLeftH(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::h);
diff --git a/test/Modules/Inputs/templates-right.h b/test/Modules/Inputs/templates-right.h
index 16d0a714d90ed..5907cbca73eed 100644
--- a/test/Modules/Inputs/templates-right.h
+++ b/test/Modules/Inputs/templates-right.h
@@ -31,3 +31,15 @@ void triggerPendingInstantiationToo() {
void redeclDefinitionEmit(){}
typedef Outer<int>::Inner OuterIntInner_right;
+
+int defineListDoubleRight() {
+ List<double> ld;
+ ld.push_back(0.0);
+ return ld.size;
+}
+
+template<typename T> struct MergePatternDecl;
+
+void outOfLineInlineUseRightF(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::f);
+void outOfLineInlineUseRightG(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::g);
+void outOfLineInlineUseRightH(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::h);
diff --git a/test/Modules/Inputs/templates-top.h b/test/Modules/Inputs/templates-top.h
index 87dcd8b7f4659..1216266f34fbf 100644
--- a/test/Modules/Inputs/templates-top.h
+++ b/test/Modules/Inputs/templates-top.h
@@ -9,6 +9,8 @@ public:
unsigned size;
};
+extern List<double> *instantiateListDoubleDeclaration;
+
namespace A {
class Y {
template <typename T> friend class WhereAmI;
@@ -23,3 +25,18 @@ public:
template<typename T> struct Outer {
struct Inner {};
};
+
+template<bool, bool> struct ExplicitInstantiation {
+ void f() {}
+};
+
+template<typename> struct DelayUpdates {};
+
+template<typename T> struct OutOfLineInline {
+ void f();
+ void g();
+ void h();
+};
+template<typename T> inline void OutOfLineInline<T>::f() {}
+template<typename T> inline void OutOfLineInline<T>::g() {}
+template<typename T> inline void OutOfLineInline<T>::h() {}
diff --git a/test/Modules/Inputs/undefined-type-fixit/module.map b/test/Modules/Inputs/undefined-type-fixit/module.map
new file mode 100644
index 0000000000000..f5ce34b8fc063
--- /dev/null
+++ b/test/Modules/Inputs/undefined-type-fixit/module.map
@@ -0,0 +1,9 @@
+module public1 {
+ header "public1.h"
+}
+module public2 {
+ header "public2.h"
+ module public2sub {
+ header "public2sub.h"
+ }
+}
diff --git a/test/Modules/Inputs/undefined-type-fixit/public1.h b/test/Modules/Inputs/undefined-type-fixit/public1.h
new file mode 100644
index 0000000000000..bc98ca9e0ec64
--- /dev/null
+++ b/test/Modules/Inputs/undefined-type-fixit/public1.h
@@ -0,0 +1,6 @@
+#ifndef PUBLIC1_H
+#define PUBLIC1_H
+
+struct use_this1 { int field; };
+
+#endif
diff --git a/test/Modules/Inputs/undefined-type-fixit/public2.h b/test/Modules/Inputs/undefined-type-fixit/public2.h
new file mode 100644
index 0000000000000..2aa3e9614c81a
--- /dev/null
+++ b/test/Modules/Inputs/undefined-type-fixit/public2.h
@@ -0,0 +1,6 @@
+#ifndef PUBLIC2_H
+#define PUBLIC2_H
+
+struct use_this2 { int field; };
+
+#endif
diff --git a/test/Modules/Inputs/undefined-type-fixit/public2sub.h b/test/Modules/Inputs/undefined-type-fixit/public2sub.h
new file mode 100644
index 0000000000000..4c8c3cce03335
--- /dev/null
+++ b/test/Modules/Inputs/undefined-type-fixit/public2sub.h
@@ -0,0 +1,6 @@
+#ifndef PUBLIC2SUB_H
+#define PUBLIC2SUB_H
+
+struct use_this2sub { int field; };
+
+#endif
diff --git a/test/Modules/Inputs/unnecessary-module-map-parsing/a1.h b/test/Modules/Inputs/unnecessary-module-map-parsing/a1.h
new file mode 100644
index 0000000000000..56757a701bf5c
--- /dev/null
+++ b/test/Modules/Inputs/unnecessary-module-map-parsing/a1.h
@@ -0,0 +1 @@
+void f() {}
diff --git a/test/Modules/Inputs/unnecessary-module-map-parsing/module.map b/test/Modules/Inputs/unnecessary-module-map-parsing/module.map
new file mode 100644
index 0000000000000..6d4ceeeb0ccac
--- /dev/null
+++ b/test/Modules/Inputs/unnecessary-module-map-parsing/module.map
@@ -0,0 +1,3 @@
+module a {
+ eader "unknown.h"
+}
diff --git a/test/Modules/Inputs/update-after-load/a.h b/test/Modules/Inputs/update-after-load/a.h
new file mode 100644
index 0000000000000..0ebcf3e34a701
--- /dev/null
+++ b/test/Modules/Inputs/update-after-load/a.h
@@ -0,0 +1 @@
+namespace llvm {}
diff --git a/test/Modules/Inputs/update-after-load/b.h b/test/Modules/Inputs/update-after-load/b.h
new file mode 100644
index 0000000000000..64e9bfd4bc794
--- /dev/null
+++ b/test/Modules/Inputs/update-after-load/b.h
@@ -0,0 +1,2 @@
+#include "a.h"
+namespace llvm { void f(); }
diff --git a/test/Modules/Inputs/update-after-load/module.map b/test/Modules/Inputs/update-after-load/module.map
new file mode 100644
index 0000000000000..21e160ea051b6
--- /dev/null
+++ b/test/Modules/Inputs/update-after-load/module.map
@@ -0,0 +1 @@
+module a { header "a.h" } module b { header "b.h" }
diff --git a/test/Modules/Inputs/update-after-load/modules.timestamp b/test/Modules/Inputs/update-after-load/modules.timestamp
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/Inputs/update-after-load/modules.timestamp
diff --git a/test/Modules/Rmodule-build.m b/test/Modules/Rmodule-build.m
new file mode 100644
index 0000000000000..b8abc01c2c1a4
--- /dev/null
+++ b/test/Modules/Rmodule-build.m
@@ -0,0 +1,34 @@
+// REQUIRES: shell
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo '// A' > %t/A.h
+// RUN: echo '// B' > %t/B.h
+// RUN: echo 'module A { header "A.h" }' > %t/module.modulemap
+// RUN: echo 'module B { header "B.h" }' >> %t/module.modulemap
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -verify \
+// RUN: -I %t -Rmodule-build
+
+@import A; // expected-remark{{building module 'A' as}}
+@import B; // expected-remark{{building module 'B' as}}
+@import A; // no diagnostic
+@import B; // no diagnostic
+
+// RUN: echo ' ' >> %t/B.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
+// RUN: -Rmodule-build 2>&1 | FileCheck %s
+
+// RUN: echo ' ' >> %t/B.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
+// RUN: -Reverything 2>&1 | FileCheck %s
+
+// RUN: echo ' ' >> %t/B.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
+// RUN: 2>&1 | count 0
+
+// RUN: echo ' ' >> %t/B.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
+// RUN: -Rmodule-build -Rno-everything 2>&1 | count 0
+
+// CHECK-NOT: building module 'A'
+// CHECK: building module 'B'
diff --git a/test/Modules/Werror-Wsystem-headers.m b/test/Modules/Werror-Wsystem-headers.m
new file mode 100644
index 0000000000000..c4cd1a6378ccf
--- /dev/null
+++ b/test/Modules/Werror-Wsystem-headers.m
@@ -0,0 +1,23 @@
+// REQUIRES: shell
+// RUN: rm -rf %t
+// RUN: rm -rf %t-saved
+// RUN: mkdir %t-saved
+
+// Initial module build
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify
+// RUN: cp %t/cstd.pcm %t-saved/cstd.pcm
+
+// Even with -Werror don't rebuild a system module
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify -Werror
+// RUN: diff %t/cstd.pcm %t-saved/cstd.pcm
+
+// Unless -Wsystem-headers is on
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify \
+// RUN: -Werror=unused -Wsystem-headers
+// RUN: not diff %t/cstd.pcm %t-saved/cstd.pcm
+
+// expected-no-diagnostics
+@import cstd;
diff --git a/test/Modules/Werror.m b/test/Modules/Werror.m
new file mode 100644
index 0000000000000..94a98a5a198d0
--- /dev/null
+++ b/test/Modules/Werror.m
@@ -0,0 +1,75 @@
+// REQUIRES: shell
+// RUN: rm -rf %t
+// RUN: rm -rf %t-saved
+// RUN: mkdir -p %t-saved
+
+// Initial module build (-Werror=header-guard)
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -Werror=header-guard
+// RUN: cp %t/Module.pcm %t-saved/Module.pcm
+
+// Building with looser -Werror options does not rebuild
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella
+// RUN: diff %t/Module.pcm %t-saved/Module.pcm
+
+// Make the build more restricted (-Werror)
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -Werror -Wno-incomplete-umbrella
+// RUN: not diff %t/Module.pcm %t-saved/Module.pcm
+// RUN: cp %t/Module.pcm %t-saved/Module.pcm
+
+// Ensure -Werror=header-guard is less strict than -Werror
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -Werror=header-guard -Wno-incomplete-umbrella
+// RUN: diff %t/Module.pcm %t-saved/Module.pcm
+
+// But -Werror=unused is not, because some of its diags are DefaultIgnore
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -Werror=unused
+// RUN: not diff %t/Module.pcm %t-saved/Module.pcm
+// RUN: cp %t/Module.pcm %t-saved/Module.pcm
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -Werror -Wno-incomplete-umbrella
+
+// FIXME: when rebuilding the module, take the union of the diagnostic options
+// so that we don't need to rebuild here
+// RUN-DISABLED: diff %t/Module.pcm %t-saved/Module.pcm
+
+// -Wno-everything, -Werror
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -Wno-everything -Wall -Werror
+// RUN: cp %t/Module.pcm %t-saved/Module.pcm
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -Wall -Werror
+// RUN: not diff %t/Module.pcm %t-saved/Module.pcm
+
+// -pedantic, -Werror is not compatible with -Wall -Werror
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -Werror -pedantic
+// RUN: not diff %t/Module.pcm %t-saved/Module.pcm
+// RUN: cp %t/Module.pcm %t-saved/Module.pcm
+
+// -pedantic-errors is less strict that -pedantic, -Werror
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -pedantic-errors
+// RUN: diff %t/Module.pcm %t-saved/Module.pcm
+
+// -Wsystem-headers does not affect non-system modules
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -F %S/Inputs -fsyntax-only %s -verify -Wno-incomplete-umbrella \
+// RUN: -pedantic-errors -Wsystem-headers
+// RUN: diff %t/Module.pcm %t-saved/Module.pcm
+
+// expected-no-diagnostics
+@import Module;
diff --git a/test/Modules/auto-module-import.m b/test/Modules/auto-module-import.m
index d7fb9d1f9fd6f..bf9937778631a 100644
--- a/test/Modules/auto-module-import.m
+++ b/test/Modules/auto-module-import.m
@@ -83,6 +83,6 @@ int getNotInModule() {
return not_in_module;
}
-void includeNotAtTopLevel() {
- #include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} expected-error {{expected expression}}
-}
+void includeNotAtTopLevel() { // expected-note {{to match this '{'}}
+ #include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} expected-error {{expected '}'}}
+} // expected-error {{extraneous closing brace}}
diff --git a/test/Modules/autolink.m b/test/Modules/autolink.m
index 077aac5374a0e..47eda3f80e011 100644
--- a/test/Modules/autolink.m
+++ b/test/Modules/autolink.m
@@ -1,6 +1,7 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -fmodules -F %S/Inputs -I %S/Inputs %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -fno-autolink -o - -fmodules-cache-path=%t -fmodules -F %S/Inputs -I %S/Inputs %s | FileCheck --check-prefix=CHECK-AUTOLINK-DISABLED %s
+// RUN: %clang_cc1 -emit-pch -fmodules-cache-path=%t -fmodules -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/autolink-sub3.pch
+// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -fmodules -F %S/Inputs -I %S/Inputs -include-pch %t.pch %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -fno-autolink -o - -fmodules-cache-path=%t -fmodules -F %S/Inputs -I %S/Inputs -include-pch %t.pch %s | FileCheck --check-prefix=CHECK-AUTOLINK-DISABLED %s
@import autolink.sub2;
@@ -29,11 +30,16 @@ int use_no_umbrella() {
return no_umbrella_A;
}
+int use_autolink_sub3() {
+ return autolink_sub3();
+}
+
// NOTE: "autolink_sub" is intentionally not linked.
-// CHECK: !llvm.module.flags = !{!0, !1, !2, !3, !4}
-// CHECK: !4 = metadata !{i32 6, metadata !"Linker Options", metadata ![[AUTOLINK_OPTIONS:[0-9]+]]}
-// CHECK: ![[AUTOLINK_OPTIONS]] = metadata !{metadata ![[AUTOLINK_FRAMEWORK:[0-9]+]], metadata ![[AUTOLINK:[0-9]+]], metadata ![[DEPENDSONMODULE:[0-9]+]], metadata ![[MODULE:[0-9]+]], metadata ![[NOUMBRELLA:[0-9]+]]}
+// CHECK: !llvm.module.flags = !{{{.*}}}
+// CHECK: !{{[0-9]+}} = metadata !{i32 6, metadata !"Linker Options", metadata ![[AUTOLINK_OPTIONS:[0-9]+]]}
+// CHECK: ![[AUTOLINK_OPTIONS]] = metadata !{metadata ![[AUTOLINK_PCH:[0-9]+]], metadata ![[AUTOLINK_FRAMEWORK:[0-9]+]], metadata ![[AUTOLINK:[0-9]+]], metadata ![[DEPENDSONMODULE:[0-9]+]], metadata ![[MODULE:[0-9]+]], metadata ![[NOUMBRELLA:[0-9]+]]}
+// CHECK: ![[AUTOLINK_PCH]] = metadata !{metadata !"{{(-l|/DEFAULTLIB:)}}autolink_from_pch{{(\.lib)?}}"}
// CHECK: ![[AUTOLINK_FRAMEWORK]] = metadata !{metadata !"-framework", metadata !"autolink_framework"}
// CHECK: ![[AUTOLINK]] = metadata !{metadata !"{{(-l|/DEFAULTLIB:)}}autolink{{(\.lib)?}}"}
// CHECK: ![[DEPENDSONMODULE]] = metadata !{metadata !"-framework", metadata !"DependsOnModule"}
diff --git a/test/Modules/compiler_builtins_arm.m b/test/Modules/compiler_builtins_arm.m
index d15437cafcdb1..5da6a12fb3a60 100644
--- a/test/Modules/compiler_builtins_arm.m
+++ b/test/Modules/compiler_builtins_arm.m
@@ -1,6 +1,5 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fsyntax-only -triple thumbv7-none-linux-gnueabihf -target-abi aapcs -target-cpu cortex-a8 -mfloat-abi hard -std=c99 -fmodules -fmodules-cache-path=%t -D__need_wint_t %s -verify
// expected-no-diagnostics
-// REQUIRES: arm-registered-target
@import _Builtin_intrinsics.arm.neon;
diff --git a/test/Modules/config_macros.m b/test/Modules/config_macros.m
index 200744d614a7b..b147317bf60d3 100644
--- a/test/Modules/config_macros.m
+++ b/test/Modules/config_macros.m
@@ -24,5 +24,5 @@ char *test_bar() {
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -DWANT_FOO=1 -emit-module -fmodule-name=config %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -DWANT_FOO=1 %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -DWANT_FOO=1 %s -verify
diff --git a/test/Modules/cxx-decls.cpp b/test/Modules/cxx-decls.cpp
index ba3281aaec7a5..5498b47fc9fe8 100644
--- a/test/Modules/cxx-decls.cpp
+++ b/test/Modules/cxx-decls.cpp
@@ -1,8 +1,11 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -ast-dump -ast-dump-filter merge -std=c++11 | FileCheck %s
// expected-no-diagnostics
+void use_implicit_new() { operator new[](3); }
+
@import dummy;
@import cxx_decls.imported;
@@ -19,3 +22,15 @@ void test_friends(HasFriends s) {
friend_1(s);
friend_2(s);
}
+
+static_assert(!__is_trivial(HasNontrivialDefaultConstructor), "");
+static_assert(!__has_trivial_constructor(HasNontrivialDefaultConstructor), "");
+
+void use_implicit_new_again() { operator new[](3); }
+
+int importMergeUsedFlag = getMergeUsedFlag();
+
+@import cxx_decls_merged;
+
+// CHECK: VarDecl [[mergeUsedFlag:0x[0-9a-f]*]] {{.*}} in cxx_decls.imported used mergeUsedFlag
+// CHECK: VarDecl {{0x[0-9a-f]*}} prev [[mergeUsedFlag]] {{.*}} in cxx_decls_merged used mergeUsedFlag
diff --git a/test/Modules/cxx-inline-namespace.cpp b/test/Modules/cxx-inline-namespace.cpp
index 5b967901b3384..f67d43b6843a1 100644
--- a/test/Modules/cxx-inline-namespace.cpp
+++ b/test/Modules/cxx-inline-namespace.cpp
@@ -2,5 +2,8 @@
// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
@import cxx_inline_namespace;
+@import cxx_inline_namespace_b;
T x; // expected-error {{unknown type name 'T'}}
+
+X::Elaborated *p;
diff --git a/test/Modules/cxx-irgen.cpp b/test/Modules/cxx-irgen.cpp
new file mode 100644
index 0000000000000..4c61a3a3583be
--- /dev/null
+++ b/test/Modules/cxx-irgen.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-optzns -emit-llvm -o - %s | FileCheck %s
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@import cxx_irgen_top;
+
+// CHECK-DAG: call {{[a-z]*[ ]?i32}} @_ZN8CtorInitIiE1fEv(
+CtorInit<int> x;
+
+@import cxx_irgen_left;
+@import cxx_irgen_right;
+
+// CHECK-DAG: define available_externally hidden {{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[ALWAYS_INLINE:.*]] align
+int a = S<int>::g();
+
+// CHECK-DAG: define available_externally {{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align
+int b = h();
+
+// CHECK-DAG: define linkonce_odr {{signext i32|i32}} @_Z3minIiET_S0_S0_(i32
+int c = min(1, 2);
+
+// CHECK: attributes #[[ALWAYS_INLINE]] = {{.*}} alwaysinline
diff --git a/test/Modules/cxx-templates.cpp b/test/Modules/cxx-templates.cpp
index 65f41f677be59..cbe9f35089515 100644
--- a/test/Modules/cxx-templates.cpp
+++ b/test/Modules/cxx-templates.cpp
@@ -1,7 +1,8 @@
// RUN: rm -rf %t
-// RUN: not %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups | FileCheck %s --check-prefix=CHECK-GLOBAL
-// RUN: not %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups -ast-dump-filter N | FileCheck %s --check-prefix=CHECK-NAMESPACE-N
-// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
+// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups | FileCheck %s --check-prefix=CHECK-GLOBAL
+// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups -ast-dump-filter N | FileCheck %s --check-prefix=CHECK-NAMESPACE-N
+// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump | FileCheck %s --check-prefix=CHECK-DUMP
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
@import cxx_templates_a;
@import cxx_templates_b;
@@ -28,8 +29,8 @@ void g() {
N::f<double>(1.0);
N::f<int>();
N::f(); // expected-error {{no matching function}}
- // expected-note@Inputs/cxx-templates-b.h:6 {{couldn't infer template argument}}
- // expected-note@Inputs/cxx-templates-b.h:7 {{requires single argument 't'}}
+ // expected-note@Inputs/cxx-templates-a.h:6 {{couldn't infer template argument}}
+ // expected-note@Inputs/cxx-templates-a.h:7 {{requires 1 argument}}
template_param_kinds_1<0>(); // ok, from cxx-templates-a.h
template_param_kinds_1<int>(); // ok, from cxx-templates-b.h
@@ -70,8 +71,15 @@ void g() {
// Trigger the instantiation of a template in 'a' that uses a type defined in
// 'b_impl'. That type is not visible here, nor in 'a'. This fails; there is
// no reason why DefinedInBImpl should be visible here.
+ //
+ // We turn off error recovery for modules in this test (so we don't get an
+ // implicit import of cxx_templates_b_impl), and that results in us producing
+ // a big spew of errors here.
+ //
// expected-error@Inputs/cxx-templates-a.h:19 {{definition of 'DefinedInBImpl' must be imported}}
- // expected-note@Inputs/cxx-templates-b-impl.h:1 {{definition is here}}
+ // expected-note@Inputs/cxx-templates-b-impl.h:1 +{{definition is here}}
+ // expected-error@Inputs/cxx-templates-a.h:19 +{{}}
+ // expected-error@Inputs/cxx-templates-a.h:20 +{{}}
PerformDelayedLookup(defined_in_b_impl); // expected-note {{in instantiation of}}
merge_templates_a = merge_templates_b; // ok, same type
@@ -88,8 +96,23 @@ void g() {
static_assert(enum_c_from_a == enum_c_from_b, "");
CommonTemplate<int> cti;
CommonTemplate<int>::E eee = CommonTemplate<int>::c;
+
+ TemplateInstantiationVisibility<char[1]> tiv1;
+ TemplateInstantiationVisibility<char[2]> tiv2;
+ TemplateInstantiationVisibility<char[3]> tiv3; // expected-error {{must be imported from module 'cxx_templates_b_impl'}}
+ // expected-note@cxx-templates-b-impl.h:10 {{previous definition is here}}
+ TemplateInstantiationVisibility<char[4]> tiv4;
+
+ int &p = WithPartialSpecializationUse().f();
+ int &q = WithExplicitSpecializationUse().inner_template<int>();
}
+static_assert(Outer<int>::Inner<int>::f() == 1, "");
+static_assert(Outer<int>::Inner<int>::g() == 2, "");
+
+static_assert(MergeTemplateDefinitions<int>::f() == 1, "");
+static_assert(MergeTemplateDefinitions<int>::g() == 2, "");
+
RedeclaredAsFriend<int> raf1;
RedeclareTemplateAsFriend<double> rtaf;
RedeclaredAsFriend<double> raf2;
@@ -116,6 +139,15 @@ void testImplicitSpecialMembers(SomeTemplate<char[1]> &a,
c = d;
}
+bool testFriendInClassTemplate(Std::WithFriend<int> wfi) {
+ return wfi != wfi;
+}
+
+namespace Std {
+ void g(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+ // expected-note@cxx-templates-common.h:21 {{previous}}
+}
+
// CHECK-GLOBAL: DeclarationName 'f'
// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
// CHECK-GLOBAL-NEXT: `-FunctionTemplate {{.*}} 'f'
@@ -123,3 +155,13 @@ void testImplicitSpecialMembers(SomeTemplate<char[1]> &a,
// CHECK-NAMESPACE-N: DeclarationName 'f'
// CHECK-NAMESPACE-N-NEXT: |-FunctionTemplate {{.*}} 'f'
// CHECK-NAMESPACE-N-NEXT: `-FunctionTemplate {{.*}} 'f'
+
+// CHECK-DUMP: ClassTemplateDecl {{.*}} <{{.*[/\\]}}cxx-templates-common.h:1:1, {{.*}}> col:{{.*}} in cxx_templates_common SomeTemplate
+// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev [[CHAR2:[^ ]*]] {{.*}} SomeTemplate
+// CHECK-DUMP-NEXT: TemplateArgument type 'char [2]'
+// CHECK-DUMP: ClassTemplateSpecializationDecl [[CHAR2]] {{.*}} SomeTemplate definition
+// CHECK-DUMP-NEXT: TemplateArgument type 'char [2]'
+// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev [[CHAR1:[^ ]*]] {{.*}} SomeTemplate
+// CHECK-DUMP-NEXT: TemplateArgument type 'char [1]'
+// CHECK-DUMP: ClassTemplateSpecializationDecl [[CHAR1]] {{.*}} SomeTemplate definition
+// CHECK-DUMP-NEXT: TemplateArgument type 'char [1]'
diff --git a/test/Modules/declare-use.S b/test/Modules/declare-use.S
new file mode 100644
index 0000000000000..2c5d8af7dd25a
--- /dev/null
+++ b/test/Modules/declare-use.S
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang -fmodule-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XS -I %S/Inputs/declare-use -S %s -Xclang -verify
+// expected-no-diagnostics
+
+#include "s.h"
diff --git a/test/Modules/declare-use1.cpp b/test/Modules/declare-use1.cpp
index 4508017c12d20..5fc43360ffa3d 100644
--- a/test/Modules/declare-use1.cpp
+++ b/test/Modules/declare-use1.cpp
@@ -1,7 +1,8 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
+// RUN: %clang_cc1 -fmodule-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
#include "g.h"
#include "e.h"
-#include "f.h" // expected-error {{use of a module not declared used}}
-const int g2 = g1+e+f;
+#include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}}
+#include "i.h"
+const int g2 = g1 + e + f + aux_i;
diff --git a/test/Modules/declare-use2.cpp b/test/Modules/declare-use2.cpp
index a2ec55e5e5ca3..45352891685d2 100644
--- a/test/Modules/declare-use2.cpp
+++ b/test/Modules/declare-use2.cpp
@@ -1,7 +1,7 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodules-decluse -fmodule-name=XH -I %S/Inputs/declare-use %s -verify
+// RUN: %clang_cc1 -fmodule-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XH -I %S/Inputs/declare-use %s -verify
#include "h.h"
#include "e.h"
-#include "f.h" // expected-error {{use of a module not declared used}}
+#include "f.h" // expected-error {{module XH does not depend on a module exporting 'f.h'}}
const int h2 = h1+e+f;
diff --git a/test/Modules/declare-use3.cpp b/test/Modules/declare-use3.cpp
new file mode 100644
index 0000000000000..8b0bbfa756c32
--- /dev/null
+++ b/test/Modules/declare-use3.cpp
@@ -0,0 +1,4 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -include "g.h" -include "e.h" -include "f.h" -include "i.h" -fmodule-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
+// expected-error {{module XG does not depend on a module exporting 'f.h'}}
+const int g2 = g1 + e + f + aux_i;
diff --git a/test/Modules/declare-use4.cpp b/test/Modules/declare-use4.cpp
new file mode 100644
index 0000000000000..1d346469f1ef0
--- /dev/null
+++ b/test/Modules/declare-use4.cpp
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
+
+#define ALLOWED_INC "b.h"
+
+#include "j.h"
+
+const int g2 = j;
+
+// expected-no-diagnostics
diff --git a/test/Modules/decldef.mm b/test/Modules/decldef.mm
index 35694935dfbb9..2e2bd8a75e20f 100644
--- a/test/Modules/decldef.mm
+++ b/test/Modules/decldef.mm
@@ -1,14 +1,18 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_EARLY
-// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify
+// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_1 -DUSE_2 -DUSE_3 -DUSE_4
+// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_2 -DUSE_3 -DUSE_4
+// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_3 -DUSE_4
+// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_4
-// expected-note@Inputs/def.h:5 {{previous}}
+// expected-note@Inputs/def.h:5 0-1{{previous}}
+// expected-note@Inputs/def.h:16 0-1{{previous}}
+// expected-note@Inputs/def-include.h:11 0-1{{previous}}
@class Def;
Def *def;
-class Def2; // expected-note {{forward decl}}
+class Def2; // expected-note 0-1{{forward decl}}
Def2 *def2;
-namespace Def3NS { class Def3; } // expected-note {{forward decl}}
+namespace Def3NS { class Def3; } // expected-note 0-1{{forward decl}}
Def3NS::Def3 *def3;
@interface Unrelated
@@ -16,9 +20,10 @@ Def3NS::Def3 *def3;
@end
@import decldef;
-#ifdef USE_EARLY
+#ifdef USE_1
A *a1; // expected-error{{declaration of 'A' must be imported from module 'decldef.Def'}}
B *b1;
+#define USED
#endif
@import decldef.Decl;
@@ -26,14 +31,23 @@ A *a2;
B *b;
void testA(A *a) {
+#ifdef USE_2
a->ivar = 17;
-#ifndef USE_EARLY
+ #ifndef USED
// expected-error@-2{{definition of 'A' must be imported from module 'decldef.Def' before it is required}}
+ #define USED
+ #endif
#endif
}
void testB() {
- B b; // Note: redundant error silenced
+#ifdef USE_3
+ B b;
+ #ifndef USED
+ // expected-error@-2{{definition of 'B' must be imported from module 'decldef.Def' before it is required}}
+ #define USED
+ #endif
+#endif
}
void testDef() {
@@ -41,9 +55,12 @@ void testDef() {
}
void testDef2() {
- // FIXME: These should both work, since we've (implicitly) imported
- // decldef.Def here, but they don't, because nothing has triggered the lazy
- // loading of the definitions of these classes.
- def2->func(); // expected-error {{incomplete}}
- def3->func(); // expected-error {{incomplete}}
+#ifdef USE_4
+ def2->func();
+ def3->func();
+ #ifndef USED
+ // expected-error@-3 {{definition of 'Def2' must be imported}}
+ #define USED
+ #endif
+#endif
}
diff --git a/test/Modules/dependency-dump-dependent-module.m b/test/Modules/dependency-dump-dependent-module.m
new file mode 100644
index 0000000000000..3b04435dd594f
--- /dev/null
+++ b/test/Modules/dependency-dump-dependent-module.m
@@ -0,0 +1,22 @@
+// When a module depends on another, check that we dump the dependency header
+// files for both.
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -module-dependency-dir %t/vfs -F %S/Inputs -I %S/Inputs -verify %s
+// expected-no-diagnostics
+
+// RUN: FileCheck %s -check-prefix=VFS < %t/vfs/vfs.yaml
+// VFS: 'name': "AlsoDependsOnModule.h"
+// VFS: 'name': "SubFramework.h"
+// VFS: 'name': "Treasure.h"
+// VFS: 'name': "Module.h"
+// VFS: 'name': "Sub.h"
+// VFS: 'name': "Sub2.h"
+
+@import AlsoDependsOnModule;
+
+// FIXME: This fails on win32 due to ERROR_FILENAME_EXCED_RANGE
+// if the working directory is too deep.
+// We should make Win32/Path.inc capable of long pathnames with '\\?\'.
+// For now, this is suppressed on win32.
+// REQUIRES: shell
diff --git a/test/Modules/dependency-dump.m b/test/Modules/dependency-dump.m
new file mode 100644
index 0000000000000..630af4950c186
--- /dev/null
+++ b/test/Modules/dependency-dump.m
@@ -0,0 +1,15 @@
+// Check that we can dump all of the headers a module depends on, and a VFS map
+// for the same.
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -module-dependency-dir %t/vfs -F %S/Inputs -I %S/Inputs -verify %s
+// expected-no-diagnostics
+
+// RUN: FileCheck %s -check-prefix=VFS -input-file %t/vfs/vfs.yaml
+// VFS: 'name': "SubFramework.h"
+// VFS: 'name': "Treasure.h"
+// VFS: 'name': "Module.h"
+// VFS: 'name': "Sub.h"
+// VFS: 'name': "Sub2.h"
+
+@import Module;
diff --git a/test/Modules/dependency-gen-inferred-map.m b/test/Modules/dependency-gen-inferred-map.m
new file mode 100644
index 0000000000000..11cc872881159
--- /dev/null
+++ b/test/Modules/dependency-gen-inferred-map.m
@@ -0,0 +1,8 @@
+// Test that the virtual file "__inferred_module.map" doesn't show up as dependency.
+
+// RUN: rm -rf %t-mcp
+// RUN: %clang_cc1 -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d -MT %s.o -F %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
+// RUN: FileCheck %s < %t.d
+// CHECK-NOT: __inferred_module
+
+@import Module;
diff --git a/test/Modules/dependency-gen-pch.m b/test/Modules/dependency-gen-pch.m
new file mode 100644
index 0000000000000..65e22d485dd20
--- /dev/null
+++ b/test/Modules/dependency-gen-pch.m
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t-mcp
+// RUN: mkdir -p %t-mcp
+
+// RUN: %clang_cc1 -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -module-file-deps -dependency-file %t.d -MT %s.o -I %S/Inputs -fmodules -fdisable-module-hash -fmodules-cache-path=%t-mcp -emit-pch -o %t.pch %s
+// RUN: FileCheck %s < %t.d
+// CHECK: dependency-gen-pch.m.o
+// CHECK-NEXT: dependency-gen-pch.m
+// CHECK-NEXT: diamond_top.pcm
+// CHECK-NEXT: Inputs{{.}}diamond_top.h
+// CHECK-NEXT: Inputs{{.}}module.map
+
+#import "diamond_top.h"
diff --git a/test/Modules/dependency-gen.m b/test/Modules/dependency-gen.m
new file mode 100644
index 0000000000000..dec83848f061e
--- /dev/null
+++ b/test/Modules/dependency-gen.m
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t-mcp
+// RUN: mkdir -p %t-mcp
+
+// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
+// RUN: FileCheck %s < %t.d.1
+// CHECK: dependency-gen.m
+// CHECK: Inputs{{.}}diamond_top.h
+// CHECK: Inputs{{.}}module.map
+// CHECK-NOT: usr{{.}}include{{.}}module.map
+// CHECK-NOT: stdint.h
+
+
+// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
+// RUN: FileCheck %s -check-prefix=CHECK-SYS < %t.d.2
+// CHECK-SYS: dependency-gen.m
+// CHECK-SYS: Inputs{{.}}diamond_top.h
+// CHECK-SYS: Inputs{{.}}module.map
+// CHECK-SYS: usr{{.}}include{{.}}module.map
+// CHECK-SYS: stdint.h
+
+#import "diamond_top.h"
+#import "stdint.h" // inside sysroot
diff --git a/test/Modules/diag-pragma.c b/test/Modules/diag-pragma.c
index 7ec3400bba24b..89435c176ed59 100644
--- a/test/Modules/diag-pragma.c
+++ b/test/Modules/diag-pragma.c
@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diag_pragma %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t %s
+// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s
// FIXME: When we have a syntax for modules in C, use that.
@import diag_pragma;
diff --git a/test/Modules/diamond-pch.c b/test/Modules/diamond-pch.c
index e7ad02dbe48aa..f66ad877dee48 100644
--- a/test/Modules/diamond-pch.c
+++ b/test/Modules/diamond-pch.c
@@ -3,8 +3,8 @@
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_left %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodules-cache-path=%t -o %t.pch %S/Inputs/diamond.h
-// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -include-pch %t.pch %s -verify
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodules-cache-path=%t -I %S/Inputs -o %t.pch %S/Inputs/diamond.h
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -include-pch %t.pch %s -I %S/Inputs -verify
// FIXME: When we have a syntax for modules in C, use that.
void test_diamond(int i, float f, double d, char c) {
diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c
index 89d5bc0dda5f6..8b824081a1e39 100644
--- a/test/Modules/diamond.c
+++ b/test/Modules/diamond.c
@@ -3,7 +3,7 @@
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_left %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t %s -verify
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s -verify
// FIXME: When we have a syntax for modules in C, use that.
@import diamond_bottom;
diff --git a/test/Modules/exclude-header.c b/test/Modules/exclude-header.c
new file mode 100644
index 0000000000000..4134c82483d34
--- /dev/null
+++ b/test/Modules/exclude-header.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules -fmodules-cache-path=%t -I %S/Inputs/exclude-header %s -verify
+
+@import x;
+
+a var_a;
+b var_b1; // expected-error {{unknown type name 'b'}}
+
+@import y;
+
+b var_b2;
diff --git a/test/Modules/extern_c.cpp b/test/Modules/extern_c.cpp
new file mode 100644
index 0000000000000..ba466f2a53a22
--- /dev/null
+++ b/test/Modules/extern_c.cpp
@@ -0,0 +1,81 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DEXTERN_C
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DEXTERN_CXX
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DEXTERN_C -DEXTERN_CXX
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DEXTERN_C -DNAMESPACE
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_CXX
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DEXTERN_CXX
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DNAMESPACE
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs -x c %s
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs/elsewhere -I %S/Inputs %s -DEXTERN_C -DINDIRECT
+
+#ifdef INDIRECT
+#include "c-header-indirect.h"
+#endif
+
+#ifdef NAMESPACE
+namespace M {
+#endif
+
+#ifdef EXTERN_C
+extern "C" {
+#endif
+
+#ifdef EXTERN_CXX
+extern "C++" {
+#endif
+
+#ifdef CXX_HEADER
+#define HEADER "cxx-header.h"
+#else
+#define HEADER "c-header.h"
+#endif
+
+#include HEADER
+
+#if defined(EXTERN_C) && !defined(EXTERN_CXX) && defined(CXX_HEADER)
+// expected-error@-3 {{import of C++ module 'cxx_library' appears within extern "C" language linkage specification}}
+// expected-note@-17 {{extern "C" language linkage specification begins here}}
+#elif defined(NAMESPACE)
+// expected-error-re@-6 {{import of module '{{c_library.inner|cxx_library}}' appears within namespace 'M'}}
+// expected-note@-24 {{namespace 'M' begins here}}
+#endif
+
+#ifdef EXTERN_CXX
+}
+#endif
+
+#ifdef EXTERN_C
+}
+#endif
+
+#ifdef NAMESPACE
+}
+using namespace M;
+#endif
+
+#ifdef __cplusplus
+namespace N {
+#endif
+ void g() {
+ int k = f();
+ }
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+ int f;
+#if !defined(CXX_HEADER)
+ // expected-error@-2 {{redefinition of 'f' as different kind of symbol}}
+ // expected-note@c-header.h:1 {{previous}}
+#endif
+
+#ifdef __cplusplus
+ }
+}
+#endif
+
+suppress_expected_no_diagnostics_error error_here; // expected-error {{}}
diff --git a/test/Modules/extern_c_bad.cpp b/test/Modules/extern_c_bad.cpp
new file mode 100644
index 0000000000000..bafdc046ce0ad
--- /dev/null
+++ b/test/Modules/extern_c_bad.cpp
@@ -0,0 +1,2 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -verify -fmodules -x c++ -emit-module -fmodules-cache-path=%t -fmodule-name=c_library_bad %S/Inputs/module.map
diff --git a/test/Modules/fatal-module-loader-error.m b/test/Modules/fatal-module-loader-error.m
index 6af3b4c7c3709..2d8dd24e51356 100644
--- a/test/Modules/fatal-module-loader-error.m
+++ b/test/Modules/fatal-module-loader-error.m
@@ -23,4 +23,4 @@
// Also check that libclang does not create a PCH with such an error.
// RUN: not c-index-test -write-pch %t.pch -fmodules -fmodules-cache-path=%t \
// RUN: %s -Xclang -fdisable-module-hash -F %S/Inputs 2>&1 | FileCheck %s
-// CHECK: Unable to write PCH file
+// CHECK: {{^}}Failure: AST deserialization error occurred{{$}}
diff --git a/test/Modules/fmodules-validate-once-per-build-session.c b/test/Modules/fmodules-validate-once-per-build-session.c
new file mode 100644
index 0000000000000..346d5a72c3e87
--- /dev/null
+++ b/test/Modules/fmodules-validate-once-per-build-session.c
@@ -0,0 +1,45 @@
+#include "foo.h"
+
+// Clear the module cache.
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/Inputs
+// RUN: mkdir -p %t/modules-to-compare
+
+// ===
+// Create a module with system headers.
+// RUN: echo 'void meow(void);' > %t/Inputs/foo.h
+// RUN: echo 'module Foo [system] { header "foo.h" }' > %t/Inputs/module.map
+
+// ===
+// Compile the module.
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
+// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm
+
+// ===
+// Use it, and make sure that we did not recompile it.
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
+// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
+
+// RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
+
+// ===
+// Change the sources.
+// RUN: echo 'void meow2(void);' > %t/Inputs/foo.h
+
+// ===
+// Use the module, and make sure that we did not recompile it, even though the sources changed.
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
+// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
+
+// RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
+
+// ===
+// Recompile the module if the today's date is before 01 January 2030.
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s
+// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
+// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
+
+// RUN: not diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
diff --git a/test/Modules/import-self.m b/test/Modules/import-self.m
new file mode 100644
index 0000000000000..68be565eaf406
--- /dev/null
+++ b/test/Modules/import-self.m
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/submodules %s 2>&1 | FileCheck %s
+// CHECK: import of module 'import_self.c' appears within same top-level module 'import_self'
+
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/submodules -fmodule-name=import_self %s \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-fmodule-name %s
+// CHECK-fmodule-name: import of module 'import_self.b' appears within same top-level module 'import_self'
+
+@import import_self.b;
diff --git a/test/Modules/include-relative.c b/test/Modules/include-relative.c
new file mode 100644
index 0000000000000..9ca76eeb921c8
--- /dev/null
+++ b/test/Modules/include-relative.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp -r %S/Inputs/include-relative %t/include-relative
+// RUN: cd %t
+// RUN: %clang_cc1 -fmodules -x c -verify -fmodules-cache-path=%t -I include-relative %s
+// REQUIRES: shell
+
+// expected-no-diagnostics
+
+#include "a.h"
+
+int f() { return n; }
diff --git a/test/Modules/inferred-framework-case.m b/test/Modules/inferred-framework-case.m
new file mode 100644
index 0000000000000..e511155de9efc
--- /dev/null
+++ b/test/Modules/inferred-framework-case.m
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify -DA
+// FIXME: PR20299 - getCanonicalName() is not implemented on Windows.
+// REQUIRES: shell
+
+@import MOdule; // expected-error{{module 'MOdule' not found}}
+@import Module;
diff --git a/test/Modules/irgen.c b/test/Modules/irgen.c
index 9a7cf7eff08c6..c44afb1becb12 100644
--- a/test/Modules/irgen.c
+++ b/test/Modules/irgen.c
@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=irgen -triple x86_64-apple-darwin10 %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
// FIXME: When we have a syntax for modules in C, use that.
@import irgen;
diff --git a/test/Modules/linkage-merge.cpp b/test/Modules/linkage-merge.cpp
index 9cc9ae64bf974..664716d3bed7d 100644
--- a/test/Modules/linkage-merge.cpp
+++ b/test/Modules/linkage-merge.cpp
@@ -7,6 +7,5 @@ static int f(int);
int f(int);
static void g(int);
-// expected-error@-1 {{declaration conflicts with target of using declaration already in scope}}
-// expected-note@Inputs/linkage-merge-foo.h:2 {{target of using declaration}}
-// expected-note@Inputs/linkage-merge-bar.h:3 {{using declaration}}
+// expected-error@-1 {{functions that differ only in their return type cannot be overloaded}}
+// expected-note@Inputs/linkage-merge-foo.h:2 {{previous declaration is here}}
diff --git a/test/Modules/linkage-merge.m b/test/Modules/linkage-merge.m
index e838ca10183df..12ad32fa3d184 100644
--- a/test/Modules/linkage-merge.m
+++ b/test/Modules/linkage-merge.m
@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=linkage_merge_left %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -w %s -verify
// Test redeclarations of functions where the original declaration is
// still hidden.
diff --git a/test/Modules/load-after-failure.m b/test/Modules/load-after-failure.m
new file mode 100644
index 0000000000000..f471fd88d505f
--- /dev/null
+++ b/test/Modules/load-after-failure.m
@@ -0,0 +1,25 @@
+// REQUIRES: shell
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+
+// RUN: echo '@import B;' > %t/A.h
+// RUN: echo '@import C;' > %t/B.h
+// RUN: echo '@import D;' >> %t/B.h
+// RUN: echo '// C.h' > %t/C.h
+// RUN: echo '// D.h' > %t/D.h
+// RUN: echo 'module A { header "A.h" }' > %t/module.modulemap
+// RUN: echo 'module B { header "B.h" }' >> %t/module.modulemap
+// RUN: echo 'module C { header "C.h" }' >> %t/module.modulemap
+// RUN: echo 'module D { header "D.h" }' >> %t/module.modulemap
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %t %s -verify
+// RUN: echo " " >> %t/D.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %t %s -verify
+// expected-no-diagnostics
+
+
+@import C;
+@import A;
+@import C;
+// When compiling A, C will be be loaded then removed when D fails. Ensure
+// this does not cause problems importing C again later.
diff --git a/test/Modules/load_failure.c b/test/Modules/load_failure.c
index 6c6d812bafa36..8b0d202ee8b5c 100644
--- a/test/Modules/load_failure.c
+++ b/test/Modules/load_failure.c
@@ -8,10 +8,10 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -fdisable-module-hash -emit-module -fmodule-name=load_failure %S/Inputs/module.map
-// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
// CHECK-NONEXISTENT: load_failure.c:2:9: fatal error: module 'load_nonexistent' not found
-// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -fdisable-module-hash %s -DFAILURE 2> %t.out
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs -fdisable-module-hash %s -DFAILURE 2> %t.out
// RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t.out
// FIXME: Clean up diagnostic text below and give it a location
diff --git a/test/Modules/lookup.cpp b/test/Modules/lookup.cpp
index efd88f47e35e4..bfe0307a0b2e0 100644
--- a/test/Modules/lookup.cpp
+++ b/test/Modules/lookup.cpp
@@ -26,8 +26,8 @@ void f() {
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodules-cache-path=%t -fmodule-name=lookup_left_cxx %S/Inputs/module.map -verify
// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodules-cache-path=%t -fmodule-name=lookup_right_cxx %S/Inputs/module.map -verify
-// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t %s -verify
-// RUN: %clang_cc1 -fmodules -ast-print -x objective-c++ -fmodules-cache-path=%t %s | FileCheck -check-prefix=CHECK-PRINT %s
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -I %S/Inputs %s -verify
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c++ -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix=CHECK-PRINT %s
// FIXME: When we have a syntax for modules in C++, use that.
// CHECK-PRINT: int *f0(int *);
diff --git a/test/Modules/lookup.m b/test/Modules/lookup.m
index 54c74913907d2..187e8763ca639 100644
--- a/test/Modules/lookup.m
+++ b/test/Modules/lookup.m
@@ -1,8 +1,8 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -verify %s
-// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodules-cache-path=%t %s | FileCheck -check-prefix=CHECK-PRINT %s
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix=CHECK-PRINT %s
@import lookup_left_objc;
@import lookup_right_objc;
diff --git a/test/Modules/macro-hiding.cpp b/test/Modules/macro-hiding.cpp
new file mode 100644
index 0000000000000..b166f4b194cfb
--- /dev/null
+++ b/test/Modules/macro-hiding.cpp
@@ -0,0 +1,104 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DB2 -DC1 -DD1
+//
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DE1
+
+#ifdef A1
+#include "a1.h"
+#endif
+
+#ifdef A2
+#include "a2.h"
+#endif
+
+#ifdef B1
+#include "b1.h"
+#endif
+
+#ifdef B2
+#include "b2.h"
+#endif
+
+#ifdef C1
+#include "c1.h"
+#endif
+
+#ifdef D1
+#include "d1.h"
+#endif
+
+#ifdef E1
+#include "e1.h"
+#endif
+
+#ifdef E2
+#include "e2.h"
+#endif
+
+#if defined(A1) || defined(B2) || defined(C1) || defined(D1) || defined(E1) || defined(E2)
+void h() { assert(true); }
+#else
+void assert() {}
+#endif
diff --git a/test/Modules/macro-reexport/a1.h b/test/Modules/macro-reexport/a1.h
new file mode 100644
index 0000000000000..39933315f7ee6
--- /dev/null
+++ b/test/Modules/macro-reexport/a1.h
@@ -0,0 +1 @@
+#define assert(x) a
diff --git a/test/Modules/macro-reexport/a2.h b/test/Modules/macro-reexport/a2.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/macro-reexport/a2.h
diff --git a/test/Modules/macro-reexport/b1.h b/test/Modules/macro-reexport/b1.h
new file mode 100644
index 0000000000000..e69de29bb2d1d
--- /dev/null
+++ b/test/Modules/macro-reexport/b1.h
diff --git a/test/Modules/macro-reexport/b2.h b/test/Modules/macro-reexport/b2.h
new file mode 100644
index 0000000000000..26150458d3531
--- /dev/null
+++ b/test/Modules/macro-reexport/b2.h
@@ -0,0 +1,2 @@
+#include "a2.h"
+#define assert(x) b
diff --git a/test/Modules/macro-reexport/c1.h b/test/Modules/macro-reexport/c1.h
new file mode 100644
index 0000000000000..d6a20e7419c19
--- /dev/null
+++ b/test/Modules/macro-reexport/c1.h
@@ -0,0 +1,2 @@
+#include "b1.h"
+#define assert(x) c
diff --git a/test/Modules/macro-reexport/d1.h b/test/Modules/macro-reexport/d1.h
new file mode 100644
index 0000000000000..fbd68d5de5821
--- /dev/null
+++ b/test/Modules/macro-reexport/d1.h
@@ -0,0 +1,2 @@
+#include "c1.h"
+#define assert(x) d
diff --git a/test/Modules/macro-reexport/d2.h b/test/Modules/macro-reexport/d2.h
new file mode 100644
index 0000000000000..688f2d98a13b8
--- /dev/null
+++ b/test/Modules/macro-reexport/d2.h
@@ -0,0 +1 @@
+#include "b2.h"
diff --git a/test/Modules/macro-reexport/macro-reexport.cpp b/test/Modules/macro-reexport/macro-reexport.cpp
new file mode 100644
index 0000000000000..47b15c2740bd5
--- /dev/null
+++ b/test/Modules/macro-reexport/macro-reexport.cpp
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -DD2 -I. %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DD2 -I. -fmodules %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DC1 -I. %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DC1 -I. -fmodules %s -fmodules-cache-path=%t -verify
+
+#ifdef D2
+#include "d2.h"
+void f() { return assert(true); } // expected-error {{undeclared identifier 'b'}}
+#else
+#include "c1.h"
+void f() { return assert(true); } // expected-error {{undeclared identifier 'c'}}
+#endif
diff --git a/test/Modules/macro-reexport/module.modulemap b/test/Modules/macro-reexport/module.modulemap
new file mode 100644
index 0000000000000..21585b692e3f9
--- /dev/null
+++ b/test/Modules/macro-reexport/module.modulemap
@@ -0,0 +1,15 @@
+module b {
+ module b2 { header "b2.h" export * }
+ module b1 { header "b1.h" export * }
+}
+module a {
+ module a1 { header "a1.h" export * }
+ module a2 { header "a2.h" export * }
+}
+module c {
+ module c1 { header "c1.h" export * }
+}
+module d {
+ module d1 { header "d1.h" export * }
+ module d2 { header "d2.h" export * }
+}
diff --git a/test/Modules/macro-undef-through-pch.m b/test/Modules/macro-undef-through-pch.m
new file mode 100644
index 0000000000000..0e5e99fb8befc
--- /dev/null
+++ b/test/Modules/macro-undef-through-pch.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c-header -fmodules -fmodules-cache-path=%t \
+// RUN: -I%S/Inputs/macro-undef-through-pch -emit-pch \
+// RUN: %S/Inputs/macro-undef-through-pch/foo.h -o %t.pch
+// RUN: %clang_cc1 -x objective-c -fmodules -fmodules-cache-path=%t \
+// RUN: -I%S/Inputs/macro-undef-through-pch -emit-pch \
+// RUN: -include-pch %t.pch %s
+
+// PR19215
+#undef AB
diff --git a/test/Modules/macros.c b/test/Modules/macros.c
index 541c95be58de7..7a7e570ca256b 100644
--- a/test/Modules/macros.c
+++ b/test/Modules/macros.c
@@ -3,18 +3,16 @@
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_left %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_right %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t %s
-// RUN: not %clang_cc1 -E -fmodules -x objective-c -fmodules-cache-path=%t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s
+// RUN: not %clang_cc1 -E -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
// FIXME: When we have a syntax for modules in C, use that.
// These notes come from headers in modules, and are bogus.
// FIXME: expected-note@Inputs/macros_left.h:11{{previous definition is here}}
// FIXME: expected-note@Inputs/macros_right.h:12{{previous definition is here}}
// expected-note@Inputs/macros_right.h:12{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}}
-// expected-note@Inputs/macros_top.h:13{{other definition of 'TOP_RIGHT_REDEF'}}
// expected-note@Inputs/macros_right.h:13{{expanding this definition of 'LEFT_RIGHT_DIFFERENT2'}}
// expected-note@Inputs/macros_left.h:14{{other definition of 'LEFT_RIGHT_DIFFERENT'}}
-// expected-note@Inputs/macros_right.h:17{{expanding this definition of 'TOP_RIGHT_REDEF'}}
@import macros;
@@ -79,8 +77,8 @@ void f() {
# error TOP should be visible
#endif
-#ifndef TOP_LEFT_UNDEF
-# error TOP_LEFT_UNDEF should still be defined
+#ifdef TOP_LEFT_UNDEF
+# error TOP_LEFT_UNDEF should not be defined
#endif
void test1() {
@@ -112,7 +110,7 @@ void test2() {
int i;
float f;
double d;
- TOP_RIGHT_REDEF *fp = &f; // expected-warning{{ambiguous expansion of macro 'TOP_RIGHT_REDEF'}}
+ TOP_RIGHT_REDEF *fp = &f; // ok, right's definition overrides top's definition
LEFT_RIGHT_IDENTICAL *ip = &i;
LEFT_RIGHT_DIFFERENT *ip2 = &i; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT'}}
@@ -134,6 +132,33 @@ void test3() {
@import macros_right.undef;
-#ifndef TOP_RIGHT_UNDEF
-# error TOP_RIGHT_UNDEF should still be defined
+// FIXME: When macros_right.undef is built, macros_top is visible because
+// the state from building macros_right leaks through, so macros_right.undef
+// undefines macros_top's macro.
+#ifdef TOP_RIGHT_UNDEF
+# error TOP_RIGHT_UNDEF should not be defined
+#endif
+
+@import macros_other;
+
+#ifndef TOP_OTHER_UNDEF1
+# error TOP_OTHER_UNDEF1 should still be defined
+#endif
+
+#ifndef TOP_OTHER_UNDEF2
+# error TOP_OTHER_UNDEF2 should still be defined
#endif
+
+#ifndef TOP_OTHER_REDEF1
+# error TOP_OTHER_REDEF1 should still be defined
+#endif
+int n1 = TOP_OTHER_REDEF1; // expected-warning{{ambiguous expansion of macro 'TOP_OTHER_REDEF1'}}
+// expected-note@macros_top.h:19 {{expanding this definition}}
+// expected-note@macros_other.h:4 {{other definition}}
+
+#ifndef TOP_OTHER_REDEF2
+# error TOP_OTHER_REDEF2 should still be defined
+#endif
+int n2 = TOP_OTHER_REDEF2; // ok
+
+int n3 = TOP_OTHER_DEF_RIGHT_UNDEF; // ok
diff --git a/test/Modules/macros2.c b/test/Modules/macros2.c
new file mode 100644
index 0000000000000..c4c8059011ccd
--- /dev/null
+++ b/test/Modules/macros2.c
@@ -0,0 +1,83 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s
+
+// This test checks some of the same things as macros.c, but imports modules in
+// a different order.
+
+@import macros_other;
+
+int n0 = TOP_OTHER_DEF_RIGHT_UNDEF; // ok
+
+@import macros_top;
+
+TOP_OTHER_DEF_RIGHT_UNDEF *n0b; // expected-warning{{ambiguous expansion of macro 'TOP_OTHER_DEF_RIGHT_UNDEF'}}
+// expected-note@macros_top.h:22 {{expanding this definition of 'TOP_OTHER_DEF_RIGHT_UNDEF'}}
+// expected-note@macros_other.h:6 {{other definition of 'TOP_OTHER_DEF_RIGHT_UNDEF'}}
+
+@import macros_right;
+@import macros_left;
+
+#ifdef TOP_LEFT_UNDEF
+# error TOP_LEFT_UNDEF should not be defined
+#endif
+
+#ifndef TOP_RIGHT_UNDEF
+# error TOP_RIGHT_UNDEF should still be defined
+#endif
+
+void test() {
+ float f;
+ TOP_RIGHT_REDEF *fp = &f; // ok, right's definition overrides top's definition
+
+ // Note, left's definition wins here, whereas right's definition wins in
+ // macros.c.
+ int i;
+ LEFT_RIGHT_IDENTICAL *ip = &i;
+ LEFT_RIGHT_DIFFERENT *ip2 = &f; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT'}}
+ // expected-note@macros_left.h:14 {{expanding this}}
+ // expected-note@macros_right.h:12 {{other}}
+ LEFT_RIGHT_DIFFERENT2 *ip3 = &f; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT2}}
+ // expected-note@macros_left.h:11 {{expanding this}}
+ // expected-note@macros_right.h:13 {{other}}
+#undef LEFT_RIGHT_DIFFERENT3
+ int LEFT_RIGHT_DIFFERENT3;
+}
+
+@import macros_right.undef;
+
+// FIXME: See macros.c.
+#ifdef TOP_RIGHT_UNDEF
+# error TOP_RIGHT_UNDEF should not be defined
+#endif
+
+#ifndef TOP_OTHER_UNDEF1
+# error TOP_OTHER_UNDEF1 should still be defined
+#endif
+
+#ifndef TOP_OTHER_UNDEF2
+# error TOP_OTHER_UNDEF2 should still be defined
+#endif
+
+#ifndef TOP_OTHER_REDEF1
+# error TOP_OTHER_REDEF1 should still be defined
+#endif
+int n1 = TOP_OTHER_REDEF1; // expected-warning{{ambiguous expansion of macro 'TOP_OTHER_REDEF1'}}
+// expected-note@macros_top.h:19 {{expanding this definition}}
+// expected-note@macros_other.h:4 {{other definition}}
+
+#ifndef TOP_OTHER_REDEF2
+# error TOP_OTHER_REDEF2 should still be defined
+#endif
+int n2 = TOP_OTHER_REDEF2; // ok
+
+int n3 = TOP_OTHER_DEF_RIGHT_UNDEF; // ok
+
+int top_redef_in_submodules = TOP_REDEF_IN_SUBMODULES;
+@import macros_top.c;
+void test2() {
+ int TOP_REDEF_IN_SUBMODULES = top_redef_in_submodules;
+}
diff --git a/test/Modules/malformed.cpp b/test/Modules/malformed.cpp
new file mode 100644
index 0000000000000..cd7b33493998b
--- /dev/null
+++ b/test/Modules/malformed.cpp
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/malformed -DHEADER="a1.h" %s 2>&1 | FileCheck %s --check-prefix=CHECK-A
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/malformed -DHEADER="b1.h" %s 2>&1 | FileCheck %s --check-prefix=CHECK-B
+
+#define STR2(x) #x
+#define STR(x) STR2(x)
+#include STR(HEADER)
+
+// CHECK-A: While building module 'malformed_a'
+// CHECK-A: a1.h:1:{{.*}} error: expected '}'
+// CHECK-A: a1.h:1:{{.*}} note: to match this '{'
+//
+// CHECK-A: While building module 'malformed_a'
+// CHECK-A: a2.h:1:{{.*}} error: extraneous closing brace
+
+// CHECK-B: While building module 'malformed_b'
+// CHECK-B: b1.h:2:{{.*}} error: expected '}'
+// CHECK-B: b1.h:1:{{.*}} note: to match this '{'
+// CHECK-B: b1.h:3:{{.*}} error: extraneous closing brace ('}')
+//
+// CHECK-B: While building module 'malformed_b'
+// CHECK-B: b2.h:1:{{.*}} error: redefinition of 'g'
+// CHECK-B: b2.h:1:{{.*}} note: previous definition is here
diff --git a/test/Modules/missing-header.m b/test/Modules/missing-header.m
new file mode 100644
index 0000000000000..c2c1673ac5b0f
--- /dev/null
+++ b/test/Modules/missing-header.m
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -x objective-c -fmodules-cache-path=%t -fmodules -I %S/Inputs/submodules %s 2>&1 | FileCheck %s
+
+// FIXME: cannot use -verify, because the error from inside the module build has
+// a different source manager than the verifier.
+
+@import missing_unavailable_headers; // OK
+@import missing_unavailable_headers.not_missing; // OK
+// CHECK-NOT: missing_unavailable_headers
+
+@import missing_headers;
+// CHECK: module.map:15:27: error: header 'missing.h' not found
+// CHECK: could not build module 'missing_headers'
diff --git a/test/Modules/missing-submodule.m b/test/Modules/missing-submodule.m
new file mode 100644
index 0000000000000..4f3553ce6c4bb
--- /dev/null
+++ b/test/Modules/missing-submodule.m
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -F %S/Inputs %s -verify
+#include <Module/NotInModule.h> // expected-warning{{missing submodule 'Module.NotInModule'}}
+
+int getNotInModule() {
+ return not_in_module;
+}
diff --git a/test/Modules/module-private.cpp b/test/Modules/module-private.cpp
index 438dcab9841ca..9213a0f20cbca 100644
--- a/test/Modules/module-private.cpp
+++ b/test/Modules/module-private.cpp
@@ -1,7 +1,7 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -fmodule-name=module_private_left -emit-module %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -fmodule-name=module_private_right -emit-module %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t %s -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -I %S/Inputs %s -verify
// FIXME: When we have a syntax for modules in C++, use that.
@import module_private_left;
diff --git a/test/Modules/module_file_info.m b/test/Modules/module_file_info.m
index 09319d60fe804..2447a747e3ddd 100644
--- a/test/Modules/module_file_info.m
+++ b/test/Modules/module_file_info.m
@@ -2,11 +2,14 @@
@import DependsOnModule;
// RUN: rm -rf %t
-// RUN: %clang_cc1 -w -fmodules -fdisable-module-hash -fmodules-cache-path=%t -F %S/Inputs -DBLARG -DWIBBLE=WOBBLE %s
+// RUN: %clang_cc1 -w -Wunused -fmodules -fdisable-module-hash -fmodules-cache-path=%t -F %S/Inputs -DBLARG -DWIBBLE=WOBBLE %s
// RUN: %clang_cc1 -module-file-info %t/DependsOnModule.pcm | FileCheck %s
// CHECK: Generated by this Clang:
+// CHECK: Module name: DependsOnModule
+// CHECK: Module map file: {{.*}}DependsOnModule.framework{{[/\\]}}module.map
+
// CHECK: Language options:
// CHECK: C99: Yes
// CHECK: Objective-C 1: Yes
@@ -16,8 +19,11 @@
// CHECK: Triple:
// CHECK: CPU:
// CHECK: ABI:
-// CHECK: C++ ABI:
-// CHECK: Linker version:
+
+// CHECK: Diagnostic options:
+// CHECK: IgnoreWarnings: Yes
+// CHECK: Diagnostic flags:
+// CHECK: -Wunused
// CHECK: Header search options:
// CHECK: System root [-isysroot=]: '/'
diff --git a/test/Modules/modulemap-locations.m b/test/Modules/modulemap-locations.m
new file mode 100644
index 0000000000000..9acdcd63436bd
--- /dev/null
+++ b/test/Modules/modulemap-locations.m
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/ModuleMapLocations/Module_ModuleMap -I %S/Inputs/ModuleMapLocations/Both -F %S/Inputs/ModuleMapLocations -x objective-c -fsyntax-only %s -verify
+
+// regular
+@import module_modulemap;
+@import both;
+// framework
+@import Module_ModuleMap_F;
+@import Module_ModuleMap_F.Private;
+@import Both_F;
+@import Inferred;
+
+void test() {
+ will_be_found1();
+ wont_be_found1(); // expected-warning{{implicit declaration of function 'wont_be_found1' is invalid in C99}}
+ will_be_found2();
+ wont_be_found2(); // expected-warning{{implicit declaration of function 'wont_be_found2' is invalid in C99}}
+}
diff --git a/test/Modules/modules-with-same-name.m b/test/Modules/modules-with-same-name.m
new file mode 100644
index 0000000000000..c90aa5d7d842d
--- /dev/null
+++ b/test/Modules/modules-with-same-name.m
@@ -0,0 +1,35 @@
+// REQUIRES: shell
+// RUN: rm -rf %t
+
+// A from path 1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-ignore-macro=EXPECTED_PATH -fmodules-ignore-macro=DIRECT -fsyntax-only %s -verify -I %S/Inputs/modules-with-same-name/path1/A -DDIRECT -DEXPECTED_PATH=1
+
+// A from path 2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-ignore-macro=EXPECTED_PATH -fmodules-ignore-macro=DIRECT -fsyntax-only %s -verify -I %S/Inputs/modules-with-same-name/path2/A -DDIRECT -DEXPECTED_PATH=2
+
+// Confirm that we have two pcm files (one for each 'A').
+// RUN: find %t -name "A-*.pcm" | count 2
+
+// DependsOnA, using A from path 1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-ignore-macro=EXPECTED_PATH -fmodules-ignore-macro=DIRECT -fsyntax-only %s -verify -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -DEXPECTED_PATH=1
+
+// Confirm that we have three pcm files (one for each 'A', and one for 'DependsOnA')
+// RUN: find %t -name "*.pcm" | count 3
+
+// DependsOnA, using A from path 2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-ignore-macro=EXPECTED_PATH -fmodules-ignore-macro=DIRECT -fsyntax-only %s -verify -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path2/A -DEXPECTED_PATH=2
+
+// Confirm that we still have three pcm files, since DependsOnA will be rebuilt
+// RUN: find %t -name "*.pcm" | count 3
+
+#ifdef DIRECT
+@import A;
+#else
+@import DependsOnA;
+#endif
+
+#if FROM_PATH != EXPECTED_PATH
+#error "Got the wrong module!"
+#endif
+
+// expected-no-diagnostics
diff --git a/test/Modules/namespaces.cpp b/test/Modules/namespaces.cpp
index 8c225e051bdea..a6f4c25cc0944 100644
--- a/test/Modules/namespaces.cpp
+++ b/test/Modules/namespaces.cpp
@@ -36,6 +36,9 @@ void test() {
double &dr3 = global(1.0);
double &dr4 = ::global2(1.0);
double &dr5 = LookupBeforeImport::f(1.0);
+
+ struct AddAndReexportBeforeImport::S s;
+ int k = AddAndReexportBeforeImport::S;
}
// Test namespaces merged without a common first declaration.
@@ -69,8 +72,8 @@ void testMergedMerged() {
// Test merging when using anonymous namespaces, which does not
// actually perform any merging.
void testAnonymousNotMerged() {
- N11::consumeFoo(N11::getFoo()); // expected-error{{cannot initialize a parameter of type 'N11::<anonymous>::Foo *' with an rvalue of type 'N11::<anonymous>::Foo *'}}
- N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a parameter of type 'N12::<anonymous>::Foo *' with an rvalue of type 'N12::<anonymous>::Foo *'}}
+ N11::consumeFoo(N11::getFoo()); // expected-error{{cannot initialize a parameter of type 'N11::(anonymous namespace)::Foo *' with an rvalue of type 'N11::(anonymous namespace)::Foo *'}}
+ N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a parameter of type 'N12::(anonymous namespace)::Foo *' with an rvalue of type 'N12::(anonymous namespace)::Foo *'}}
}
// expected-note@Inputs/namespaces-right.h:60 {{passing argument to parameter here}}
diff --git a/test/Modules/no-stale-modtime.m b/test/Modules/no-stale-modtime.m
new file mode 100644
index 0000000000000..1bff2b017a430
--- /dev/null
+++ b/test/Modules/no-stale-modtime.m
@@ -0,0 +1,37 @@
+// Ensure that when rebuilding a module we don't save its old modtime when
+// building modules that depend on it.
+
+// REQUIRES: shell
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// This could be replaced by diamond_*, except we want to modify the top header
+// RUN: echo '@import l; @import r;' > %t/b.h
+// RUN: echo '@import t; // fromt l' > %t/l.h
+// RUN: echo '@import t; // fromt r' > %t/r.h
+// RUN: echo '// top' > %t/t.h
+// RUN: echo 'module b { header "b.h" } module l { header "l.h" }' > %t/module.map
+// RUN: echo 'module r { header "r.h" } module t { header "t.h" }' >> %t/module.map
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -I %t -fsyntax-only %s -Rmodule-build 2>&1 \
+// RUN: | FileCheck -check-prefix=REBUILD-ALL %s
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -I %t -fsyntax-only %s -Rmodule-build -verify
+
+// Add an identifier to ensure everything depending on t is out of date
+// RUN: echo 'extern int a;' >> %t/t.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -I %t -fsyntax-only %s -Rmodule-build 2>&1 \
+// RUN: | FileCheck -check-prefix=REBUILD-ALL %s
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
+// RUN: -I %t -fsyntax-only %s -Rmodule-build -verify
+
+// REBUILD-ALL: building module 'b'
+// REBUILD-ALL: building module 'l'
+// REBUILD-ALL: building module 't'
+// REBUILD-ALL: building module 'r'
+
+// Use -verify when expecting no modules to be rebuilt.
+// expected-no-diagnostics
+
+@import b;
diff --git a/test/Modules/objc-categories.m b/test/Modules/objc-categories.m
index f08b13a78ab2a..a66ab8d631255 100644
--- a/test/Modules/objc-categories.m
+++ b/test/Modules/objc-categories.m
@@ -4,7 +4,7 @@
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify
@import category_bottom;
diff --git a/test/Modules/objc_redef.m b/test/Modules/objc_redef.m
index f91124172f763..28e47665f24f5 100644
--- a/test/Modules/objc_redef.m
+++ b/test/Modules/objc_redef.m
@@ -8,6 +8,6 @@ int test(id x) {
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=weird_objc %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify
// expected-no-diagnostics
diff --git a/test/Modules/prune.m b/test/Modules/prune.m
index 8af7e6c395ae7..7bc771f7843d5 100644
--- a/test/Modules/prune.m
+++ b/test/Modules/prune.m
@@ -14,33 +14,33 @@
// RUN: %clang_cc1 -DIMPORT_DEPENDS_ON_MODULE -fmodules-ignore-macro=DIMPORT_DEPENDS_ON_MODULE -fmodules -F %S/Inputs -fmodules-cache-path=%t %s -verify
// RUN: %clang_cc1 -DIMPORT_DEPENDS_ON_MODULE -fmodules-ignore-macro=DIMPORT_DEPENDS_ON_MODULE -fmodules -F %S/Inputs -fmodules-cache-path=%t %s -verify
// RUN: ls %t | grep modules.timestamp
-// RUN: ls -R %t | grep ^Module.pcm
-// RUN: ls -R %t | grep DependsOnModule.pcm
+// RUN: ls -R %t | grep ^Module.*pcm
+// RUN: ls -R %t | grep DependsOnModule.*pcm
// Set the timestamp back more than two days. We should try to prune,
// but nothing gets pruned because the module files are new enough.
// RUN: touch -m -a -t 201101010000 %t/modules.timestamp
// RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
// RUN: ls %t | grep modules.timestamp
-// RUN: ls -R %t | grep ^Module.pcm
-// RUN: ls -R %t | grep DependsOnModule.pcm
+// RUN: ls -R %t | grep ^Module.*pcm
+// RUN: ls -R %t | grep DependsOnModule.*pcm
// Set the DependsOnModule access time back more than four days.
// This shouldn't prune anything, because the timestamp has been updated, so
// the pruning mechanism won't fire.
-// RUN: find %t -name DependsOnModule.pcm | xargs touch -a -t 201101010000
+// RUN: find %t -name DependsOnModule*.pcm | xargs touch -a -t 201101010000
// RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
// RUN: ls %t | grep modules.timestamp
-// RUN: ls -R %t | grep ^Module.pcm
-// RUN: ls -R %t | grep DependsOnModule.pcm
+// RUN: ls -R %t | grep ^Module.*pcm
+// RUN: ls -R %t | grep DependsOnModule.*pcm
// Set both timestamp and DependsOnModule.pcm back beyond the cutoff.
// This should trigger pruning, which will remove DependsOnModule but not Module.
// RUN: touch -m -a -t 201101010000 %t/modules.timestamp
-// RUN: find %t -name DependsOnModule.pcm | xargs touch -a -t 201101010000
+// RUN: find %t -name DependsOnModule*.pcm | xargs touch -a -t 201101010000
// RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
// RUN: ls %t | grep modules.timestamp
-// RUN: ls -R %t | grep ^Module.pcm
-// RUN: ls -R %t | not grep DependsOnModule.pcm
+// RUN: ls -R %t | grep ^Module.*pcm
+// RUN: ls -R %t | not grep DependsOnModule.*pcm
// expected-no-diagnostics
diff --git a/test/Modules/recursive.c b/test/Modules/recursive.c
new file mode 100644
index 0000000000000..5315b10522b4a
--- /dev/null
+++ b/test/Modules/recursive.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s 2>&1 | FileCheck %s
+#include "recursive1.h"
+
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=recursive1 %S/Inputs/module.map 2>&1 | FileCheck %s
+
+// CHECK: While building module 'recursive1'{{( imported from .*[/\]recursive.c:3)?}}:
+// CHECK-NEXT: While building module 'recursive2' imported from {{.*Inputs[/\]}}recursive1.h:1:
+// CHECK-NEXT: In file included from <module-includes>:1:
+// CHECK-NEXT: recursive2.h:1:10: fatal error: cyclic dependency in module 'recursive1': recursive1 -> recursive2 -> recursive1
diff --git a/test/Modules/redecl-add-after-load.cpp b/test/Modules/redecl-add-after-load.cpp
new file mode 100644
index 0000000000000..68deaf8b4ef9f
--- /dev/null
+++ b/test/Modules/redecl-add-after-load.cpp
@@ -0,0 +1,59 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 -DIMPORT_DECLS
+
+#ifdef IMPORT_DECLS
+// expected-no-diagnostics
+@import redecl_add_after_load_decls;
+#else
+typedef struct A B;
+extern const int variable;
+extern constexpr int function();
+constexpr int test(bool b) { return b ? variable : function(); }
+
+namespace N {
+ typedef struct A B;
+ extern const int variable;
+ extern constexpr int function();
+}
+typedef N::B NB;
+constexpr int N_test(bool b) { return b ? N::variable : N::function(); }
+
+@import redecl_add_after_load_top;
+typedef C::A CB;
+constexpr int C_test(bool b) { return b ? C::variable : C::function(); }
+
+struct D {
+ struct A; // expected-note {{forward}}
+ static const int variable;
+ static constexpr int function(); // expected-note {{here}}
+};
+typedef D::A DB;
+constexpr int D_test(bool b) { return b ? D::variable : D::function(); } // expected-note {{subexpression}} expected-note {{undefined}}
+#endif
+
+@import redecl_add_after_load;
+
+B tu_struct_test;
+constexpr int tu_variable_test = test(true);
+constexpr int tu_function_test = test(false);
+
+NB ns_struct_test;
+constexpr int ns_variable_test = N_test(true);
+constexpr int ns_function_test = N_test(false);
+
+CB struct_struct_test;
+constexpr int struct_variable_test = C_test(true);
+constexpr int struct_function_test = C_test(false);
+
+// FIXME: We should accept this, but we're currently too lazy when merging class
+// definitions to determine that the definitions in redecl_add_after_load are
+// definitions of these entities.
+DB merged_struct_struct_test;
+constexpr int merged_struct_variable_test = D_test(true);
+constexpr int merged_struct_function_test = D_test(false);
+#ifndef IMPORT_DECLS
+// expected-error@-4 {{incomplete}}
+// expected-error@-4 {{constant}} expected-note@-4 {{in call to}}
+// expected-error@-4 {{constant}} expected-note@-4 {{in call to}}
+#endif
diff --git a/test/Modules/redecl-namespaces.mm b/test/Modules/redecl-namespaces.mm
index 93102c04bc3a2..203daa9a2bb01 100644
--- a/test/Modules/redecl-namespaces.mm
+++ b/test/Modules/redecl-namespaces.mm
@@ -10,4 +10,4 @@ void test() {
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -emit-module -fmodule-name=redecl_namespaces_left %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -emit-module -fmodule-name=redecl_namespaces_right %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -w %s -verify
diff --git a/test/Modules/redeclarations.m b/test/Modules/redeclarations.m
index f210f37f3ab8b..11aca7597830d 100644
--- a/test/Modules/redeclarations.m
+++ b/test/Modules/redeclarations.m
@@ -7,6 +7,6 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=redeclarations_right %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify
// expected-no-diagnostics
diff --git a/test/Modules/redecls/main.m b/test/Modules/redecls/main.m
index 9ec02b03f2cce..bf3788a96d80e 100644
--- a/test/Modules/redecls/main.m
+++ b/test/Modules/redecls/main.m
@@ -1,9 +1,9 @@
// RUN: rm -rf %t.mcp
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=a %S/module.map -fmodules-cache-path=%t.mcp
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=b %S/module.map -fmodules-cache-path=%t.mcp
-// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t1.pch -fmodules-cache-path=%t.mcp
-// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t2.pch -include-pch %t1.pch -fmodules-cache-path=%t.mcp
-// RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -fmodules-cache-path=%t.mcp -verify
+// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t1.pch -fmodules-cache-path=%t.mcp -I %S
+// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t2.pch -include-pch %t1.pch -fmodules-cache-path=%t.mcp -I %S
+// RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -I %S -fmodules-cache-path=%t.mcp -verify
#ifndef HEADER1
#define HEADER1
diff --git a/test/Modules/renamed.m b/test/Modules/renamed.m
index 4e8f5329bb0f6..ec2616e9a7243 100644
--- a/test/Modules/renamed.m
+++ b/test/Modules/renamed.m
@@ -3,6 +3,6 @@
int f() { return same_api; }
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -I %S/Inputs -fmodules-cache-path=%t %s -verify
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/oldname -fmodules-cache-path=%t %s -verify
// expected-no-diagnostics
diff --git a/test/Modules/require-modular-includes.m b/test/Modules/require-modular-includes.m
new file mode 100644
index 0000000000000..835a35243396f
--- /dev/null
+++ b/test/Modules/require-modular-includes.m
@@ -0,0 +1,83 @@
+// RUN: rm -rf %t
+// REQUIRES: shell
+
+// Including a header from the imported module
+// RUN: echo '@import FromImportedModuleOK;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -Werror -fsyntax-only -x objective-c -
+
+// Including a non-modular header
+// RUN: echo '@import FromImportedModuleFail;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -I %S/Inputs/require-modular-includes \
+// RUN: -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Including a header from a subframework
+// RUN: echo '@import FromSubframework;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -Werror -fsyntax-only -x objective-c -
+
+// Including a header from a subframework (fail)
+// RUN: echo '@import FromNonModularSubframework;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -I %S/Inputs/require-modular-includes \
+// RUN: -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Including a non-modular header from a submodule
+// RUN: echo '@import FromImportedSubModule;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -I %S/Inputs/require-modular-includes \
+// RUN: -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Including a non-modular header (directly) with -fmodule-name set
+// RUN: echo '#include "NotInModule.h"' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -I %S/Inputs/require-modular-includes \
+// RUN: -Werror -fmodule-name=A -fsyntax-only -x objective-c -
+
+// Including an excluded header
+// RUN: echo '@import IncludeExcluded;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -Werror -fsyntax-only -x objective-c -
+
+// Including a header from another module
+// RUN: echo '@import FromAnotherModule;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -I %S/Inputs/require-modular-includes \
+// RUN: -Werror -fsyntax-only -x objective-c -
+
+// Including an excluded header from another module
+// RUN: echo '@import ExcludedFromAnotherModule;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -I %S/Inputs/require-modular-includes \
+// RUN: -Werror -fsyntax-only -x objective-c -
+
+// Including a header from an umbrella directory
+// RUN: echo '@import FromUmbrella;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -I %S/Inputs/require-modular-includes \
+// RUN: -Werror -fsyntax-only -x objective-c -
+
+// A includes B includes non-modular C
+// RUN: echo '@import A;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN: -I %S/Inputs/require-modular-includes \
+// RUN: -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Non-framework module (pass)
+// RUN: echo '@import NotFramework;' | \
+// RUN: %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN: -fmodules-cache-path=%t -I %S/Inputs/require-modular-includes \
+// RUN: -Werror -fsyntax-only -x objective-c -
+
+// CHECK: include of non-modular header
diff --git a/test/Modules/resolution-change.m b/test/Modules/resolution-change.m
new file mode 100644
index 0000000000000..011782eec2bf6
--- /dev/null
+++ b/test/Modules/resolution-change.m
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+
+// Build PCH using A from path 1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -emit-pch -o %t-A.pch %s
+
+// Use the PCH with the same header search options; should be fine
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -include-pch %t-A.pch %s -fsyntax-only -Werror
+
+// Different -W options are ok
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -include-pch %t-A.pch %s -fsyntax-only -Werror -Wauto-import
+
+// Use the PCH with no way to resolve DependsOnA
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NODOA %s
+// CHECK-NODOA: module 'DependsOnA' imported by AST file '{{.*A.pch}}' not found
+
+// Use the PCH with no way to resolve A
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NOA %s
+// CHECK-NOA: module 'A' imported by AST file '{{.*DependsOnA.*pcm}}' not found
+
+// Use the PCH and have it resolve the the other A
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path2/A -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-WRONGA %s
+// CHECK-WRONGA: module 'A' imported by AST file '{{.*DependsOnA.*pcm}}' found in a different module map file ({{.*path2.*}}) than when the importing AST file was built ({{.*path1.*}})
+
+#ifndef HEADER
+#define HEADER
+@import DependsOnA;
+#endif
diff --git a/test/Modules/strict-decluse.cpp b/test/Modules/strict-decluse.cpp
new file mode 100644
index 0000000000000..fa6955aef0d69
--- /dev/null
+++ b/test/Modules/strict-decluse.cpp
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-maps -fmodules-cache-path=%t -fmodules-strict-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
+
+#include "g.h"
+#include "e.h"
+#include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}}
+#include "i.h" // expected-error {{module XG does not depend on a module exporting 'i.h'}}
+
+const int g2 = g1 + e + f + aux_i;
diff --git a/test/Modules/string_names.cpp b/test/Modules/string_names.cpp
new file mode 100644
index 0000000000000..ed65aa8a67033
--- /dev/null
+++ b/test/Modules/string_names.cpp
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fmodules-decluse -I %S/Inputs/string_names %s -fmodule-name="my/module-a" -verify
+
+#include "a.h"
+#include "b.h" // expected-error {{does not depend on a module exporting}}
+#include "c.h"
diff --git a/test/Modules/subframework-from-intermediate-path.m b/test/Modules/subframework-from-intermediate-path.m
new file mode 100644
index 0000000000000..ae0bd64e394aa
--- /dev/null
+++ b/test/Modules/subframework-from-intermediate-path.m
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
+
+@import DependsOnModule;
+@import SubFramework; // expected-error{{module 'SubFramework' not found}}
diff --git a/test/Modules/submodules.cpp b/test/Modules/submodules.cpp
index 9c62389eadc04..c3b2623016a8f 100644
--- a/test/Modules/submodules.cpp
+++ b/test/Modules/submodules.cpp
@@ -26,11 +26,3 @@ hash_map<int, float> ints_to_floats; // expected-error{{declaration of 'hash_map
@import std.hash_map;
hash_map<int, float> ints_to_floats2;
-
-@import import_self.b;
-extern MyTypeA import_self_test_a; // expected-error {{must be imported from module 'import_self.a'}}
-// expected-note@import-self-a.h:1 {{here}}
-extern MyTypeC import_self_test_c;
-// FIXME: This should be valid; import_self.b re-exports import_self.d.
-extern MyTypeD import_self_test_d; // expected-error {{must be imported from module 'import_self.d'}}
-// expected-note@import-self-d.h:1 {{here}}
diff --git a/test/Modules/system_version.m b/test/Modules/system_version.m
index 85b3263f7256f..bc82bf8bc17b2 100644
--- a/test/Modules/system_version.m
+++ b/test/Modules/system_version.m
@@ -11,21 +11,21 @@
// Run once with no system version file. We should end up with one module.
// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c ModA.pcm| grep 1
+// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 1
// Add a system version file and run again. We should now have two
// module variants.
// RUN: mkdir -p %t/System/Library/CoreServices
// RUN: echo "hello" > %t/System/Library/CoreServices/SystemVersion.plist
// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c ModA.pcm| grep 2
+// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 2
// Change the system version file and run again. We should now have three
// module variants.
// RUN: mkdir -p %t/System/Library/CoreServices
// RUN: echo "modules" > %t/System/Library/CoreServices/SystemVersion.plist
// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c ModA.pcm| grep 3
+// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 3
// expected-no-diagnostics
@import ModA;
diff --git a/test/Modules/template-specialization-visibility.cpp b/test/Modules/template-specialization-visibility.cpp
new file mode 100644
index 0000000000000..efcfd93dd88bf
--- /dev/null
+++ b/test/Modules/template-specialization-visibility.cpp
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs/template-specialization-visibility -std=c++11 %s
+//
+// expected-no-diagnostics
+
+#include "c.h"
+
+S<int> implicit_inst_class_template;
+int k1 = implicit_inst_class_template.n;
+
+S<char> explicit_inst_class_template;
+int k2 = explicit_inst_class_template.n;
+
+#include "a.h"
+
+T<int>::S implicit_inst_member_class_template;
+int k3 = implicit_inst_member_class_template.n;
+
+T<char>::S explicit_inst_member_class_template;
+int k4 = explicit_inst_member_class_template.n;
+
+T<int>::E implicit_inst_member_enum_template;
+int k5 = decltype(implicit_inst_member_enum_template)::e;
+
+T<char>::E explicit_inst_member_enum_template;
+int k6 = decltype(explicit_inst_member_enum_template)::e;
diff --git a/test/Modules/templates.mm b/test/Modules/templates.mm
index 080f9e7c665e3..78348af41e778 100644
--- a/test/Modules/templates.mm
+++ b/test/Modules/templates.mm
@@ -4,6 +4,12 @@
// expected-no-diagnostics
@import templates_left;
+
+void testInlineRedeclEarly() {
+ // instantiate definition now, we'll add another declaration in _right.
+ OutOfLineInline<int>().h();
+}
+
@import templates_right;
// CHECK: @list_left = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 8,
@@ -20,6 +26,9 @@ void testTemplateClasses() {
N::Set<char> set_char;
set_char.insert('A');
+
+ List<double> list_double;
+ list_double.push_back(0.0);
}
void testPendingInstantiations() {
@@ -36,6 +45,19 @@ void testRedeclDefinition() {
redeclDefinitionEmit();
}
+void testInlineRedecl() {
+ outOfLineInlineUseLeftF();
+ outOfLineInlineUseRightG();
+
+ outOfLineInlineUseRightF();
+ outOfLineInlineUseLeftG();
+}
+
+// CHECK-NOT: @_ZN21ExplicitInstantiationILb0ELb0EE1fEv(
+// CHECK: declare {{.*}}@_ZN21ExplicitInstantiationILb1ELb0EE1fEv(
+// CHECK: define {{.*}}@_ZN21ExplicitInstantiationILb1ELb1EE1fEv(
+// CHECK-NOT: @_ZN21ExplicitInstantiationILb0ELb0EE1fEv(
+
// These three are all the same type.
typedef OuterIntInner_left OuterIntInner;
typedef OuterIntInner_right OuterIntInner;
@@ -58,12 +80,23 @@ unsigned testMixedStruct() {
// CHECK: call {{.*}}memcpy{{.*}}(i8* %{{.*}}, i8* bitcast ({{.*}}* @_ZZ15testMixedStructvE1r to i8*), i64 16,
ListInt_right r{0, 2};
- // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* %[[l]])
+ // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[l]])
useListInt(l);
- // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* %[[r]])
+ // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[r]])
useListInt(r);
// CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_left to i8*), i64 8) to i32*)
// CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_right to i8*), i64 8) to i32*)
return list_left.*size_right + list_right.*size_left;
}
+
+template<typename T> struct MergePatternDecl {
+ typedef int Type;
+ void f(Type);
+};
+template<typename T> void MergePatternDecl<T>::f(Type type) {}
+// CHECK: define {{.*}}@_ZN21ExplicitInstantiationILb0ELb1EE1fEv(
+template struct ExplicitInstantiation<false, true>;
+template struct ExplicitInstantiation<true, true>;
+
+void testDelayUpdatesImpl() { testDelayUpdates<int>(); }
diff --git a/test/Modules/undefined-type-fixit1.cpp b/test/Modules/undefined-type-fixit1.cpp
new file mode 100644
index 0000000000000..78ce174f54622
--- /dev/null
+++ b/test/Modules/undefined-type-fixit1.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fmodules-search-all -I %S/Inputs/undefined-type-fixit %s -verify
+
+//#include "public1.h"
+#include "public2.h"
+#include "public2sub.h"
+
+use_this1 client_variable1; // expected-error{{declaration of 'use_this1' must be imported from module 'public1' before it is required}}
+use_this2 client_variable2;
+use_this2sub client_variable2sub;
+
+// expected-note@Inputs/undefined-type-fixit/public1.h:4 {{previous declaration is here}}
diff --git a/test/Modules/unnecessary-module-map-parsing.c b/test/Modules/unnecessary-module-map-parsing.c
new file mode 100644
index 0000000000000..4c83448179e06
--- /dev/null
+++ b/test/Modules/unnecessary-module-map-parsing.c
@@ -0,0 +1,8 @@
+// This checks that we are not parsing module maps if modules are not enabled.
+
+// RUN: not %clang_cc1 -fmodules -I %S/Inputs/unnecessary-module-map-parsing -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -I %S/Inputs/unnecessary-module-map-parsing -fsyntax-only %s
+
+// CHECK: error: expected umbrella, header, submodule, or module export
+
+#include "a1.h"
diff --git a/test/Modules/update-after-load.cpp b/test/Modules/update-after-load.cpp
new file mode 100644
index 0000000000000..f497ea47945b3
--- /dev/null
+++ b/test/Modules/update-after-load.cpp
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/update-after-load -verify -fmodules-cache-path=%t %s
+
+// expected-no-diagnostics
+#include "a.h"
+namespace llvm {}
+#include "b.h"
+void llvm::f() {}
diff --git a/test/Modules/validate-system-headers.m b/test/Modules/validate-system-headers.m
new file mode 100644
index 0000000000000..48ea64c5a938f
--- /dev/null
+++ b/test/Modules/validate-system-headers.m
@@ -0,0 +1,43 @@
+// RUN: rm -rf %t/ModuleCache
+// RUN: mkdir -p %t/Inputs/usr/include
+// RUN: touch %t/Inputs/usr/include/foo.h
+// RUN: echo 'module Foo [system] { header "foo.h" }' > %t/Inputs/usr/include/module.map
+
+////
+// Build a module using a system header
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
+// RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
+
+////
+// Modify the system header, and confirm that we don't notice without -fmodules-validate-system-headers.
+// The pcm file in the cache should fail to validate.
+// RUN: echo ' ' >> %t/Inputs/usr/include/foo.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
+// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
+
+////
+// Now make sure we rebuild the module when -fmodules-validate-system-headers is set.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
+// RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
+
+
+////
+// This should override -fmodules-validate-once-per-build-session
+// RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
+// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
+
+// Modify the system header...
+// RUN: echo ' ' >> %t/Inputs/usr/include/foo.h
+
+// Don't recompile due to -fmodules-validate-once-per-build-session
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
+// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
+
+// Now add -fmodules-validate-system-headers and rebuild
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
+// RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
+
+// REQUIRES: shell
+
+@import Foo;