diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/Modules | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/Modules')
130 files changed, 1915 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h b/clang/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h new file mode 100644 index 0000000..1417e0c --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/CmdLine.framework/Headers/CmdLine.h b/clang/test/Modules/Inputs/CmdLine.framework/Headers/CmdLine.h new file mode 100644 index 0000000..46b8fc0 --- /dev/null +++ b/clang/test/Modules/Inputs/CmdLine.framework/Headers/CmdLine.h @@ -0,0 +1,6 @@ +#ifdef FOO_RETURNS_INT_PTR +int *foo(void); +#else +float *foo(void); +#endif + diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h new file mode 100644 index 0000000..69f9e8e --- /dev/null +++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h @@ -0,0 +1 @@ +double *sub_framework_other; diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h new file mode 100644 index 0000000..e6e835e --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h new file mode 100644 index 0000000..9425f48 --- /dev/null +++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h @@ -0,0 +1,5 @@ +#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/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h new file mode 100644 index 0000000..724d798 --- /dev/null +++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h @@ -0,0 +1,5 @@ +class CXXOnly { + public: + CXXOnly(); + ~CXXOnly(); +}; diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h new file mode 100644 index 0000000..5ee3f92 --- /dev/null +++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h @@ -0,0 +1 @@ +int depends_on_module_other; diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h b/clang/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h new file mode 100644 index 0000000..4b3c30c --- /dev/null +++ b/clang/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h @@ -0,0 +1,2 @@ +int depends_on_module_private; + diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/module.map b/clang/test/Modules/Inputs/DependsOnModule.framework/module.map new file mode 100644 index 0000000..2a3dd80 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map b/clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map new file mode 100644 index 0000000..5ed0029 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/MethodPoolA.h b/clang/test/Modules/Inputs/MethodPoolA.h new file mode 100644 index 0000000..6af24a9 --- /dev/null +++ b/clang/test/Modules/Inputs/MethodPoolA.h @@ -0,0 +1,8 @@ + + + + +@interface A ++ (int)method1; +- (int)method2:(int)param; +@end diff --git a/clang/test/Modules/Inputs/MethodPoolB.h b/clang/test/Modules/Inputs/MethodPoolB.h new file mode 100644 index 0000000..e1e86ed --- /dev/null +++ b/clang/test/Modules/Inputs/MethodPoolB.h @@ -0,0 +1,13 @@ + + + + + + + + + +@interface B +- (int)method1; +- (int)method2:(float)param; +@end diff --git a/clang/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/clang/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h new file mode 100644 index 0000000..f7f9fb6 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h b/clang/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h new file mode 100644 index 0000000..6e81adc --- /dev/null +++ b/clang/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h @@ -0,0 +1 @@ +unsigned *Buried_Treasure; diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Module.h b/clang/test/Modules/Inputs/Module.framework/Headers/Module.h new file mode 100644 index 0000000..738b222 --- /dev/null +++ b/clang/test/Modules/Inputs/Module.framework/Headers/Module.h @@ -0,0 +1,22 @@ +// expected-warning{{umbrella header}} + +#ifndef MODULE_H +#define MODULE_H +const char *getModuleVersion(void); + +#ifdef FOO +# error Module should have been built without -DFOO +#endif + +@interface Module ++(const char *)version; // retrieve module version ++alloc; +@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/clang/test/Modules/Inputs/Module.framework/Headers/NotInModule.h b/clang/test/Modules/Inputs/Module.framework/Headers/NotInModule.h new file mode 100644 index 0000000..6b15791 --- /dev/null +++ b/clang/test/Modules/Inputs/Module.framework/Headers/NotInModule.h @@ -0,0 +1 @@ +int not_in_module; diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Sub.h b/clang/test/Modules/Inputs/Module.framework/Headers/Sub.h new file mode 100644 index 0000000..dea76e7 --- /dev/null +++ b/clang/test/Modules/Inputs/Module.framework/Headers/Sub.h @@ -0,0 +1,3 @@ +#include <Module/Sub2.h> +int *Module_Sub; + diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Sub2.h b/clang/test/Modules/Inputs/Module.framework/Headers/Sub2.h new file mode 100644 index 0000000..beed4a8 --- /dev/null +++ b/clang/test/Modules/Inputs/Module.framework/Headers/Sub2.h @@ -0,0 +1 @@ +int *Module_Sub2; diff --git a/clang/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h b/clang/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h new file mode 100644 index 0000000..0782336 --- /dev/null +++ b/clang/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h @@ -0,0 +1 @@ +int module_private; diff --git a/clang/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h b/clang/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h new file mode 100644 index 0000000..5142f56 --- /dev/null +++ b/clang/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h @@ -0,0 +1,3 @@ + +@__experimental_modules_import MutuallyRecursive2; + diff --git a/clang/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h b/clang/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h new file mode 100644 index 0000000..8a3cc33 --- /dev/null +++ b/clang/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h @@ -0,0 +1,6 @@ + + +@__experimental_modules_import MutuallyRecursive1; + + + diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h new file mode 100644 index 0000000..73f32bf --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h new file mode 100644 index 0000000..dc6770f --- /dev/null +++ b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h @@ -0,0 +1 @@ +int no_umbrella_B; diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h new file mode 100644 index 0000000..ac4a14a --- /dev/null +++ b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h @@ -0,0 +1 @@ +this is gibberish diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h new file mode 100644 index 0000000..4a9351a --- /dev/null +++ b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h @@ -0,0 +1 @@ +int no_umbrella_C; diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h b/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h new file mode 100644 index 0000000..bd606d2 --- /dev/null +++ b/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h @@ -0,0 +1 @@ +int no_umbrella_A_private; diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h b/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h new file mode 100644 index 0000000..442be2d --- /dev/null +++ b/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h @@ -0,0 +1 @@ +int no_umbrella_B_private; diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/module.map b/clang/test/Modules/Inputs/NoUmbrella.framework/module.map new file mode 100644 index 0000000..4a4d970 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map b/clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map new file mode 100644 index 0000000..0507ba0 --- /dev/null +++ b/clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map @@ -0,0 +1,4 @@ +explicit module NoUmbrella.Private { + umbrella "PrivateHeaders" + explicit module * { } +} diff --git a/clang/test/Modules/Inputs/System/usr/include/module.map b/clang/test/Modules/Inputs/System/usr/include/module.map new file mode 100644 index 0000000..884b59c --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/System/usr/include/stdbool.h b/clang/test/Modules/Inputs/System/usr/include/stdbool.h new file mode 100644 index 0000000..760d7dc --- /dev/null +++ b/clang/test/Modules/Inputs/System/usr/include/stdbool.h @@ -0,0 +1 @@ +// Testing hack: does not define bool/true/false. diff --git a/clang/test/Modules/Inputs/System/usr/include/stdint.h b/clang/test/Modules/Inputs/System/usr/include/stdint.h new file mode 100644 index 0000000..e8e50f9 --- /dev/null +++ b/clang/test/Modules/Inputs/System/usr/include/stdint.h @@ -0,0 +1 @@ +typedef int my_awesome_nonstandard_integer_type; diff --git a/clang/test/Modules/Inputs/System/usr/include/stdio.h b/clang/test/Modules/Inputs/System/usr/include/stdio.h new file mode 100644 index 0000000..9a7b106 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/category_bottom.h b/clang/test/Modules/Inputs/category_bottom.h new file mode 100644 index 0000000..b53d9c3 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/category_left.h b/clang/test/Modules/Inputs/category_left.h new file mode 100644 index 0000000..736fa43 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/category_other.h b/clang/test/Modules/Inputs/category_other.h new file mode 100644 index 0000000..1bb5a91 --- /dev/null +++ b/clang/test/Modules/Inputs/category_other.h @@ -0,0 +1,6 @@ +@__experimental_modules_import category_top; + +@interface Foo(Other) +-(void)other; +@end + diff --git a/clang/test/Modules/Inputs/category_right.h b/clang/test/Modules/Inputs/category_right.h new file mode 100644 index 0000000..d993b50 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/category_top.h b/clang/test/Modules/Inputs/category_top.h new file mode 100644 index 0000000..c9558b6 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/decl.h b/clang/test/Modules/Inputs/decl.h new file mode 100644 index 0000000..8dbe11e --- /dev/null +++ b/clang/test/Modules/Inputs/decl.h @@ -0,0 +1,2 @@ +@class A; +typedef struct B B; diff --git a/clang/test/Modules/Inputs/decl2.h b/clang/test/Modules/Inputs/decl2.h new file mode 100644 index 0000000..decf6e0 --- /dev/null +++ b/clang/test/Modules/Inputs/decl2.h @@ -0,0 +1 @@ +@class A; diff --git a/clang/test/Modules/Inputs/def-include.h b/clang/test/Modules/Inputs/def-include.h new file mode 100644 index 0000000..9e0e575 --- /dev/null +++ b/clang/test/Modules/Inputs/def-include.h @@ -0,0 +1,13 @@ + + + + + + + + + + +struct B { + int b1; +}; diff --git a/clang/test/Modules/Inputs/def.h b/clang/test/Modules/Inputs/def.h new file mode 100644 index 0000000..6d06b08 --- /dev/null +++ b/clang/test/Modules/Inputs/def.h @@ -0,0 +1,11 @@ +#include "def-include.h" + + + +@interface A { +@public + int ivar; +} +@end + + diff --git a/clang/test/Modules/Inputs/diamond.h b/clang/test/Modules/Inputs/diamond.h new file mode 100644 index 0000000..15b5290 --- /dev/null +++ b/clang/test/Modules/Inputs/diamond.h @@ -0,0 +1 @@ +@__experimental_modules_import diamond_bottom; diff --git a/clang/test/Modules/Inputs/diamond_bottom.h b/clang/test/Modules/Inputs/diamond_bottom.h new file mode 100644 index 0000000..b45fa93 --- /dev/null +++ b/clang/test/Modules/Inputs/diamond_bottom.h @@ -0,0 +1,4 @@ +@__experimental_modules_import diamond_left; +@__experimental_modules_import diamond_right; + +char bottom(char *x); diff --git a/clang/test/Modules/Inputs/diamond_left.h b/clang/test/Modules/Inputs/diamond_left.h new file mode 100644 index 0000000..cc406ab --- /dev/null +++ b/clang/test/Modules/Inputs/diamond_left.h @@ -0,0 +1,9 @@ +@__experimental_modules_import diamond_top; + +float left(float *); + +int top_left(char *c); + +int left_and_right(int*); + + diff --git a/clang/test/Modules/Inputs/diamond_right.h b/clang/test/Modules/Inputs/diamond_right.h new file mode 100644 index 0000000..2ba1d77 --- /dev/null +++ b/clang/test/Modules/Inputs/diamond_right.h @@ -0,0 +1,7 @@ +@__experimental_modules_import diamond_top; + +double right(double *); + +struct left_and_right { + int left, right; +}; diff --git a/clang/test/Modules/Inputs/diamond_top.h b/clang/test/Modules/Inputs/diamond_top.h new file mode 100644 index 0000000..34998cd --- /dev/null +++ b/clang/test/Modules/Inputs/diamond_top.h @@ -0,0 +1,4 @@ +int top(int *); + +int top_left(char *c); + diff --git a/clang/test/Modules/Inputs/irgen.h b/clang/test/Modules/Inputs/irgen.h new file mode 100644 index 0000000..9936bf6 --- /dev/null +++ b/clang/test/Modules/Inputs/irgen.h @@ -0,0 +1 @@ +static inline int triple(int x) { return x * 3; } diff --git a/clang/test/Modules/Inputs/load_failure.h b/clang/test/Modules/Inputs/load_failure.h new file mode 100644 index 0000000..5bcb44d --- /dev/null +++ b/clang/test/Modules/Inputs/load_failure.h @@ -0,0 +1 @@ +int fail(int); diff --git a/clang/test/Modules/Inputs/lookup_left.h b/clang/test/Modules/Inputs/lookup_left.h new file mode 100644 index 0000000..01723d4 --- /dev/null +++ b/clang/test/Modules/Inputs/lookup_left.h @@ -0,0 +1,3 @@ +@interface A +- (int)method; +@end diff --git a/clang/test/Modules/Inputs/lookup_left.hpp b/clang/test/Modules/Inputs/lookup_left.hpp new file mode 100644 index 0000000..66d6206 --- /dev/null +++ b/clang/test/Modules/Inputs/lookup_left.hpp @@ -0,0 +1,5 @@ +int *f0(int*); + +#pragma weak weak_identifier // expected-warning{{weak identifier 'weak_identifier' never declared}} + + diff --git a/clang/test/Modules/Inputs/lookup_right.h b/clang/test/Modules/Inputs/lookup_right.h new file mode 100644 index 0000000..f8f0c97 --- /dev/null +++ b/clang/test/Modules/Inputs/lookup_right.h @@ -0,0 +1,5 @@ + +@interface B +- (double)method; +@end + diff --git a/clang/test/Modules/Inputs/lookup_right.hpp b/clang/test/Modules/Inputs/lookup_right.hpp new file mode 100644 index 0000000..8845347 --- /dev/null +++ b/clang/test/Modules/Inputs/lookup_right.hpp @@ -0,0 +1 @@ +float *f0(float*); diff --git a/clang/test/Modules/Inputs/macros.h b/clang/test/Modules/Inputs/macros.h new file mode 100644 index 0000000..4f53556 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map new file mode 100644 index 0000000..e8d1f2c --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/module_private_left.h b/clang/test/Modules/Inputs/module_private_left.h new file mode 100644 index 0000000..ff33999 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/module_private_right.h b/clang/test/Modules/Inputs/module_private_right.h new file mode 100644 index 0000000..53efe25 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/namespaces-left.h b/clang/test/Modules/Inputs/namespaces-left.h new file mode 100644 index 0000000..d253fed --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/namespaces-right.h b/clang/test/Modules/Inputs/namespaces-right.h new file mode 100644 index 0000000..7e7286e --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/namespaces-top.h b/clang/test/Modules/Inputs/namespaces-top.h new file mode 100644 index 0000000..0c607f5 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h b/clang/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h new file mode 100644 index 0000000..7462376 --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h @@ -0,0 +1,4 @@ +int umbrella; + +#include "umbrella_sub.h" + diff --git a/clang/test/Modules/Inputs/normal-module-map/Umbrella/module.map b/clang/test/Modules/Inputs/normal-module-map/Umbrella/module.map new file mode 100644 index 0000000..611cf9f --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h b/clang/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h new file mode 100644 index 0000000..9fdccd1 --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h @@ -0,0 +1,2 @@ +int umbrella_sub; + diff --git a/clang/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h b/clang/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h new file mode 100644 index 0000000..36110d8 --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h @@ -0,0 +1 @@ +int umbrella2; diff --git a/clang/test/Modules/Inputs/normal-module-map/Umbrella2/module.map b/clang/test/Modules/Inputs/normal-module-map/Umbrella2/module.map new file mode 100644 index 0000000..1e57704 --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella2/module.map @@ -0,0 +1,3 @@ +module Umbrella2 { + umbrella header "Umbrella2.h" +} diff --git a/clang/test/Modules/Inputs/normal-module-map/a1.h b/clang/test/Modules/Inputs/normal-module-map/a1.h new file mode 100644 index 0000000..f2d5a49 --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/a1.h @@ -0,0 +1 @@ +int a1; diff --git a/clang/test/Modules/Inputs/normal-module-map/a2.h b/clang/test/Modules/Inputs/normal-module-map/a2.h new file mode 100644 index 0000000..5c4e7ff --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/a2.h @@ -0,0 +1 @@ +int a2; diff --git a/clang/test/Modules/Inputs/normal-module-map/b1.h b/clang/test/Modules/Inputs/normal-module-map/b1.h new file mode 100644 index 0000000..2ed1112 --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/b1.h @@ -0,0 +1,2 @@ +int b1; + diff --git a/clang/test/Modules/Inputs/normal-module-map/module.map b/clang/test/Modules/Inputs/normal-module-map/module.map new file mode 100644 index 0000000..e17f44a --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/normal-module-map/nested/module.map b/clang/test/Modules/Inputs/normal-module-map/nested/module.map new file mode 100644 index 0000000..fd463c2 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/normal-module-map/nested/nested1.h b/clang/test/Modules/Inputs/normal-module-map/nested/nested1.h new file mode 100644 index 0000000..3790d1a --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/nested/nested1.h @@ -0,0 +1 @@ +int nested1; diff --git a/clang/test/Modules/Inputs/normal-module-map/nested/nested2.h b/clang/test/Modules/Inputs/normal-module-map/nested/nested2.h new file mode 100644 index 0000000..d56d601 --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/nested/nested2.h @@ -0,0 +1 @@ +int nested2; diff --git a/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h b/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h new file mode 100644 index 0000000..ab180fe --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h @@ -0,0 +1,2 @@ +int nested_umbrella_a; + diff --git a/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h b/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h new file mode 100644 index 0000000..a903f5d --- /dev/null +++ b/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h @@ -0,0 +1,2 @@ +int nested_umbrella_b; + diff --git a/clang/test/Modules/Inputs/point.h b/clang/test/Modules/Inputs/point.h new file mode 100644 index 0000000..eab23d5 --- /dev/null +++ b/clang/test/Modules/Inputs/point.h @@ -0,0 +1,2 @@ +struct Point { int x, y; }; + diff --git a/clang/test/Modules/Inputs/redecl-merge-bottom.h b/clang/test/Modules/Inputs/redecl-merge-bottom.h new file mode 100644 index 0000000..40a9404 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/redecl-merge-left-left.h b/clang/test/Modules/Inputs/redecl-merge-left-left.h new file mode 100644 index 0000000..5f48883 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/redecl-merge-left.h b/clang/test/Modules/Inputs/redecl-merge-left.h new file mode 100644 index 0000000..b3a7ba8 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/redecl-merge-right.h b/clang/test/Modules/Inputs/redecl-merge-right.h new file mode 100644 index 0000000..de7aa08 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/redecl-merge-top-explicit.h b/clang/test/Modules/Inputs/redecl-merge-top-explicit.h new file mode 100644 index 0000000..e06ff7a --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/redecl-merge-top.h b/clang/test/Modules/Inputs/redecl-merge-top.h new file mode 100644 index 0000000..519254c --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/redecl_namespaces_left.h b/clang/test/Modules/Inputs/redecl_namespaces_left.h new file mode 100644 index 0000000..49595ea --- /dev/null +++ b/clang/test/Modules/Inputs/redecl_namespaces_left.h @@ -0,0 +1,3 @@ +namespace A { + int i; +} diff --git a/clang/test/Modules/Inputs/redecl_namespaces_right.h b/clang/test/Modules/Inputs/redecl_namespaces_right.h new file mode 100644 index 0000000..fdf65ba --- /dev/null +++ b/clang/test/Modules/Inputs/redecl_namespaces_right.h @@ -0,0 +1,3 @@ +namespace A { + int j; +} diff --git a/clang/test/Modules/Inputs/redeclarations_left.h b/clang/test/Modules/Inputs/redeclarations_left.h new file mode 100644 index 0000000..4dfbf1d --- /dev/null +++ b/clang/test/Modules/Inputs/redeclarations_left.h @@ -0,0 +1,2 @@ +@class NSObject; + diff --git a/clang/test/Modules/Inputs/redeclarations_right.h b/clang/test/Modules/Inputs/redeclarations_right.h new file mode 100644 index 0000000..d3861fe --- /dev/null +++ b/clang/test/Modules/Inputs/redeclarations_right.h @@ -0,0 +1,2 @@ +@interface NSObject +@end diff --git a/clang/test/Modules/Inputs/subdir/module.map b/clang/test/Modules/Inputs/subdir/module.map new file mode 100644 index 0000000..4cd0215 --- /dev/null +++ b/clang/test/Modules/Inputs/subdir/module.map @@ -0,0 +1,3 @@ +module subdir { + header "subdir.h" +} diff --git a/clang/test/Modules/Inputs/subdir/subdir.h b/clang/test/Modules/Inputs/subdir/subdir.h new file mode 100644 index 0000000..0fb3d21 --- /dev/null +++ b/clang/test/Modules/Inputs/subdir/subdir.h @@ -0,0 +1 @@ +const char *getSubdir(); diff --git a/clang/test/Modules/Inputs/submodules/hash_map.h b/clang/test/Modules/Inputs/submodules/hash_map.h new file mode 100644 index 0000000..ce85984 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/submodules/module.map b/clang/test/Modules/Inputs/submodules/module.map new file mode 100644 index 0000000..16cedac --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/submodules/type_traits.h b/clang/test/Modules/Inputs/submodules/type_traits.h new file mode 100644 index 0000000..4dad090 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/submodules/vector.h b/clang/test/Modules/Inputs/submodules/vector.h new file mode 100644 index 0000000..8e1cdc8 --- /dev/null +++ b/clang/test/Modules/Inputs/submodules/vector.h @@ -0,0 +1,3 @@ +template<typename T> class vector { }; + +#define HAVE_VECTOR diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/A_one.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/A_one.h new file mode 100644 index 0000000..4a2c239 --- /dev/null +++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/A_one.h @@ -0,0 +1 @@ +int *A1; diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/A_two.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/A_two.h new file mode 100644 index 0000000..1b08599 --- /dev/null +++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/A_two.h @@ -0,0 +1 @@ +unsigned int *A2; diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/B_one.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/B_one.h new file mode 100644 index 0000000..0f44a56 --- /dev/null +++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/B_one.h @@ -0,0 +1 @@ +short *B1; diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/B_two.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/B_two.h new file mode 100644 index 0000000..0e51242 --- /dev/null +++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/B_two.h @@ -0,0 +1 @@ +unsigned short *B2; diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/C_one.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/C_one.h new file mode 100644 index 0000000..fb1c7de --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/wildcard-submodule-exports/C_two.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/C_two.h new file mode 100644 index 0000000..050a8f3 --- /dev/null +++ b/clang/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/clang/test/Modules/Inputs/wildcard-submodule-exports/module.map b/clang/test/Modules/Inputs/wildcard-submodule-exports/module.map new file mode 100644 index 0000000..64b0d89 --- /dev/null +++ b/clang/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/clang/test/Modules/auto-module-import.m b/clang/test/Modules/auto-module-import.m new file mode 100644 index 0000000..fbd0a54 --- /dev/null +++ b/clang/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/clang/test/Modules/compiler_builtins.m b/clang/test/Modules/compiler_builtins.m new file mode 100644 index 0000000..de6f57b --- /dev/null +++ b/clang/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/clang/test/Modules/cstd.m b/clang/test/Modules/cstd.m new file mode 100644 index 0000000..1752cd3 --- /dev/null +++ b/clang/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/clang/test/Modules/cycles.c b/clang/test/Modules/cycles.c new file mode 100644 index 0000000..256f118 --- /dev/null +++ b/clang/test/Modules/cycles.c @@ -0,0 +1,12 @@ +// RUN: rm -rf %t +// 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: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/clang/test/Modules/decldef.mm b/clang/test/Modules/decldef.mm new file mode 100644 index 0000000..64a66d5 --- /dev/null +++ b/clang/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/clang/test/Modules/diamond-pch.c b/clang/test/Modules/diamond-pch.c new file mode 100644 index 0000000..4397c19 --- /dev/null +++ b/clang/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/clang/test/Modules/diamond.c b/clang/test/Modules/diamond.c new file mode 100644 index 0000000..076eec4 --- /dev/null +++ b/clang/test/Modules/diamond.c @@ -0,0 +1,29 @@ + + + +// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}} + +@__experimental_modules_import diamond_bottom; + +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 -fmodule-cache-path %t %s -verify +// FIXME: When we have a syntax for modules in C, use that. diff --git a/clang/test/Modules/driver.c b/clang/test/Modules/driver.c new file mode 100644 index 0000000..de10cd0 --- /dev/null +++ b/clang/test/Modules/driver.c @@ -0,0 +1,6 @@ +// RUN: %clang %s -### 2>&1 | FileCheck -check-prefix NO_MODULE_CACHE %s +// RUN: %clang -fmodule-cache-path blarg %s -### 2>&1 | FileCheck -check-prefix WITH_MODULE_CACHE %s + +// CHECK-NO_MODULE_CACHE: {{clang.*"-fmodule-cache-path"}} + +// CHECK-WITH_MODULE_CACHE: {{clang.*"-fmodule-cache-path" "blarg"}} diff --git a/clang/test/Modules/header-import.m b/clang/test/Modules/header-import.m new file mode 100644 index 0000000..5444854 --- /dev/null +++ b/clang/test/Modules/header-import.m @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s + +#import "point.h" +@__experimental_modules_import Module; +#import "point.h" + diff --git a/clang/test/Modules/inferred-submodules.m b/clang/test/Modules/inferred-submodules.m new file mode 100644 index 0000000..bee1cec --- /dev/null +++ b/clang/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/clang/test/Modules/irgen.c b/clang/test/Modules/irgen.c new file mode 100644 index 0000000..4a080db --- /dev/null +++ b/clang/test/Modules/irgen.c @@ -0,0 +1,13 @@ +// 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. + +@__experimental_modules_import irgen; + +// CHECK: define void @triple_value +void triple_value(int *px) { + *px = triple(*px); +} + +// CHECK: define internal i32 @triple(i32 diff --git a/clang/test/Modules/load_failure.c b/clang/test/Modules/load_failure.c new file mode 100644 index 0000000..3a96301 --- /dev/null +++ b/clang/test/Modules/load_failure.c @@ -0,0 +1,21 @@ +#ifdef NONEXISTENT +@__experimental_modules_import load_nonexistent; +#endif + +#ifdef FAILURE +@__experimental_modules_import load_failure; +#endif + +// 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 -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/clang/test/Modules/lookup.cpp b/clang/test/Modules/lookup.cpp new file mode 100644 index 0000000..9839035 --- /dev/null +++ b/clang/test/Modules/lookup.cpp @@ -0,0 +1,34 @@ + +#define import @__experimental_modules_import +import lookup_left_cxx; +#undef import +#define IMPORT(X) @__experimental_modules_import X +IMPORT(lookup_right_cxx); + +void test(int i, float f) { + // unqualified lookup + f0(&i); + f0(&f); + + // qualified lookup into the translation unit + ::f0(&i); + ::f0(&f); +} + +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 *); +// CHECK-PRINT: void test(int i, float f) + diff --git a/clang/test/Modules/lookup.m b/clang/test/Modules/lookup.m new file mode 100644 index 0000000..c82503f --- /dev/null +++ b/clang/test/Modules/lookup.m @@ -0,0 +1,20 @@ + +// lookup_left.h: expected-note{{using}} +// lookup_right.h: expected-note{{also found}} +@__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: 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 +// CHECK-PRINT: void test(id x) + diff --git a/clang/test/Modules/macros.c b/clang/test/Modules/macros.c new file mode 100644 index 0000000..83e1c66 --- /dev/null +++ b/clang/test/Modules/macros.c @@ -0,0 +1,30 @@ +// 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. + +@__experimental_modules_import macros; + +#ifndef INTEGER +# error INTEGER macro should be visible +#endif + +#ifdef FLOAT +# error FLOAT macro should not be visible +#endif + +#ifdef MODULE +# error MODULE macro should not be visible +#endif + +// CHECK-PREPROCESSED: double d +double d; +DOUBLE *dp = &d; + +#__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. +} diff --git a/clang/test/Modules/method_pool.m b/clang/test/Modules/method_pool.m new file mode 100644 index 0000000..25582ca --- /dev/null +++ b/clang/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/clang/test/Modules/module-private.cpp b/clang/test/Modules/module-private.cpp new file mode 100644 index 0000000..246dcaf --- /dev/null +++ b/clang/test/Modules/module-private.cpp @@ -0,0 +1,96 @@ +// 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. + +@__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 +} + +int test_broken() { + HiddenStruct hidden; // expected-error{{use of undeclared identifier 'HiddenStruct'}} + + Integer i; // expected-error{{use of undeclared identifier 'Integer'}} + + int *ip = 0; + f1(ip); // expected-error{{use of undeclared identifier 'f1'}} + + vector<int> vec; // expected-error{{use of undeclared identifier 'vector'}} \ + // expected-error{{expected '(' for function-style cast or type construction}} \ + // expected-error{{use of undeclared identifier 'vec'}} + + VisibleStruct vs; + vs.field = 0; // expected-error{{no member named 'field' in 'VisibleStruct'}} + vs.setField(1); // expected-error{{no member named 'setField' in 'VisibleStruct'}} + + return hidden_var; // expected-error{{use of undeclared identifier 'hidden_var'}} +} + +// Check for private redeclarations of public entities. +template<typename T> +class public_class_template; + +template<typename T> +__module_private__ class public_class_template; + + +typedef int public_typedef; +typedef __module_private__ int public_typedef; + +extern int public_var; +extern __module_private__ int public_var; + +void public_func(); +__module_private__ void public_func(); + +template<typename T> +void public_func_template(); +template<typename T> +__module_private__ void public_func_template(); + +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__}} + +template<typename T> +struct public_class { + struct inner_struct; + static int static_var; + + friend __module_private__ void public_func_friend(); + friend __module_private__ struct public_struct_friend; +}; + +template<> __module_private__ struct public_class<int>::inner_struct { }; // expected-error{{member specialization cannot be declared __module_private__}} +template<> __module_private__ int public_class<int>::static_var = 17; // expected-error{{member specialization cannot be declared __module_private__}} + +template<> +__module_private__ struct public_class<float> { }; // expected-error{{template specialization cannot be declared __module_private__}} + +template<typename T> +__module_private__ struct public_class<T *> { }; // expected-error{{partial specialization cannot be declared __module_private__}} + +// Check for attempts to make parameters and variables with automatic +// storage module-private. + +void local_var_private(__module_private__ int param) { // expected-error{{parameter 'param' cannot be declared __module_private__}} + __module_private__ struct Local { int x, y; } local; //expected-error{{local variable 'local' cannot be declared __module_private__}} + + __module_private__ struct OtherLocal { int x; }; // expected-error{{local struct cannot be declared __module_private__}} + + typedef __module_private__ int local_typedef; // expected-error{{typedef 'local_typedef' cannot be declared __module_private__}} +} + +// Check struct size +struct LikeVisibleStruct { + int field; + virtual void setField(int f); +}; + +int check_struct_size[sizeof(VisibleStruct) == sizeof(LikeVisibleStruct)? 1 : -1]; diff --git a/clang/test/Modules/namespaces.cpp b/clang/test/Modules/namespaces.cpp new file mode 100644 index 0000000..19e0c5a --- /dev/null +++ b/clang/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/clang/test/Modules/normal-module-map.cpp b/clang/test/Modules/normal-module-map.cpp new file mode 100644 index 0000000..7cd4482 --- /dev/null +++ b/clang/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/clang/test/Modules/objc-categories.m b/clang/test/Modules/objc-categories.m new file mode 100644 index 0000000..340f279 --- /dev/null +++ b/clang/test/Modules/objc-categories.m @@ -0,0 +1,40 @@ +// 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 + +@__experimental_modules_import category_bottom; + + + + +// in category_left.h: expected-note {{previous definition}} + +@interface Foo(Source) +-(void)source; +@end + +void test(Foo *foo, LeftFoo *leftFoo) { + [foo source]; + [foo bottom]; + [foo left]; + [foo right1]; + [foo right2]; + [foo top]; + [foo top2]; + [foo top3]; + + [leftFoo left]; + [leftFoo bottom]; +} + +// 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/clang/test/Modules/on-demand-build-warnings.m b/clang/test/Modules/on-demand-build-warnings.m new file mode 100644 index 0000000..24975c0 --- /dev/null +++ b/clang/test/Modules/on-demand-build-warnings.m @@ -0,0 +1,5 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -verify %s + +@__experimental_modules_import Module; // expected-warning{{building module 'Module' from source}} + diff --git a/clang/test/Modules/on-demand-build.m b/clang/test/Modules/on-demand-build.m new file mode 100644 index 0000000..cf1ae99 --- /dev/null +++ b/clang/test/Modules/on-demand-build.m @@ -0,0 +1,27 @@ +// RUN: rm -rf %t +// 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 +@__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(); + const char *version2 = [Module version]; + + 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/clang/test/Modules/on-demand-macros.m b/clang/test/Modules/on-demand-macros.m new file mode 100644 index 0000000..2b8c545 --- /dev/null +++ b/clang/test/Modules/on-demand-macros.m @@ -0,0 +1,13 @@ +// RUN: rm -rf %t +// 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 + +@__experimental_modules_import CmdLine; + +void test() { +#ifdef FOO_RETURNS_INT_PTR + int *ip = foo(); +#else + float *fp = foo(); +#endif +} diff --git a/clang/test/Modules/redecl-merge.m b/clang/test/Modules/redecl-merge.m new file mode 100644 index 0000000..d7930ac --- /dev/null +++ b/clang/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/clang/test/Modules/redecl-namespaces.mm b/clang/test/Modules/redecl-namespaces.mm new file mode 100644 index 0000000..e338821 --- /dev/null +++ b/clang/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/clang/test/Modules/redeclarations.m b/clang/test/Modules/redeclarations.m new file mode 100644 index 0000000..3f3e695 --- /dev/null +++ b/clang/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/clang/test/Modules/requires.m b/clang/test/Modules/requires.m new file mode 100644 index 0000000..ce2537c --- /dev/null +++ b/clang/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/clang/test/Modules/subframeworks.m b/clang/test/Modules/subframeworks.m new file mode 100644 index 0000000..09298c4 --- /dev/null +++ b/clang/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/clang/test/Modules/submodules-preprocess.cpp b/clang/test/Modules/submodules-preprocess.cpp new file mode 100644 index 0000000..8d6c2cd --- /dev/null +++ b/clang/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/clang/test/Modules/submodules.cpp b/clang/test/Modules/submodules.cpp new file mode 100644 index 0000000..60d5ae0 --- /dev/null +++ b/clang/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/clang/test/Modules/submodules.m b/clang/test/Modules/submodules.m new file mode 100644 index 0000000..e014bea --- /dev/null +++ b/clang/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/clang/test/Modules/wildcard-submodule-exports.cpp b/clang/test/Modules/wildcard-submodule-exports.cpp new file mode 100644 index 0000000..6b4f02c --- /dev/null +++ b/clang/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; +} + |