diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-05-27 18:47:56 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-05-27 18:47:56 +0000 |
commit | 5e20cdd81c44a443562a09007668ffdf76c455af (patch) | |
tree | dbbd4047878da71c1a706e26ce05b4e7791b14cc /test/Modules | |
parent | d5f23b0b7528b5c3caed1ba14f897cc4aaa9e3c3 (diff) | |
download | src-5e20cdd81c44a443562a09007668ffdf76c455af.tar.gz src-5e20cdd81c44a443562a09007668ffdf76c455af.zip |
Vendor import of clang trunk r238337:vendor/clang/clang-trunk-r238337
Notes
Notes:
svn path=/vendor/clang/dist/; revision=283627
svn path=/vendor/clang/clang-trunk-r238337/; revision=283628; tag=vendor/clang/clang-trunk-r238337
Diffstat (limited to 'test/Modules')
232 files changed, 1976 insertions, 157 deletions
diff --git a/test/Modules/Inputs/DependsOnModule.framework/module.map b/test/Modules/Inputs/DependsOnModule.framework/module.map index 5a1cacaad2a3..b62308583df4 100644 --- a/test/Modules/Inputs/DependsOnModule.framework/module.map +++ b/test/Modules/Inputs/DependsOnModule.framework/module.map @@ -16,6 +16,12 @@ framework module DependsOnModule { requires !objc header "not_objc.h" } + explicit module CustomReq1 { + requires custom_req1 + } + explicit module CustomReq2 { + requires custom_req2 + } explicit framework module SubFramework { umbrella header "SubFramework.h" diff --git a/test/Modules/Inputs/Module.framework/Headers/Module.h b/test/Modules/Inputs/Module.framework/Headers/Module.h index 3d2476b20431..7299823c81be 100644 --- a/test/Modules/Inputs/Module.framework/Headers/Module.h +++ b/test/Modules/Inputs/Module.framework/Headers/Module.h @@ -25,4 +25,13 @@ const char *getModuleVersion(void); __asm("foo"); +typedef struct __sFILE { + int _offset; +} FILE; + +extern FILE *myFile; + +#define SOME_MACRO_ATTR_GETTING_UNDEFINED __attribute__((objc_method_family(none))) +#undef SOME_MACRO_ATTR_GETTING_UNDEFINED + #endif // MODULE_H diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h index 9dabfc089a15..aa47ef47c484 100644 --- a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h +++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h @@ -1 +1,2 @@ +@import Module; // Don't cause redefinition error. void will_be_found2(void); diff --git a/test/Modules/Inputs/PR21687/a.h b/test/Modules/Inputs/PR21687/a.h new file mode 100644 index 000000000000..023606eb35a7 --- /dev/null +++ b/test/Modules/Inputs/PR21687/a.h @@ -0,0 +1 @@ +struct X { X(); virtual ~X(); }; diff --git a/test/Modules/Inputs/PR21687/b.h b/test/Modules/Inputs/PR21687/b.h new file mode 100644 index 000000000000..7085b1f67391 --- /dev/null +++ b/test/Modules/Inputs/PR21687/b.h @@ -0,0 +1,2 @@ +#include "a.h" +X *n = new X; diff --git a/test/Modules/Inputs/PR21687/c.h b/test/Modules/Inputs/PR21687/c.h new file mode 100644 index 000000000000..5c5d555a3f07 --- /dev/null +++ b/test/Modules/Inputs/PR21687/c.h @@ -0,0 +1,4 @@ +#include "a.h" +inline void f() { X x, y(x); } +#include "b.h" +X x, y(x); diff --git a/test/Modules/Inputs/PR21687/module.modulemap b/test/Modules/Inputs/PR21687/module.modulemap new file mode 100644 index 000000000000..77e0a89e39a0 --- /dev/null +++ b/test/Modules/Inputs/PR21687/module.modulemap @@ -0,0 +1,3 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } +module c { header "c.h" export * } diff --git a/test/Modules/Inputs/anon-namespace/a.h b/test/Modules/Inputs/anon-namespace/a.h new file mode 100644 index 000000000000..fe71f4004e4a --- /dev/null +++ b/test/Modules/Inputs/anon-namespace/a.h @@ -0,0 +1 @@ +namespace N {} diff --git a/test/Modules/Inputs/anon-namespace/b1.h b/test/Modules/Inputs/anon-namespace/b1.h new file mode 100644 index 000000000000..480e8e46a95e --- /dev/null +++ b/test/Modules/Inputs/anon-namespace/b1.h @@ -0,0 +1,2 @@ +namespace N {} +namespace N { namespace {} } diff --git a/test/Modules/Inputs/anon-namespace/b2.h b/test/Modules/Inputs/anon-namespace/b2.h new file mode 100644 index 000000000000..8e7535f3626d --- /dev/null +++ b/test/Modules/Inputs/anon-namespace/b2.h @@ -0,0 +1,2 @@ +#include "a.h" +namespace N {} diff --git a/test/Modules/Inputs/anon-namespace/c.h b/test/Modules/Inputs/anon-namespace/c.h new file mode 100644 index 000000000000..fe71f4004e4a --- /dev/null +++ b/test/Modules/Inputs/anon-namespace/c.h @@ -0,0 +1 @@ +namespace N {} diff --git a/test/Modules/Inputs/anon-namespace/module.modulemap b/test/Modules/Inputs/anon-namespace/module.modulemap new file mode 100644 index 000000000000..3d390d2d4e71 --- /dev/null +++ b/test/Modules/Inputs/anon-namespace/module.modulemap @@ -0,0 +1,3 @@ +module a { header "a.h" export * } +module b { module b1 { header "b1.h" export * } module b2 { header "b2.h" export * } } +module c { header "c.h" export * } diff --git a/test/Modules/Inputs/cxx-decls-imported.h b/test/Modules/Inputs/cxx-decls-imported.h index 8c1e74f17c3c..a4910fee753e 100644 --- a/test/Modules/Inputs/cxx-decls-imported.h +++ b/test/Modules/Inputs/cxx-decls-imported.h @@ -47,3 +47,6 @@ typedef decltype(name_for_linkage2_inner_a) NameForLinkage2Inner; namespace Aliased { extern int a; } namespace Alias = Aliased; + +struct InhCtorA { InhCtorA(int); }; +struct InhCtorB : InhCtorA { using InhCtorA::InhCtorA; }; diff --git a/test/Modules/Inputs/cxx-decls-merged.h b/test/Modules/Inputs/cxx-decls-merged.h index 86e81a9bb681..5eefb44992f2 100644 --- a/test/Modules/Inputs/cxx-decls-merged.h +++ b/test/Modules/Inputs/cxx-decls-merged.h @@ -25,3 +25,6 @@ typedef decltype(name_for_linkage2_inner_b) NameForLinkage2Inner; namespace Aliased { extern int b; } namespace Alias = Aliased; + +struct InhCtorA { InhCtorA(int); }; +struct InhCtorB : InhCtorA { using InhCtorA::InhCtorA; }; diff --git a/test/Modules/Inputs/cxx-dtor/a.h b/test/Modules/Inputs/cxx-dtor/a.h new file mode 100644 index 000000000000..023606eb35a7 --- /dev/null +++ b/test/Modules/Inputs/cxx-dtor/a.h @@ -0,0 +1 @@ +struct X { X(); virtual ~X(); }; diff --git a/test/Modules/Inputs/cxx-dtor/b.h b/test/Modules/Inputs/cxx-dtor/b.h new file mode 100644 index 000000000000..75958564cc9c --- /dev/null +++ b/test/Modules/Inputs/cxx-dtor/b.h @@ -0,0 +1,3 @@ +struct X { X(); virtual ~X(); }; +inline X::~X() {} +#include "a.h" diff --git a/test/Modules/Inputs/cxx-dtor/module.modulemap b/test/Modules/Inputs/cxx-dtor/module.modulemap new file mode 100644 index 000000000000..61578a1865aa --- /dev/null +++ b/test/Modules/Inputs/cxx-dtor/module.modulemap @@ -0,0 +1,2 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } diff --git a/test/Modules/Inputs/cxx-lookup/module.modulemap b/test/Modules/Inputs/cxx-lookup/module.modulemap index 6d397af250c8..385c8c9b6f82 100644 --- a/test/Modules/Inputs/cxx-lookup/module.modulemap +++ b/test/Modules/Inputs/cxx-lookup/module.modulemap @@ -6,3 +6,5 @@ module C { } module X { header "x.h" export * } module Y { header "y.h" export * } +module na { header "na.h" export * } +module nb { header "nb.h" export * } diff --git a/test/Modules/Inputs/cxx-lookup/na.h b/test/Modules/Inputs/cxx-lookup/na.h new file mode 100644 index 000000000000..684d37e8a08a --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/na.h @@ -0,0 +1 @@ +namespace N { struct S { friend struct foo; }; } diff --git a/test/Modules/Inputs/cxx-lookup/nb.h b/test/Modules/Inputs/cxx-lookup/nb.h new file mode 100644 index 000000000000..092c882c64d8 --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/nb.h @@ -0,0 +1 @@ +namespace N { extern int n; } diff --git a/test/Modules/Inputs/declare-use/module.map b/test/Modules/Inputs/declare-use/module.map index ae8615278aca..2dad0d061cfe 100644 --- a/test/Modules/Inputs/declare-use/module.map +++ b/test/Modules/Inputs/declare-use/module.map @@ -3,7 +3,7 @@ module XA { } module XB { - header "b.h" + module B { header "b.h" } } module XC { @@ -39,10 +39,11 @@ module XG { use XE use XJ use XK + use XN } module XH { - header "h.h" + module H { header "h.h" } header "h1.h" header "s.h" use XC @@ -66,5 +67,11 @@ module XM { textual header "m2.h" } +module XN { + module sub { + header "sub.h" + } +} + module XS { } diff --git a/test/Modules/Inputs/declare-use/sub.h b/test/Modules/Inputs/declare-use/sub.h new file mode 100644 index 000000000000..63d4234ce707 --- /dev/null +++ b/test/Modules/Inputs/declare-use/sub.h @@ -0,0 +1,4 @@ +#ifndef SUB_H +#define SUB_H +const int sub = 42; +#endif diff --git a/test/Modules/Inputs/deferred-lookup/a.h b/test/Modules/Inputs/deferred-lookup/a.h new file mode 100644 index 000000000000..751aae014961 --- /dev/null +++ b/test/Modules/Inputs/deferred-lookup/a.h @@ -0,0 +1 @@ +namespace N { int f(int); } diff --git a/test/Modules/Inputs/deferred-lookup/b.h b/test/Modules/Inputs/deferred-lookup/b.h new file mode 100644 index 000000000000..23925e2e93ce --- /dev/null +++ b/test/Modules/Inputs/deferred-lookup/b.h @@ -0,0 +1,6 @@ +namespace N { template<typename T> struct A { friend int f(A); }; } +namespace N { int f(int); } +namespace N { int f(int); } +#include "a.h" +namespace N { int f(int); } +inline int g() { return f(N::A<int>()); } diff --git a/test/Modules/Inputs/deferred-lookup/module.modulemap b/test/Modules/Inputs/deferred-lookup/module.modulemap new file mode 100644 index 000000000000..61578a1865aa --- /dev/null +++ b/test/Modules/Inputs/deferred-lookup/module.modulemap @@ -0,0 +1,2 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } diff --git a/test/Modules/Inputs/diagnostics-aux.modulemap b/test/Modules/Inputs/diagnostics-aux.modulemap new file mode 100644 index 000000000000..d067d04d3d6a --- /dev/null +++ b/test/Modules/Inputs/diagnostics-aux.modulemap @@ -0,0 +1 @@ +module foo {} diff --git a/test/Modules/macro-reexport/a2.h b/test/Modules/Inputs/empty.h index e69de29bb2d1..e69de29bb2d1 100644 --- a/test/Modules/macro-reexport/a2.h +++ b/test/Modules/Inputs/empty.h diff --git a/test/Modules/Inputs/empty/empty.h b/test/Modules/Inputs/empty/empty.h new file mode 100644 index 000000000000..e26b0ab556c1 --- /dev/null +++ b/test/Modules/Inputs/empty/empty.h @@ -0,0 +1 @@ +// This file intentionally left empty. diff --git a/test/Modules/macro-reexport/b1.h b/test/Modules/Inputs/explicit-build/d.h index e69de29bb2d1..e69de29bb2d1 100644 --- a/test/Modules/macro-reexport/b1.h +++ b/test/Modules/Inputs/explicit-build/d.h diff --git a/test/Modules/Inputs/explicit-build/module.modulemap b/test/Modules/Inputs/explicit-build/module.modulemap index bd6ea830c2d4..992eed683580 100644 --- a/test/Modules/Inputs/explicit-build/module.modulemap +++ b/test/Modules/Inputs/explicit-build/module.modulemap @@ -1,3 +1,4 @@ module a { header "a.h" } module b { header "b.h" export * } module c { header "c.h" export * } +module d { header "d.h" } diff --git a/test/Modules/Inputs/header-in-multiple-maps/a.h b/test/Modules/Inputs/header-in-multiple-maps/a.h new file mode 100644 index 000000000000..4c5cd949f234 --- /dev/null +++ b/test/Modules/Inputs/header-in-multiple-maps/a.h @@ -0,0 +1 @@ +struct A {}; diff --git a/test/Modules/Inputs/header-in-multiple-maps/map1 b/test/Modules/Inputs/header-in-multiple-maps/map1 new file mode 100644 index 000000000000..ba9baac00ca5 --- /dev/null +++ b/test/Modules/Inputs/header-in-multiple-maps/map1 @@ -0,0 +1,3 @@ +module a { header "a.h" } +module b { header "a.h" } +module c { textual header "a.h" } diff --git a/test/Modules/Inputs/header-in-multiple-maps/map2 b/test/Modules/Inputs/header-in-multiple-maps/map2 new file mode 100644 index 000000000000..67e0df3b55f5 --- /dev/null +++ b/test/Modules/Inputs/header-in-multiple-maps/map2 @@ -0,0 +1,3 @@ +module a { textual header "a.h" } +module b { header "a.h" } +module c { header "a.h" } diff --git a/test/Modules/Inputs/header-in-multiple-maps/map3 b/test/Modules/Inputs/header-in-multiple-maps/map3 new file mode 100644 index 000000000000..c859fd74b5d2 --- /dev/null +++ b/test/Modules/Inputs/header-in-multiple-maps/map3 @@ -0,0 +1,3 @@ +module a { header "a.h" } +module b { textual header "a.h" } +module c { header "a.h" } diff --git a/test/Modules/Inputs/initializer_list b/test/Modules/Inputs/initializer_list/direct.h index 6058f803a3dd..6058f803a3dd 100644 --- a/test/Modules/Inputs/initializer_list +++ b/test/Modules/Inputs/initializer_list/direct.h diff --git a/test/Modules/Inputs/initializer_list/direct.modulemap b/test/Modules/Inputs/initializer_list/direct.modulemap new file mode 100644 index 000000000000..56a410002012 --- /dev/null +++ b/test/Modules/Inputs/initializer_list/direct.modulemap @@ -0,0 +1 @@ +module initializer_list { header "direct.h" } diff --git a/test/Modules/Inputs/initializer_list/indirect.h b/test/Modules/Inputs/initializer_list/indirect.h new file mode 100644 index 000000000000..75e9817dce37 --- /dev/null +++ b/test/Modules/Inputs/initializer_list/indirect.h @@ -0,0 +1 @@ +#include "direct.h" diff --git a/test/Modules/Inputs/initializer_list/indirect.modulemap b/test/Modules/Inputs/initializer_list/indirect.modulemap new file mode 100644 index 000000000000..14deacfddfe1 --- /dev/null +++ b/test/Modules/Inputs/initializer_list/indirect.modulemap @@ -0,0 +1 @@ +module initializer_list { header "indirect.h" } diff --git a/test/Modules/Inputs/invalidate-identifiers/a.h b/test/Modules/Inputs/invalidate-identifiers/a.h new file mode 100644 index 000000000000..16fe9edcf4d7 --- /dev/null +++ b/test/Modules/Inputs/invalidate-identifiers/a.h @@ -0,0 +1,17 @@ +// Ensure that loading 'i' introduces enough identifiers to cause the +// identifier table to be reallocated. +#define TYPEDEFS(x) typedef x##0 x; typedef x##1 x; +#define DEPTH_0(x) DEPTH_1(x##0) DEPTH_1(x##1) TYPEDEFS(x) +#define DEPTH_1(x) DEPTH_2(x##0) DEPTH_2(x##1) TYPEDEFS(x) +#define DEPTH_2(x) DEPTH_3(x##0) DEPTH_3(x##1) TYPEDEFS(x) +#define DEPTH_3(x) DEPTH_4(x##0) DEPTH_4(x##1) TYPEDEFS(x) +#define DEPTH_4(x) DEPTH_5(x##0) DEPTH_5(x##1) TYPEDEFS(x) +#define DEPTH_5(x) DEPTH_6(x##0) DEPTH_6(x##1) TYPEDEFS(x) +#define DEPTH_6(x) DEPTH_7(x##0) DEPTH_7(x##1) TYPEDEFS(x) +#define DEPTH_7(x) DEPTH_8(x##0) DEPTH_8(x##1) TYPEDEFS(x) +#define DEPTH_8(x) DEPTH_9(x##0) DEPTH_9(x##1) TYPEDEFS(x) +#define DEPTH_9(x) DEPTH_A(x##0) DEPTH_A(x##1) TYPEDEFS(x) +#define DEPTH_A(x) DEPTH_B(x##0) DEPTH_B(x##1) TYPEDEFS(x) +#define DEPTH_B(x) typedef int x; +DEPTH_0(i) +extern i v; diff --git a/test/Modules/Inputs/invalidate-identifiers/b.h b/test/Modules/Inputs/invalidate-identifiers/b.h new file mode 100644 index 000000000000..2af246dc7749 --- /dev/null +++ b/test/Modules/Inputs/invalidate-identifiers/b.h @@ -0,0 +1,2 @@ +extern int v; +#include "a.h" diff --git a/test/Modules/redecls/module.map b/test/Modules/Inputs/invalidate-identifiers/module.modulemap index a36568207b68..a36568207b68 100644 --- a/test/Modules/redecls/module.map +++ b/test/Modules/Inputs/invalidate-identifiers/module.modulemap diff --git a/test/Modules/Inputs/macro-ambiguity/a/quote/a_quote.h b/test/Modules/Inputs/macro-ambiguity/a/quote/a_quote.h new file mode 100644 index 000000000000..efe6fa195230 --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/a/quote/a_quote.h @@ -0,0 +1,8 @@ +#ifndef A_QUOTE_H +#define A_QUOTE_H + +#define FOO1_QUOTE(x) x + x +#define BAR1_QUOTE(x) x + x +#define BAZ1_QUOTE(x) x + x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/a/system/a_system.h b/test/Modules/Inputs/macro-ambiguity/a/system/a_system.h new file mode 100644 index 000000000000..f9f32879ae91 --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/a/system/a_system.h @@ -0,0 +1,15 @@ +#ifndef A_SYSTEM_H +#define A_SYSTEM_H + +// FIXME: We have to use this to mark the header as a system header in +// a module because header search didn't actually occur and so we can't have +// found the header via system header search, even though when we map to this +// header and load the module we will have mapped to the header by finding it +// via system header search. +#pragma GCC system_header + +#define FOO1_SYSTEM(x) x + x +#define BAR1_SYSTEM(x) x + x +#define BAZ1_SYSTEM(x) x + x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/b/quote/b_quote.h b/test/Modules/Inputs/macro-ambiguity/b/quote/b_quote.h new file mode 100644 index 000000000000..f5e990f1464d --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/b/quote/b_quote.h @@ -0,0 +1,8 @@ +#ifndef B_QUOTE_H +#define B_QUOTE_H + +#define FOO2_QUOTE(x) x + x +#define BAR2_QUOTE(x) x + x +#define BAZ2_QUOTE(x) x + x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/b/system/b_system.h b/test/Modules/Inputs/macro-ambiguity/b/system/b_system.h new file mode 100644 index 000000000000..5b55303265e5 --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/b/system/b_system.h @@ -0,0 +1,15 @@ +#ifndef B_SYSTEM_H +#define B_SYSTEM_H + +// FIXME: We have to use this to mark the header as a system header in +// a module because header search didn't actually occur and so we can't have +// found the header via system header search, even though when we map to this +// header and load the module we will have mapped to the header by finding it +// via system header search. +#pragma GCC system_header + +#define FOO2_SYSTEM(x) x + x +#define BAR2_SYSTEM(x) x + x +#define BAZ2_SYSTEM(x) x + x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/c/quote/c_quote.h b/test/Modules/Inputs/macro-ambiguity/c/quote/c_quote.h new file mode 100644 index 000000000000..131430026f8c --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/c/quote/c_quote.h @@ -0,0 +1,7 @@ +#ifndef C_QUOTE_H +#define C_QUOTE_H + +#define FOO1_QUOTE(x) 2 * x +#define FOO2_QUOTE(x) 2 * x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/c/system/c_system.h b/test/Modules/Inputs/macro-ambiguity/c/system/c_system.h new file mode 100644 index 000000000000..25e795d71da0 --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/c/system/c_system.h @@ -0,0 +1,14 @@ +#ifndef C_SYSTEM_H +#define C_SYSTEM_H + +// FIXME: We have to use this to mark the header as a system header in +// a module because header search didn't actually occur and so we can't have +// found the header via system header search, even though when we map to this +// header and load the module we will have mapped to the header by finding it +// via system header search. +#pragma GCC system_header + +#define FOO1_SYSTEM(x) 2 * x +#define FOO2_SYSTEM(x) 2 * x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/d/quote/d_quote.h b/test/Modules/Inputs/macro-ambiguity/d/quote/d_quote.h new file mode 100644 index 000000000000..ac9d43b9efea --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/d/quote/d_quote.h @@ -0,0 +1,7 @@ +#ifndef D_QUOTE_H +#define D_QUOTE_H + +#define BAR1_QUOTE(x) 2 * x +#define BAR2_QUOTE(x) 2 * x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/d/system/d_system.h b/test/Modules/Inputs/macro-ambiguity/d/system/d_system.h new file mode 100644 index 000000000000..5c10cc14e889 --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/d/system/d_system.h @@ -0,0 +1,14 @@ +#ifndef D_SYSTEM_H +#define D_SYSTEM_H + +// FIXME: We have to use this to mark the header as a system header in +// a module because header search didn't actually occur and so we can't have +// found the header via system header search, even though when we map to this +// header and load the module we will have mapped to the header by finding it +// via system header search. +#pragma GCC system_header + +#define BAR1_SYSTEM(x) 2 * x +#define BAR2_SYSTEM(x) 2 * x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/e/quote/e_quote.h b/test/Modules/Inputs/macro-ambiguity/e/quote/e_quote.h new file mode 100644 index 000000000000..78494299a944 --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/e/quote/e_quote.h @@ -0,0 +1,7 @@ +#ifndef E_QUOTE_H +#define E_QUOTE_H + +#define BAZ1_QUOTE(x) 2 * x +#define BAZ2_QUOTE(x) 2 * x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/e/system/e_system.h b/test/Modules/Inputs/macro-ambiguity/e/system/e_system.h new file mode 100644 index 000000000000..c9e13419edc5 --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/e/system/e_system.h @@ -0,0 +1,7 @@ +#ifndef E_SYSTEM_H +#define E_SYSTEM_H + +#define BAZ1_SYSTEM(x) 2 * x +#define BAZ2_SYSTEM(x) 2 * x + +#endif diff --git a/test/Modules/Inputs/macro-ambiguity/module.modulemap b/test/Modules/Inputs/macro-ambiguity/module.modulemap new file mode 100644 index 000000000000..23da294c745f --- /dev/null +++ b/test/Modules/Inputs/macro-ambiguity/module.modulemap @@ -0,0 +1,25 @@ +module a { + header "Inputs/macro-ambiguity/a/quote/a_quote.h" + header "Inputs/macro-ambiguity/a/system/a_system.h" + export * +} +module b [system] { + header "Inputs/macro-ambiguity/b/quote/b_quote.h" + header "Inputs/macro-ambiguity/b/system/b_system.h" + export * +} +module c { + header "Inputs/macro-ambiguity/c/quote/c_quote.h" + header "Inputs/macro-ambiguity/c/system/c_system.h" + export * +} +module d [system] { + header "Inputs/macro-ambiguity/d/quote/d_quote.h" + header "Inputs/macro-ambiguity/d/system/d_system.h" + export * +} +module e { + textual header "Inputs/macro-ambiguity/e/quote/e_quote.h" + textual header "Inputs/macro-ambiguity/e/system/e_system.h" + export * +} diff --git a/test/Modules/Inputs/macro-masking/a.h b/test/Modules/Inputs/macro-masking/a.h new file mode 100644 index 000000000000..dbc17b8cbcf6 --- /dev/null +++ b/test/Modules/Inputs/macro-masking/a.h @@ -0,0 +1,2 @@ +#define MACRO +#include "b.h" diff --git a/test/Modules/Inputs/macro-masking/b.h b/test/Modules/Inputs/macro-masking/b.h new file mode 100644 index 000000000000..0d14daf13af3 --- /dev/null +++ b/test/Modules/Inputs/macro-masking/b.h @@ -0,0 +1 @@ +#undef MACRO diff --git a/test/Modules/Inputs/macro-masking/module.modulemap b/test/Modules/Inputs/macro-masking/module.modulemap new file mode 100644 index 000000000000..63e1014dda80 --- /dev/null +++ b/test/Modules/Inputs/macro-masking/module.modulemap @@ -0,0 +1,4 @@ +module X { + module A { header "a.h" export * } + module B { header "b.h" export * } +} diff --git a/test/Modules/macro-reexport/a1.h b/test/Modules/Inputs/macro-reexport/a1.h index 39933315f7ee..39933315f7ee 100644 --- a/test/Modules/macro-reexport/a1.h +++ b/test/Modules/Inputs/macro-reexport/a1.h diff --git a/test/Modules/Inputs/macro-reexport/a2.h b/test/Modules/Inputs/macro-reexport/a2.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Modules/Inputs/macro-reexport/a2.h diff --git a/test/Modules/Inputs/macro-reexport/b1.h b/test/Modules/Inputs/macro-reexport/b1.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Modules/Inputs/macro-reexport/b1.h diff --git a/test/Modules/macro-reexport/b2.h b/test/Modules/Inputs/macro-reexport/b2.h index 26150458d353..26150458d353 100644 --- a/test/Modules/macro-reexport/b2.h +++ b/test/Modules/Inputs/macro-reexport/b2.h diff --git a/test/Modules/macro-reexport/c1.h b/test/Modules/Inputs/macro-reexport/c1.h index b63c278577f6..b63c278577f6 100644 --- a/test/Modules/macro-reexport/c1.h +++ b/test/Modules/Inputs/macro-reexport/c1.h diff --git a/test/Modules/macro-reexport/d1.h b/test/Modules/Inputs/macro-reexport/d1.h index 99abd2481597..99abd2481597 100644 --- a/test/Modules/macro-reexport/d1.h +++ b/test/Modules/Inputs/macro-reexport/d1.h diff --git a/test/Modules/macro-reexport/d2.h b/test/Modules/Inputs/macro-reexport/d2.h index 688f2d98a13b..688f2d98a13b 100644 --- a/test/Modules/macro-reexport/d2.h +++ b/test/Modules/Inputs/macro-reexport/d2.h diff --git a/test/Modules/macro-reexport/e1.h b/test/Modules/Inputs/macro-reexport/e1.h index 6c6829df3654..6c6829df3654 100644 --- a/test/Modules/macro-reexport/e1.h +++ b/test/Modules/Inputs/macro-reexport/e1.h diff --git a/test/Modules/macro-reexport/e2.h b/test/Modules/Inputs/macro-reexport/e2.h index 7bc0b4972d2c..7bc0b4972d2c 100644 --- a/test/Modules/macro-reexport/e2.h +++ b/test/Modules/Inputs/macro-reexport/e2.h diff --git a/test/Modules/macro-reexport/f1.h b/test/Modules/Inputs/macro-reexport/f1.h index f8f6502a90c6..f8f6502a90c6 100644 --- a/test/Modules/macro-reexport/f1.h +++ b/test/Modules/Inputs/macro-reexport/f1.h diff --git a/test/Modules/macro-reexport/module.modulemap b/test/Modules/Inputs/macro-reexport/module.modulemap index 896bda041c30..896bda041c30 100644 --- a/test/Modules/macro-reexport/module.modulemap +++ b/test/Modules/Inputs/macro-reexport/module.modulemap diff --git a/test/Modules/Inputs/macros-indirect.h b/test/Modules/Inputs/macros-indirect.h new file mode 100644 index 000000000000..c90300e464fb --- /dev/null +++ b/test/Modules/Inputs/macros-indirect.h @@ -0,0 +1 @@ +#define INDIRECTLY_IN_MACROS 1 diff --git a/test/Modules/Inputs/macros.h b/test/Modules/Inputs/macros.h index 27f43c0626ec..a0ae7a315822 100644 --- a/test/Modules/Inputs/macros.h +++ b/test/Modules/Inputs/macros.h @@ -17,3 +17,4 @@ int (INTEGER); extern int __MODULE__; #endif +#include "macros-indirect.h" diff --git a/test/Modules/Inputs/merge-anon-in-template/a.h b/test/Modules/Inputs/merge-anon-in-template/a.h new file mode 100644 index 000000000000..82540e397bf3 --- /dev/null +++ b/test/Modules/Inputs/merge-anon-in-template/a.h @@ -0,0 +1,4 @@ +template<typename T> struct is_floating { + enum { value = 0 }; + typedef int type; +}; diff --git a/test/Modules/Inputs/merge-anon-in-template/b.h b/test/Modules/Inputs/merge-anon-in-template/b.h new file mode 100644 index 000000000000..87c053d962d4 --- /dev/null +++ b/test/Modules/Inputs/merge-anon-in-template/b.h @@ -0,0 +1,2 @@ +#include "a.h" +bool k = is_floating<int>::value; diff --git a/test/Modules/Inputs/merge-anon-in-template/c.h b/test/Modules/Inputs/merge-anon-in-template/c.h new file mode 100644 index 000000000000..e0b9b0a3317c --- /dev/null +++ b/test/Modules/Inputs/merge-anon-in-template/c.h @@ -0,0 +1,6 @@ +template<typename T> struct is_floating { + enum { value = 0 }; + typedef int type; +}; +#include "b.h" +bool n20 = is_floating<int>::value; diff --git a/test/Modules/Inputs/merge-anon-in-template/module.modulemap b/test/Modules/Inputs/merge-anon-in-template/module.modulemap new file mode 100644 index 000000000000..77e0a89e39a0 --- /dev/null +++ b/test/Modules/Inputs/merge-anon-in-template/module.modulemap @@ -0,0 +1,3 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } +module c { header "c.h" export * } diff --git a/test/Modules/Inputs/merge-decl-context/a.h b/test/Modules/Inputs/merge-decl-context/a.h new file mode 100644 index 000000000000..89cc7120fd17 --- /dev/null +++ b/test/Modules/Inputs/merge-decl-context/a.h @@ -0,0 +1,24 @@ +#ifndef A_H +#define A_H + +template <typename T> +struct A { + template <typename I> + A(I i1, I i2) { + } + A(double) {} + A(double, double) {} + A(double, int) {} + A(int, double) {} +}; + +template <typename T1, typename T2> +T1 fff(T2* t) { + return T1(t, t); +} + +inline A<int> ff(int i) { + return fff<A<int>>(&i); +} + +#endif diff --git a/test/Modules/Inputs/merge-decl-context/b.h b/test/Modules/Inputs/merge-decl-context/b.h new file mode 100644 index 000000000000..cb06ac8e27c9 --- /dev/null +++ b/test/Modules/Inputs/merge-decl-context/b.h @@ -0,0 +1,6 @@ +#ifndef B_H +#define B_H + +#include "a.h" + +#endif diff --git a/test/Modules/Inputs/merge-decl-context/c.h b/test/Modules/Inputs/merge-decl-context/c.h new file mode 100644 index 000000000000..af3a723969be --- /dev/null +++ b/test/Modules/Inputs/merge-decl-context/c.h @@ -0,0 +1,7 @@ +#ifndef C_H +#define C_H + +#include "a.h" +#include "b.h" + +#endif diff --git a/test/Modules/Inputs/merge-decl-context/d.h b/test/Modules/Inputs/merge-decl-context/d.h new file mode 100644 index 000000000000..ccc7308b2499 --- /dev/null +++ b/test/Modules/Inputs/merge-decl-context/d.h @@ -0,0 +1,7 @@ +#ifndef D_H +#define D_H + +#include "a.h" +#include "b.h" + +#endif diff --git a/test/Modules/Inputs/merge-decl-context/merge-decl-context.modulemap b/test/Modules/Inputs/merge-decl-context/merge-decl-context.modulemap new file mode 100644 index 000000000000..46f69548bc67 --- /dev/null +++ b/test/Modules/Inputs/merge-decl-context/merge-decl-context.modulemap @@ -0,0 +1,18 @@ +module "a" { + textual header "a.h" +} + +module "b" { + export * + header "b.h" +} + +module "c" { + export * + header "c.h" +} + +module "d" { + export * + header "d.h" +} diff --git a/test/Modules/Inputs/merge-decl-order/a.h b/test/Modules/Inputs/merge-decl-order/a.h new file mode 100644 index 000000000000..f505a424c7e6 --- /dev/null +++ b/test/Modules/Inputs/merge-decl-order/a.h @@ -0,0 +1,2 @@ +namespace N { struct SA { friend struct foo; }; } +namespace N { struct foo; } diff --git a/test/Modules/Inputs/merge-decl-order/b.h b/test/Modules/Inputs/merge-decl-order/b.h new file mode 100644 index 000000000000..49b06cafd05e --- /dev/null +++ b/test/Modules/Inputs/merge-decl-order/b.h @@ -0,0 +1,2 @@ +namespace N { struct SB { friend struct foo; }; } +#include "a.h" diff --git a/test/Modules/Inputs/merge-decl-order/module.modulemap b/test/Modules/Inputs/merge-decl-order/module.modulemap new file mode 100644 index 000000000000..61578a1865aa --- /dev/null +++ b/test/Modules/Inputs/merge-decl-order/module.modulemap @@ -0,0 +1,2 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } diff --git a/test/Modules/Inputs/merge-dependent-friends/a.h b/test/Modules/Inputs/merge-dependent-friends/a.h new file mode 100644 index 000000000000..44b1c1db5688 --- /dev/null +++ b/test/Modules/Inputs/merge-dependent-friends/a.h @@ -0,0 +1,2 @@ +namespace N { template<typename T> struct A { friend int f(A); }; } +int a = f(N::A<int>()); diff --git a/test/Modules/Inputs/merge-dependent-friends/b.h b/test/Modules/Inputs/merge-dependent-friends/b.h new file mode 100644 index 000000000000..bce33876d54d --- /dev/null +++ b/test/Modules/Inputs/merge-dependent-friends/b.h @@ -0,0 +1,2 @@ +namespace N { template<typename T> struct A { friend int f(A); }; } +int b = f(N::A<int>()); diff --git a/test/Modules/Inputs/merge-dependent-friends/c.h b/test/Modules/Inputs/merge-dependent-friends/c.h new file mode 100644 index 000000000000..3620ce3d539f --- /dev/null +++ b/test/Modules/Inputs/merge-dependent-friends/c.h @@ -0,0 +1,6 @@ +namespace N { template<typename T> struct A { friend int f(A); }; } +// It would seem like this variable should be called 'c'. +// But that makes the original problem disappear... +int e = f(N::A<int>()); +#include "a.h" +#include "b.h" diff --git a/test/Modules/Inputs/merge-dependent-friends/d.h b/test/Modules/Inputs/merge-dependent-friends/d.h new file mode 100644 index 000000000000..ce3f69fa387f --- /dev/null +++ b/test/Modules/Inputs/merge-dependent-friends/d.h @@ -0,0 +1,2 @@ +namespace N { template<typename T> struct A { friend int f(A); }; } +#include "c.h" diff --git a/test/Modules/Inputs/merge-dependent-friends/module.modulemap b/test/Modules/Inputs/merge-dependent-friends/module.modulemap new file mode 100644 index 000000000000..73a7c41ec589 --- /dev/null +++ b/test/Modules/Inputs/merge-dependent-friends/module.modulemap @@ -0,0 +1,4 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } +module c { header "c.h" export * } +module d { header "d.h" export * } diff --git a/test/Modules/Inputs/merge-friends/decl.h b/test/Modules/Inputs/merge-friends/decl.h new file mode 100644 index 000000000000..f658f94ff987 --- /dev/null +++ b/test/Modules/Inputs/merge-friends/decl.h @@ -0,0 +1 @@ +namespace N { struct foo; } diff --git a/test/Modules/Inputs/merge-friends/friend.h b/test/Modules/Inputs/merge-friends/friend.h new file mode 100644 index 000000000000..bbbd8edb3a4f --- /dev/null +++ b/test/Modules/Inputs/merge-friends/friend.h @@ -0,0 +1,2 @@ +namespace N { struct n8 { friend struct foo; }; } +#include "decl.h" diff --git a/test/Modules/Inputs/merge-friends/module.modulemap b/test/Modules/Inputs/merge-friends/module.modulemap new file mode 100644 index 000000000000..1fa52c91c8d4 --- /dev/null +++ b/test/Modules/Inputs/merge-friends/module.modulemap @@ -0,0 +1,2 @@ +module decl { header "decl.h" export * } +module friend { header "friend.h" export * } diff --git a/test/Modules/Inputs/merge-implicit-special-members/a.h b/test/Modules/Inputs/merge-implicit-special-members/a.h new file mode 100644 index 000000000000..3029e4afb85a --- /dev/null +++ b/test/Modules/Inputs/merge-implicit-special-members/a.h @@ -0,0 +1 @@ +struct pthread_mutex_t { int lock; }; diff --git a/test/Modules/Inputs/merge-implicit-special-members/b.h b/test/Modules/Inputs/merge-implicit-special-members/b.h new file mode 100644 index 000000000000..3029e4afb85a --- /dev/null +++ b/test/Modules/Inputs/merge-implicit-special-members/b.h @@ -0,0 +1 @@ +struct pthread_mutex_t { int lock; }; diff --git a/test/Modules/Inputs/merge-implicit-special-members/c.h b/test/Modules/Inputs/merge-implicit-special-members/c.h new file mode 100644 index 000000000000..ee0bebb2ee79 --- /dev/null +++ b/test/Modules/Inputs/merge-implicit-special-members/c.h @@ -0,0 +1,3 @@ +#include "a.h" +#include "b.h" +int k = pthread_mutex_t().lock; diff --git a/test/Modules/Inputs/merge-implicit-special-members/module.modulemap b/test/Modules/Inputs/merge-implicit-special-members/module.modulemap new file mode 100644 index 000000000000..77e0a89e39a0 --- /dev/null +++ b/test/Modules/Inputs/merge-implicit-special-members/module.modulemap @@ -0,0 +1,3 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } +module c { header "c.h" export * } diff --git a/test/Modules/Inputs/merge-name-for-linkage/a.h b/test/Modules/Inputs/merge-name-for-linkage/a.h new file mode 100644 index 000000000000..82f2fdd83e31 --- /dev/null +++ b/test/Modules/Inputs/merge-name-for-linkage/a.h @@ -0,0 +1 @@ +typedef union {} pthread_mutex_t; diff --git a/test/Modules/Inputs/merge-name-for-linkage/b.h b/test/Modules/Inputs/merge-name-for-linkage/b.h new file mode 100644 index 000000000000..82f2fdd83e31 --- /dev/null +++ b/test/Modules/Inputs/merge-name-for-linkage/b.h @@ -0,0 +1 @@ +typedef union {} pthread_mutex_t; diff --git a/test/Modules/Inputs/merge-name-for-linkage/module.modulemap b/test/Modules/Inputs/merge-name-for-linkage/module.modulemap new file mode 100644 index 000000000000..61578a1865aa --- /dev/null +++ b/test/Modules/Inputs/merge-name-for-linkage/module.modulemap @@ -0,0 +1,2 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } diff --git a/test/Modules/Inputs/merge-nested-templates/a.h b/test/Modules/Inputs/merge-nested-templates/a.h new file mode 100644 index 000000000000..826d2571fd11 --- /dev/null +++ b/test/Modules/Inputs/merge-nested-templates/a.h @@ -0,0 +1 @@ +#include "string.ii" diff --git a/test/Modules/Inputs/merge-nested-templates/b.h b/test/Modules/Inputs/merge-nested-templates/b.h new file mode 100644 index 000000000000..516694e38e98 --- /dev/null +++ b/test/Modules/Inputs/merge-nested-templates/b.h @@ -0,0 +1,2 @@ +#include "a.h" +std::wstring::iterator j; diff --git a/test/Modules/Inputs/merge-nested-templates/c.h b/test/Modules/Inputs/merge-nested-templates/c.h new file mode 100644 index 000000000000..ab95e145ef52 --- /dev/null +++ b/test/Modules/Inputs/merge-nested-templates/c.h @@ -0,0 +1,3 @@ +#include "string.ii" +std::wstring::iterator i; +#include "b.h" diff --git a/test/Modules/Inputs/merge-nested-templates/module.modulemap b/test/Modules/Inputs/merge-nested-templates/module.modulemap new file mode 100644 index 000000000000..77e0a89e39a0 --- /dev/null +++ b/test/Modules/Inputs/merge-nested-templates/module.modulemap @@ -0,0 +1,3 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } +module c { header "c.h" export * } diff --git a/test/Modules/Inputs/merge-nested-templates/string.ii b/test/Modules/Inputs/merge-nested-templates/string.ii new file mode 100644 index 000000000000..136d8e70083d --- /dev/null +++ b/test/Modules/Inputs/merge-nested-templates/string.ii @@ -0,0 +1,14 @@ +namespace std { + template <typename, typename Container> struct normal_iterator { + normal_iterator() {} + + template <typename I> + normal_iterator(normal_iterator<I, typename Container::iterator>) {} + }; + + template <typename pointer> struct basic_string { + typedef normal_iterator<pointer, basic_string> iterator; + }; + + typedef basic_string<wchar_t *> wstring; +} diff --git a/test/Modules/Inputs/merge-target-features/foo.h b/test/Modules/Inputs/merge-target-features/foo.h new file mode 100644 index 000000000000..1c8b3f62826a --- /dev/null +++ b/test/Modules/Inputs/merge-target-features/foo.h @@ -0,0 +1,8 @@ +#ifndef FOO_H +#define FOO_H + +int foo(int x) { + return x + 42; +} + +#endif // FOO_H diff --git a/test/Modules/Inputs/merge-target-features/module.modulemap b/test/Modules/Inputs/merge-target-features/module.modulemap new file mode 100644 index 000000000000..f2e9932e4a4f --- /dev/null +++ b/test/Modules/Inputs/merge-target-features/module.modulemap @@ -0,0 +1 @@ +module foo { header "Inputs/merge-target-features/foo.h" export * } diff --git a/test/Modules/Inputs/merge-template-friend/def.h b/test/Modules/Inputs/merge-template-friend/def.h new file mode 100644 index 000000000000..c75f5f6867bb --- /dev/null +++ b/test/Modules/Inputs/merge-template-friend/def.h @@ -0,0 +1,3 @@ +namespace ns { +template <typename T> class C {}; +} diff --git a/test/Modules/Inputs/merge-template-friend/friend.h b/test/Modules/Inputs/merge-template-friend/friend.h new file mode 100644 index 000000000000..97fb758b437e --- /dev/null +++ b/test/Modules/Inputs/merge-template-friend/friend.h @@ -0,0 +1,4 @@ +namespace ns { template <typename T> class C; }; +class A { + template <typename T> friend class ::ns::C; +}; diff --git a/test/Modules/Inputs/merge-template-friend/module.modulemap b/test/Modules/Inputs/merge-template-friend/module.modulemap new file mode 100644 index 000000000000..7737ad9b0ca2 --- /dev/null +++ b/test/Modules/Inputs/merge-template-friend/module.modulemap @@ -0,0 +1,3 @@ +module a { header "friend.h" export * } +module b { header "def.h" export * } + diff --git a/test/Modules/Inputs/merge-template-members/a1.h b/test/Modules/Inputs/merge-template-members/a1.h new file mode 100644 index 000000000000..9212a3f0debc --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/a1.h @@ -0,0 +1,9 @@ +namespace N { + template <typename> struct A { + int n; + A() : n() {} + }; + + // Create declaration of A<int>. + typedef A<int> AI; +} diff --git a/test/Modules/Inputs/merge-template-members/a2.h b/test/Modules/Inputs/merge-template-members/a2.h new file mode 100644 index 000000000000..9212a3f0debc --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/a2.h @@ -0,0 +1,9 @@ +namespace N { + template <typename> struct A { + int n; + A() : n() {} + }; + + // Create declaration of A<int>. + typedef A<int> AI; +} diff --git a/test/Modules/Inputs/merge-template-members/b1.h b/test/Modules/Inputs/merge-template-members/b1.h new file mode 100644 index 000000000000..3828e267edde --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/b1.h @@ -0,0 +1,6 @@ +#include "a1.h" + +// Add update record for definition of A<int> and constructors. +// We need an eagerly-emitted use here to get the problematic +// deserialization ordering. +N::A<int> b1; diff --git a/test/Modules/Inputs/merge-template-members/b2.h b/test/Modules/Inputs/merge-template-members/b2.h new file mode 100644 index 000000000000..37357acc6adf --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/b2.h @@ -0,0 +1,6 @@ +#include "a2.h" + +// Add update record for definition of A<int> and constructors. +// We need an eagerly-emitted use here to get the problematic +// deserialization ordering. +N::A<int> b2; diff --git a/test/Modules/Inputs/merge-template-members/c.h b/test/Modules/Inputs/merge-template-members/c.h new file mode 100644 index 000000000000..92f20a0b1329 --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/c.h @@ -0,0 +1,14 @@ +namespace N { + template <typename> struct A { + int n; + A() : n() {} + }; + + // Trigger instantiation of definition of A<int>. + struct C { + A<int> a; + }; +} + +// Merge in another declaration and update records. +#include "b1.h" diff --git a/test/Modules/Inputs/merge-template-members/def.h b/test/Modules/Inputs/merge-template-members/def.h new file mode 100644 index 000000000000..f9f65c34db05 --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/def.h @@ -0,0 +1,2 @@ +template<typename> struct A { int n; }; +template<typename> struct B { typedef A<void> C; }; diff --git a/test/Modules/Inputs/merge-template-members/merge.h b/test/Modules/Inputs/merge-template-members/merge.h new file mode 100644 index 000000000000..72d2d3622e88 --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/merge.h @@ -0,0 +1,2 @@ +#include "b1.h" +#include "b2.h" diff --git a/test/Modules/Inputs/merge-template-members/module.modulemap b/test/Modules/Inputs/merge-template-members/module.modulemap new file mode 100644 index 000000000000..0d72e58fbf1b --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/module.modulemap @@ -0,0 +1,9 @@ +module def { header "def.h" export * } +module update { header "update.h" export * } + +module a1 { header "a1.h" export * } +module a2 { header "a2.h" export * } +module b1 { header "b1.h" export * } +module b2 { header "b2.h" export * } +module merge { header "merge.h" export * } +module c { header "c.h" export * } diff --git a/test/Modules/Inputs/merge-template-members/update.h b/test/Modules/Inputs/merge-template-members/update.h new file mode 100644 index 000000000000..cceb52db4039 --- /dev/null +++ b/test/Modules/Inputs/merge-template-members/update.h @@ -0,0 +1,2 @@ +#include "def.h" +B<int>::C use1; diff --git a/test/Modules/Inputs/merge-vtable-codegen/a.h b/test/Modules/Inputs/merge-vtable-codegen/a.h new file mode 100644 index 000000000000..c2885379aa41 --- /dev/null +++ b/test/Modules/Inputs/merge-vtable-codegen/a.h @@ -0,0 +1,8 @@ +#ifndef A_H +#define A_H + +struct A { + virtual void x(); +}; + +#endif diff --git a/test/Modules/Inputs/merge-vtable-codegen/b.h b/test/Modules/Inputs/merge-vtable-codegen/b.h new file mode 100644 index 000000000000..770e46077f93 --- /dev/null +++ b/test/Modules/Inputs/merge-vtable-codegen/b.h @@ -0,0 +1,17 @@ +#ifndef B_H +#define B_H + +#include "a.h" + +class B : virtual public A { + virtual void x() {} +}; + +void b(A* p) { + p->x(); + // Instantiating a class that virtually inherits 'A' + // triggers calculation of the vtable offsets in 'A'. + B b; +} + +#endif diff --git a/test/Modules/Inputs/merge-vtable-codegen/c.h b/test/Modules/Inputs/merge-vtable-codegen/c.h new file mode 100644 index 000000000000..40cbbb047cb4 --- /dev/null +++ b/test/Modules/Inputs/merge-vtable-codegen/c.h @@ -0,0 +1,6 @@ +#ifndef C_H +#define C_H + +#include "a.h" + +#endif diff --git a/test/Modules/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap b/test/Modules/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap new file mode 100644 index 000000000000..1edaa07101f9 --- /dev/null +++ b/test/Modules/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap @@ -0,0 +1,11 @@ +module "a" { + textual header "a.h" +} + +module "b" { + header "b.h" +} + +module "c" { + header "c.h" +} diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index 7040ee7e5ab6..8ec3e21121b7 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -296,10 +296,6 @@ module warn_unused_local_typedef { header "warn-unused-local-typedef.h" } -module initializer_list { - header "initializer_list" -} - module using_decl { module a { header "using-decl-a.h" export * } module b { header "using-decl-b.h" export * } diff --git a/test/Modules/Inputs/no-implicit-builds/b.h b/test/Modules/Inputs/no-implicit-builds/b.h new file mode 100644 index 000000000000..4fe1c76825cb --- /dev/null +++ b/test/Modules/Inputs/no-implicit-builds/b.h @@ -0,0 +1,6 @@ +#ifndef B_H +#define B_H + +int b; + +#endif diff --git a/test/Modules/Inputs/no-implicit-builds/b.modulemap b/test/Modules/Inputs/no-implicit-builds/b.modulemap new file mode 100644 index 000000000000..3c8ca540010c --- /dev/null +++ b/test/Modules/Inputs/no-implicit-builds/b.modulemap @@ -0,0 +1,3 @@ +module "b" { + header "b.h" +} diff --git a/test/Modules/Inputs/preprocess/file.h b/test/Modules/Inputs/preprocess/file.h new file mode 100644 index 000000000000..808ade5768b1 --- /dev/null +++ b/test/Modules/Inputs/preprocess/file.h @@ -0,0 +1,3 @@ +struct __FILE; +#include "fwd.h" +typedef struct __FILE FILE; diff --git a/test/Modules/Inputs/preprocess/fwd.h b/test/Modules/Inputs/preprocess/fwd.h new file mode 100644 index 000000000000..4a19c6d0c057 --- /dev/null +++ b/test/Modules/Inputs/preprocess/fwd.h @@ -0,0 +1 @@ +struct __FILE; diff --git a/test/Modules/Inputs/preprocess/module.modulemap b/test/Modules/Inputs/preprocess/module.modulemap new file mode 100644 index 000000000000..a5c5b61dddc5 --- /dev/null +++ b/test/Modules/Inputs/preprocess/module.modulemap @@ -0,0 +1,2 @@ +module fwd { header "fwd.h" export * } +module file { header "file.h" export * } diff --git a/test/Modules/Inputs/redecl-add-after-load-decls.h b/test/Modules/Inputs/redecl-add-after-load-decls.h index fbe6b9387a17..a4227971a876 100644 --- a/test/Modules/Inputs/redecl-add-after-load-decls.h +++ b/test/Modules/Inputs/redecl-add-after-load-decls.h @@ -16,9 +16,9 @@ typedef C::A CB; constexpr int C_test(bool b) { return b ? C::variable : C::function(); } struct D { - struct A; // expected-note {{forward}} + struct A; static const int variable; - static constexpr int function(); // expected-note {{here}} + static constexpr int function(); }; typedef D::A DB; -constexpr int D_test(bool b) { return b ? D::variable : D::function(); } // expected-note {{subexpression}} expected-note {{undefined}} +constexpr int D_test(bool b) { return b ? D::variable : D::function(); } diff --git a/test/Modules/Inputs/redecl-found-building-chains/a.h b/test/Modules/Inputs/redecl-found-building-chains/a.h new file mode 100644 index 000000000000..27f503c2c607 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/a.h @@ -0,0 +1 @@ +struct A; diff --git a/test/Modules/Inputs/redecl-found-building-chains/b.h b/test/Modules/Inputs/redecl-found-building-chains/b.h new file mode 100644 index 000000000000..f69dccb2a0f4 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/b.h @@ -0,0 +1,2 @@ +struct A; // ensure that loading b's canonical decl doesn't load the definition +struct A {}; diff --git a/test/Modules/Inputs/redecl-found-building-chains/c.h b/test/Modules/Inputs/redecl-found-building-chains/c.h new file mode 100644 index 000000000000..27f503c2c607 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/c.h @@ -0,0 +1 @@ +struct A; diff --git a/test/Modules/Inputs/redecl-found-building-chains/d.h b/test/Modules/Inputs/redecl-found-building-chains/d.h new file mode 100644 index 000000000000..0beef5a79da4 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/d.h @@ -0,0 +1,6 @@ +#include "a.h" // ensure that our canonical decl is not from b +struct A; +#include "b.h" +struct A; +#include "c.h" // ensure that our type for A doesn't reference the definition in b +struct A; diff --git a/test/Modules/Inputs/redecl-found-building-chains/module.modulemap b/test/Modules/Inputs/redecl-found-building-chains/module.modulemap new file mode 100644 index 000000000000..73a7c41ec589 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/module.modulemap @@ -0,0 +1,4 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } +module c { header "c.h" export * } +module d { header "d.h" export * } diff --git a/test/Modules/Inputs/redecl-templates/a.h b/test/Modules/Inputs/redecl-templates/a.h new file mode 100644 index 000000000000..fd25fcf0768d --- /dev/null +++ b/test/Modules/Inputs/redecl-templates/a.h @@ -0,0 +1,8 @@ +template<int N> struct A; +template<> struct A<1>; + +template<int N> constexpr void f(); +template<> constexpr void f<1>(); + +template<int N> extern int v; +template<> extern int v<1>; diff --git a/test/Modules/Inputs/redecl-templates/module.modulemap b/test/Modules/Inputs/redecl-templates/module.modulemap new file mode 100644 index 000000000000..648035898f9c --- /dev/null +++ b/test/Modules/Inputs/redecl-templates/module.modulemap @@ -0,0 +1 @@ +module A { header "a.h" } diff --git a/test/Modules/redecls/a.h b/test/Modules/Inputs/redecls/a.h index 1647f86606a8..1647f86606a8 100644 --- a/test/Modules/redecls/a.h +++ b/test/Modules/Inputs/redecls/a.h diff --git a/test/Modules/redecls/b.h b/test/Modules/Inputs/redecls/b.h index d41573ddc78a..d41573ddc78a 100644 --- a/test/Modules/redecls/b.h +++ b/test/Modules/Inputs/redecls/b.h diff --git a/test/Modules/Inputs/redecls/module.map b/test/Modules/Inputs/redecls/module.map new file mode 100644 index 000000000000..a36568207b68 --- /dev/null +++ b/test/Modules/Inputs/redecls/module.map @@ -0,0 +1,2 @@ +module a { header "a.h" } +module b { header "b.h" } diff --git a/test/Modules/self-import-header/af.framework/Headers/a1.h b/test/Modules/Inputs/self-import-header/af.framework/Headers/a1.h index 31ae279bde2d..31ae279bde2d 100644 --- a/test/Modules/self-import-header/af.framework/Headers/a1.h +++ b/test/Modules/Inputs/self-import-header/af.framework/Headers/a1.h diff --git a/test/Modules/self-import-header/af.framework/Headers/a2.h b/test/Modules/Inputs/self-import-header/af.framework/Headers/a2.h index cc7e6e20b667..cc7e6e20b667 100644 --- a/test/Modules/self-import-header/af.framework/Headers/a2.h +++ b/test/Modules/Inputs/self-import-header/af.framework/Headers/a2.h diff --git a/test/Modules/self-import-header/af.framework/module.map b/test/Modules/Inputs/self-import-header/af.framework/module.map index 87176831df2d..87176831df2d 100644 --- a/test/Modules/self-import-header/af.framework/module.map +++ b/test/Modules/Inputs/self-import-header/af.framework/module.map diff --git a/test/Modules/self-import-header/depend_builtin/h1.h b/test/Modules/Inputs/self-import-header/depend_builtin/h1.h index 13298efce877..13298efce877 100644 --- a/test/Modules/self-import-header/depend_builtin/h1.h +++ b/test/Modules/Inputs/self-import-header/depend_builtin/h1.h diff --git a/test/Modules/self-import-header/depend_builtin/module.map b/test/Modules/Inputs/self-import-header/depend_builtin/module.map index a736ad85c136..a736ad85c136 100644 --- a/test/Modules/self-import-header/depend_builtin/module.map +++ b/test/Modules/Inputs/self-import-header/depend_builtin/module.map diff --git a/test/Modules/Inputs/stress1/common.h b/test/Modules/Inputs/stress1/common.h new file mode 100644 index 000000000000..b52520ee8f55 --- /dev/null +++ b/test/Modules/Inputs/stress1/common.h @@ -0,0 +1,74 @@ +#ifndef STRESS1_COMMON_H +#define STRESS1_COMMON_H + +inline char function00(char x) { return x + x; } +inline short function00(short x) { return x + x; } +inline int function00(int x) { return x + x; } + +namespace N01 { struct S00; } + +namespace N00 { +struct S00 { + char c; + short s; + int i; + + S00(char x) : c(x) {} + S00(short x) : s(x) {} + S00(int x) : i(x) {} + + char method00(char x) { return x + x; } + short method00(short x) { return x + x; } + int method00(int x) { return x + x; } + + operator char() { return c; } + operator short() { return s; } + operator int() { return i; } +}; +struct S01 {}; +struct S02 {}; +template <typename T> struct S03 { + struct S00 : N00::S00 {}; +}; +template <int I, template <typename> class U> struct S03<U<int>[I]> + : U<int>::S00 { + S03(); + S03(int); + S03(short); + S03(char); + template <typename V = decltype(I)> S03(V); +}; +template <> struct S03<S03<int>[42]> : S00 {}; +} + +namespace N01 { +struct S00 : N00::S00 { + using N00::S00::S00; +}; +struct S01 {}; +struct S02 {}; +} + +using namespace N00; + +template <int I, template <typename> class U> template <typename V> S03<U<int>[I]>::S03(V x) : S00(x) {} +template <int I, template <typename> class U> S03<U<int>[I]>::S03() : S00(I) {} +template <int I, template <typename> class U> S03<U<int>[I]>::S03(char x) : S00(x) {} +template <int I, template <typename> class U> S03<U<int>[I]>::S03(short x) : S00(x) {} +template <int I, template <typename> class U> S03<U<int>[I]>::S03(int x) : S00(x) {} + +#pragma weak pragma_weak00 +#pragma weak pragma_weak01 +#pragma weak pragma_weak02 +#pragma weak pragma_weak03 +#pragma weak pragma_weak04 +#pragma weak pragma_weak05 + +extern "C" int pragma_weak00(); +extern "C" int pragma_weak01(); +extern "C" int pragma_weak02(); +extern "C" int pragma_weak03; +extern "C" int pragma_weak04; +extern "C" int pragma_weak05; + +#endif diff --git a/test/Modules/Inputs/stress1/m00.h b/test/Modules/Inputs/stress1/m00.h new file mode 100644 index 000000000000..ca5af38f58ce --- /dev/null +++ b/test/Modules/Inputs/stress1/m00.h @@ -0,0 +1,6 @@ +#ifndef STRESS1_M00_H +#define STRESS1_M00_H + +#include "common.h" + +#endif diff --git a/test/Modules/Inputs/stress1/m01.h b/test/Modules/Inputs/stress1/m01.h new file mode 100644 index 000000000000..23a3d4b289f6 --- /dev/null +++ b/test/Modules/Inputs/stress1/m01.h @@ -0,0 +1,10 @@ +#ifndef STRESS1_M01_H +#define STRESS1_M01_H + +#include "common.h" + +// Trigger the use of special members for a class this is also defined in other +// modules. +inline N00::S01 m01_special_members() { return N00::S01(); } + +#endif diff --git a/test/Modules/Inputs/stress1/m02.h b/test/Modules/Inputs/stress1/m02.h new file mode 100644 index 000000000000..bb9714ff7471 --- /dev/null +++ b/test/Modules/Inputs/stress1/m02.h @@ -0,0 +1,6 @@ +#ifndef STRESS1_M02_H +#define STRESS1_M02_H + +#include "common.h" + +#endif diff --git a/test/Modules/Inputs/stress1/m03.h b/test/Modules/Inputs/stress1/m03.h new file mode 100644 index 000000000000..b6dbb68ccd53 --- /dev/null +++ b/test/Modules/Inputs/stress1/m03.h @@ -0,0 +1,6 @@ +#ifndef STRESS1_M03_H +#define STRESS1_M03_H + +#include "common.h" + +#endif diff --git a/test/Modules/Inputs/stress1/merge00.h b/test/Modules/Inputs/stress1/merge00.h new file mode 100644 index 000000000000..46d5e4138279 --- /dev/null +++ b/test/Modules/Inputs/stress1/merge00.h @@ -0,0 +1,30 @@ +#ifndef STRESS1_MERGE00_H +#define STRESS1_MERGE00_H + +// These don't match the imported declarations because we import them from +// modules which are built in isolation of the current header's pragma state +// much like they are built in isolation of the incoming macro state. +// FIXME: We should expect warnings here but we can't because verify doesn't +// work for modules. +//#pragma weak pragma_weak01 // expected-warning {{weak identifier 'pragma_weak01' never declared}} +//#pragma weak pragma_weak04 // expected-warning {{weak identifier 'pragma_waek04' never declared}} + +#include "common.h" +#include "m00.h" +#include "m01.h" +#include "m02.h" +#include "m03.h" + +inline int g() { return N00::S00('a').method00('b') + (int)S00(42) + function00(42); } + +// Use implicit special memebers again for S01 to ensure that we merge them in +// successfully from m01. +inline N00::S01 h() { return N00::S01(); } + +#pragma weak pragma_weak02 +#pragma weak pragma_weak05 + +extern "C" int pragma_weak02(); +int pragma_weak05; + +#endif diff --git a/test/Modules/Inputs/stress1/module.modulemap b/test/Modules/Inputs/stress1/module.modulemap new file mode 100644 index 000000000000..2b687b015215 --- /dev/null +++ b/test/Modules/Inputs/stress1/module.modulemap @@ -0,0 +1,6 @@ +module m00 { header "Inputs/stress1/m00.h" export * } +module m01 { header "Inputs/stress1/m01.h" export * } +module m02 { header "Inputs/stress1/m02.h" export * } +module m03 { header "Inputs/stress1/m03.h" export * } + +module merge00 { header "Inputs/stress1/merge00.h" export * } diff --git a/test/Modules/Inputs/submodule-visibility/a.h b/test/Modules/Inputs/submodule-visibility/a.h new file mode 100644 index 000000000000..d8805c92f24d --- /dev/null +++ b/test/Modules/Inputs/submodule-visibility/a.h @@ -0,0 +1 @@ +int n; diff --git a/test/Modules/Inputs/submodule-visibility/b.h b/test/Modules/Inputs/submodule-visibility/b.h new file mode 100644 index 000000000000..fa419c0c5c48 --- /dev/null +++ b/test/Modules/Inputs/submodule-visibility/b.h @@ -0,0 +1 @@ +int m = n; diff --git a/test/Modules/Inputs/submodule-visibility/cycle1.h b/test/Modules/Inputs/submodule-visibility/cycle1.h new file mode 100644 index 000000000000..05e85aef10d8 --- /dev/null +++ b/test/Modules/Inputs/submodule-visibility/cycle1.h @@ -0,0 +1,8 @@ +#ifndef CYCLE1 +#define CYCLE1 + +#include "cycle2.h" + +struct C1 {}; + +#endif diff --git a/test/Modules/Inputs/submodule-visibility/cycle2.h b/test/Modules/Inputs/submodule-visibility/cycle2.h new file mode 100644 index 000000000000..de9fd8e01aaf --- /dev/null +++ b/test/Modules/Inputs/submodule-visibility/cycle2.h @@ -0,0 +1,8 @@ +#ifndef CYCLE2 +#define CYCLE2 + +#include "cycle1.h" + +struct C2 {}; + +#endif diff --git a/test/Modules/Inputs/submodule-visibility/module.modulemap b/test/Modules/Inputs/submodule-visibility/module.modulemap new file mode 100644 index 000000000000..2e13344dc635 --- /dev/null +++ b/test/Modules/Inputs/submodule-visibility/module.modulemap @@ -0,0 +1,6 @@ +module x { module a { header "a.h" } module b { header "b.h" } } + +module cycles { + module cycle1 { header "cycle1.h" } + module cycle2 { header "cycle2.h" } +} diff --git a/test/Modules/Inputs/submodules-merge-defs/defs.h b/test/Modules/Inputs/submodules-merge-defs/defs.h new file mode 100644 index 000000000000..68b57a4a62fe --- /dev/null +++ b/test/Modules/Inputs/submodules-merge-defs/defs.h @@ -0,0 +1,48 @@ +struct A { int a_member; }; +inline int use_a(A a) { return a.a_member; } + +class B { + struct Inner1 {}; +public: + struct Inner2; + template<typename T> void f(); +}; +// Check that lookup and access checks are performed in the right context. +struct B::Inner2 : Inner1 {}; +template<typename T> void B::f() {} + +// Check that base-specifiers are correctly disambiguated. +template<int N> struct C_Base { struct D { constexpr operator int() const { return 0; } }; }; +const int C_Const = 0; +struct C1 : C_Base<C_Base<0>::D{}> {} extern c1; +struct C2 : C_Base<C_Const<0>::D{} extern c2; + +typedef struct { int a; void f(); struct X; } D; +struct D::X { int dx; } extern dx; +inline int use_dx(D::X dx) { return dx.dx; } + +template<typename T> int E(T t) { return t; } + +template<typename T> struct F { + int f(); + template<typename U> int g(); + static int n; +}; +template<typename T> int F<T>::f() { return 0; } +template<typename T> template<typename U> int F<T>::g() { return 0; } +template<typename T> int F<T>::n = 0; +template<> template<typename U> int F<char>::g() { return 0; } +template<> struct F<void> { int h(); }; +inline int F<void>::h() { return 0; } +template<typename T> struct F<T *> { int i(); }; +template<typename T> int F<T*>::i() { return 0; } + +namespace G { + enum A { a, b, c, d, e }; + enum { f, g, h }; + typedef enum { i, j } k; + typedef enum {} l; +} + +template<typename T = int, int N = 3, template<typename> class K = F> int H(int a = 1); +template<typename T = int, int N = 3, template<typename> class K = F> using I = decltype(H<T, N, K>()); diff --git a/test/Modules/Inputs/submodules-merge-defs/empty.h b/test/Modules/Inputs/submodules-merge-defs/empty.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Modules/Inputs/submodules-merge-defs/empty.h diff --git a/test/Modules/Inputs/submodules-merge-defs/import-and-redefine.h b/test/Modules/Inputs/submodules-merge-defs/import-and-redefine.h new file mode 100644 index 000000000000..8d695bc45f4d --- /dev/null +++ b/test/Modules/Inputs/submodules-merge-defs/import-and-redefine.h @@ -0,0 +1,5 @@ +// Trigger import of definitions, but don't make them visible. +#include "empty.h" + +// Now parse the definitions again. +#include "defs.h" diff --git a/test/Modules/Inputs/submodules-merge-defs/merged-defs.h b/test/Modules/Inputs/submodules-merge-defs/merged-defs.h new file mode 100644 index 000000000000..31c69c6a447d --- /dev/null +++ b/test/Modules/Inputs/submodules-merge-defs/merged-defs.h @@ -0,0 +1 @@ +#include "defs.h" diff --git a/test/Modules/Inputs/submodules-merge-defs/module.modulemap b/test/Modules/Inputs/submodules-merge-defs/module.modulemap new file mode 100644 index 000000000000..82abdb088f19 --- /dev/null +++ b/test/Modules/Inputs/submodules-merge-defs/module.modulemap @@ -0,0 +1,16 @@ +module "stuff" { + textual header "defs.h" + module "empty" { header "empty.h" } + module "use" { header "use-defs.h" } +} + +module "redef" { + header "import-and-redefine.h" + // Do not re-export stuff.use + use "stuff" +} + +module "merged-defs" { + header "merged-defs.h" + use "stuff" +} diff --git a/test/Modules/Inputs/submodules-merge-defs/use-defs.h b/test/Modules/Inputs/submodules-merge-defs/use-defs.h new file mode 100644 index 000000000000..31c69c6a447d --- /dev/null +++ b/test/Modules/Inputs/submodules-merge-defs/use-defs.h @@ -0,0 +1 @@ +#include "defs.h" diff --git a/test/Modules/Inputs/update-exception-spec/a.h b/test/Modules/Inputs/update-exception-spec/a.h new file mode 100644 index 000000000000..078ebf9aecf7 --- /dev/null +++ b/test/Modules/Inputs/update-exception-spec/a.h @@ -0,0 +1,2 @@ +struct A { ~A() throw(int); }; +struct B { A a; }; diff --git a/test/Modules/Inputs/update-exception-spec/b.h b/test/Modules/Inputs/update-exception-spec/b.h new file mode 100644 index 000000000000..f75b559bee43 --- /dev/null +++ b/test/Modules/Inputs/update-exception-spec/b.h @@ -0,0 +1,3 @@ +struct A { ~A() throw(int); }; +struct B { A a; }; +inline void f(B *p) { p->~B(); } diff --git a/test/Modules/Inputs/update-exception-spec/c.h b/test/Modules/Inputs/update-exception-spec/c.h new file mode 100644 index 000000000000..067dbb650556 --- /dev/null +++ b/test/Modules/Inputs/update-exception-spec/c.h @@ -0,0 +1,3 @@ +#include "a.h" +#include "b.h" +inline void g(B *p) { p->~B(); } diff --git a/test/Modules/Inputs/update-exception-spec/module.modulemap b/test/Modules/Inputs/update-exception-spec/module.modulemap new file mode 100644 index 000000000000..880ae38b97a0 --- /dev/null +++ b/test/Modules/Inputs/update-exception-spec/module.modulemap @@ -0,0 +1,3 @@ +module a { header "a.h" } +module b { header "b.h" } +module c { header "c.h" } diff --git a/test/Modules/anon-namespace.cpp b/test/Modules/anon-namespace.cpp new file mode 100644 index 000000000000..6c085ebc8858 --- /dev/null +++ b/test/Modules/anon-namespace.cpp @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/anon-namespace -verify %s +// expected-no-diagnostics +#include "b1.h" +#include "c.h" +using namespace N; diff --git a/test/Modules/autolink.m b/test/Modules/autolink.m index 5f2e9bd20208..e6507703be96 100644 --- a/test/Modules/autolink.m +++ b/test/Modules/autolink.m @@ -39,9 +39,9 @@ int use_autolink_sub3() { // CHECK: !llvm.module.flags = !{{{.*}}} // CHECK: !{{[0-9]+}} = !{i32 6, !"Linker Options", ![[AUTOLINK_OPTIONS:[0-9]+]]} // CHECK: ![[AUTOLINK_OPTIONS]] = !{![[AUTOLINK_PCH:[0-9]+]], ![[AUTOLINK_FRAMEWORK:[0-9]+]], ![[AUTOLINK:[0-9]+]], ![[DEPENDSONMODULE:[0-9]+]], ![[MODULE:[0-9]+]], ![[NOUMBRELLA:[0-9]+]]} -// CHECK: ![[AUTOLINK_PCH]] = !{!"{{(-l|/DEFAULTLIB:)}}autolink_from_pch{{(\.lib)?}}"} +// CHECK: ![[AUTOLINK_PCH]] = !{!"{{(\\01|-l|/DEFAULTLIB:)}}autolink_from_pch{{(\.lib)?}}"} // CHECK: ![[AUTOLINK_FRAMEWORK]] = !{!"-framework", !"autolink_framework"} -// CHECK: ![[AUTOLINK]] = !{!"{{(-l|/DEFAULTLIB:)}}autolink{{(\.lib)?}}"} +// CHECK: ![[AUTOLINK]] = !{!"{{(\\01|-l|/DEFAULTLIB:)}}autolink{{(\.lib)?}}"} // CHECK: ![[DEPENDSONMODULE]] = !{!"-framework", !"DependsOnModule"} // CHECK: ![[MODULE]] = !{!"-framework", !"Module"} // CHECK: ![[NOUMBRELLA]] = !{!"-framework", !"NoUmbrella"} diff --git a/test/Modules/crashes.m b/test/Modules/crashes.m new file mode 100644 index 000000000000..edefd379e8a5 --- /dev/null +++ b/test/Modules/crashes.m @@ -0,0 +1,16 @@ +// RUN: rm -rf %t.mcp +// RUN: %clang_cc1 -fmodules-cache-path=%t.mcp -fmodules -F %S/Inputs -fobjc-arc %s -verify + +@import Module; + +__attribute__((objc_root_class)) +@interface Test +// rdar://19904648 +// The diagnostic will try to find a suitable macro name to use (instead of raw __attribute__). +// While iterating through the macros it would dereference a null pointer if the macro was undefined in the same module as it was originally defined in. +@property (assign) id newFile; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}} \ + // expected-note {{explicitly declare getter '-newFile' with '__attribute__((objc_method_family(none)))' to return an 'unowned' object}} +@end + +@implementation Test +@end diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m index 24bca19b7aa9..200779a0f3d7 100644 --- a/test/Modules/cstd.m +++ b/test/Modules/cstd.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang -fsyntax-only -isystem %S/Inputs/System/usr/include -ffreestanding -fmodules -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s +// RUN: %clang_cc1 -fsyntax-only -isystem %S/Inputs/System/usr/include -ffreestanding -fmodules -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s @import uses_other_constants; const double other_value = DBL_MAX; diff --git a/test/Modules/cxx-decls.cpp b/test/Modules/cxx-decls.cpp index 109306ed79df..4064040c1257 100644 --- a/test/Modules/cxx-decls.cpp +++ b/test/Modules/cxx-decls.cpp @@ -52,5 +52,7 @@ int use_namespace_alias() { return Alias::a + Alias::b; } void use_extern_c_function_2() { ExternCFunction(); } +InhCtorB inhctorb(2); + // CHECK: VarDecl [[mergeUsedFlag:0x[0-9a-f]*]] {{.*}} in cxx_decls.imported used mergeUsedFlag // CHECK: VarDecl {{0x[0-9a-f]*}} prev [[mergeUsedFlag]] {{.*}} in cxx_decls_merged used mergeUsedFlag diff --git a/test/Modules/cxx-dtor.cpp b/test/Modules/cxx-dtor.cpp new file mode 100644 index 000000000000..ead67ec334e7 --- /dev/null +++ b/test/Modules/cxx-dtor.cpp @@ -0,0 +1,3 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs/cxx-dtor -emit-llvm-only %s +#include "b.h" diff --git a/test/Modules/cxx-irgen.cpp b/test/Modules/cxx-irgen.cpp index ecaf704b87bb..13902bf92622 100644 --- a/test/Modules/cxx-irgen.cpp +++ b/test/Modules/cxx-irgen.cpp @@ -5,7 +5,6 @@ @import cxx_irgen_top; -// CHECK-DAG: call {{[a-z]*[ ]?i32}} @_ZN8CtorInitIiE1fEv( CtorInit<int> x; @import cxx_irgen_left; @@ -34,23 +33,25 @@ int b = h(); // CHECK-DAG: define linkonce_odr {{signext i32|i32}} @_Z3minIiET_S0_S0_(i32 int c = min(1, 2); - -// CHECK-LABEL: define {{.*}} @_ZN20OperatorDeleteLookup1AD0Ev( -// CHECK: call void @_ZN20OperatorDeleteLookup1AdlEPv( +// CHECK: define available_externally {{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align namespace ImplicitSpecialMembers { - // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2EOS0_( - // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( - // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_( // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( - // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2EOS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2EOS0_( // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2ERKS0_( // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( - // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2EOS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2EOS0_( // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( - // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2ERKS0_( // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2EOS0_( + // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN20OperatorDeleteLookup1AD0Ev( + // CHECK: call void @_ZN20OperatorDeleteLookup1AdlEPv( + + // CHECK-DAG: call {{[a-z]*[ ]?i32}} @_ZN8CtorInitIiE1fEv( extern B b1; B b2(b1); @@ -71,6 +72,5 @@ namespace OperatorDeleteLookup { void g() { f(); } } -// CHECK: define available_externally {{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align // CHECK: attributes #[[ALWAYS_INLINE]] = {{.*}} alwaysinline diff --git a/test/Modules/cxx-lookup.cpp b/test/Modules/cxx-lookup.cpp index 47c879dbb636..bd019c7f4ae4 100644 --- a/test/Modules/cxx-lookup.cpp +++ b/test/Modules/cxx-lookup.cpp @@ -4,3 +4,8 @@ namespace llvm {} #include "c2.h" llvm::GlobalValue *p; + +#include "na.h" +namespace N { struct foo; } +#include "nb.h" +N::foo *use_n_foo; diff --git a/test/Modules/cxx-templates.cpp b/test/Modules/cxx-templates.cpp index d9c8a8c27d0d..00fc38b52209 100644 --- a/test/Modules/cxx-templates.cpp +++ b/test/Modules/cxx-templates.cpp @@ -1,7 +1,7 @@ // RUN: rm -rf %t // RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump-lookups | FileCheck %s --check-prefix=CHECK-GLOBAL // RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump-lookups -ast-dump-filter N | FileCheck %s --check-prefix=CHECK-NAMESPACE-N -// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump | FileCheck %s --check-prefix=CHECK-DUMP +// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-filter SomeTemplate | FileCheck %s --check-prefix=CHECK-DUMP // RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 // RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 -DEARLY_IMPORT @@ -28,14 +28,8 @@ void g() { f<double>(1.0); f<int>(); f(); // expected-error {{no matching function}} -#ifdef EARLY_IMPORT - // FIXME: The textual inclusion above shouldn't affect this! - // expected-note@Inputs/cxx-templates-a.h:3 {{couldn't infer template argument}} - // expected-note@Inputs/cxx-templates-a.h:4 {{requires 1 argument}} -#else // expected-note@Inputs/cxx-templates-b.h:3 {{couldn't infer template argument}} // expected-note@Inputs/cxx-templates-b.h:4 {{requires single argument}} -#endif N::f(0); N::f<double>(1.0); @@ -131,8 +125,6 @@ void g() { static_assert(Outer<int>::Inner<int>::f() == 1, ""); static_assert(Outer<int>::Inner<int>::g() == 2, ""); -#ifndef EARLY_IMPORT -// FIXME: The textual inclusion above shouldn't cause this to fail! static_assert(MergeTemplateDefinitions<int>::f() == 1, ""); static_assert(MergeTemplateDefinitions<int>::g() == 2, ""); @@ -146,7 +138,6 @@ MergeSpecializations<int[]>::partially_specialized_in_c spec_in_c_1; MergeSpecializations<char>::explicitly_specialized_in_a spec_in_a_2; MergeSpecializations<double>::explicitly_specialized_in_b spec_in_b_2; MergeSpecializations<bool>::explicitly_specialized_in_c spec_in_c_2; -#endif MergeAnonUnionMember<> maum_main; typedef DontWalkPreviousDeclAfterMerging<int> dwpdam_typedef_2; @@ -195,11 +186,11 @@ namespace Std { // CHECK-NAMESPACE-N-NEXT: `-FunctionTemplate {{.*}} 'f' // CHECK-DUMP: ClassTemplateDecl {{.*}} <{{.*[/\\]}}cxx-templates-common.h:1:1, {{.*}}> col:{{.*}} in cxx_templates_common SomeTemplate -// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev [[CHAR2:[^ ]*]] {{.*}} SomeTemplate +// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate // CHECK-DUMP-NEXT: TemplateArgument type 'char [2]' -// CHECK-DUMP: ClassTemplateSpecializationDecl [[CHAR2]] {{.*}} SomeTemplate definition +// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition // CHECK-DUMP-NEXT: TemplateArgument type 'char [2]' -// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev [[CHAR1:[^ ]*]] {{.*}} SomeTemplate +// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate // CHECK-DUMP-NEXT: TemplateArgument type 'char [1]' -// CHECK-DUMP: ClassTemplateSpecializationDecl [[CHAR1]] {{.*}} SomeTemplate definition +// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition // CHECK-DUMP-NEXT: TemplateArgument type 'char [1]' diff --git a/test/Modules/declare-use-compatible.cpp b/test/Modules/declare-use-compatible.cpp new file mode 100644 index 000000000000..4c3d79bd71c9 --- /dev/null +++ b/test/Modules/declare-use-compatible.cpp @@ -0,0 +1,36 @@ +// Used module not built with -decluse. +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -fmodules -fmodule-name=XB -emit-module \ +// RUN: -I %S/Inputs/declare-use %S/Inputs/declare-use/module.map -o %t/b.pcm +// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodules-decluse \ +// RUN: -fmodule-file=%t/b.pcm -fmodule-name=XE -I %S/Inputs/declare-use %s +// +// Main module not built with -decluse. +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -fmodules -fmodule-name=XB -emit-module \ +// RUN: -fmodules-decluse \ +// RUN: -I %S/Inputs/declare-use %S/Inputs/declare-use/module.map -o %t/b.pcm +// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodule-file=%t/b.pcm -fmodule-name=XE -I %S/Inputs/declare-use %s +// +// Used module not built with -decluse. +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -fmodules -fmodule-name=XB -emit-module \ +// RUN: -I %S/Inputs/declare-use %S/Inputs/declare-use/module.map -o %t/b.pcm +// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodules-strict-decluse \ +// RUN: -fmodule-file=%t/b.pcm -fmodule-name=XE -I %S/Inputs/declare-use %s +// +// Main module not built with -decluse. +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -fmodules -fmodule-name=XB -emit-module \ +// RUN: -fmodules-strict-decluse \ +// RUN: -I %S/Inputs/declare-use %S/Inputs/declare-use/module.map -o %t/b.pcm +// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodule-file=%t/b.pcm -fmodule-name=XE -I %S/Inputs/declare-use %s + +#include "b.h" + +const int g = b; + diff --git a/test/Modules/declare-use1.cpp b/test/Modules/declare-use1.cpp index 5fc43360ffa3..adba59556f8d 100644 --- a/test/Modules/declare-use1.cpp +++ b/test/Modules/declare-use1.cpp @@ -5,4 +5,5 @@ #include "e.h" #include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}} #include "i.h" -const int g2 = g1 + e + f + aux_i; +#include "sub.h" +const int g2 = g1 + e + f + aux_i + sub; diff --git a/test/Modules/declare-use5.cpp b/test/Modules/declare-use5.cpp new file mode 100644 index 000000000000..b34be0f1104b --- /dev/null +++ b/test/Modules/declare-use5.cpp @@ -0,0 +1,9 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodule-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XN -I %S/Inputs/declare-use %s -verify + + +#include "sub.h" + +const int a = sub; + +// expected-no-diagnostics diff --git a/test/Modules/deferred-lookup.cpp b/test/Modules/deferred-lookup.cpp new file mode 100644 index 000000000000..aaac389da0dc --- /dev/null +++ b/test/Modules/deferred-lookup.cpp @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/deferred-lookup -verify %s +// expected-no-diagnostics + +namespace N { int f(int); } +#include "b.h" diff --git a/test/Modules/dependency-gen.modulemap.cpp b/test/Modules/dependency-gen.modulemap index c49714c14ed9..6aa2e007ebb8 100644 --- a/test/Modules/dependency-gen.modulemap.cpp +++ b/test/Modules/dependency-gen.modulemap @@ -1,9 +1,7 @@ -// REQUIRES: shell -// // RUN: cd %S // RUN: rm -f %t.cpm %t-base.pcm %t-base.d %t.d // RUN: %clang_cc1 -I. -x c++ -fmodule-maps -fmodule-name=test-base -fno-modules-implicit-maps -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse Inputs/dependency-gen-base.modulemap -dependency-file %t-base.d -MT %t-base.pcm -o %t-base.pcm -fmodule-map-file-home-is-cwd -// RUN: %clang_cc1 -I. -x c++ -fmodule-maps -fmodule-name=test -fno-modules-implicit-maps -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse -fmodule-file=%t-base.pcm dependency-gen.modulemap.cpp -dependency-file %t.d -MT %t.pcm -o %t.pcm -fmodule-map-file-home-is-cwd +// RUN: %clang_cc1 -I. -x c++ -fmodule-maps -fmodule-name=test -fno-modules-implicit-maps -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse -fmodule-file=%t-base.pcm %s -dependency-file %t.d -MT %t.pcm -o %t.pcm -fmodule-map-file-home-is-cwd // RUN: FileCheck %s < %t.d module "test" { export * @@ -14,5 +12,5 @@ module "test" { extern module "test-base2" "Inputs/dependency-gen-base2.modulemap" extern module "test-base" "Inputs/dependency-gen-base.modulemap" -// CHECK: {{ |\./}}Inputs/dependency-gen-included2.h -// CHECK: {{ |\./}}Inputs/dependency-gen-base.modulemap +// CHECK: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h +// CHECK: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap diff --git a/test/Modules/diagnostics.modulemap b/test/Modules/diagnostics.modulemap new file mode 100644 index 000000000000..aef094d3bf64 --- /dev/null +++ b/test/Modules/diagnostics.modulemap @@ -0,0 +1,14 @@ +// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/diagnostics-aux.modulemap -fmodule-map-file=%s -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s + +// PR22299: Ensure we can produce diagnostics for duplicate modules from -fmodule-map-file=. +// +// CHECK: diagnostics.modulemap:[[@LINE+2]]:8: error: redefinition of module 'foo' +// CHECK: diagnostics-aux.modulemap:1:8: note: previously defined here +module foo {} + +//* Check that we accept BCPL comments properly, not just as an extension. */ + +module bad_use { + // CHECK: diagnostics.modulemap:[[@LINE+1]]:22: error: use declarations are only allowed in top-level modules + module submodule { use foo } +} diff --git a/test/Modules/empty.modulemap b/test/Modules/empty.modulemap new file mode 100644 index 000000000000..ef1d4a80ecfc --- /dev/null +++ b/test/Modules/empty.modulemap @@ -0,0 +1,15 @@ +// RUN: rm -rf %t +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -emit-module -fmodule-name=empty -o %t/base.pcm \ +// RUN: %s +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -emit-module -fmodule-name=empty -o %t/check.pcm \ +// RUN: %s +// +// RUN: diff %t/base.pcm %t/check.pcm + +module empty { header "Inputs/empty.h" export * } diff --git a/test/Modules/explicit-build-relpath.cpp b/test/Modules/explicit-build-relpath.cpp index d9c15660b6ad..f16556641d79 100644 --- a/test/Modules/explicit-build-relpath.cpp +++ b/test/Modules/explicit-build-relpath.cpp @@ -1,5 +1,3 @@ -// REQUIRES: shell -// // RUN: rm -rf %t // RUN: mkdir %t // RUN: cd %t diff --git a/test/Modules/explicit-build.cpp b/test/Modules/explicit-build.cpp index ce3a1af41626..6fe9f7ee46a3 100644 --- a/test/Modules/explicit-build.cpp +++ b/test/Modules/explicit-build.cpp @@ -64,6 +64,19 @@ // RUN: -fmodule-file=%t/c.pcm \ // RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C +// ------------------------------- +// Check that -fmodule-file= in a module build makes the file transitively +// available even if it's not used. +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fno-implicit-modules -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/b.pcm \ +// RUN: -fmodule-name=d -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/d.pcm \ +// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty +// +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fno-implicit-modules -Rmodule-build -fno-modules-error-recovery \ +// RUN: -I%S/Inputs/explicit-build \ +// RUN: -fmodule-file=%t/d.pcm \ +// RUN: -verify %s -DHAVE_A -DHAVE_B + #if HAVE_A #include "a.h" static_assert(a == 1, ""); @@ -148,11 +161,24 @@ // RUN: -fmodule-file=%t/not.pcm \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s // +// CHECK-BAD-FILE: fatal error: file '{{.*}}not.pcm' is not a valid precompiled module file + // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ // RUN: -fmodule-file=%t/nonexistent.pcm \ -// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-FILE %s +// +// CHECK-NO-FILE: fatal error: module file '{{.*}}nonexistent.pcm' not found + +// RUN: mv %t/a.pcm %t/a-tmp.pcm +// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -I%S/Inputs/explicit-build \ +// RUN: -fmodule-file=%t/c.pcm \ +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-FILE-INDIRECT %s +// RUN: mv %t/a-tmp.pcm %t/a.pcm // -// CHECK-BAD-FILE: fatal error: file '{{.*}}t.pcm' is not a precompiled module file +// CHECK-NO-FILE-INDIRECT: error: module file '{{.*}}a.pcm' not found +// CHECK-NO-FILE-INDIRECT-NEXT: note: imported by module 'b' in '{{.*}}b.pcm' +// CHECK-NO-FILE-INDIRECT-NEXT: note: imported by module 'c' in '{{.*}}c.pcm' // ------------------------------- // Check that we don't get upset if B's timestamp is newer than C's. diff --git a/test/Modules/exponential-paths.cpp b/test/Modules/exponential-paths.cpp new file mode 100644 index 000000000000..34ab4205131d --- /dev/null +++ b/test/Modules/exponential-paths.cpp @@ -0,0 +1,209 @@ +// REQUIRES: shell +// +// RUN: rm -rf %t +// RUN: mkdir %t +// +// Build module map with 40 modules; two layers with importing and re-exporting +// the previous layer. +// +// RUN: echo 'module a0 { header "a0.h" export * }' > %t/module.modulemap +// RUN: echo 'module b0 { header "b0.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a1 { header "a1.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b1 { header "b1.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a2 { header "a2.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b2 { header "b2.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a3 { header "a3.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b3 { header "b3.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a4 { header "a4.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b4 { header "b4.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a5 { header "a5.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b5 { header "b5.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a6 { header "a6.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b6 { header "b6.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a7 { header "a7.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b7 { header "b7.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a8 { header "a8.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b8 { header "b8.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a9 { header "a9.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b9 { header "b9.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a10 { header "a10.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b10 { header "b10.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a11 { header "a11.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b11 { header "b11.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a12 { header "a12.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b12 { header "b12.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a13 { header "a13.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b13 { header "b13.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a14 { header "a14.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b14 { header "b14.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a15 { header "a15.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b15 { header "b15.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a16 { header "a16.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b16 { header "b16.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a17 { header "a17.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b17 { header "b17.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a18 { header "a18.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b18 { header "b18.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a19 { header "a19.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b19 { header "b19.h" export * }' >> %t/module.modulemap +// RUN: echo 'module a20 { header "a20.h" export * }' >> %t/module.modulemap +// RUN: echo 'module b20 { header "b20.h" export * }' >> %t/module.modulemap +// +// Build the corresponding headers. +// +// RUN: echo 'template<int> struct X {}; extern X<0> x0;' > %t/x.h +// RUN: echo 'extern int n;' > %t/a0.h +// RUN: cp %t/a0.h %t/b0.h +// RUN: echo '#include "x.h"' > %t/a1.h +// RUN: echo '#include "a0.h"' >> %t/a1.h +// RUN: echo '#include "b0.h"' >> %t/a1.h +// RUN: cp %t/a1.h %t/b1.h +// RUN: echo '#include "x.h"' > %t/a2.h +// RUN: echo '#include "a1.h"' >> %t/a2.h +// RUN: echo '#include "b1.h"' >> %t/a2.h +// RUN: cp %t/a2.h %t/b2.h +// RUN: echo '#include "x.h"' > %t/a3.h +// RUN: echo '#include "a2.h"' >> %t/a3.h +// RUN: echo '#include "b2.h"' >> %t/a3.h +// RUN: cp %t/a3.h %t/b3.h +// RUN: echo '#include "x.h"' > %t/a4.h +// RUN: echo '#include "a3.h"' >> %t/a4.h +// RUN: echo '#include "b3.h"' >> %t/a4.h +// RUN: cp %t/a4.h %t/b4.h +// RUN: echo '#include "x.h"' > %t/a5.h +// RUN: echo '#include "a4.h"' >> %t/a5.h +// RUN: echo '#include "b4.h"' >> %t/a5.h +// RUN: cp %t/a5.h %t/b5.h +// RUN: echo '#include "x.h"' > %t/a6.h +// RUN: echo '#include "a5.h"' >> %t/a6.h +// RUN: echo '#include "b5.h"' >> %t/a6.h +// RUN: cp %t/a6.h %t/b6.h +// RUN: echo '#include "x.h"' > %t/a7.h +// RUN: echo '#include "a6.h"' >> %t/a7.h +// RUN: echo '#include "b6.h"' >> %t/a7.h +// RUN: cp %t/a7.h %t/b7.h +// RUN: echo '#include "x.h"' > %t/a8.h +// RUN: echo '#include "a7.h"' >> %t/a8.h +// RUN: echo '#include "b7.h"' >> %t/a8.h +// RUN: cp %t/a8.h %t/b8.h +// RUN: echo '#include "x.h"' > %t/a9.h +// RUN: echo '#include "a8.h"' >> %t/a9.h +// RUN: echo '#include "b8.h"' >> %t/a9.h +// RUN: cp %t/a9.h %t/b9.h +// RUN: echo '#include "x.h"' > %t/a10.h +// RUN: echo '#include "a9.h"' >> %t/a10.h +// RUN: echo '#include "b9.h"' >> %t/a10.h +// RUN: cp %t/a10.h %t/b10.h +// RUN: echo '#include "x.h"' > %t/a11.h +// RUN: echo '#include "a10.h"' >> %t/a11.h +// RUN: echo '#include "b10.h"' >> %t/a11.h +// RUN: cp %t/a11.h %t/b11.h +// RUN: echo '#include "x.h"' > %t/a12.h +// RUN: echo '#include "a11.h"' >> %t/a12.h +// RUN: echo '#include "b11.h"' >> %t/a12.h +// RUN: cp %t/a12.h %t/b12.h +// RUN: echo '#include "x.h"' > %t/a13.h +// RUN: echo '#include "a12.h"' >> %t/a13.h +// RUN: echo '#include "b12.h"' >> %t/a13.h +// RUN: cp %t/a13.h %t/b13.h +// RUN: echo '#include "x.h"' > %t/a14.h +// RUN: echo '#include "a13.h"' >> %t/a14.h +// RUN: echo '#include "b13.h"' >> %t/a14.h +// RUN: cp %t/a14.h %t/b14.h +// RUN: echo '#include "x.h"' > %t/a15.h +// RUN: echo '#include "a14.h"' >> %t/a15.h +// RUN: echo '#include "b14.h"' >> %t/a15.h +// RUN: cp %t/a15.h %t/b15.h +// RUN: echo '#include "x.h"' > %t/a16.h +// RUN: echo '#include "a15.h"' >> %t/a16.h +// RUN: echo '#include "b15.h"' >> %t/a16.h +// RUN: cp %t/a16.h %t/b16.h +// RUN: echo '#include "x.h"' > %t/a17.h +// RUN: echo '#include "a16.h"' >> %t/a17.h +// RUN: echo '#include "b16.h"' >> %t/a17.h +// RUN: cp %t/a17.h %t/b17.h +// RUN: echo '#include "x.h"' > %t/a18.h +// RUN: echo '#include "a17.h"' >> %t/a18.h +// RUN: echo '#include "b17.h"' >> %t/a18.h +// RUN: cp %t/a18.h %t/b18.h +// RUN: echo '#include "x.h"' > %t/a19.h +// RUN: echo '#include "a18.h"' >> %t/a19.h +// RUN: echo '#include "b18.h"' >> %t/a19.h +// RUN: cp %t/a19.h %t/b19.h +// RUN: echo '#include "x.h"' > %t/a20.h +// RUN: echo '#include "a19.h"' >> %t/a20.h +// RUN: echo '#include "b19.h"' >> %t/a20.h +// RUN: cp %t/a20.h %t/b20.h +// +// Explicitly build all the modules. +// +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a0 -x c++ -emit-module %t/module.modulemap -o %t/a0.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b0 -x c++ -emit-module %t/module.modulemap -o %t/b0.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a1 -x c++ -emit-module %t/module.modulemap -o %t/a1.pcm -fmodule-file=%t/a0.pcm -fmodule-file=%t/b0.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b1 -x c++ -emit-module %t/module.modulemap -o %t/b1.pcm -fmodule-file=%t/a0.pcm -fmodule-file=%t/b0.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a2 -x c++ -emit-module %t/module.modulemap -o %t/a2.pcm -fmodule-file=%t/a1.pcm -fmodule-file=%t/b1.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b2 -x c++ -emit-module %t/module.modulemap -o %t/b2.pcm -fmodule-file=%t/a1.pcm -fmodule-file=%t/b1.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a3 -x c++ -emit-module %t/module.modulemap -o %t/a3.pcm -fmodule-file=%t/a2.pcm -fmodule-file=%t/b2.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b3 -x c++ -emit-module %t/module.modulemap -o %t/b3.pcm -fmodule-file=%t/a2.pcm -fmodule-file=%t/b2.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a4 -x c++ -emit-module %t/module.modulemap -o %t/a4.pcm -fmodule-file=%t/a3.pcm -fmodule-file=%t/b3.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b4 -x c++ -emit-module %t/module.modulemap -o %t/b4.pcm -fmodule-file=%t/a3.pcm -fmodule-file=%t/b3.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a5 -x c++ -emit-module %t/module.modulemap -o %t/a5.pcm -fmodule-file=%t/a4.pcm -fmodule-file=%t/b4.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b5 -x c++ -emit-module %t/module.modulemap -o %t/b5.pcm -fmodule-file=%t/a4.pcm -fmodule-file=%t/b4.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a6 -x c++ -emit-module %t/module.modulemap -o %t/a6.pcm -fmodule-file=%t/a5.pcm -fmodule-file=%t/b5.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b6 -x c++ -emit-module %t/module.modulemap -o %t/b6.pcm -fmodule-file=%t/a5.pcm -fmodule-file=%t/b5.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a7 -x c++ -emit-module %t/module.modulemap -o %t/a7.pcm -fmodule-file=%t/a6.pcm -fmodule-file=%t/b6.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b7 -x c++ -emit-module %t/module.modulemap -o %t/b7.pcm -fmodule-file=%t/a6.pcm -fmodule-file=%t/b6.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a8 -x c++ -emit-module %t/module.modulemap -o %t/a8.pcm -fmodule-file=%t/a7.pcm -fmodule-file=%t/b7.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b8 -x c++ -emit-module %t/module.modulemap -o %t/b8.pcm -fmodule-file=%t/a7.pcm -fmodule-file=%t/b7.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a9 -x c++ -emit-module %t/module.modulemap -o %t/a9.pcm -fmodule-file=%t/a8.pcm -fmodule-file=%t/b8.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b9 -x c++ -emit-module %t/module.modulemap -o %t/b9.pcm -fmodule-file=%t/a8.pcm -fmodule-file=%t/b8.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a10 -x c++ -emit-module %t/module.modulemap -o %t/a10.pcm -fmodule-file=%t/a9.pcm -fmodule-file=%t/b9.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b10 -x c++ -emit-module %t/module.modulemap -o %t/b10.pcm -fmodule-file=%t/a9.pcm -fmodule-file=%t/b9.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a11 -x c++ -emit-module %t/module.modulemap -o %t/a11.pcm -fmodule-file=%t/a10.pcm -fmodule-file=%t/b10.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b11 -x c++ -emit-module %t/module.modulemap -o %t/b11.pcm -fmodule-file=%t/a10.pcm -fmodule-file=%t/b10.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a12 -x c++ -emit-module %t/module.modulemap -o %t/a12.pcm -fmodule-file=%t/a11.pcm -fmodule-file=%t/b11.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b12 -x c++ -emit-module %t/module.modulemap -o %t/b12.pcm -fmodule-file=%t/a11.pcm -fmodule-file=%t/b11.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a13 -x c++ -emit-module %t/module.modulemap -o %t/a13.pcm -fmodule-file=%t/a12.pcm -fmodule-file=%t/b12.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b13 -x c++ -emit-module %t/module.modulemap -o %t/b13.pcm -fmodule-file=%t/a12.pcm -fmodule-file=%t/b12.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a14 -x c++ -emit-module %t/module.modulemap -o %t/a14.pcm -fmodule-file=%t/a13.pcm -fmodule-file=%t/b13.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b14 -x c++ -emit-module %t/module.modulemap -o %t/b14.pcm -fmodule-file=%t/a13.pcm -fmodule-file=%t/b13.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a15 -x c++ -emit-module %t/module.modulemap -o %t/a15.pcm -fmodule-file=%t/a14.pcm -fmodule-file=%t/b14.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b15 -x c++ -emit-module %t/module.modulemap -o %t/b15.pcm -fmodule-file=%t/a14.pcm -fmodule-file=%t/b14.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a16 -x c++ -emit-module %t/module.modulemap -o %t/a16.pcm -fmodule-file=%t/a15.pcm -fmodule-file=%t/b15.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b16 -x c++ -emit-module %t/module.modulemap -o %t/b16.pcm -fmodule-file=%t/a15.pcm -fmodule-file=%t/b15.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a17 -x c++ -emit-module %t/module.modulemap -o %t/a17.pcm -fmodule-file=%t/a16.pcm -fmodule-file=%t/b16.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b17 -x c++ -emit-module %t/module.modulemap -o %t/b17.pcm -fmodule-file=%t/a16.pcm -fmodule-file=%t/b16.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a18 -x c++ -emit-module %t/module.modulemap -o %t/a18.pcm -fmodule-file=%t/a17.pcm -fmodule-file=%t/b17.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b18 -x c++ -emit-module %t/module.modulemap -o %t/b18.pcm -fmodule-file=%t/a17.pcm -fmodule-file=%t/b17.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a19 -x c++ -emit-module %t/module.modulemap -o %t/a19.pcm -fmodule-file=%t/a18.pcm -fmodule-file=%t/b18.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b19 -x c++ -emit-module %t/module.modulemap -o %t/b19.pcm -fmodule-file=%t/a18.pcm -fmodule-file=%t/b18.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=a20 -x c++ -emit-module %t/module.modulemap -o %t/a20.pcm -fmodule-file=%t/a19.pcm -fmodule-file=%t/b19.pcm +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fmodule-name=b20 -x c++ -emit-module %t/module.modulemap -o %t/b20.pcm -fmodule-file=%t/a19.pcm -fmodule-file=%t/b19.pcm +// +// Build, using all the modules. +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%t -fsyntax-only %s \ +// RUN: -fmodule-file=%t/a0.pcm -fmodule-file=%t/b0.pcm \ +// RUN: -fmodule-file=%t/a1.pcm -fmodule-file=%t/b1.pcm \ +// RUN: -fmodule-file=%t/a2.pcm -fmodule-file=%t/b2.pcm \ +// RUN: -fmodule-file=%t/a3.pcm -fmodule-file=%t/b3.pcm \ +// RUN: -fmodule-file=%t/a4.pcm -fmodule-file=%t/b4.pcm \ +// RUN: -fmodule-file=%t/a5.pcm -fmodule-file=%t/b5.pcm \ +// RUN: -fmodule-file=%t/a6.pcm -fmodule-file=%t/b6.pcm \ +// RUN: -fmodule-file=%t/a7.pcm -fmodule-file=%t/b7.pcm \ +// RUN: -fmodule-file=%t/a8.pcm -fmodule-file=%t/b8.pcm \ +// RUN: -fmodule-file=%t/a9.pcm -fmodule-file=%t/b9.pcm \ +// RUN: -fmodule-file=%t/a10.pcm -fmodule-file=%t/b10.pcm \ +// RUN: -fmodule-file=%t/a11.pcm -fmodule-file=%t/b11.pcm \ +// RUN: -fmodule-file=%t/a12.pcm -fmodule-file=%t/b12.pcm \ +// RUN: -fmodule-file=%t/a13.pcm -fmodule-file=%t/b13.pcm \ +// RUN: -fmodule-file=%t/a14.pcm -fmodule-file=%t/b14.pcm \ +// RUN: -fmodule-file=%t/a15.pcm -fmodule-file=%t/b15.pcm \ +// RUN: -fmodule-file=%t/a16.pcm -fmodule-file=%t/b16.pcm \ +// RUN: -fmodule-file=%t/a17.pcm -fmodule-file=%t/b17.pcm \ +// RUN: -fmodule-file=%t/a18.pcm -fmodule-file=%t/b18.pcm \ +// RUN: -fmodule-file=%t/a19.pcm -fmodule-file=%t/b19.pcm \ +// RUN: -fmodule-file=%t/a20.pcm -fmodule-file=%t/b20.pcm + +#include "a20.h" +#include "b20.h" +int k = n; diff --git a/test/Modules/filename.cpp b/test/Modules/filename.cpp index 66891a04b744..460b6e6b9571 100644 --- a/test/Modules/filename.cpp +++ b/test/Modules/filename.cpp @@ -1,6 +1,5 @@ // RUN: cd %S // RUN: %clang_cc1 -I. -fmodule-maps -fmodule-name=A -fmodule-map-file=%S/Inputs/filename/module.map %s -E | FileCheck %s -// REQUIRES: shell #include "Inputs/filename/a.h" diff --git a/test/Modules/header-in-multiple-maps.cpp b/test/Modules/header-in-multiple-maps.cpp new file mode 100644 index 000000000000..a9c0c80eca86 --- /dev/null +++ b/test/Modules/header-in-multiple-maps.cpp @@ -0,0 +1,9 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/header-in-multiple-maps -fmodule-map-file=%S/Inputs/header-in-multiple-maps/map1 -verify %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/header-in-multiple-maps -fmodule-map-file=%S/Inputs/header-in-multiple-maps/map2 -verify %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/header-in-multiple-maps -fmodule-map-file=%S/Inputs/header-in-multiple-maps/map3 -verify %s +// expected-no-diagnostics + +#include "a.h" +#include "a.h" +A *p; diff --git a/test/Modules/ignored_macros.m b/test/Modules/ignored_macros.m index e8ee50ace315..669db4ddc2da 100644 --- a/test/Modules/ignored_macros.m +++ b/test/Modules/ignored_macros.m @@ -10,7 +10,7 @@ // RUN: %clang_cc1 -fmodules-cache-path=%t.modules -fmodules -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify // RUN: not %clang_cc1 -fmodules-cache-path=%t.modules -DIGNORED=1 -fmodules -I %S/Inputs -include-pch %t.pch %s > %t.err 2>&1 // RUN: FileCheck -check-prefix=CHECK-CONFLICT %s < %t.err -// CHECK-CONFLICT: module 'ignored_macros' found in both +// CHECK-CONFLICT: PCH was compiled with module cache path // Third trial: pass -DIGNORED=1 only to the second invocation, but // make it ignored. There should be no failure, IGNORED is defined in diff --git a/test/Modules/implementation-of-module.m b/test/Modules/implementation-of-module.m index b39840420156..818cce8c36de 100644 --- a/test/Modules/implementation-of-module.m +++ b/test/Modules/implementation-of-module.m @@ -16,7 +16,7 @@ // RUN: %clang_cc1 -x objective-c-header -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \ // RUN: -fmodule-implementation-of category_right -emit-pch -o %t.pch // RUN: %clang_cc1 -x objective-c-header -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \ -// RUN: -DWITH_PREFIX -include-pch %t.pch -fmodule-implementation-of category_right +// RUN: -DWITH_PREFIX -fmodules-ignore-macro=WITH_PREFIX -include-pch %t.pch -fmodule-implementation-of category_right #ifndef WITH_PREFIX diff --git a/test/Modules/include-relative.c b/test/Modules/include-relative.c index 9ca76eeb921c..264df5f31897 100644 --- a/test/Modules/include-relative.c +++ b/test/Modules/include-relative.c @@ -3,7 +3,6 @@ // RUN: cp -r %S/Inputs/include-relative %t/include-relative // RUN: cd %t // RUN: %clang_cc1 -fmodules -x c -verify -fmodules-cache-path=%t -I include-relative %s -// REQUIRES: shell // expected-no-diagnostics diff --git a/test/Modules/initializer_list.cpp b/test/Modules/initializer_list.cpp index 0cbcbbb70e46..ea6e282195d9 100644 --- a/test/Modules/initializer_list.cpp +++ b/test/Modules/initializer_list.cpp @@ -1,7 +1,23 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 +// +// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t \ +// RUN: -I %S/Inputs/initializer_list \ +// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \ +// RUN: %s -verify -std=c++11 +// +// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t \ +// RUN: -I %S/Inputs/initializer_list \ +// RUN: -fmodule-map-file=%S/Inputs/initializer_list/indirect.modulemap \ +// RUN: %s -verify -std=c++11 -DINCLUDE_DIRECT // expected-no-diagnostics + +#ifdef INCLUDE_DIRECT +#include "direct.h" +auto k = {1, 2, 3}; +#endif + @import initializer_list; +auto v = {1, 2, 3}; int n = std::min({1, 2, 3}); diff --git a/test/Modules/invalidate-identifiers.c b/test/Modules/invalidate-identifiers.c new file mode 100644 index 000000000000..de3aa10db46b --- /dev/null +++ b/test/Modules/invalidate-identifiers.c @@ -0,0 +1,4 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/invalidate-identifiers -emit-llvm-only %s + +#include "b.h" diff --git a/test/Modules/linkage-merge.cpp b/test/Modules/linkage-merge.cpp index 664716d3bed7..3ac8053761bf 100644 --- a/test/Modules/linkage-merge.cpp +++ b/test/Modules/linkage-merge.cpp @@ -7,5 +7,9 @@ static int f(int); int f(int); static void g(int); -// expected-error@-1 {{functions that differ only in their return type cannot be overloaded}} +// FIXME: Whether we notice the problem here depends on the order in which we +// happen to find lookup results for 'g'; LookupResult::resolveKind needs to +// be taught to prefer a visible result over a non-visible one. +// +// expected-error@9 {{functions that differ only in their return type cannot be overloaded}} // expected-note@Inputs/linkage-merge-foo.h:2 {{previous declaration is here}} diff --git a/test/Modules/macro-ambiguity.cpp b/test/Modules/macro-ambiguity.cpp new file mode 100644 index 000000000000..af43b35839ab --- /dev/null +++ b/test/Modules/macro-ambiguity.cpp @@ -0,0 +1,136 @@ +// RUN: rm -rf %t +// RUN: cd %S +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -v \ +// RUN: -iquote Inputs/macro-ambiguity/a/quote \ +// RUN: -isystem Inputs/macro-ambiguity/a/system \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=a -o %t/a.pcm \ +// RUN: Inputs/macro-ambiguity/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -v \ +// RUN: -iquote Inputs/macro-ambiguity/b/quote \ +// RUN: -isystem Inputs/macro-ambiguity/b/system \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=b -o %t/b.pcm \ +// RUN: Inputs/macro-ambiguity/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -v \ +// RUN: -iquote Inputs/macro-ambiguity/c/quote \ +// RUN: -isystem Inputs/macro-ambiguity/c/system \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=c -o %t/c.pcm \ +// RUN: Inputs/macro-ambiguity/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -v \ +// RUN: -iquote Inputs/macro-ambiguity/d/quote \ +// RUN: -isystem Inputs/macro-ambiguity/d/system \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=d -o %t/d.pcm \ +// RUN: Inputs/macro-ambiguity/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -v \ +// RUN: -iquote Inputs/macro-ambiguity/a/quote \ +// RUN: -isystem Inputs/macro-ambiguity/a/system \ +// RUN: -iquote Inputs/macro-ambiguity/b/quote \ +// RUN: -isystem Inputs/macro-ambiguity/b/system \ +// RUN: -iquote Inputs/macro-ambiguity/c/quote \ +// RUN: -isystem Inputs/macro-ambiguity/c/system \ +// RUN: -iquote Inputs/macro-ambiguity/d/quote \ +// RUN: -isystem Inputs/macro-ambiguity/d/system \ +// RUN: -iquote Inputs/macro-ambiguity/e/quote \ +// RUN: -isystem Inputs/macro-ambiguity/e/system \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/macro-ambiguity/module.modulemap \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-file=%t/b.pcm \ +// RUN: -fmodule-file=%t/c.pcm \ +// RUN: -fmodule-file=%t/d.pcm \ +// RUN: -Wambiguous-macro -verify macro-ambiguity.cpp +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -v -fmodules-local-submodule-visibility \ +// RUN: -iquote Inputs/macro-ambiguity/a/quote \ +// RUN: -isystem Inputs/macro-ambiguity/a/system \ +// RUN: -iquote Inputs/macro-ambiguity/b/quote \ +// RUN: -isystem Inputs/macro-ambiguity/b/system \ +// RUN: -iquote Inputs/macro-ambiguity/c/quote \ +// RUN: -isystem Inputs/macro-ambiguity/c/system \ +// RUN: -iquote Inputs/macro-ambiguity/d/quote \ +// RUN: -isystem Inputs/macro-ambiguity/d/system \ +// RUN: -iquote Inputs/macro-ambiguity/e/quote \ +// RUN: -isystem Inputs/macro-ambiguity/e/system \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/macro-ambiguity/module.modulemap \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-file=%t/b.pcm \ +// RUN: -fmodule-file=%t/c.pcm \ +// RUN: -fmodule-file=%t/d.pcm \ +// RUN: -Wambiguous-macro -verify macro-ambiguity.cpp + +// Include the textual headers first to maximize the ways in which things can +// become ambiguous. +#include "e_quote.h" +#include <e_system.h> + +#include "a_quote.h" +#include <a_system.h> +#include "b_quote.h" +#include <b_system.h> +#include "c_quote.h" +#include <c_system.h> +#include "d_quote.h" +#include <d_system.h> + +int test(int x) { + // We expect to get warnings for all of the quoted includes but none of the + // system includes here because the first module is a non-system module and + // the quote macros come from non-system-headers. + x = FOO1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} + // expected-note@Inputs/macro-ambiguity/c/quote/c_quote.h:4 {{expanding this definition}} + // expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:4 {{other definition}} + + x = FOO1_SYSTEM(x); + + x = BAR1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} + // expected-note@Inputs/macro-ambiguity/d/quote/d_quote.h:4 {{expanding this definition}} + // expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:5 {{other definition}} + + x = BAR1_SYSTEM(x); + + x = BAZ1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} + // expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:6 {{expanding this definition}} + // expected-note@Inputs/macro-ambiguity/e/quote/e_quote.h:4 {{other definition}} + + x = BAZ1_SYSTEM(x); + + // Here, we don't even warn on bar because in that cas both b and d are + // system modules and so the use of non-system headers is irrelevant. + x = FOO2_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} + // expected-note@Inputs/macro-ambiguity/c/quote/c_quote.h:5 {{expanding this definition}} + // expected-note@Inputs/macro-ambiguity/b/quote/b_quote.h:4 {{other definition}} + + x = FOO2_SYSTEM(x); + + x = BAR2_QUOTE(x); + + x = BAR2_SYSTEM(x); + + x = BAZ2_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} + // expected-note@Inputs/macro-ambiguity/b/quote/b_quote.h:6 {{expanding this definition}} + // expected-note@Inputs/macro-ambiguity/e/quote/e_quote.h:5 {{other definition}} + + x = BAZ2_SYSTEM(x); + return x; +} diff --git a/test/Modules/macro-masking.cpp b/test/Modules/macro-masking.cpp new file mode 100644 index 000000000000..3d4e8e0ba49a --- /dev/null +++ b/test/Modules/macro-masking.cpp @@ -0,0 +1,16 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fsyntax-only -fmodules %s -fmodules-cache-path=%t -verify -I%S/Inputs/macro-masking +// RxN: %clang_cc1 -fsyntax-only -fmodules -fmodules-local-submodule-visibility %s -fmodules-cache-path=%t -verify -I%S/Inputs/macro-masking -DLOCAL_VISIBILITY +// expected-no-diagnostics + +#include "a.h" + +#ifdef LOCAL_VISIBILITY +# ifndef MACRO +# error should still be defined, undef does not override define +# endif +#else +# ifdef MACRO +# error should have been undefined! +# endif +#endif diff --git a/test/Modules/macro-reexport.cpp b/test/Modules/macro-reexport.cpp new file mode 100644 index 000000000000..2be6f1532cb4 --- /dev/null +++ b/test/Modules/macro-reexport.cpp @@ -0,0 +1,39 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fsyntax-only -DC1 -I%S/Inputs/macro-reexport %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fsyntax-only -DC1 -I%S/Inputs/macro-reexport -fmodules %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fsyntax-only -DD1 -I%S/Inputs/macro-reexport %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fsyntax-only -DD1 -I%S/Inputs/macro-reexport -fmodules %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fsyntax-only -DD2 -I%S/Inputs/macro-reexport %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fsyntax-only -DD2 -I%S/Inputs/macro-reexport -fmodules %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fsyntax-only -DF1 -I%S/Inputs/macro-reexport %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fsyntax-only -DF1 -I%S/Inputs/macro-reexport -fmodules %s -fmodules-cache-path=%t -verify +// +// RUN: %clang_cc1 -fmodules-local-submodule-visibility -fsyntax-only -DC1 -I%S/Inputs/macro-reexport %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fmodules-local-submodule-visibility -fsyntax-only -DC1 -I%S/Inputs/macro-reexport -fmodules %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fmodules-local-submodule-visibility -fsyntax-only -DD1 -I%S/Inputs/macro-reexport %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fmodules-local-submodule-visibility -fsyntax-only -DD1 -I%S/Inputs/macro-reexport -fmodules %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fmodules-local-submodule-visibility -fsyntax-only -DD2 -I%S/Inputs/macro-reexport %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fmodules-local-submodule-visibility -fsyntax-only -DD2 -I%S/Inputs/macro-reexport -fmodules %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fmodules-local-submodule-visibility -fsyntax-only -DF1 -I%S/Inputs/macro-reexport %s -fmodules-cache-path=%t -verify +// RUN: %clang_cc1 -fmodules-local-submodule-visibility -fsyntax-only -DF1 -I%S/Inputs/macro-reexport -fmodules %s -fmodules-cache-path=%t -verify + +#if defined(F1) +#include "f1.h" +void f() { return assert(true); } // expected-error {{undeclared identifier 'd'}} +#include "e2.h" // undefines d1's macro +void g() { return assert(true); } // expected-error {{undeclared identifier 'assert'}} +#elif defined(D1) +#include "e1.h" // undefines c1's macro but not d1's macro +#include "d1.h" +void f() { return assert(true); } // expected-error {{undeclared identifier 'd'}} +#include "e2.h" // undefines d1's macro +void g() { return assert(true); } // expected-error {{undeclared identifier 'assert'}} +#elif defined(D2) +#include "d2.h" +void f() { return assert(true); } // expected-error {{undeclared identifier 'b'}} +#else +// e2 undefines d1's macro, which overrides c1's macro. +#include "e2.h" +#include "c1.h" +void f() { return assert(true); } // expected-error {{undeclared identifier 'assert'}} +#endif diff --git a/test/Modules/macro-reexport/macro-reexport.cpp b/test/Modules/macro-reexport/macro-reexport.cpp deleted file mode 100644 index af2ec847ce07..000000000000 --- a/test/Modules/macro-reexport/macro-reexport.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fsyntax-only -DC1 -I. %s -fmodules-cache-path=%t -verify -// RUN: %clang_cc1 -fsyntax-only -DC1 -I. -fmodules %s -fmodules-cache-path=%t -verify -// RUN: %clang_cc1 -fsyntax-only -DD1 -I. %s -fmodules-cache-path=%t -verify -// RUN: %clang_cc1 -fsyntax-only -DD1 -I. -fmodules %s -fmodules-cache-path=%t -verify -// RUN: %clang_cc1 -fsyntax-only -DD2 -I. %s -fmodules-cache-path=%t -verify -// RUN: %clang_cc1 -fsyntax-only -DD2 -I. -fmodules %s -fmodules-cache-path=%t -verify -// RUN: %clang_cc1 -fsyntax-only -DF1 -I. %s -fmodules-cache-path=%t -verify -// RUN: %clang_cc1 -fsyntax-only -DF1 -I. -fmodules %s -fmodules-cache-path=%t -verify - -#if defined(F1) -#include "f1.h" -void f() { return assert(true); } // expected-error {{undeclared identifier 'd'}} -#include "e2.h" // undefines d1's macro -void g() { return assert(true); } // expected-error {{undeclared identifier 'assert'}} -#elif defined(D1) -#include "e1.h" // undefines c1's macro but not d1's macro -#include "d1.h" -void f() { return assert(true); } // expected-error {{undeclared identifier 'd'}} -#include "e2.h" // undefines d1's macro -void g() { return assert(true); } // expected-error {{undeclared identifier 'assert'}} -#elif defined(D2) -#include "d2.h" -void f() { return assert(true); } // expected-error {{undeclared identifier 'b'}} -#else -// e2 undefines d1's macro, which overrides c1's macro. -#include "e2.h" -#include "c1.h" -void f() { return assert(true); } // expected-error {{undeclared identifier 'assert'}} -#endif diff --git a/test/Modules/macros.c b/test/Modules/macros.c index 92ea88a48020..538d4a8d6a74 100644 --- a/test/Modules/macros.c +++ b/test/Modules/macros.c @@ -1,9 +1,7 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_top %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_left %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_right %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s +// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s -detailed-preprocessing-record +// RUN: %clang_cc1 -fmodules -DLOCAL_VISIBILITY -fmodules-local-submodule-visibility -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s // RUN: not %clang_cc1 -E -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix CHECK-PREPROCESSED %s // FIXME: When we have a syntax for modules in C, use that. // These notes come from headers in modules, and are bogus. @@ -13,6 +11,7 @@ // expected-note@Inputs/macros_right.h:12{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}} // expected-note@Inputs/macros_right.h:13{{expanding this definition of 'LEFT_RIGHT_DIFFERENT2'}} // expected-note@Inputs/macros_left.h:14{{other definition of 'LEFT_RIGHT_DIFFERENT'}} +// expected-note@Inputs/macros_left.h:11{{other definition of 'LEFT_RIGHT_DIFFERENT2'}} @import macros; @@ -28,6 +27,10 @@ # error MODULE macro should not be visible #endif +#ifndef INDIRECTLY_IN_MACROS +# error INDIRECTLY_IN_MACROS should be visible +#endif + // CHECK-PREPROCESSED: double d double d; DOUBLE *dp = &d; @@ -138,11 +141,20 @@ TOP_DEF_RIGHT_UNDEF *TDRUf() { return TDRUp; } int TOP_DEF_RIGHT_UNDEF; // ok, no longer defined -// FIXME: When macros_right.undef is built, macros_top is visible because -// the state from building macros_right leaks through, so macros_right.undef -// undefines macros_top's macro. -#ifdef TOP_RIGHT_UNDEF -# error TOP_RIGHT_UNDEF should not be defined +#ifdef LOCAL_VISIBILITY +// TOP_RIGHT_UNDEF should not be undefined, because macros_right.undef does +// not undefine macros_right's macro. +# ifndef TOP_RIGHT_UNDEF +# error TOP_RIGHT_UNDEF should still be defined +# endif +#else +// When macros_right.undef is built and local submodule visibility is not +// enabled, macros_top is visible because the state from building +// macros_right leaks through, so macros_right.undef undefines macros_top's +// macro. +# ifdef TOP_RIGHT_UNDEF +# error TOP_RIGHT_UNDEF should not be defined +# endif #endif @import macros_other; diff --git a/test/Modules/macros2.c b/test/Modules/macros2.c index c4c8059011cc..0bb801ee995b 100644 --- a/test/Modules/macros2.c +++ b/test/Modules/macros2.c @@ -1,9 +1,6 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_top %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_left %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_right %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s +// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s -DLOCAL_VISIBILITY // This test checks some of the same things as macros.c, but imports modules in // a different order. @@ -49,9 +46,15 @@ void test() { @import macros_right.undef; -// FIXME: See macros.c. -#ifdef TOP_RIGHT_UNDEF -# error TOP_RIGHT_UNDEF should not be defined +// See macros.c. +#ifdef LOCAL_VISIBILITY +# ifndef TOP_RIGHT_UNDEF +# error TOP_RIGHT_UNDEF should still be defined +# endif +#else +# ifdef TOP_RIGHT_UNDEF +# error TOP_RIGHT_UNDEF should not be defined +# endif #endif #ifndef TOP_OTHER_UNDEF1 diff --git a/test/Modules/malformed.cpp b/test/Modules/malformed.cpp index 2554c3a8729f..2d07c4cd0da7 100644 --- a/test/Modules/malformed.cpp +++ b/test/Modules/malformed.cpp @@ -1,8 +1,6 @@ // This test explicitly cd's to the test/Modules directory so that we can test // that filenames found via relative -I paths are printed correctly. // -// REQUIRES: shell -// // RUN: rm -rf %t // RUN: cd %S // RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I Inputs/malformed -DHEADER="a1.h" %s 2>&1 | FileCheck %s --check-prefix=CHECK-A @@ -32,6 +30,6 @@ void test() { f<int>(); } // Test that we use relative paths to name files within an imported module. // -// CHECK-C: In module 'c' imported from malformed.cpp:14: +// CHECK-C: In module 'c' imported from malformed.cpp:12: // CHECK-C: {{^}}Inputs/malformed/c.h:1:33: error: type 'int' cannot be used prior to '::' // CHECK-C: {{^}}malformed.cpp:[[@LINE-5]]:15: note: in instantiation of diff --git a/test/Modules/merge-anon-in-template.cpp b/test/Modules/merge-anon-in-template.cpp new file mode 100644 index 000000000000..6e4e6e09e9cd --- /dev/null +++ b/test/Modules/merge-anon-in-template.cpp @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-anon-in-template -verify %s +// expected-no-diagnostics +#include "a.h" +#include "c.h" +is_floating<int>::type t; diff --git a/test/Modules/merge-decl-context.cpp b/test/Modules/merge-decl-context.cpp new file mode 100644 index 000000000000..208ba9212e82 --- /dev/null +++ b/test/Modules/merge-decl-context.cpp @@ -0,0 +1,28 @@ +// RUN: rm -rf %t + +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=b -o %t/b.pcm -fmodule-maps \ +// RUN: -emit-module %S/Inputs/merge-decl-context/merge-decl-context.modulemap -I%S/Inputs \ +// RUN: -I %S/Inputs/merge-decl-context +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=c -o %t/c.pcm -fmodule-maps \ +// RUN: -fmodule-file=%t/b.pcm -fno-implicit-modules \ +// RUN: -emit-module %S/Inputs/merge-decl-context/merge-decl-context.modulemap -I%S/Inputs \ +// RUN: -I %S/Inputs/merge-decl-context +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=d -o %t/d.pcm -fmodule-maps \ +// RUN: -fmodule-file=%t/b.pcm -fno-implicit-modules \ +// RUN: -emit-module %S/Inputs/merge-decl-context/merge-decl-context.modulemap -I%S/Inputs \ +// RUN: -I %S/Inputs/merge-decl-context + +// Use the two modules in a single compile. +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%t/c.pcm -fmodule-file=%t/b.pcm \ +// RUN: -fmodule-file=%t/d.pcm -fno-implicit-modules \ +// RUN: -fmodule-map-file=%S/Inputs/merge-decl-context/merge-decl-context.modulemap -I%S/Inputs \ +// RUN: -emit-llvm -o %t/test.o %s + +#include "Inputs/merge-decl-context/a.h" +#include "Inputs/merge-decl-context/b.h" +#include "Inputs/merge-decl-context/c.h" +#include "Inputs/merge-decl-context/d.h" + +void t() { + ff(42); +} diff --git a/test/Modules/merge-decl-order.cpp b/test/Modules/merge-decl-order.cpp new file mode 100644 index 000000000000..d3b21fdf8ae5 --- /dev/null +++ b/test/Modules/merge-decl-order.cpp @@ -0,0 +1,9 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-decl-order -verify %s +// expected-no-diagnostics + +// Check that we include all decls from 'a' before the decls from 'b' in foo's +// redecl chain. If we don't, then name lookup only finds invisible friend +// declarations and the lookup below will fail. +#include "b.h" +N::foo *use; diff --git a/test/Modules/merge-dependent-friends.cpp b/test/Modules/merge-dependent-friends.cpp new file mode 100644 index 000000000000..0b0c903c318f --- /dev/null +++ b/test/Modules/merge-dependent-friends.cpp @@ -0,0 +1,4 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-dependent-friends -verify %s +// expected-no-diagnostics +#include "d.h" diff --git a/test/Modules/merge-friends.cpp b/test/Modules/merge-friends.cpp new file mode 100644 index 000000000000..8284bfee680a --- /dev/null +++ b/test/Modules/merge-friends.cpp @@ -0,0 +1,5 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-friends -verify %s +// expected-no-diagnostics +#include "friend.h" +N::foo *use; diff --git a/test/Modules/merge-implicit-special-members.cpp b/test/Modules/merge-implicit-special-members.cpp new file mode 100644 index 000000000000..a8b917cb01b9 --- /dev/null +++ b/test/Modules/merge-implicit-special-members.cpp @@ -0,0 +1,5 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-implicit-special-members -verify %s +// expected-no-diagnostics +#include "c.h" +int n = pthread_mutex_t().lock; diff --git a/test/Modules/merge-name-for-linkage.cpp b/test/Modules/merge-name-for-linkage.cpp new file mode 100644 index 000000000000..1700b610a5c2 --- /dev/null +++ b/test/Modules/merge-name-for-linkage.cpp @@ -0,0 +1,8 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-name-for-linkage -verify %s +// expected-no-diagnostics +typedef union {} pthread_mutex_t; +#include "a.h" +pthread_mutex_t x; +#include "b.h" +pthread_mutex_t y; diff --git a/test/Modules/merge-nested-templates.cpp b/test/Modules/merge-nested-templates.cpp new file mode 100644 index 000000000000..42764eaed64f --- /dev/null +++ b/test/Modules/merge-nested-templates.cpp @@ -0,0 +1,4 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-nested-templates -verify %s +// expected-no-diagnostics +#include "c.h" diff --git a/test/Modules/merge-target-features.cpp b/test/Modules/merge-target-features.cpp new file mode 100644 index 000000000000..ccf3aab3d0fa --- /dev/null +++ b/test/Modules/merge-target-features.cpp @@ -0,0 +1,66 @@ +// RUN: rm -rf %t +// RUN: cd %S +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -iquote Inputs/merge-target-features \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=foo -o %t/foo.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 -target-feature +sse2 \ +// RUN: Inputs/merge-target-features/module.modulemap +// +// RUN: not %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -iquote Inputs/merge-target-features \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/merge-target-features/module.modulemap \ +// RUN: -fmodule-file=%t/foo.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 \ +// RUN: -fsyntax-only merge-target-features.cpp 2>&1 \ +// RUN: | FileCheck --check-prefix=SUBSET %s +// SUBSET: AST file was compiled with the target feature'+sse2' but the current translation unit is not +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -iquote Inputs/merge-target-features \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/merge-target-features/module.modulemap \ +// RUN: -fmodule-file=%t/foo.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 -target-feature +sse2 \ +// RUN: -fsyntax-only merge-target-features.cpp 2>&1 \ +// RUN: | FileCheck --allow-empty --check-prefix=SAME %s +// SAME-NOT: error: +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -iquote Inputs/merge-target-features \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/merge-target-features/module.modulemap \ +// RUN: -fmodule-file=%t/foo.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 -target-feature +sse2 -target-feature +sse3 \ +// RUN: -fsyntax-only merge-target-features.cpp 2>&1 \ +// RUN: | FileCheck --allow-empty --check-prefix=SUPERSET %s +// SUPERSET-NOT: error: +// +// RUN: not %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -iquote Inputs/merge-target-features \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/merge-target-features/module.modulemap \ +// RUN: -fmodule-file=%t/foo.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 -target-feature +cx16 \ +// RUN: -fsyntax-only merge-target-features.cpp 2>&1 \ +// RUN: | FileCheck --check-prefix=MISMATCH %s +// MISMATCH: AST file was compiled with the target feature'+sse2' but the current translation unit is not +// MISMATCH: current translation unit was compiled with the target feature'+cx16' but the AST file was not + +#include "foo.h" + +int test(int x) { + return foo(x); +} diff --git a/test/Modules/merge-template-friend.cpp b/test/Modules/merge-template-friend.cpp new file mode 100644 index 000000000000..8a1910dad620 --- /dev/null +++ b/test/Modules/merge-template-friend.cpp @@ -0,0 +1,22 @@ +// RUN: rm -rf %t +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -emit-module -fmodule-name=a -o %t/a.pcm \ +// RUN: %S/Inputs/merge-template-friend/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -emit-module -fmodule-name=b -o %t/b.pcm \ +// RUN: %S/Inputs/merge-template-friend/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -I%S/Inputs/merge-template-friend \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-file=%t/b.pcm \ +// RUN: -verify %s + +#include "friend.h" +#include "def.h" + +::ns::C<int> c; + +// expected-no-diagnostics diff --git a/test/Modules/merge-template-members.cpp b/test/Modules/merge-template-members.cpp new file mode 100644 index 000000000000..1fdaa9c29be2 --- /dev/null +++ b/test/Modules/merge-template-members.cpp @@ -0,0 +1,27 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-template-members -verify -emit-llvm-only %s -DTEST=1 +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-template-members -verify -emit-llvm-only %s -DTEST=2 +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-template-members -verify -emit-llvm-only %s -DTEST=3 +// expected-no-diagnostics + +#if TEST == 1 + +template<typename> struct A { int n; }; +template<typename> struct B { typedef A<void> C; }; +template class B<int>; + +#include "update.h" +B<int>::C use2; + +#elif TEST == 2 + +#include "c.h" +N::A<int> ai; + +#elif TEST == 3 + +#include "merge.h" + +#else +#error Unknown test +#endif diff --git a/test/Modules/merge-vtable-codegen.cpp b/test/Modules/merge-vtable-codegen.cpp new file mode 100644 index 000000000000..7372073891c5 --- /dev/null +++ b/test/Modules/merge-vtable-codegen.cpp @@ -0,0 +1,24 @@ +// RUN: rm -rf %t + +// First, build two modules that both re-export the same header. +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=b -o %t/b.pcm -fmodule-maps \ +// RUN: -emit-module %S/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap \ +// RUN: -I %S/Inputs/merge-vtable-codegen +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=c -o %t/c.pcm -fmodule-maps \ +// RUN: -emit-module %S/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap \ +// RUN: -I %S/Inputs/merge-vtable-codegen + +// Use the two modules in a single compile. +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%t/b.pcm -fmodule-file=%t/c.pcm \ +// RUN: -fmodule-map-file=%S/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap \ +// RUN: -emit-llvm -o %t/test.o %s + +// Note that order is important: +// Module 'c' just reexports A, while module 'b' defines a method that uses a +// virtual method of A. +#include "Inputs/merge-vtable-codegen/c.h" +#include "Inputs/merge-vtable-codegen/b.h" + +void t() { + b(nullptr); +} diff --git a/test/Modules/modular_maps.cpp b/test/Modules/modular_maps.cpp index 606c979c4c2f..bedf2e02fb4c 100644 --- a/test/Modules/modular_maps.cpp +++ b/test/Modules/modular_maps.cpp @@ -11,9 +11,6 @@ // RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=Inputs/modular_maps/modulea-cwd.map -fmodule-map-file=Inputs/modular_maps/modulec-cwd.map -I Inputs/modular_maps %s -verify -fmodule-map-file-home-is-cwd // RxN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=Inputs/modular_maps/modulec-cwd.map -fmodule-map-file=Inputs/modular_maps/modulea-cwd.map -I Inputs/modular_maps %s -verify -fmodule-map-file-home-is-cwd -// chdir is unsupported on Lit internal runner. -// REQUIRES: shell - #include "common.h" #include "a.h" #include "b.h" // expected-error {{private header}} diff --git a/test/Modules/modulemap-locations.m b/test/Modules/modulemap-locations.m index 9acdcd63436b..949c4786263d 100644 --- a/test/Modules/modulemap-locations.m +++ b/test/Modules/modulemap-locations.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/ModuleMapLocations/Module_ModuleMap -I %S/Inputs/ModuleMapLocations/Both -F %S/Inputs/ModuleMapLocations -x objective-c -fsyntax-only %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/ModuleMapLocations/Module_ModuleMap -I %S/Inputs/ModuleMapLocations/Both -F %S/Inputs/ModuleMapLocations -I %S/Inputs/ModuleMapLocations -F %S/Inputs -x objective-c -fsyntax-only %s -verify // regular @import module_modulemap; diff --git a/test/Modules/no-implicit-builds.cpp b/test/Modules/no-implicit-builds.cpp new file mode 100644 index 000000000000..d9e8fa1da1c8 --- /dev/null +++ b/test/Modules/no-implicit-builds.cpp @@ -0,0 +1,33 @@ +// RUN: rm -rf %t + +// Produce an error if a module is needed, but not found. +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \ +// RUN: -fno-implicit-modules %s -verify + +// Compile the module and put it into the cache. +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \ +// RUN: %s -Rmodule-build 2>&1 | FileCheck --check-prefix=CHECK-CACHE-BUILD %s +// CHECK-CACHE-BUILD: {{building module 'b'}} + +// Produce an error if a module is found in the cache but implicit modules is off. +// Note that the command line must match the command line for the first check, otherwise +// this check might not find the module in the cache and trivially succeed. +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \ +// RUN: %s -Rmodule-build -fno-implicit-modules -verify + +// Verify that we can still pass the module via -fmodule-file when implicit modules +// are switched off: +// - First, explicitly compile the module: +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=b -o %t/b.pcm \ +// RUN: -emit-module %S/Inputs/no-implicit-builds/b.modulemap \ +// RUN: -fno-implicit-modules +// +// - Next, verify that we can load it: +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%t/b.pcm \ +// RUN: -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \ +// RUN: -fno-implicit-modules %s + +#include "Inputs/no-implicit-builds/b.h" // expected-error {{is needed but has not been provided}} diff --git a/test/Modules/odr.cpp b/test/Modules/odr.cpp index 120ca20e0a87..4ac257cd03aa 100644 --- a/test/Modules/odr.cpp +++ b/test/Modules/odr.cpp @@ -15,9 +15,9 @@ bool b = F<int>{0} == F<int>{1}; int x = f() + g(); // expected-note@a.h:5 {{definition has no member 'e2'}} -// expected-note@a.h:3 {{declaration of 'f' does not match}} -// expected-note@a.h:1 {{definition has no member 'm'}} +// expected-note@b.h:3 {{declaration of 'f' does not match}} +// expected-note@b.h:1 {{definition has no member 'n'}} // expected-error@b.h:5 {{'E::e2' from module 'b' is not present in definition of 'E' in module 'a'}} -// expected-error@b.h:3 {{'Y::f' from module 'b' is not present in definition of 'Y' in module 'a'}} -// expected-error@b.h:2 {{'Y::m' from module 'b' is not present in definition of 'Y' in module 'a'}} +// expected-error@a.h:3 {{'Y::f' from module 'a' is not present in definition of 'Y' in module 'b'}} +// expected-error@a.h:2 {{'Y::n' from module 'a' is not present in definition of 'Y' in module 'b'}} diff --git a/test/Modules/pr21687.cpp b/test/Modules/pr21687.cpp new file mode 100644 index 000000000000..ad67489541d8 --- /dev/null +++ b/test/Modules/pr21687.cpp @@ -0,0 +1,3 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/PR21687 -emit-llvm-only %s +#include "c.h" diff --git a/test/Modules/preprocess.m b/test/Modules/preprocess.m index 5c32997f62fb..9b563fef821c 100644 --- a/test/Modules/preprocess.m +++ b/test/Modules/preprocess.m @@ -1,9 +1,14 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -include %S/Inputs/preprocess-prefix.h -E %s | FileCheck -strict-whitespace %s -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -x objective-c-header -emit-pch %S/Inputs/preprocess-prefix.h -o %t.pch -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -include-pch %t.pch -E %s | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -I %S/Inputs/preprocess -include %S/Inputs/preprocess-prefix.h -E %s | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -I %S/Inputs/preprocess -x objective-c-header -emit-pch %S/Inputs/preprocess-prefix.h -o %t.pch +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -I %S/Inputs/preprocess -include-pch %t.pch -E %s | FileCheck -strict-whitespace %s +// +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -I %S/Inputs/preprocess -x objective-c++ -include %S/Inputs/preprocess-prefix.h -E %s | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -I %S/Inputs/preprocess -x objective-c++-header -emit-pch %S/Inputs/preprocess-prefix.h -o %t.pch +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -I %S/Inputs/preprocess -x objective-c++ -include-pch %t.pch -E %s | FileCheck -strict-whitespace %s #import "diamond_right.h" #import "diamond_right.h" // to check that imports get their own line +#include "file.h" void test() { top_left_before(); left_and_right(); @@ -15,6 +20,7 @@ void test() { // CHECK: @import diamond_right; /* clang -E: implicit import for "{{.*}}diamond_right.h" */{{$}} // CHECK: @import diamond_right; /* clang -E: implicit import for "{{.*}}diamond_right.h" */{{$}} +// CHECK: @import file; /* clang -E: implicit import for "{{.*}}file.h" */{{$}} // CHECK-NEXT: void test() {{{$}} // CHECK-NEXT: top_left_before();{{$}} // CHECK-NEXT: left_and_right();{{$}} diff --git a/test/Modules/private.cpp b/test/Modules/private.cpp index 93b4b9457f44..31e60e47e3d5 100644 --- a/test/Modules/private.cpp +++ b/test/Modules/private.cpp @@ -1,5 +1,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -x objective-c -fmodules-cache-path=%t -fmodules -I %S/Inputs/private %s -verify +// RUN: %clang_cc1 -x objective-c -fmodules-cache-path=%t -fmodules -I %S/Inputs/private %s -fsyntax-only -Wno-private-header #include "common.h" @import libPrivate1; diff --git a/test/Modules/public-private.modulemap b/test/Modules/public-private.modulemap new file mode 100644 index 000000000000..a898a1b74363 --- /dev/null +++ b/test/Modules/public-private.modulemap @@ -0,0 +1,11 @@ +// RUN: rm -rf %t.modules +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.modules -fmodule-map-file=%s -I%S -include "Inputs/empty.h" /dev/null +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.modules -fmodule-map-file=%s -I%S -include "Inputs/dummy.h" /dev/null +module A { + header "Inputs/empty.h" + private header "Inputs/empty.h" +} +module B { + private header "Inputs/dummy.h" + header "Inputs/dummy.h" +} diff --git a/test/Modules/redecl-add-after-load.cpp b/test/Modules/redecl-add-after-load.cpp index 68deaf8b4ef9..8ca70ad9580b 100644 --- a/test/Modules/redecl-add-after-load.cpp +++ b/test/Modules/redecl-add-after-load.cpp @@ -2,8 +2,9 @@ // RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 // RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 -DIMPORT_DECLS -#ifdef IMPORT_DECLS // expected-no-diagnostics + +#ifdef IMPORT_DECLS @import redecl_add_after_load_decls; #else typedef struct A B; @@ -24,12 +25,12 @@ typedef C::A CB; constexpr int C_test(bool b) { return b ? C::variable : C::function(); } struct D { - struct A; // expected-note {{forward}} + struct A; static const int variable; - static constexpr int function(); // expected-note {{here}} + static constexpr int function(); }; typedef D::A DB; -constexpr int D_test(bool b) { return b ? D::variable : D::function(); } // expected-note {{subexpression}} expected-note {{undefined}} +constexpr int D_test(bool b) { return b ? D::variable : D::function(); } #endif @import redecl_add_after_load; @@ -46,14 +47,6 @@ CB struct_struct_test; constexpr int struct_variable_test = C_test(true); constexpr int struct_function_test = C_test(false); -// FIXME: We should accept this, but we're currently too lazy when merging class -// definitions to determine that the definitions in redecl_add_after_load are -// definitions of these entities. DB merged_struct_struct_test; constexpr int merged_struct_variable_test = D_test(true); constexpr int merged_struct_function_test = D_test(false); -#ifndef IMPORT_DECLS -// expected-error@-4 {{incomplete}} -// expected-error@-4 {{constant}} expected-note@-4 {{in call to}} -// expected-error@-4 {{constant}} expected-note@-4 {{in call to}} -#endif diff --git a/test/Modules/redecl-found-building-chains.cpp b/test/Modules/redecl-found-building-chains.cpp new file mode 100644 index 000000000000..1173863cebad --- /dev/null +++ b/test/Modules/redecl-found-building-chains.cpp @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/redecl-found-building-chains -verify %s +// expected-no-diagnostics +int n, m; +#include "d.h" +A a; diff --git a/test/Modules/redecl-templates.cpp b/test/Modules/redecl-templates.cpp new file mode 100644 index 000000000000..6bbec02f1056 --- /dev/null +++ b/test/Modules/redecl-templates.cpp @@ -0,0 +1,32 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -I %S/Inputs/redecl-templates %s -verify -std=c++14 +// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs/redecl-templates %s -verify -std=c++14 +// expected-no-diagnostics + +template<int N> struct A {}; +template<int N> using X = A<N>; + +template<int N> constexpr void f() {} +template<int N> constexpr void g() { f<N>(); } + +template<int N> extern int v; +template<int N> int &w = v<N>; + +#include "a.h" + +// Be careful not to mention A here, that'll import the decls from "a.h". +int g(X<1> *); +X<1> *p = 0; + +// This will implicitly instantiate A<1> if we haven't imported the explicit +// specialization declaration from "a.h". +int k = g(p); +// Likewise for f and v. +void h() { g<1>(); } +int &x = w<1>; + +// This is OK: we declared the explicit specialization before we triggered +// instantiation of this specialization. +template<> struct A<1> {}; +template<> constexpr void f<1>() {} +template<> int v<1>; diff --git a/test/Modules/redecls/main.m b/test/Modules/redecls.m index bf3788a96d80..fa643b90ac8a 100644 --- a/test/Modules/redecls/main.m +++ b/test/Modules/redecls.m @@ -1,9 +1,7 @@ // RUN: rm -rf %t.mcp -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=a %S/module.map -fmodules-cache-path=%t.mcp -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=b %S/module.map -fmodules-cache-path=%t.mcp -// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t1.pch -fmodules-cache-path=%t.mcp -I %S -// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t2.pch -include-pch %t1.pch -fmodules-cache-path=%t.mcp -I %S -// RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -I %S -fmodules-cache-path=%t.mcp -verify +// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t1.pch -fmodules-cache-path=%t.mcp -I %S/Inputs/redecls +// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t2.pch -include-pch %t1.pch -fmodules-cache-path=%t.mcp -I %S/Inputs/redecls +// RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -I %S/Inputs/redecls -fmodules-cache-path=%t.mcp -verify #ifndef HEADER1 #define HEADER1 diff --git a/test/Modules/relative-dep-gen.cpp b/test/Modules/relative-dep-gen.cpp index c8171777154a..86c465147742 100644 --- a/test/Modules/relative-dep-gen.cpp +++ b/test/Modules/relative-dep-gen.cpp @@ -1,20 +1,18 @@ -// REQUIRES: shell -// // RUN: cd %S // RUN: rm -rf %t // RUN: mkdir %t // -// RUN: %clang_cc1 -cc1 -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen.modulemap -dependency-file %t/build.d -MT mod.pcm -o %t/mod.pcm -// RUN: %clang_cc1 -cc1 -fmodule-map-file=Inputs/relative-dep-gen.modulemap -fmodule-file=%t/mod.pcm -dependency-file %t/use-explicit.d -MT use.o relative-dep-gen.cpp -fsyntax-only -// RUN: %clang_cc1 -cc1 -fmodule-map-file=Inputs/relative-dep-gen.modulemap -dependency-file %t/use-implicit.d relative-dep-gen.cpp -MT use.o -fsyntax-only +// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen.modulemap -dependency-file %t/build.d -MT mod.pcm -o %t/mod.pcm +// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen.modulemap -fmodule-file=%t/mod.pcm -dependency-file %t/use-explicit.d -MT use.o relative-dep-gen.cpp -fsyntax-only +// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen.modulemap -dependency-file %t/use-implicit.d relative-dep-gen.cpp -MT use.o -fsyntax-only // // RUN: FileCheck --check-prefix=CHECK-BUILD %s < %t/build.d // RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit.d // RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-implicit.d // -// RUN: %clang_cc1 -cc1 -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/build-cwd.d -MT mod.pcm -o %t/mod-cwd.pcm -fmodule-map-file-home-is-cwd -// RUN: %clang_cc1 -cc1 -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -fmodule-file=%t/mod-cwd.pcm -dependency-file %t/use-explicit-cwd.d -MT use.o relative-dep-gen.cpp -fsyntax-only -fmodule-map-file-home-is-cwd -// RUN: %clang_cc1 -cc1 -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/use-implicit-cwd.d relative-dep-gen.cpp -MT use.o -fsyntax-only -fmodule-map-file-home-is-cwd +// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/build-cwd.d -MT mod.pcm -o %t/mod-cwd.pcm -fmodule-map-file-home-is-cwd +// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -fmodule-file=%t/mod-cwd.pcm -dependency-file %t/use-explicit-cwd.d -MT use.o relative-dep-gen.cpp -fsyntax-only -fmodule-map-file-home-is-cwd +// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/use-implicit-cwd.d relative-dep-gen.cpp -MT use.o -fsyntax-only -fmodule-map-file-home-is-cwd // // RUN: FileCheck --check-prefix=CHECK-BUILD %s < %t/build-cwd.d // RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit-cwd.d diff --git a/test/Modules/requires.m b/test/Modules/requires.m index b8b2c55698c4..ff0ddfeb3359 100644 --- a/test/Modules/requires.m +++ b/test/Modules/requires.m @@ -1,6 +1,8 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify +// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify -fmodule-feature custom_req1 @import DependsOnModule.CXX; // expected-error{{module 'DependsOnModule.CXX' requires feature 'cplusplus'}} @import DependsOnModule.NotCXX; @import DependsOnModule.NotObjC; // expected-error{{module 'DependsOnModule.NotObjC' is incompatible with feature 'objc'}} +@import DependsOnModule.CustomReq1; // OK +@import DependsOnModule.CustomReq2; // expected-error{{module 'DependsOnModule.CustomReq2' requires feature 'custom_req2'}} diff --git a/test/Modules/self-import-header.m b/test/Modules/self-import-header.m new file mode 100644 index 000000000000..9b4bd5dee520 --- /dev/null +++ b/test/Modules/self-import-header.m @@ -0,0 +1,9 @@ +// rdar://13840148 + +// RUN: rm -rf %t +// RUN: %clang -fsyntax-only -isysroot %S/Inputs/System/usr/include -fmodules -fmodules-cache-path=%t \ +// RUN: -target x86_64-darwin \ +// RUN: -F %S -F %S/Inputs/self-import-header -I %S/Inputs/self-import-header \ +// RUN: %s -D__need_wint_t -Werror=implicit-function-declaration + +@import af; diff --git a/test/Modules/self-import-header/test.m b/test/Modules/self-import-header/test.m deleted file mode 100644 index 377c01d66eb3..000000000000 --- a/test/Modules/self-import-header/test.m +++ /dev/null @@ -1,8 +0,0 @@ -// rdar://13840148 - -// RUN: rm -rf %t -// RUN: %clang -fsyntax-only -isysroot %S/../Inputs/System/usr/include -fmodules -fmodules-cache-path=%t \ -// RUN: -target x86_64-darwin \ -// RUN: -F %S -I %S %s -D__need_wint_t -Werror=implicit-function-declaration - -@import af; diff --git a/test/Modules/stress1.cpp b/test/Modules/stress1.cpp new file mode 100644 index 000000000000..df690aa7e657 --- /dev/null +++ b/test/Modules/stress1.cpp @@ -0,0 +1,114 @@ +// RUN: rm -rf %t +// RUN: cd %S +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=m00 -o %t/m00.pcm \ +// RUN: Inputs/stress1/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=m00 -o %t/m00_check.pcm \ +// RUN: Inputs/stress1/module.modulemap +// +// RUN: diff %t/m00.pcm %t/m00_check.pcm +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fdelayed-template-parsing \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=m01 -o %t/m01.pcm \ +// RUN: Inputs/stress1/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fdelayed-template-parsing \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=m01 -o %t/m01_check.pcm \ +// RUN: Inputs/stress1/module.modulemap +// +// RUN: diff %t/m01.pcm %t/m01_check.pcm +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=m02 -o %t/m02.pcm \ +// RUN: Inputs/stress1/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=m03 -o %t/m03.pcm \ +// RUN: Inputs/stress1/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-file=%t/m00.pcm \ +// RUN: -fmodule-file=%t/m01.pcm \ +// RUN: -fmodule-file=%t/m02.pcm \ +// RUN: -fmodule-file=%t/m03.pcm \ +// RUN: -emit-module -fmodule-name=merge00 -o %t/merge00.pcm \ +// RUN: Inputs/stress1/module.modulemap +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-file=%t/m00.pcm \ +// RUN: -fmodule-file=%t/m01.pcm \ +// RUN: -fmodule-file=%t/m02.pcm \ +// RUN: -fmodule-file=%t/m03.pcm \ +// RUN: -emit-module -fmodule-name=merge00 -o %t/merge00_check.pcm \ +// RUN: Inputs/stress1/module.modulemap +// +// RUN: diff %t/merge00.pcm %t/merge00_check.pcm +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/stress1/module.modulemap \ +// RUN: -fmodule-file=%t/m00.pcm \ +// RUN: -fmodule-file=%t/m01.pcm \ +// RUN: -fmodule-file=%t/m02.pcm \ +// RUN: -fmodule-file=%t/m03.pcm \ +// RUN: -fmodule-file=%t/merge00.pcm \ +// RUN: -verify stress1.cpp -S -emit-llvm -o %t/stress1.ll +// +// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \ +// RUN: -I Inputs/stress1 \ +// RUN: -fno-implicit-modules -fno-modules-implicit-maps \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/stress1/module.modulemap \ +// RUN: -fmodule-file=%t/m00.pcm \ +// RUN: -fmodule-file=%t/m01.pcm \ +// RUN: -fmodule-file=%t/m02.pcm \ +// RUN: -fmodule-file=%t/m03.pcm \ +// RUN: -fmodule-file=%t/merge00.pcm \ +// RUN: -verify stress1.cpp -S -emit-llvm -o %t/stress1_check.ll +// +// RUN: diff -u %t/stress1.ll %t/stress1_check.ll +// +// expected-no-diagnostics + +#include "m00.h" +#include "m01.h" +#include "m02.h" +#include "m03.h" + +#include "merge00.h" + +int f() { return N01::S00('a').method00('b') + (int)N00::S00(42) + function00(42) + g(); } + +int f2() { + return pragma_weak00() + pragma_weak01() + pragma_weak02() + + pragma_weak03 + pragma_weak04 + pragma_weak05; +} diff --git a/test/Modules/submodule-visibility-cycles.cpp b/test/Modules/submodule-visibility-cycles.cpp new file mode 100644 index 000000000000..fca8df9f77ee --- /dev/null +++ b/test/Modules/submodule-visibility-cycles.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fno-modules-error-recovery -fmodules-local-submodule-visibility -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s + +#include "cycle1.h" +C1 c1; +C2 c2; // expected-error {{must be imported}} expected-error {{}} +// expected-note@cycle2.h:6 {{here}} + +#include "cycle2.h" +C2 c3; diff --git a/test/Modules/submodule-visibility.cpp b/test/Modules/submodule-visibility.cpp new file mode 100644 index 000000000000..07be1c2d0c34 --- /dev/null +++ b/test/Modules/submodule-visibility.cpp @@ -0,0 +1,22 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s -DALLOW_NAME_LEAKAGE +// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s -DIMPORT +// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fmodule-name=x -I%S/Inputs/submodule-visibility -verify %s +// RUN: %clang_cc1 -fmodule-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s + +#include "a.h" +#include "b.h" + +#if ALLOW_NAME_LEAKAGE +// expected-no-diagnostics +#elif IMPORT +// expected-error@-6 {{could not build module 'x'}} +#else +// The use of -fmodule-name=x causes us to textually include the above headers. +// The submodule visibility rules are still applied in this case. +// +// expected-error@b.h:1 {{declaration of 'n' must be imported from module 'x.a'}} +// expected-note@a.h:1 {{here}} +#endif + +int k = n + m; // OK, a and b are visible here. diff --git a/test/Modules/submodules-merge-defs.cpp b/test/Modules/submodules-merge-defs.cpp new file mode 100644 index 000000000000..0e2f5d9e5468 --- /dev/null +++ b/test/Modules/submodules-merge-defs.cpp @@ -0,0 +1,56 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -DTEXTUAL +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility -DTEXTUAL +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility + +// Trigger import of definitions, but don't make them visible. +#include "empty.h" + +A pre_a; // expected-error {{must be imported}} expected-error {{must use 'struct'}} +// expected-note@defs.h:1 +{{here}} +// FIXME: We should warn that use_a is being used without being imported. +int pre_use_a = use_a(pre_a); // expected-error {{'A' must be imported}} + +B::Inner2 pre_bi; // expected-error +{{must be imported}} +// expected-note@defs.h:4 +{{here}} +// expected-note@defs.h:11 +{{here}} + +C_Base<1> pre_cb1; // expected-error +{{must be imported}} +// expected-note@defs.h:15 +{{here}} +C1 pre_c1; // expected-error +{{must be imported}} expected-error {{must use 'struct'}} +// expected-note@defs.h:17 +{{here}} +C2 pre_c2; // expected-error +{{must be imported}} expected-error {{must use 'struct'}} +// expected-note@defs.h:18 +{{here}} + +D::X pre_dx; // expected-error +{{must be imported}} +// expected-note@defs.h:20 +{{here}} +// expected-note@defs.h:21 +{{here}} +// FIXME: We should warn that use_dx is being used without being imported. +int pre_use_dx = use_dx(pre_dx); + +int pre_e = E(0); // expected-error {{must be imported}} +// expected-note@defs.h:24 +{{here}} + +int pre_ff = F<int>().f(); // expected-error +{{must be imported}} +int pre_fg = F<int>().g<int>(); // expected-error +{{must be imported}} +// expected-note@defs.h:26 +{{here}} + +// Make definitions from second module visible. +#ifdef TEXTUAL +#include "import-and-redefine.h" +#else +#include "merged-defs.h" +#endif + +A post_a; +int post_use_a = use_a(post_a); +B::Inner2 post_bi; +C_Base<1> post_cb1; +C1 c1; +C2 c2; +D::X post_dx; +int post_use_dx = use_dx(post_dx); +int post_e = E(0); +int post_ff = F<char>().f(); +int post_fg = F<char>().g<int>(); diff --git a/test/Modules/templates-2.mm b/test/Modules/templates-2.mm index b7ceafbbc5ba..8a752f761335 100644 --- a/test/Modules/templates-2.mm +++ b/test/Modules/templates-2.mm @@ -23,14 +23,14 @@ void testEmitDefaultedSpecialMembers() { // CHECK-LABEL: define {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED1Ev( // CHECK: call {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED2Ev( -// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED2Ev( -// CHECK: call void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EED2Ev( -// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EED2Ev( -// CHECK: call void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcED2Ev( -// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcED2Ev( - // CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EEC2Ev( // CHECK: call void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EEC2Ev( // CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EEC2Ev( // CHECK: call void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcEC2Ev( // CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcEC2Ev( + +// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED2Ev( +// CHECK: call void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EED2Ev( +// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EED2Ev( +// CHECK: call void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcED2Ev( +// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcED2Ev( diff --git a/test/Modules/templates.mm b/test/Modules/templates.mm index d60b873d0f38..aafe0186c3ec 100644 --- a/test/Modules/templates.mm +++ b/test/Modules/templates.mm @@ -86,8 +86,8 @@ unsigned testMixedStruct() { // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[r]]) useListInt(r); - // CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_left to i8*), i64 8) to i32*) - // CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_right to i8*), i64 8) to i32*) + // CHECK: load i32, i32* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @list_left to i8*), i64 8) to i32*) + // CHECK: load i32, i32* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @list_right to i8*), i64 8) to i32*) return list_left.*size_right + list_right.*size_left; } @@ -106,11 +106,11 @@ void testStaticDataMember() { WithUndefinedStaticDataMember<int[]> load_it; // CHECK-LABEL: define linkonce_odr i32* @_Z23getStaticDataMemberLeftv( - // CHECK: ret i32* getelementptr inbounds ([0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0) + // CHECK: ret i32* getelementptr inbounds ([0 x i32], [0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0) (void) getStaticDataMemberLeft(); // CHECK-LABEL: define linkonce_odr i32* @_Z24getStaticDataMemberRightv( - // CHECK: ret i32* getelementptr inbounds ([0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0) + // CHECK: ret i32* getelementptr inbounds ([0 x i32], [0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0) (void) getStaticDataMemberRight(); } diff --git a/test/Modules/update-exception-spec.cpp b/test/Modules/update-exception-spec.cpp new file mode 100644 index 000000000000..bccdddc9c09b --- /dev/null +++ b/test/Modules/update-exception-spec.cpp @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fmodules -fmodules-cache-path=%t -I%S/Inputs/update-exception-spec -emit-llvm-only %s +#include "a.h" +void use(B *p); +#include "c.h" +void use(B *p) { g(p); } diff --git a/test/Modules/warn-unused-local-typedef.cpp b/test/Modules/warn-unused-local-typedef.cpp index 60e0612d6ce7..030a52de4647 100644 --- a/test/Modules/warn-unused-local-typedef.cpp +++ b/test/Modules/warn-unused-local-typedef.cpp @@ -1,3 +1,4 @@ +// XFAIL: hexagon // RUN: rm -rf %t // RUN: %clang -Wunused-local-typedef -c -x objective-c++ -fcxx-modules -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -o /dev/null 2>&1 | FileCheck %s -check-prefix=CHECK_1 // RUN: %clang -Wunused-local-typedef -c -x objective-c++ -fcxx-modules -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -o /dev/null 2>&1 | FileCheck %s -check-prefix=CHECK_2 -allow-empty |