summaryrefslogtreecommitdiffstats
path: root/test/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'test/Modules')
-rw-r--r--test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h2
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h1
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h2
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h4
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h5
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Headers/other.h1
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h2
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/module.map19
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/module_private.map6
-rw-r--r--test/Modules/Inputs/MethodPoolA.h8
-rw-r--r--test/Modules/Inputs/MethodPoolB.h13
-rw-r--r--test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h5
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h1
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/Module.h10
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/NotInModule.h1
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/Sub.h3
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/Sub2.h1
-rw-r--r--test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h1
-rw-r--r--test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h2
-rw-r--r--test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h2
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/Headers/A.h8
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/Headers/B.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/module.map9
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/module_private.map4
-rw-r--r--test/Modules/Inputs/System/usr/include/module.map21
-rw-r--r--test/Modules/Inputs/System/usr/include/stdbool.h1
-rw-r--r--test/Modules/Inputs/System/usr/include/stdint.h1
-rw-r--r--test/Modules/Inputs/System/usr/include/stdio.h3
-rw-r--r--test/Modules/Inputs/category_bottom.h11
-rw-r--r--test/Modules/Inputs/category_left.h15
-rw-r--r--test/Modules/Inputs/category_other.h6
-rw-r--r--test/Modules/Inputs/category_right.h12
-rw-r--r--test/Modules/Inputs/category_top.h14
-rw-r--r--test/Modules/Inputs/decl.h2
-rw-r--r--test/Modules/Inputs/decl2.h1
-rw-r--r--test/Modules/Inputs/def-include.h13
-rw-r--r--test/Modules/Inputs/def.h11
-rw-r--r--test/Modules/Inputs/diamond.h1
-rw-r--r--test/Modules/Inputs/diamond_bottom.h4
-rw-r--r--test/Modules/Inputs/diamond_left.h2
-rw-r--r--test/Modules/Inputs/diamond_right.h2
-rw-r--r--test/Modules/Inputs/irgen.h1
-rw-r--r--test/Modules/Inputs/macros.h10
-rw-r--r--test/Modules/Inputs/module.map86
-rw-r--r--test/Modules/Inputs/module_private_left.h26
-rw-r--r--test/Modules/Inputs/module_private_right.h13
-rw-r--r--test/Modules/Inputs/namespaces-left.h53
-rw-r--r--test/Modules/Inputs/namespaces-right.h61
-rw-r--r--test/Modules/Inputs/namespaces-top.h14
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h4
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella/module.map3
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h2
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella2/module.map3
-rw-r--r--test/Modules/Inputs/normal-module-map/a1.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/a2.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/b1.h2
-rw-r--r--test/Modules/Inputs/normal-module-map/module.map13
-rw-r--r--test/Modules/Inputs/normal-module-map/nested/module.map4
-rw-r--r--test/Modules/Inputs/normal-module-map/nested/nested1.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/nested/nested2.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/nested_umbrella/a.h2
-rw-r--r--test/Modules/Inputs/normal-module-map/nested_umbrella/b.h2
-rw-r--r--test/Modules/Inputs/redecl-merge-bottom.h28
-rw-r--r--test/Modules/Inputs/redecl-merge-left-left.h7
-rw-r--r--test/Modules/Inputs/redecl-merge-left.h90
-rw-r--r--test/Modules/Inputs/redecl-merge-right.h94
-rw-r--r--test/Modules/Inputs/redecl-merge-top-explicit.h9
-rw-r--r--test/Modules/Inputs/redecl-merge-top.h20
-rw-r--r--test/Modules/Inputs/redecl_namespaces_left.h3
-rw-r--r--test/Modules/Inputs/redecl_namespaces_right.h3
-rw-r--r--test/Modules/Inputs/redeclarations_left.h2
-rw-r--r--test/Modules/Inputs/redeclarations_right.h2
-rw-r--r--test/Modules/Inputs/subdir/module.map3
-rw-r--r--test/Modules/Inputs/subdir/subdir.h1
-rw-r--r--test/Modules/Inputs/submodules/hash_map.h4
-rw-r--r--test/Modules/Inputs/submodules/module.map5
-rw-r--r--test/Modules/Inputs/submodules/type_traits.h12
-rw-r--r--test/Modules/Inputs/submodules/vector.h3
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/A_one.h1
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/A_two.h1
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/B_one.h1
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/B_two.h1
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/C_one.h4
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/C_two.h4
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/module.map20
-rw-r--r--test/Modules/auto-module-import.c13
-rw-r--r--test/Modules/auto-module-import.m73
-rw-r--r--test/Modules/compiler_builtins.m10
-rw-r--r--test/Modules/cstd.m29
-rw-r--r--test/Modules/cycles.c12
-rw-r--r--test/Modules/decldef.mm28
-rw-r--r--test/Modules/diamond-pch.c28
-rw-r--r--test/Modules/diamond.c14
-rw-r--r--test/Modules/header-import.m4
-rw-r--r--test/Modules/inferred-submodules.m15
-rw-r--r--test/Modules/irgen.c12
-rw-r--r--test/Modules/load_failure.c16
-rw-r--r--test/Modules/lookup.cpp21
-rw-r--r--test/Modules/lookup.m13
-rw-r--r--test/Modules/macros.c25
-rw-r--r--test/Modules/method_pool.m30
-rw-r--r--test/Modules/module-private.cpp82
-rw-r--r--test/Modules/namespaces.cpp64
-rw-r--r--test/Modules/normal-module-map.cpp35
-rw-r--r--test/Modules/objc-categories.m87
-rw-r--r--test/Modules/on-demand-build-warnings.m4
-rw-r--r--test/Modules/on-demand-build.m18
-rw-r--r--test/Modules/on-demand-macros.m6
-rw-r--r--test/Modules/redecl-merge.m158
-rw-r--r--test/Modules/redecl-namespaces.mm13
-rw-r--r--test/Modules/redeclarations.m11
-rw-r--r--test/Modules/requires.m5
-rw-r--r--test/Modules/subframeworks.m22
-rw-r--r--test/Modules/submodules-preprocess.cpp61
-rw-r--r--test/Modules/submodules.cpp29
-rw-r--r--test/Modules/submodules.m11
-rw-r--r--test/Modules/wildcard-submodule-exports.cpp26
122 files changed, 1614 insertions, 218 deletions
diff --git a/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h b/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h
new file mode 100644
index 0000000..1417e0c
--- /dev/null
+++ b/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h
@@ -0,0 +1,2 @@
+#import <Module/Module.h> // expected-warning{{treating #import as an import of module 'Module'}}
+
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h b/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h
new file mode 100644
index 0000000..69f9e8e
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h
@@ -0,0 +1 @@
+double *sub_framework_other;
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
new file mode 100644
index 0000000..e6e835e
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
@@ -0,0 +1,2 @@
+#include "SubFramework/Other.h"
+float *sub_framework;
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h b/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
index fa40697..9425f48 100644
--- a/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
+++ b/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
@@ -1,3 +1,5 @@
-#include <Module/Module.h>
+#include <Module/Module.h> //expected-warning{{treating #include as an import of module 'Module'}}
#define DEPENDS_ON_MODULE 1
+#__private_macro DEPENDS_ON_MODULE
+
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h b/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h
new file mode 100644
index 0000000..724d798
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h
@@ -0,0 +1,5 @@
+class CXXOnly {
+ public:
+ CXXOnly();
+ ~CXXOnly();
+};
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h b/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h
new file mode 100644
index 0000000..5ee3f92
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h
@@ -0,0 +1 @@
+int depends_on_module_other;
diff --git a/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h b/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h
new file mode 100644
index 0000000..4b3c30c
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h
@@ -0,0 +1,2 @@
+int depends_on_module_private;
+
diff --git a/test/Modules/Inputs/DependsOnModule.framework/module.map b/test/Modules/Inputs/DependsOnModule.framework/module.map
new file mode 100644
index 0000000..2a3dd80
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -0,0 +1,19 @@
+framework module DependsOnModule {
+ umbrella header "DependsOnModule.h"
+ header "other.h"
+ module * {
+ export *
+ }
+ explicit module CXX {
+ requires cplusplus
+ header "cxx_other.h"
+ }
+
+ explicit framework module SubFramework {
+ umbrella header "SubFramework.h"
+
+ module * {
+ export *
+ }
+ }
+}
diff --git a/test/Modules/Inputs/DependsOnModule.framework/module_private.map b/test/Modules/Inputs/DependsOnModule.framework/module_private.map
new file mode 100644
index 0000000..5ed0029
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/module_private.map
@@ -0,0 +1,6 @@
+explicit module DependsOnModule.Private {
+ explicit module DependsOnModule {
+ header "DependsOnModulePrivate.h"
+ }
+}
+
diff --git a/test/Modules/Inputs/MethodPoolA.h b/test/Modules/Inputs/MethodPoolA.h
new file mode 100644
index 0000000..6af24a9
--- /dev/null
+++ b/test/Modules/Inputs/MethodPoolA.h
@@ -0,0 +1,8 @@
+
+
+
+
+@interface A
++ (int)method1;
+- (int)method2:(int)param;
+@end
diff --git a/test/Modules/Inputs/MethodPoolB.h b/test/Modules/Inputs/MethodPoolB.h
new file mode 100644
index 0000000..e1e86ed
--- /dev/null
+++ b/test/Modules/Inputs/MethodPoolB.h
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+@interface B
+- (int)method1;
+- (int)method2:(float)param;
+@end
diff --git a/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
new file mode 100644
index 0000000..f7f9fb6
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
@@ -0,0 +1,5 @@
+#ifndef MODULE_SUBFRAMEWORK_H
+#define MODULE_SUBFRAMEWORK_H
+#__private_macro MODULE_SUBFRAMEWORK_H
+char *module_subframework;
+#endif
diff --git a/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h b/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h
new file mode 100644
index 0000000..6e81adc
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h
@@ -0,0 +1 @@
+unsigned *Buried_Treasure;
diff --git a/test/Modules/Inputs/Module.framework/Headers/Module.h b/test/Modules/Inputs/Module.framework/Headers/Module.h
index 7c7ef6e..738b222 100644
--- a/test/Modules/Inputs/Module.framework/Headers/Module.h
+++ b/test/Modules/Inputs/Module.framework/Headers/Module.h
@@ -1,3 +1,7 @@
+// expected-warning{{umbrella header}}
+
+#ifndef MODULE_H
+#define MODULE_H
const char *getModuleVersion(void);
#ifdef FOO
@@ -10,3 +14,9 @@ const char *getModuleVersion(void);
@end
#define MODULE_H_MACRO 1
+#__private_macro MODULE_H_MACRO
+
+#include <Module/Sub.h>
+#include <Module/Buried/Treasure.h>
+
+#endif // MODULE_H
diff --git a/test/Modules/Inputs/Module.framework/Headers/NotInModule.h b/test/Modules/Inputs/Module.framework/Headers/NotInModule.h
new file mode 100644
index 0000000..6b15791
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Headers/NotInModule.h
@@ -0,0 +1 @@
+int not_in_module;
diff --git a/test/Modules/Inputs/Module.framework/Headers/Sub.h b/test/Modules/Inputs/Module.framework/Headers/Sub.h
new file mode 100644
index 0000000..dea76e7
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Headers/Sub.h
@@ -0,0 +1,3 @@
+#include <Module/Sub2.h>
+int *Module_Sub;
+
diff --git a/test/Modules/Inputs/Module.framework/Headers/Sub2.h b/test/Modules/Inputs/Module.framework/Headers/Sub2.h
new file mode 100644
index 0000000..beed4a8
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Headers/Sub2.h
@@ -0,0 +1 @@
+int *Module_Sub2;
diff --git a/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h b/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
new file mode 100644
index 0000000..0782336
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
@@ -0,0 +1 @@
+int module_private;
diff --git a/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h b/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
index 2a8282c..5142f56 100644
--- a/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
+++ b/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
@@ -1,3 +1,3 @@
-__import_module__ MutuallyRecursive2;
+@__experimental_modules_import MutuallyRecursive2;
diff --git a/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h b/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
index 9800853..8a3cc33 100644
--- a/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
+++ b/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
@@ -1,6 +1,6 @@
-__import_module__ MutuallyRecursive1;
+@__experimental_modules_import MutuallyRecursive1;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h
new file mode 100644
index 0000000..73f32bf
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h
@@ -0,0 +1,8 @@
+int no_umbrella_A;
+
+inline int has_warning(int x) {
+ if (x > 0)
+ return x;
+ // Note: warning here is suppressed because this module is considered a
+ // "system" module.
+}
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h
new file mode 100644
index 0000000..dc6770f
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h
@@ -0,0 +1 @@
+int no_umbrella_B;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
new file mode 100644
index 0000000..ac4a14a
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
@@ -0,0 +1 @@
+this is gibberish
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h
new file mode 100644
index 0000000..4a9351a
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h
@@ -0,0 +1 @@
+int no_umbrella_C;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h b/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h
new file mode 100644
index 0000000..bd606d2
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h
@@ -0,0 +1 @@
+int no_umbrella_A_private;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h b/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h
new file mode 100644
index 0000000..442be2d
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h
@@ -0,0 +1 @@
+int no_umbrella_B_private;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/module.map b/test/Modules/Inputs/NoUmbrella.framework/module.map
new file mode 100644
index 0000000..4a4d970
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/module.map
@@ -0,0 +1,9 @@
+framework module NoUmbrella [system] {
+ umbrella "Headers"
+ module * { }
+
+ module unavailable {
+ requires unavailable
+ header "Boom.h"
+ }
+}
diff --git a/test/Modules/Inputs/NoUmbrella.framework/module_private.map b/test/Modules/Inputs/NoUmbrella.framework/module_private.map
new file mode 100644
index 0000000..0507ba0
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/module_private.map
@@ -0,0 +1,4 @@
+explicit module NoUmbrella.Private {
+ umbrella "PrivateHeaders"
+ explicit module * { }
+}
diff --git a/test/Modules/Inputs/System/usr/include/module.map b/test/Modules/Inputs/System/usr/include/module.map
new file mode 100644
index 0000000..884b59c
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/module.map
@@ -0,0 +1,21 @@
+module cstd [system] {
+ // Only in compiler support directory
+ module float_constants {
+ header "float.h"
+ }
+
+ // Only in system headers directory
+ module stdio {
+ header "stdio.h"
+ }
+
+ // In both directories (compiler support version wins, does not forward)
+ module stdbool {
+ header "stdbool.h"
+ }
+
+ // In both directories (compiler support version wins, forwards)
+ module stdint {
+ header "stdint.h"
+ }
+}
diff --git a/test/Modules/Inputs/System/usr/include/stdbool.h b/test/Modules/Inputs/System/usr/include/stdbool.h
new file mode 100644
index 0000000..760d7dc
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdbool.h
@@ -0,0 +1 @@
+// Testing hack: does not define bool/true/false.
diff --git a/test/Modules/Inputs/System/usr/include/stdint.h b/test/Modules/Inputs/System/usr/include/stdint.h
new file mode 100644
index 0000000..e8e50f9
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdint.h
@@ -0,0 +1 @@
+typedef int my_awesome_nonstandard_integer_type;
diff --git a/test/Modules/Inputs/System/usr/include/stdio.h b/test/Modules/Inputs/System/usr/include/stdio.h
new file mode 100644
index 0000000..9a7b106
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdio.h
@@ -0,0 +1,3 @@
+typedef struct { int id; } FILE;
+int fprintf(FILE*restrict, const char* restrict format, ...);
+
diff --git a/test/Modules/Inputs/category_bottom.h b/test/Modules/Inputs/category_bottom.h
new file mode 100644
index 0000000..b53d9c3
--- /dev/null
+++ b/test/Modules/Inputs/category_bottom.h
@@ -0,0 +1,11 @@
+@__experimental_modules_import category_left;
+
+@interface Foo(Bottom)
+-(void)bottom;
+@end
+
+@__experimental_modules_import category_right;
+
+@interface LeftFoo(Bottom)
+-(void)bottom;
+@end
diff --git a/test/Modules/Inputs/category_left.h b/test/Modules/Inputs/category_left.h
new file mode 100644
index 0000000..736fa43
--- /dev/null
+++ b/test/Modules/Inputs/category_left.h
@@ -0,0 +1,15 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Left)
+-(void)left;
+@end
+
+@interface LeftFoo
+-(void)left;
+@end
+
+@interface Foo(Duplicate)
+@end
+
+@interface Foo(Duplicate)
+@end
diff --git a/test/Modules/Inputs/category_other.h b/test/Modules/Inputs/category_other.h
new file mode 100644
index 0000000..1bb5a91
--- /dev/null
+++ b/test/Modules/Inputs/category_other.h
@@ -0,0 +1,6 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Other)
+-(void)other;
+@end
+
diff --git a/test/Modules/Inputs/category_right.h b/test/Modules/Inputs/category_right.h
new file mode 100644
index 0000000..d993b50
--- /dev/null
+++ b/test/Modules/Inputs/category_right.h
@@ -0,0 +1,12 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Right1)
+-(void)right1;
+@end
+
+@interface Foo(Right2)
+-(void)right2;
+@end
+
+@interface Foo(Duplicate) // expected-warning {{duplicate definition of category}}
+@end
diff --git a/test/Modules/Inputs/category_top.h b/test/Modules/Inputs/category_top.h
new file mode 100644
index 0000000..c9558b6
--- /dev/null
+++ b/test/Modules/Inputs/category_top.h
@@ -0,0 +1,14 @@
+@interface Foo
+@end
+
+@interface Foo(Top)
+-(void)top;
+@end
+
+@interface Foo(Top2)
+-(void)top2;
+@end
+
+@interface Foo(Top3)
+-(void)top3;
+@end
diff --git a/test/Modules/Inputs/decl.h b/test/Modules/Inputs/decl.h
new file mode 100644
index 0000000..8dbe11e
--- /dev/null
+++ b/test/Modules/Inputs/decl.h
@@ -0,0 +1,2 @@
+@class A;
+typedef struct B B;
diff --git a/test/Modules/Inputs/decl2.h b/test/Modules/Inputs/decl2.h
new file mode 100644
index 0000000..decf6e0
--- /dev/null
+++ b/test/Modules/Inputs/decl2.h
@@ -0,0 +1 @@
+@class A;
diff --git a/test/Modules/Inputs/def-include.h b/test/Modules/Inputs/def-include.h
new file mode 100644
index 0000000..9e0e575
--- /dev/null
+++ b/test/Modules/Inputs/def-include.h
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+struct B {
+ int b1;
+};
diff --git a/test/Modules/Inputs/def.h b/test/Modules/Inputs/def.h
new file mode 100644
index 0000000..6d06b08
--- /dev/null
+++ b/test/Modules/Inputs/def.h
@@ -0,0 +1,11 @@
+#include "def-include.h"
+
+
+
+@interface A {
+@public
+ int ivar;
+}
+@end
+
+
diff --git a/test/Modules/Inputs/diamond.h b/test/Modules/Inputs/diamond.h
new file mode 100644
index 0000000..15b5290
--- /dev/null
+++ b/test/Modules/Inputs/diamond.h
@@ -0,0 +1 @@
+@__experimental_modules_import diamond_bottom;
diff --git a/test/Modules/Inputs/diamond_bottom.h b/test/Modules/Inputs/diamond_bottom.h
index e0b06d6..b45fa93 100644
--- a/test/Modules/Inputs/diamond_bottom.h
+++ b/test/Modules/Inputs/diamond_bottom.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_left;
-__import_module__ diamond_right;
+@__experimental_modules_import diamond_left;
+@__experimental_modules_import diamond_right;
char bottom(char *x);
diff --git a/test/Modules/Inputs/diamond_left.h b/test/Modules/Inputs/diamond_left.h
index 88cbf60..cc406ab 100644
--- a/test/Modules/Inputs/diamond_left.h
+++ b/test/Modules/Inputs/diamond_left.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_top;
+@__experimental_modules_import diamond_top;
float left(float *);
diff --git a/test/Modules/Inputs/diamond_right.h b/test/Modules/Inputs/diamond_right.h
index 6f8bb82..2ba1d77 100644
--- a/test/Modules/Inputs/diamond_right.h
+++ b/test/Modules/Inputs/diamond_right.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_top;
+@__experimental_modules_import diamond_top;
double right(double *);
diff --git a/test/Modules/Inputs/irgen.h b/test/Modules/Inputs/irgen.h
new file mode 100644
index 0000000..9936bf6
--- /dev/null
+++ b/test/Modules/Inputs/irgen.h
@@ -0,0 +1 @@
+static inline int triple(int x) { return x * 3; }
diff --git a/test/Modules/Inputs/macros.h b/test/Modules/Inputs/macros.h
new file mode 100644
index 0000000..4f53556
--- /dev/null
+++ b/test/Modules/Inputs/macros.h
@@ -0,0 +1,10 @@
+#define MODULE
+#define INTEGER(X) int
+#define FLOAT float
+#define DOUBLE double
+
+#__public_macro INTEGER
+#__private_macro FLOAT
+#__private_macro MODULE
+
+int (INTEGER);
diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map
new file mode 100644
index 0000000..e8d1f2c
--- /dev/null
+++ b/test/Modules/Inputs/module.map
@@ -0,0 +1,86 @@
+module diamond_top { header "diamond_top.h" }
+module diamond_left {
+ header "diamond_left.h"
+ export diamond_top
+}
+module diamond_right {
+ header "diamond_right.h"
+ export diamond_top
+}
+module diamond_bottom {
+ header "diamond_bottom.h"
+ export *
+}
+module irgen { header "irgen.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" }
+module lookup_right_cxx { header "lookup_right.hpp" }
+module module_private_left { header "module_private_left.h" }
+module module_private_right { header "module_private_right.h" }
+module macros { header "macros.h" }
+module category_top { header "category_top.h" }
+module category_left {
+ header "category_left.h"
+ export category_top
+}
+module category_right {
+ header "category_right.h"
+ export category_top
+}
+module category_bottom {
+ header "category_bottom.h"
+ export category_left
+ export category_right
+}
+module category_other { header "category_other.h" }
+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 load_failure { header "load_failure.h" }
+
+module decldef {
+ explicit module Decl { header "decl.h" }
+ explicit module Decl2 { header "decl2.h" }
+ explicit module Def { header "def.h" }
+}
+
+module redecl_merge_top {
+ header "redecl-merge-top.h"
+ explicit module Explicit { header "redecl-merge-top-explicit.h" }
+}
+module redecl_merge_left {
+ header "redecl-merge-left.h"
+ export *
+}
+module redecl_merge_left_left {
+ header "redecl-merge-left-left.h"
+ export *
+}
+module redecl_merge_right {
+ header "redecl-merge-right.h"
+ export *
+}
+module redecl_merge_bottom {
+ header "redecl-merge-bottom.h"
+ export *
+}
+module namespaces_top {
+ header "namespaces-top.h"
+ export *
+}
+module namespaces_left {
+ header "namespaces-left.h"
+ export *
+}
+module namespaces_right {
+ header "namespaces-right.h"
+ export *
+}
+module MethodPoolA {
+ header "MethodPoolA.h"
+}
+module MethodPoolB {
+ header "MethodPoolB.h"
+}
diff --git a/test/Modules/Inputs/module_private_left.h b/test/Modules/Inputs/module_private_left.h
new file mode 100644
index 0000000..ff33999
--- /dev/null
+++ b/test/Modules/Inputs/module_private_left.h
@@ -0,0 +1,26 @@
+__module_private__ struct HiddenStruct;
+
+__module_private__ struct HiddenStruct {
+};
+
+
+int &f0(int);
+
+template<typename T>
+__module_private__ void f1(T*);
+
+template<typename T>
+__module_private__ void f1(T*);
+
+template<typename T>
+__module_private__ class vector;
+
+template<typename T>
+__module_private__ class vector {
+};
+
+vector<float> vec_float;
+
+typedef __module_private__ int Integer;
+typedef __module_private__ int Integer;
+
diff --git a/test/Modules/Inputs/module_private_right.h b/test/Modules/Inputs/module_private_right.h
new file mode 100644
index 0000000..53efe25
--- /dev/null
+++ b/test/Modules/Inputs/module_private_right.h
@@ -0,0 +1,13 @@
+__module_private__ double &f0(double);
+__module_private__ double &f0(double);
+
+__module_private__ int hidden_var;
+
+inline void test_f0_in_right() {
+ double &dr = f0(hidden_var);
+}
+
+struct VisibleStruct {
+ __module_private__ int field;
+ __module_private__ virtual void setField(int f);
+};
diff --git a/test/Modules/Inputs/namespaces-left.h b/test/Modules/Inputs/namespaces-left.h
new file mode 100644
index 0000000..d253fed
--- /dev/null
+++ b/test/Modules/Inputs/namespaces-left.h
@@ -0,0 +1,53 @@
+@__experimental_modules_import namespaces_top;
+
+namespace N1 { }
+
+namespace N1 {
+ float& f(float);
+}
+
+namespace N2 {
+ float& f(float);
+}
+
+
+
+
+
+namespace N5 {
+ int &f(int);
+}
+
+namespace N6 {
+ int &f(int);
+}
+
+namespace N7 {
+ int &f(int);
+}
+
+namespace N8 {
+ int &f(int);
+}
+
+namespace N9 {
+ int &f(int);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+namespace N11 {
+ namespace {
+ class Foo;
+ }
+ Foo *getFoo();
+}
+
+namespace N12 {
+ namespace {
+ class Foo;
+ }
+ Foo *getFoo();
+}
diff --git a/test/Modules/Inputs/namespaces-right.h b/test/Modules/Inputs/namespaces-right.h
new file mode 100644
index 0000000..7e7286e
--- /dev/null
+++ b/test/Modules/Inputs/namespaces-right.h
@@ -0,0 +1,61 @@
+@__experimental_modules_import namespaces_top;
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 {
+ double& f(double);
+}
+
+namespace N3 {
+ double& f(double);
+}
+
+namespace N5 {
+ double &f(double);
+}
+
+namespace N6 {
+ double &f(double);
+}
+
+namespace N7 {
+ double &f(double);
+}
+
+namespace N8 {
+ int &f(int);
+}
+
+namespace N9 {
+ int &f(int);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+
+
+
+
+
+
+namespace N11 {
+ namespace {
+ class Foo;
+ }
+ void consumeFoo(Foo*);
+}
+
+namespace N12 {
+ namespace {
+ class Foo;
+ }
+ void consumeFoo(Foo*);
+}
diff --git a/test/Modules/Inputs/namespaces-top.h b/test/Modules/Inputs/namespaces-top.h
new file mode 100644
index 0000000..0c607f5
--- /dev/null
+++ b/test/Modules/Inputs/namespaces-top.h
@@ -0,0 +1,14 @@
+namespace N1 {
+ int& f(int);
+}
+
+namespace N2 {
+ int& f(int);
+}
+
+namespace N3 {
+ int& f(int);
+}
+
+namespace N12 { }
+
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h b/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h
new file mode 100644
index 0000000..7462376
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h
@@ -0,0 +1,4 @@
+int umbrella;
+
+#include "umbrella_sub.h"
+
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella/module.map b/test/Modules/Inputs/normal-module-map/Umbrella/module.map
new file mode 100644
index 0000000..611cf9f
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella/module.map
@@ -0,0 +1,3 @@
+module Umbrella {
+ umbrella header "Umbrella.h"
+} \ No newline at end of file
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h b/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h
new file mode 100644
index 0000000..9fdccd1
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h
@@ -0,0 +1,2 @@
+int umbrella_sub;
+
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h b/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h
new file mode 100644
index 0000000..36110d8
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h
@@ -0,0 +1 @@
+int umbrella2;
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella2/module.map b/test/Modules/Inputs/normal-module-map/Umbrella2/module.map
new file mode 100644
index 0000000..1e57704
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella2/module.map
@@ -0,0 +1,3 @@
+module Umbrella2 {
+ umbrella header "Umbrella2.h"
+}
diff --git a/test/Modules/Inputs/normal-module-map/a1.h b/test/Modules/Inputs/normal-module-map/a1.h
new file mode 100644
index 0000000..f2d5a49
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/a1.h
@@ -0,0 +1 @@
+int a1;
diff --git a/test/Modules/Inputs/normal-module-map/a2.h b/test/Modules/Inputs/normal-module-map/a2.h
new file mode 100644
index 0000000..5c4e7ff
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/a2.h
@@ -0,0 +1 @@
+int a2;
diff --git a/test/Modules/Inputs/normal-module-map/b1.h b/test/Modules/Inputs/normal-module-map/b1.h
new file mode 100644
index 0000000..2ed1112
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/b1.h
@@ -0,0 +1,2 @@
+int b1;
+
diff --git a/test/Modules/Inputs/normal-module-map/module.map b/test/Modules/Inputs/normal-module-map/module.map
new file mode 100644
index 0000000..e17f44a
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/module.map
@@ -0,0 +1,13 @@
+module libA {
+ module a1 { header "a1.h" }
+ header "a2.h"
+}
+
+module libB {
+ header "b1.h"
+}
+
+module nested_umbrella {
+ umbrella "nested_umbrella"
+ module * { }
+}
diff --git a/test/Modules/Inputs/normal-module-map/nested/module.map b/test/Modules/Inputs/normal-module-map/nested/module.map
new file mode 100644
index 0000000..fd463c2
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested/module.map
@@ -0,0 +1,4 @@
+module libNested {
+ header "nested1.h"
+ header "nested2.h"
+} \ No newline at end of file
diff --git a/test/Modules/Inputs/normal-module-map/nested/nested1.h b/test/Modules/Inputs/normal-module-map/nested/nested1.h
new file mode 100644
index 0000000..3790d1a
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested/nested1.h
@@ -0,0 +1 @@
+int nested1;
diff --git a/test/Modules/Inputs/normal-module-map/nested/nested2.h b/test/Modules/Inputs/normal-module-map/nested/nested2.h
new file mode 100644
index 0000000..d56d601
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested/nested2.h
@@ -0,0 +1 @@
+int nested2;
diff --git a/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h b/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h
new file mode 100644
index 0000000..ab180fe
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h
@@ -0,0 +1,2 @@
+int nested_umbrella_a;
+
diff --git a/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h b/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h
new file mode 100644
index 0000000..a903f5d
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h
@@ -0,0 +1,2 @@
+int nested_umbrella_b;
+
diff --git a/test/Modules/Inputs/redecl-merge-bottom.h b/test/Modules/Inputs/redecl-merge-bottom.h
new file mode 100644
index 0000000..40a9404
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-bottom.h
@@ -0,0 +1,28 @@
+@__experimental_modules_import redecl_merge_left;
+
+@class C4;
+@class C4;
+@protocol P4;
+@protocol P4;
+@protocol P4;
+@__experimental_modules_import redecl_merge_right;
+
+@class B;
+
+@class A;
+
+@protocol P1;
+
+struct S1;
+struct S3;
+
+void refers_to_C4(C4*);
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+#endif
+
diff --git a/test/Modules/Inputs/redecl-merge-left-left.h b/test/Modules/Inputs/redecl-merge-left-left.h
new file mode 100644
index 0000000..5f48883
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-left-left.h
@@ -0,0 +1,7 @@
+@__experimental_modules_import redecl_merge_left;
+
+@class C4;
+void accept_a_C4(C4*);
+
+@class ClassWithDef;
+
diff --git a/test/Modules/Inputs/redecl-merge-left.h b/test/Modules/Inputs/redecl-merge-left.h
new file mode 100644
index 0000000..b3a7ba8
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-left.h
@@ -0,0 +1,90 @@
+@__experimental_modules_import redecl_merge_top;
+
+@class A;
+
+@class A;
+
+@interface B
++ (B*) create_a_B;
+@end
+
+@class A;
+
+@protocol P1;
+@protocol P2
+- (void)protoMethod2;
+@end
+
+struct S1;
+struct S2 {
+ int field;
+};
+
+struct S1 *produce_S1(void);
+void consume_S2(struct S2*);
+
+// Test declarations in different modules with no common initial
+// declaration.
+@class C;
+void accept_a_C(C*);
+
+@class C2;
+void accept_a_C2(C2*);
+
+@class C3;
+void accept_a_C3(C3*);
+@class C3;
+
+@class C4;
+
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct;
+
+@protocol P3, P4;
+
+@protocol P3;
+
+struct S3;
+struct S3;
+struct S4 {
+ int field;
+};
+
+struct S3 *produce_S3(void);
+void consume_S4(struct S4*);
+
+typedef int T1;
+typedef float T2;
+
+int func0(int);
+int func1(int);
+int func2(int);
+
+
+
+
+
+
+
+
+
+
+// Spacing matters!
+extern int var1;
+extern float var2;
+
+extern double var3;
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+#endif
+
+// Make sure this doesn't introduce an ambiguity-creating 'id' at the
+// top level.
+typedef void funcptr_with_id(int id);
+
diff --git a/test/Modules/Inputs/redecl-merge-right.h b/test/Modules/Inputs/redecl-merge-right.h
new file mode 100644
index 0000000..de7aa08
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-right.h
@@ -0,0 +1,94 @@
+@__experimental_modules_import redecl_merge_top;
+
+@interface Super
+@end
+
+@interface A : Super
+- (Super*)init;
+@end
+
+@class B;
+
+@protocol P1
+- (void)protoMethod1;
+@end
+
+@protocol P1;
+
+@protocol P2;
+
+@protocol P2;
+
+@protocol P2;
+
+struct S1;
+struct S2;
+
+void consume_S1(struct S1*);
+struct S2 *produce_S2(void);
+
+// Test declarations in different modules with no common initial
+// declaration.
+@class C;
+C *get_a_C(void);
+@class C2;
+C2 *get_a_C2(void);
+@class C3;
+C3 *get_a_C3(void);
+
+@class C4;
+@class C4;
+@class C4;
+@class C4;
+C4 *get_a_C4(void);
+
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct;
+
+@protocol P4, P3;
+@protocol P3;
+@protocol P3;
+@protocol P3;
+
+struct S3;
+struct S4;
+
+void consume_S3(struct S3*);
+struct S4 *produce_S4(void);
+
+typedef int T1;
+typedef double T2;
+
+int func0(int);
+int func1(int);
+int func1(int);
+int func1(int);
+int func1(int);
+static int func2(int);
+
+
+
+
+// Spacing matters!
+extern int var1;
+extern int var2;
+
+static double var3;
+
+#ifdef __cplusplus
+template<typename T> class Vector {
+public:
+ void push_back(const T&);
+};
+#endif
+
+int ONE;
+@__experimental_modules_import redecl_merge_top.Explicit;
+const int one = ONE;
+
+@interface ClassWithDef
+- (void)method;
+@end
diff --git a/test/Modules/Inputs/redecl-merge-top-explicit.h b/test/Modules/Inputs/redecl-merge-top-explicit.h
new file mode 100644
index 0000000..e06ff7a
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-top-explicit.h
@@ -0,0 +1,9 @@
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct { int member; };
+
+#define ONE 1
+
+typedef struct my_struct_type *my_struct_ref;
diff --git a/test/Modules/Inputs/redecl-merge-top.h b/test/Modules/Inputs/redecl-merge-top.h
new file mode 100644
index 0000000..519254c
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-top.h
@@ -0,0 +1,20 @@
+@class A;
+
+@class A;
+
+@class A;
+
+@class B;
+
+@protocol P1;
+
+@protocol P2;
+@protocol P2;
+
+struct S1;
+struct S2;
+struct S2;
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+#endif
diff --git a/test/Modules/Inputs/redecl_namespaces_left.h b/test/Modules/Inputs/redecl_namespaces_left.h
new file mode 100644
index 0000000..49595ea
--- /dev/null
+++ b/test/Modules/Inputs/redecl_namespaces_left.h
@@ -0,0 +1,3 @@
+namespace A {
+ int i;
+}
diff --git a/test/Modules/Inputs/redecl_namespaces_right.h b/test/Modules/Inputs/redecl_namespaces_right.h
new file mode 100644
index 0000000..fdf65ba
--- /dev/null
+++ b/test/Modules/Inputs/redecl_namespaces_right.h
@@ -0,0 +1,3 @@
+namespace A {
+ int j;
+}
diff --git a/test/Modules/Inputs/redeclarations_left.h b/test/Modules/Inputs/redeclarations_left.h
new file mode 100644
index 0000000..4dfbf1d
--- /dev/null
+++ b/test/Modules/Inputs/redeclarations_left.h
@@ -0,0 +1,2 @@
+@class NSObject;
+
diff --git a/test/Modules/Inputs/redeclarations_right.h b/test/Modules/Inputs/redeclarations_right.h
new file mode 100644
index 0000000..d3861fe
--- /dev/null
+++ b/test/Modules/Inputs/redeclarations_right.h
@@ -0,0 +1,2 @@
+@interface NSObject
+@end
diff --git a/test/Modules/Inputs/subdir/module.map b/test/Modules/Inputs/subdir/module.map
new file mode 100644
index 0000000..4cd0215
--- /dev/null
+++ b/test/Modules/Inputs/subdir/module.map
@@ -0,0 +1,3 @@
+module subdir {
+ header "subdir.h"
+}
diff --git a/test/Modules/Inputs/subdir/subdir.h b/test/Modules/Inputs/subdir/subdir.h
new file mode 100644
index 0000000..0fb3d21
--- /dev/null
+++ b/test/Modules/Inputs/subdir/subdir.h
@@ -0,0 +1 @@
+const char *getSubdir();
diff --git a/test/Modules/Inputs/submodules/hash_map.h b/test/Modules/Inputs/submodules/hash_map.h
new file mode 100644
index 0000000..ce85984
--- /dev/null
+++ b/test/Modules/Inputs/submodules/hash_map.h
@@ -0,0 +1,4 @@
+template<typename Key, typename Data> class hash_map { };
+
+#define HAVE_HASH_MAP
+
diff --git a/test/Modules/Inputs/submodules/module.map b/test/Modules/Inputs/submodules/module.map
new file mode 100644
index 0000000..16cedac
--- /dev/null
+++ b/test/Modules/Inputs/submodules/module.map
@@ -0,0 +1,5 @@
+module std {
+ module vector { header "vector.h" }
+ module type_traits { header "type_traits.h" }
+ explicit module hash_map { header "hash_map.h" }
+}
diff --git a/test/Modules/Inputs/submodules/type_traits.h b/test/Modules/Inputs/submodules/type_traits.h
new file mode 100644
index 0000000..4dad090
--- /dev/null
+++ b/test/Modules/Inputs/submodules/type_traits.h
@@ -0,0 +1,12 @@
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+#define HAVE_TYPE_TRAITS
+
diff --git a/test/Modules/Inputs/submodules/vector.h b/test/Modules/Inputs/submodules/vector.h
new file mode 100644
index 0000000..8e1cdc8
--- /dev/null
+++ b/test/Modules/Inputs/submodules/vector.h
@@ -0,0 +1,3 @@
+template<typename T> class vector { };
+
+#define HAVE_VECTOR
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/A_one.h b/test/Modules/Inputs/wildcard-submodule-exports/A_one.h
new file mode 100644
index 0000000..4a2c239
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/A_one.h
@@ -0,0 +1 @@
+int *A1;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/A_two.h b/test/Modules/Inputs/wildcard-submodule-exports/A_two.h
new file mode 100644
index 0000000..1b08599
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/A_two.h
@@ -0,0 +1 @@
+unsigned int *A2;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/B_one.h b/test/Modules/Inputs/wildcard-submodule-exports/B_one.h
new file mode 100644
index 0000000..0f44a56
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/B_one.h
@@ -0,0 +1 @@
+short *B1;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/B_two.h b/test/Modules/Inputs/wildcard-submodule-exports/B_two.h
new file mode 100644
index 0000000..0e51242
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/B_two.h
@@ -0,0 +1 @@
+unsigned short *B2;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/C_one.h b/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
new file mode 100644
index 0000000..fb1c7de
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
@@ -0,0 +1,4 @@
+@__experimental_modules_import A.One;
+@__experimental_modules_import B.One;
+
+long *C1;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/C_two.h b/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
new file mode 100644
index 0000000..050a8f3
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
@@ -0,0 +1,4 @@
+@__experimental_modules_import A.Two;
+@__experimental_modules_import B.Two;
+
+unsigned long *C2;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/module.map b/test/Modules/Inputs/wildcard-submodule-exports/module.map
new file mode 100644
index 0000000..64b0d89
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/module.map
@@ -0,0 +1,20 @@
+module A {
+ module One { header "A_one.h" }
+ module Two { header "A_two.h" }
+}
+
+module B {
+ module One { header "B_one.h" }
+ module Two { header "B_two.h" }
+}
+
+module C {
+ module One {
+ header "C_one.h"
+ export A.*
+ }
+ module Two {
+ header "C_two.h"
+ export *
+ }
+}
diff --git a/test/Modules/auto-module-import.c b/test/Modules/auto-module-import.c
deleted file mode 100644
index 0187174..0000000
--- a/test/Modules/auto-module-import.c
+++ /dev/null
@@ -1,13 +0,0 @@
-
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %t -fauto-module-import -F %S/Inputs -verify %s
-
-#include <DependsOnModule/DependsOnModule.h>
-
-#ifdef MODULE_H_MACRO
-# error MODULE_H_MACRO should have been hidden
-#endif
-
-#ifdef DEPENDS_ON_MODULE
-# error DEPENDS_ON_MODULE should have been hidden
-#endif
diff --git a/test/Modules/auto-module-import.m b/test/Modules/auto-module-import.m
new file mode 100644
index 0000000..fbd0a54
--- /dev/null
+++ b/test/Modules/auto-module-import.m
@@ -0,0 +1,73 @@
+// other file: expected-note{{'no_umbrella_A_private' declared here}}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+#include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}}
+
+#ifdef MODULE_H_MACRO
+# error MODULE_H_MACRO should have been hidden
+#endif
+
+#ifdef DEPENDS_ON_MODULE
+# error DEPENDS_ON_MODULE should have been hidden
+#endif
+
+Module *mod; // expected-error{{unknown type name 'Module'}}
+
+#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}}
+Module *mod2;
+
+int getDependsOther() { return depends_on_module_other; }
+
+void testSubframeworkOther() {
+ double *sfo1 = sub_framework_other; // expected-error{{use of undeclared identifier 'sub_framework_other'}}
+}
+
+// Test umbrella-less submodule includes
+#include <NoUmbrella/A.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.A'}}
+int getNoUmbrellaA() { return no_umbrella_A; }
+
+// Test umbrella-less submodule includes
+#include <NoUmbrella/SubDir/C.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.SubDir.C'}}
+int getNoUmbrellaC() { return no_umbrella_C; }
+
+// Test header cross-subframework include pattern.
+#include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}}
+
+void testSubframeworkOtherAgain() {
+ double *sfo1 = sub_framework_other;
+}
+
+void testModuleSubFramework() {
+ char *msf = module_subframework;
+}
+
+#include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-warning{{treating #include as an import of module 'Module.SubFramework'}}
+
+void testModuleSubFrameworkAgain() {
+ char *msf = module_subframework;
+}
+
+// Test inclusion of private headers.
+#include <DependsOnModule/DependsOnModulePrivate.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}}
+
+int getDependsOnModulePrivate() { return depends_on_module_private; }
+
+#include <Module/ModulePrivate.h> // includes the header
+
+int getModulePrivate() { return module_private; }
+
+#include <NoUmbrella/A_Private.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}}
+int getNoUmbrellaAPrivate() { return no_umbrella_A_private; }
+
+int getNoUmbrellaBPrivateFail() { return no_umbrella_B_private; } // expected-error{{use of undeclared identifier 'no_umbrella_B_private'; did you mean 'no_umbrella_A_private'?}}
+
+// Test inclusion of headers that are under an umbrella directory but
+// not actually part of the module.
+#include <Module/NotInModule.h> // expected-warning{{treating #include as an import of module 'Module.NotInModule'}} \
+ // expected-warning{{missing submodule 'Module.NotInModule'}}
+
+int getNotInModule() {
+ return not_in_module;
+}
diff --git a/test/Modules/compiler_builtins.m b/test/Modules/compiler_builtins.m
new file mode 100644
index 0000000..de6f57b
--- /dev/null
+++ b/test/Modules/compiler_builtins.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -fmodules -fmodule-cache-path %t -D__need_wint_t %s -Xclang -verify
+
+#ifdef __SSE__
+@__experimental_modules_import _Builtin_intrinsics.intel.sse;
+#endif
+
+#ifdef __AVX2__
+@__experimental_modules_import _Builtin_intrinsics.intel.avx2;
+#endif
diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m
new file mode 100644
index 0000000..1752cd3
--- /dev/null
+++ b/test/Modules/cstd.m
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -isystem %S/Inputs/System/usr/include -fmodules -fmodule-cache-path %t -D__need_wint_t -Werror=implicit-function-declaration %s
+
+// Supplied by compiler, but referenced from the "/usr/include" module map.
+@__experimental_modules_import cstd.float_constants;
+
+float getFltMax() { return FLT_MAX; }
+
+// Supplied by the "/usr/include" module map.
+@__experimental_modules_import cstd.stdio;
+
+void test_fprintf(FILE *file) {
+ fprintf(file, "Hello, modules\n");
+}
+
+// Supplied by compiler, which forwards to the the "/usr/include" version.
+@__experimental_modules_import cstd.stdint;
+
+my_awesome_nonstandard_integer_type value;
+
+// Supplied by the compiler; that version wins.
+@__experimental_modules_import cstd.stdbool;
+
+#ifndef bool
+# error "bool was not defined!"
+#endif
+
+
+
diff --git a/test/Modules/cycles.c b/test/Modules/cycles.c
index 8e3e9c6..256f118 100644
--- a/test/Modules/cycles.c
+++ b/test/Modules/cycles.c
@@ -1,12 +1,12 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs %s 2>&1 | FileCheck %s
-
-__import_module__ MutuallyRecursive1;
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -F %S/Inputs %s 2>&1 | FileCheck %s
+// FIXME: When we have a syntax for modules in C, use that.
+@__experimental_modules_import MutuallyRecursive1;
// FIXME: Lots of redundant diagnostics here, because the preprocessor
// can't currently tell the parser not to try to load the module again.
-// CHECK: MutuallyRecursive2.h:3:19: fatal error: cyclic dependency in module 'MutuallyRecursive1': MutuallyRecursive1 -> MutuallyRecursive2 -> MutuallyRecursive1
-// CHECK: MutuallyRecursive1.h:2:19: fatal error: could not build module 'MutuallyRecursive2'
-// CHECK: cycles.c:4:19: fatal error: could not build module 'MutuallyRecursive1'
+// CHECK: MutuallyRecursive2.h:3:32: fatal error: cyclic dependency in module 'MutuallyRecursive1': MutuallyRecursive1 -> MutuallyRecursive2 -> MutuallyRecursive1
+// CHECK: MutuallyRecursive1.h:2:32: fatal error: could not build module 'MutuallyRecursive2'
+// CHECK: cycles.c:4:32: fatal error: could not build module 'MutuallyRecursive1'
diff --git a/test/Modules/decldef.mm b/test/Modules/decldef.mm
new file mode 100644
index 0000000..64a66d5
--- /dev/null
+++ b/test/Modules/decldef.mm
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -I %S/Inputs -fmodule-cache-path %t %s -verify
+
+
+// in other file: expected-note{{previous definition is here}}
+
+
+
+
+
+// in other file: expected-note{{previous definition is here}}
+
+@__experimental_modules_import decldef;
+A *a1; // expected-error{{unknown type name 'A'}}
+B *b1; // expected-error{{unknown type name 'B'}}
+@__experimental_modules_import decldef.Decl;
+
+A *a2;
+B *b;
+
+void testA(A *a) {
+ a->ivar = 17; // expected-error{{definition of 'A' must be imported before it is required}}
+}
+
+void testB() {
+ B b; // expected-error{{definition of 'B' must be imported before it is required}}
+ B b2; // Note: the reundant error was silenced.
+}
diff --git a/test/Modules/diamond-pch.c b/test/Modules/diamond-pch.c
new file mode 100644
index 0000000..4397c19
--- /dev/null
+++ b/test/Modules/diamond-pch.c
@@ -0,0 +1,28 @@
+
+
+
+// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}}
+
+void test_diamond(int i, float f, double d, char c) {
+ top(&i);
+ left(&f);
+ right(&d);
+ bottom(&c);
+ bottom(&d); // expected-warning{{incompatible pointer types passing 'double *' to parameter of type 'char *'}}
+
+ // Names in multiple places in the diamond.
+ top_left(&c);
+
+ left_and_right(&i);
+ struct left_and_right lr;
+ lr.left = 17;
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodule-cache-path %t -o %t.pch %S/Inputs/diamond.h
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -include-pch %t.pch %s -verify
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c
index 482836c..076eec4 100644
--- a/test/Modules/diamond.c
+++ b/test/Modules/diamond.c
@@ -3,7 +3,7 @@
// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}}
-__import_module__ diamond_bottom;
+@__experimental_modules_import diamond_bottom;
void test_diamond(int i, float f, double d, char c) {
top(&i);
@@ -20,8 +20,10 @@ void test_diamond(int i, float f, double d, char c) {
lr.left = 17;
}
-// RUN: %clang_cc1 -emit-module -o %T/diamond_top.pcm %S/Inputs/diamond_top.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash -emit-module -o %T/diamond_left.pcm %S/Inputs/diamond_left.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash -emit-module -o %T/diamond_right.pcm %S/Inputs/diamond_right.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash -emit-module -o %T/diamond_bottom.pcm %S/Inputs/diamond_bottom.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash %s -verify
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t %s -verify
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/test/Modules/header-import.m b/test/Modules/header-import.m
index 9996dc7..5444854 100644
--- a/test/Modules/header-import.m
+++ b/test/Modules/header-import.m
@@ -1,7 +1,7 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
#import "point.h"
-__import_module__ Module;
+@__experimental_modules_import Module;
#import "point.h"
diff --git a/test/Modules/inferred-submodules.m b/test/Modules/inferred-submodules.m
new file mode 100644
index 0000000..bee1cec
--- /dev/null
+++ b/test/Modules/inferred-submodules.m
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+@__experimental_modules_import Module.Sub;
+
+void test_Module_Sub() {
+ int *ip = Module_Sub;
+}
+
+@__experimental_modules_import Module.Buried.Treasure;
+
+void dig() {
+ unsigned *up = Buried_Treasure;
+}
+
diff --git a/test/Modules/irgen.c b/test/Modules/irgen.c
index 0debf05..4a080db 100644
--- a/test/Modules/irgen.c
+++ b/test/Modules/irgen.c
@@ -1,10 +1,9 @@
-// RUN: %clang_cc1 -emit-module -triple x86_64-apple-darwin10 -o %t/module.pcm -DBUILD_MODULE %s
-// RUN: %clang_cc1 -fmodule-cache-path %t -triple x86_64-apple-darwin10 -fdisable-module-hash -emit-llvm -o - %s | FileCheck %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=irgen -triple x86_64-apple-darwin10 %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// FIXME: When we have a syntax for modules in C, use that.
-#ifdef BUILD_MODULE
-static inline int triple(int x) { return x * 3; }
-#else
-__import_module__ module;
+@__experimental_modules_import irgen;
// CHECK: define void @triple_value
void triple_value(int *px) {
@@ -12,4 +11,3 @@ void triple_value(int *px) {
}
// CHECK: define internal i32 @triple(i32
-#endif
diff --git a/test/Modules/load_failure.c b/test/Modules/load_failure.c
index d16bba7..3a96301 100644
--- a/test/Modules/load_failure.c
+++ b/test/Modules/load_failure.c
@@ -1,19 +1,21 @@
#ifdef NONEXISTENT
-__import_module__ load_nonexistent;
+@__experimental_modules_import load_nonexistent;
#endif
#ifdef FAILURE
-__import_module__ load_failure;
+@__experimental_modules_import load_failure;
#endif
-// RUN: %clang_cc1 -x c++ -emit-module -o %T/load_failure.pcm %S/Inputs/load_failure.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
-// CHECK-NONEXISTENT: load_failure.c:2:19: fatal error: module 'load_nonexistent' not found
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fdisable-module-hash -emit-module -fmodule-name=load_failure %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
+// CHECK-NONEXISTENT: load_failure.c:2:32: fatal error: module 'load_nonexistent' not found
-// RUN: not %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash %s -DFAILURE 2> %t
-// RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -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
// CHECK-FAILURE: error: C99 was disabled in PCH file but is currently enabled
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/test/Modules/lookup.cpp b/test/Modules/lookup.cpp
index d3245f2..9839035 100644
--- a/test/Modules/lookup.cpp
+++ b/test/Modules/lookup.cpp
@@ -1,7 +1,8 @@
-#define import __import_module__
+#define import @__experimental_modules_import
import lookup_left_cxx;
-#define IMPORT(X) __import_module__ X
+#undef import
+#define IMPORT(X) @__experimental_modules_import X
IMPORT(lookup_right_cxx);
void test(int i, float f) {
@@ -14,10 +15,18 @@ void test(int i, float f) {
::f0(&f);
}
-// RUN: %clang_cc1 -emit-module -x c++ -verify -o %T/lookup_left_cxx.pcm %S/Inputs/lookup_left.hpp
-// RUN: %clang_cc1 -emit-module -x c++ -o %T/lookup_right_cxx.pcm %S/Inputs/lookup_right.hpp
-// RUN: %clang_cc1 -x c++ -fmodule-cache-path %T -fdisable-module-hash %s -verify
-// RUN: %clang_cc1 -ast-print -x c++ -fmodule-cache-path %T -fdisable-module-hash %s | FileCheck -check-prefix=CHECK-PRINT %s
+int import;
+
+void f() {
+ int import;
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodule-cache-path %t -fmodule-name=lookup_left_cxx %S/Inputs/module.map -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodule-cache-path %t -fmodule-name=lookup_right_cxx %S/Inputs/module.map -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c++ -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
+// FIXME: When we have a syntax for modules in C++, use that.
// CHECK-PRINT: int *f0(int *);
// CHECK-PRINT: float *f0(float *);
diff --git a/test/Modules/lookup.m b/test/Modules/lookup.m
index d45f936..c82503f 100644
--- a/test/Modules/lookup.m
+++ b/test/Modules/lookup.m
@@ -1,17 +1,18 @@
// lookup_left.h: expected-note{{using}}
// lookup_right.h: expected-note{{also found}}
-__import_module__ lookup_left_objc;
-__import_module__ lookup_right_objc;
+@__experimental_modules_import lookup_left_objc;
+@__experimental_modules_import lookup_right_objc;
void test(id x) {
[x method]; // expected-warning{{multiple methods named 'method' found}}
}
-// RUN: %clang_cc1 -emit-module -x objective-c -o %T/lookup_left_objc.pcm %S/Inputs/lookup_left.h
-// RUN: %clang_cc1 -emit-module -x objective-c -o %T/lookup_right_objc.pcm %S/Inputs/lookup_right.h
-// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %T -fdisable-module-hash -verify %s
-// RUN: %clang_cc1 -ast-print -x objective-c -fmodule-cache-path %T -fdisable-module-hash %s | FileCheck -check-prefix=CHECK-PRINT %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -verify %s
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
// CHECK-PRINT: - (int) method;
// CHECK-PRINT: - (double) method
diff --git a/test/Modules/macros.c b/test/Modules/macros.c
index 899c19b..83e1c66 100644
--- a/test/Modules/macros.c
+++ b/test/Modules/macros.c
@@ -1,20 +1,10 @@
-// RUN: %clang_cc1 -emit-module -o %t/macros.pcm -DMODULE %s
-// RUN: %clang_cc1 -verify -fmodule-cache-path %t -fdisable-module-hash %s
-// RUN: %clang_cc1 -E -fmodule-cache-path %t -fdisable-module-hash %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodule-cache-path %t %s
+// RUN: %clang_cc1 -E -fmodules -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// FIXME: When we have a syntax for modules in C, use that.
-#if defined(MODULE)
-#define INTEGER(X) int
-#define FLOAT float
-#define DOUBLE double
-
-#__export_macro__ INTEGER
-#__export_macro__ DOUBLE
-
-int (INTEGER);
-
-#else
-
-__import_module__ macros;
+@__experimental_modules_import macros;
#ifndef INTEGER
# error INTEGER macro should be visible
@@ -32,10 +22,9 @@ __import_module__ macros;
double d;
DOUBLE *dp = &d;
-#__export_macro__ WIBBLE // expected-error{{no macro named 'WIBBLE' to export}}
+#__public_macro WIBBLE // expected-error{{no macro named 'WIBBLE'}}
void f() {
// CHECK-PREPROCESSED: int i = INTEGER;
int i = INTEGER; // the value was exported, the macro was not.
}
-#endif
diff --git a/test/Modules/method_pool.m b/test/Modules/method_pool.m
new file mode 100644
index 0000000..25582ca
--- /dev/null
+++ b/test/Modules/method_pool.m
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-cache-path %t -fmodules -I %S/Inputs %s -verify
+
+@__experimental_modules_import MethodPoolA;
+
+
+// in other file: // expected-note{{using}}
+
+
+
+
+// in other file: expected-note{{also found}}
+
+void testMethod1(id object) {
+ [object method1];
+}
+
+void testMethod2(id object) {
+ [object method2:1];
+}
+
+@__experimental_modules_import MethodPoolB;
+
+void testMethod1Again(id object) {
+ [object method1];
+}
+
+void testMethod2Again(id object) {
+ [object method2:1]; // expected-warning{{multiple methods named 'method2:' found}}
+}
diff --git a/test/Modules/module-private.cpp b/test/Modules/module-private.cpp
index 7bd2a20..246dcaf 100644
--- a/test/Modules/module-private.cpp
+++ b/test/Modules/module-private.cpp
@@ -1,54 +1,11 @@
-// RUN: mkdir -p %t
-// RUN: %clang_cc1 -x c++ -emit-module -o %t/left.pcm %s -D MODULE_LEFT
-// RUN: %clang_cc1 -x c++ -emit-module -o %t/right.pcm %s -D MODULE_RIGHT
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash %s -verify
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_left -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_right -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
-#if defined(MODULE_LEFT)
-
-__module_private__ struct HiddenStruct;
-
-struct HiddenStruct {
-};
-
-
-int &f0(int);
-
-template<typename T>
-__module_private__ void f1(T*);
-
-template<typename T>
-void f1(T*);
-
-template<typename T>
-__module_private__ class vector;
-
-template<typename T>
-class vector {
-};
-
-vector<float> vec_float;
-
-typedef __module_private__ int Integer;
-typedef int Integer;
-
-#elif defined(MODULE_RIGHT)
-__module_private__ double &f0(double);
-double &f0(double);
-
-__module_private__ int hidden_var;
-
-inline void test_f0_in_right() {
- double &dr = f0(hidden_var);
-}
-
-struct VisibleStruct {
- __module_private__ int field;
- __module_private__ virtual void setField(int f);
-};
-
-#else
-__import_module__ left;
-__import_module__ right;
+@__experimental_modules_import module_private_left;
+@__experimental_modules_import module_private_right;
void test() {
int &ir = f0(1.0); // okay: f0() from 'right' is not visible
@@ -75,28 +32,28 @@ int test_broken() {
// Check for private redeclarations of public entities.
template<typename T>
-class public_class_template; // expected-note{{previous declaration is here}}
+class public_class_template;
template<typename T>
-__module_private__ class public_class_template; // expected-error{{__module_private__ declaration of 'public_class_template' follows public declaration}}
+__module_private__ class public_class_template;
-typedef int public_typedef; // expected-note{{previous declaration is here}}
-typedef __module_private__ int public_typedef; // expected-error{{__module_private__ declaration of 'public_typedef' follows public declaration}}
+typedef int public_typedef;
+typedef __module_private__ int public_typedef;
-extern int public_var; // expected-note{{previous declaration is here}}
-extern __module_private__ int public_var; // expected-error{{__module_private__ declaration of 'public_var' follows public declaration}}
+extern int public_var;
+extern __module_private__ int public_var;
-void public_func(); // expected-note{{previous declaration is here}}
-__module_private__ void public_func(); // expected-error{{__module_private__ declaration of 'public_func' follows public declaration}}
+void public_func();
+__module_private__ void public_func();
template<typename T>
-void public_func_template(); // expected-note{{previous declaration is here}}
+void public_func_template();
template<typename T>
-__module_private__ void public_func_template(); // expected-error{{__module_private__ declaration of 'public_func_template' follows public declaration}}
+__module_private__ void public_func_template();
-struct public_struct; // expected-note{{previous declaration is here}}
-__module_private__ struct public_struct; // expected-error{{__module_private__ declaration of 'public_struct' follows public declaration}}
+struct public_struct;
+__module_private__ struct public_struct;
// Check for attempts to make specializations private
template<> __module_private__ void public_func_template<int>(); // expected-error{{template specialization cannot be declared __module_private__}}
@@ -137,4 +94,3 @@ struct LikeVisibleStruct {
};
int check_struct_size[sizeof(VisibleStruct) == sizeof(LikeVisibleStruct)? 1 : -1];
-#endif
diff --git a/test/Modules/namespaces.cpp b/test/Modules/namespaces.cpp
new file mode 100644
index 0000000..19e0c5a
--- /dev/null
+++ b/test/Modules/namespaces.cpp
@@ -0,0 +1,64 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify
+
+// Importing modules which add declarations to a pre-existing non-imported
+// overload set does not currently work.
+// XFAIL: *
+
+namespace N6 {
+ char &f(char);
+}
+
+namespace N8 { }
+
+@__experimental_modules_import namespaces_left;
+@__experimental_modules_import namespaces_right;
+
+void test() {
+ int &ir1 = N1::f(1);
+ int &ir2 = N2::f(1);
+ int &ir3 = N3::f(1);
+ float &fr1 = N1::f(1.0f);
+ float &fr2 = N2::f(1.0f);
+ double &dr1 = N2::f(1.0);
+ double &dr2 = N3::f(1.0);
+}
+
+// Test namespaces merged without a common first declaration.
+namespace N5 {
+ char &f(char);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+void testMerged() {
+ int &ir1 = N5::f(17);
+ int &ir2 = N6::f(17);
+ int &ir3 = N7::f(17);
+ double &fr1 = N5::f(1.0);
+ double &fr2 = N6::f(1.0);
+ double &fr3 = N7::f(1.0);
+ char &cr1 = N5::f('a');
+ char &cr2 = N6::f('b');
+}
+
+// Test merging of declarations within namespaces that themselves were
+// merged without a common first declaration.
+void testMergedMerged() {
+ int &ir1 = N8::f(17);
+ int &ir2 = N9::f(17);
+ int &ir3 = N10::f(17);
+}
+
+// Test merging when using anonymous namespaces, which does not
+// actually perform any merging.
+// other file: expected-note{{passing argument to parameter here}}
+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 *'}}
+}
+
+
+// other file: expected-note{{passing argument to parameter here}}
diff --git a/test/Modules/normal-module-map.cpp b/test/Modules/normal-module-map.cpp
new file mode 100644
index 0000000..7cd4482
--- /dev/null
+++ b/test/Modules/normal-module-map.cpp
@@ -0,0 +1,35 @@
+// Note: inside the module. expected-note{{'nested_umbrella_a' declared here}}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %t -fmodules -I %S/Inputs/normal-module-map %s -verify
+#include "Umbrella/umbrella_sub.h"
+
+int getUmbrella() {
+ return umbrella + umbrella_sub;
+}
+
+@__experimental_modules_import Umbrella2;
+
+#include "a1.h"
+#include "b1.h"
+#include "nested/nested2.h"
+
+int test() {
+ return a1 + b1 + nested2;
+}
+
+@__experimental_modules_import nested_umbrella.a;
+
+int testNestedUmbrellaA() {
+ return nested_umbrella_a;
+}
+
+int testNestedUmbrellaBFail() {
+ return nested_umbrella_b; // expected-error{{use of undeclared identifier 'nested_umbrella_b'; did you mean 'nested_umbrella_a'?}}
+}
+
+@__experimental_modules_import nested_umbrella.b;
+
+int testNestedUmbrellaB() {
+ return nested_umbrella_b;
+}
diff --git a/test/Modules/objc-categories.m b/test/Modules/objc-categories.m
index 87aaa5c..340f279 100644
--- a/test/Modules/objc-categories.m
+++ b/test/Modules/objc-categories.m
@@ -1,77 +1,20 @@
-// RUN: mkdir -p %t
-// RUN: %clang_cc1 -emit-module -o %t/diamond_top.pcm %s -D MODULE_TOP
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_left.pcm %s -D MODULE_LEFT
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_right.pcm %s -D MODULE_RIGHT
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_bottom.pcm %s -D MODULE_BOTTOM
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash %s -verify
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify
-/*============================================================================*/
-#ifdef MODULE_TOP
+@__experimental_modules_import category_bottom;
-@interface Foo
-@end
-
-@interface Foo(Top)
--(void)top;
-@end
-
-/*============================================================================*/
-#elif defined(MODULE_LEFT)
-__import_module__ diamond_top;
-@interface Foo(Left)
--(void)left;
-@end
-
-@interface LeftFoo
--(void)left;
-@end
-@interface Foo(Duplicate) // expected-note {{previous definition}}
-@end
-
-@interface Foo(Duplicate)
-@end
-
-/*============================================================================*/
-#elif defined(MODULE_RIGHT)
-
-__import_module__ diamond_top;
-
-@interface Foo(Right1)
--(void)right1;
-@end
-
-@interface Foo(Right2)
--(void)right2;
-@end
-
-@interface Foo(Duplicate) // expected-warning {{duplicate definition of category}}
-@end
-
-/*============================================================================*/
-#elif defined(MODULE_BOTTOM)
-
-__import_module__ diamond_left;
-
-@interface Foo(Bottom)
--(void)bottom;
-@end
-
-__import_module__ diamond_right;
-
-@interface LeftFoo(Bottom)
--(void)bottom;
-@end
-
-/*============================================================================*/
-#else
-
-__import_module__ diamond_bottom;
+// in category_left.h: expected-note {{previous definition}}
@interface Foo(Source)
--(void)source;
+-(void)source;
@end
void test(Foo *foo, LeftFoo *leftFoo) {
@@ -81,9 +24,17 @@ void test(Foo *foo, LeftFoo *leftFoo) {
[foo right1];
[foo right2];
[foo top];
+ [foo top2];
+ [foo top3];
[leftFoo left];
[leftFoo bottom];
}
-#endif
+// Load another module that also adds categories to Foo, verify that
+// we see those categories.
+@__experimental_modules_import category_other;
+
+void test_other(Foo *foo) {
+ [foo other];
+}
diff --git a/test/Modules/on-demand-build-warnings.m b/test/Modules/on-demand-build-warnings.m
index aa122db..24975c0 100644
--- a/test/Modules/on-demand-build-warnings.m
+++ b/test/Modules/on-demand-build-warnings.m
@@ -1,5 +1,5 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -verify %s
-__import_module__ Module; // expected-warning{{building module 'Module' from source}}
+@__experimental_modules_import Module; // expected-warning{{building module 'Module' from source}}
diff --git a/test/Modules/on-demand-build.m b/test/Modules/on-demand-build.m
index 649caa8..cf1ae99 100644
--- a/test/Modules/on-demand-build.m
+++ b/test/Modules/on-demand-build.m
@@ -1,11 +1,15 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -fmodule-cache-path %t -F %S/Inputs -verify %s
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -x objective-c++ -fmodule-cache-path %t -F %S/Inputs -verify %s
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -x objective-c++ -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
#define FOO
-__import_module__ Module;
+@__experimental_modules_import Module;
@interface OtherClass
@end
+
+
+
+
// in module: expected-note{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}}
void test_getModuleVersion() {
const char *version = getModuleVersion();
@@ -14,4 +18,10 @@ void test_getModuleVersion() {
OtherClass *other = [Module alloc]; // expected-error{{init}}
}
+#ifdef MODULE_SUBFRAMEWORK_H
+# error MODULE_SUBFRAMEWORK_H should be hidden
+#endif
+
+@__experimental_modules_import subdir;
+const char *getSubdirTest() { return getSubdir(); }
diff --git a/test/Modules/on-demand-macros.m b/test/Modules/on-demand-macros.m
index 96abb23..2b8c545 100644
--- a/test/Modules/on-demand-macros.m
+++ b/test/Modules/on-demand-macros.m
@@ -1,8 +1,8 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -DFOO_RETURNS_INT_PTR -verify %s
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -DFOO_RETURNS_INT_PTR -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -verify %s
-__import_module__ CmdLine;
+@__experimental_modules_import CmdLine;
void test() {
#ifdef FOO_RETURNS_INT_PTR
diff --git a/test/Modules/redecl-merge.m b/test/Modules/redecl-merge.m
new file mode 100644
index 0000000..d7930ac
--- /dev/null
+++ b/test/Modules/redecl-merge.m
@@ -0,0 +1,158 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class
+@class C2;
+@class C3;
+@class C3;
+@__experimental_modules_import redecl_merge_left;
+typedef struct my_struct_type *my_struct_ref;
+@protocol P4;
+@class C3;
+@class C3;
+@__experimental_modules_import redecl_merge_right;
+
+@implementation A
+- (Super*)init { return self; }
+@end
+
+void f(A *a) {
+ [a init];
+}
+
+@class A;
+
+B *f1() {
+ return [B create_a_B];
+}
+
+@class B;
+
+void testProtoMerge(id<P1> p1, id<P2> p2) {
+ [p1 protoMethod1];
+ [p2 protoMethod2];
+}
+
+struct S1 {
+ int s1_field;
+};
+
+struct S3 {
+ int s3_field;
+};
+
+void testTagMerge() {
+ consume_S1(produce_S1());
+ struct S2 s2;
+ s2.field = 0;
+ consume_S2(produce_S2());
+ struct S1 s1;
+ s1.s1_field = 0;
+ consume_S3(produce_S3());
+ struct S4 s4;
+ s4.field = 0;
+ consume_S4(produce_S4());
+ struct S3 s3;
+ s3.s3_field = 0;
+}
+
+void testTypedefMerge(int i, double d) {
+ T1 *ip = &i;
+ // in other file: expected-note{{candidate found by name lookup is 'T2'}}
+ // FIXME: Typedefs aren't actually merged in the sense of other merges, because
+ // we should only merge them when the types are identical.
+ // in other file: expected-note{{candidate found by name lookup is 'T2'}}
+ // in other file: expected-note{{candidate function}}
+ T2 *dp = &d; // expected-error{{reference to 'T2' is ambiguous}}
+}
+
+void testFuncMerge(int i) {
+ func0(i);
+ // in other file: expected-note{{candidate function}}
+ func1(i);
+ func2(i); // expected-error{{call to 'func2' is ambiguous}}
+}
+
+void testVarMerge(int i) {
+ var1 = i;
+ // in other files: expected-note 2{{candidate found by name lookup is 'var2'}}
+ var2 = i; // expected-error{{reference to 'var2' is ambiguous}}
+ // in other files: expected-note 2{{candidate found by name lookup is 'var3'}}
+ var3 = i; // expected-error{{reference to 'var3' is ambiguous}}
+}
+
+// Test redeclarations of entities in explicit submodules, to make
+// sure we're maintaining the declaration chains even when normal name
+// lookup can't see what we're looking for.
+void testExplicit() {
+ Explicit *e;
+ int *(*fp)(void) = &explicit_func;
+ int *ip = explicit_func();
+
+ // FIXME: Should complain about definition not having been imported.
+ struct explicit_struct es = { 0 };
+}
+
+// Test resolution of declarations from multiple modules with no
+// common original declaration.
+void test_C(C *c) {
+ c = get_a_C();
+ accept_a_C(c);
+}
+
+void test_C2(C2 *c2) {
+ c2 = get_a_C2();
+ accept_a_C2(c2);
+}
+
+void test_C3(C3 *c3) {
+ c3 = get_a_C3();
+ accept_a_C3(c3);
+}
+
+C4 *global_C4;
+
+ClassWithDef *cwd1;
+
+@__experimental_modules_import redecl_merge_left_left;
+
+void test_C4a(C4 *c4) {
+ global_C4 = c4 = get_a_C4();
+ accept_a_C4(c4);
+}
+
+void test_ClassWithDef(ClassWithDef *cwd) {
+ [cwd method];
+}
+
+@__experimental_modules_import redecl_merge_bottom;
+
+void test_C4b() {
+ if (&refers_to_C4) {
+ }
+}
+
+@implementation B
++ (B*)create_a_B { return 0; }
+@end
+
+void g(A *a) {
+ [a init];
+}
+
+@protocol P3
+- (void)p3_method;
+@end
+
+id<P4> p4;
+id<P3> p3;
+
+#ifdef __cplusplus
+void testVector() {
+ Vector<int> vec_int;
+ vec_int.push_back(0);
+}
+#endif
+
+// Make sure we don't get conflicts with 'id'.
+funcptr_with_id fid;
+id id_global;
diff --git a/test/Modules/redecl-namespaces.mm b/test/Modules/redecl-namespaces.mm
new file mode 100644
index 0000000..e338821
--- /dev/null
+++ b/test/Modules/redecl-namespaces.mm
@@ -0,0 +1,13 @@
+@__experimental_modules_import redecl_namespaces_left;
+@__experimental_modules_import redecl_namespaces_right;
+
+void test() {
+ A::i;
+ A::j;
+ A::k; // expected-error {{no member named 'k' in namespace 'A'}}
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -emit-module -fmodule-name=redecl_namespaces_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -emit-module -fmodule-name=redecl_namespaces_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -w %s -verify
diff --git a/test/Modules/redeclarations.m b/test/Modules/redeclarations.m
new file mode 100644
index 0000000..3f3e695
--- /dev/null
+++ b/test/Modules/redeclarations.m
@@ -0,0 +1,11 @@
+@__experimental_modules_import redeclarations_left;
+@__experimental_modules_import redeclarations_right;
+
+@interface MyObject : NSObject
+@end
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify
+
diff --git a/test/Modules/requires.m b/test/Modules/requires.m
new file mode 100644
index 0000000..ce2537c
--- /dev/null
+++ b/test/Modules/requires.m
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+@__experimental_modules_import DependsOnModule.CXX; // expected-error{{module 'DependsOnModule.CXX' requires feature 'cplusplus'}}
+
diff --git a/test/Modules/subframeworks.m b/test/Modules/subframeworks.m
new file mode 100644
index 0000000..09298c4
--- /dev/null
+++ b/test/Modules/subframeworks.m
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
+// RUN: %clang_cc1 -x objective-c++ -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
+
+@__experimental_modules_import DependsOnModule;
+
+void testSubFramework() {
+ float *sf1 = sub_framework; // expected-error{{use of undeclared identifier 'sub_framework'}}
+}
+
+@__experimental_modules_import DependsOnModule.SubFramework;
+
+void testSubFrameworkAgain() {
+ float *sf2 = sub_framework;
+ double *sfo1 = sub_framework_other;
+}
+
+#ifdef __cplusplus
+@__experimental_modules_import DependsOnModule.CXX;
+
+CXXOnly cxxonly;
+#endif
diff --git a/test/Modules/submodules-preprocess.cpp b/test/Modules/submodules-preprocess.cpp
new file mode 100644
index 0000000..8d6c2cd
--- /dev/null
+++ b/test/Modules/submodules-preprocess.cpp
@@ -0,0 +1,61 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -Eonly -fmodule-cache-path %t -I %S/Inputs/submodules %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import std.vector;
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifdef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is available (but shouldn't be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+
+@__experimental_modules_import std; // import everything in 'std'
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.hash_map;
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifndef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is not available (but should be)
+#endif
diff --git a/test/Modules/submodules.cpp b/test/Modules/submodules.cpp
new file mode 100644
index 0000000..60d5ae0
--- /dev/null
+++ b/test/Modules/submodules.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -fmodules -I %S/Inputs/submodules %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import std.vector;
+
+vector<int> vi;
+
+// Note: remove_reference is not visible yet.
+remove_reference<int&>::type *int_ptr = 0; // expected-error{{unknown type name 'remove_reference'}} \
+// expected-error{{expected unqualified-id}}
+
+@__experimental_modules_import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
+
+vector<float> vf;
+remove_reference<int&>::type *int_ptr2 = 0;
+
+@__experimental_modules_import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+
+@__experimental_modules_import std; // import everything in 'std'
+
+// hash_map still isn't available.
+hash_map<int, float> ints_to_floats; // expected-error{{unknown type name 'hash_map'}} \
+// expected-error{{expected unqualified-id}}
+
+@__experimental_modules_import std.hash_map;
+
+hash_map<int, float> ints_to_floats2;
+
diff --git a/test/Modules/submodules.m b/test/Modules/submodules.m
new file mode 100644
index 0000000..e014bea
--- /dev/null
+++ b/test/Modules/submodules.m
@@ -0,0 +1,11 @@
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+// Note: transitively imports Module.Sub2.
+@__experimental_modules_import Module.Sub;
+
+int getValue() {
+ return *Module_Sub + *Module_Sub2;
+}
+
diff --git a/test/Modules/wildcard-submodule-exports.cpp b/test/Modules/wildcard-submodule-exports.cpp
new file mode 100644
index 0000000..6b4f02c
--- /dev/null
+++ b/test/Modules/wildcard-submodule-exports.cpp
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -fmodules -I %S/Inputs/wildcard-submodule-exports %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import C.One;
+
+void test_C_One() {
+ int *A1_ptr = A1;
+ long *C1_ptr = C1;
+ (void)B1; // expected-error{{use of undeclared identifier 'B1'}}
+}
+
+@__experimental_modules_import C.Two;
+
+void test_C_Two() {
+ unsigned int *A2_ptr = A2;
+ unsigned short *B2_ptr = B2;
+ unsigned long *C2_ptr = C2;
+}
+
+@__experimental_modules_import B.One;
+
+void test_B_One() {
+ short *B1_ptr = B1;
+}
+
OpenPOWER on IntegriCloud