diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-01-18 16:23:48 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-01-18 16:23:48 +0000 |
commit | 06d4ba388873e6d1cfa9cd715a8935ecc8cd2097 (patch) | |
tree | 3eb853da77d46cc77c4b017525a422f9ddb1385b /test/Modules | |
parent | 30d791273d07fac9c0c1641a0731191bca6e8606 (diff) |
Notes
Diffstat (limited to 'test/Modules')
166 files changed, 1735 insertions, 81 deletions
diff --git a/test/Modules/Inputs/AddRemovePrivate.framework/Headers/AddRemovePrivate.h b/test/Modules/Inputs/AddRemovePrivate.framework/Headers/AddRemovePrivate.h new file mode 100644 index 0000000000000..3ab77431aa2cb --- /dev/null +++ b/test/Modules/Inputs/AddRemovePrivate.framework/Headers/AddRemovePrivate.h @@ -0,0 +1 @@ +// AddRemovePrivate.h diff --git a/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.modulemap b/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.modulemap new file mode 100644 index 0000000000000..7d84297a970fa --- /dev/null +++ b/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.modulemap @@ -0,0 +1 @@ +framework module AddRemovePrivate { umbrella header "AddRemovePrivate.h" } diff --git a/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.private.modulemap b/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.private.modulemap new file mode 100644 index 0000000000000..69b67c2cee7a3 --- /dev/null +++ b/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.private.modulemap @@ -0,0 +1 @@ +explicit module AddRemovePrivate.Private { } diff --git a/test/Modules/Inputs/PR20399/FirstHeader.h b/test/Modules/Inputs/PR20399/FirstHeader.h new file mode 100644 index 0000000000000..43adf3d847ed5 --- /dev/null +++ b/test/Modules/Inputs/PR20399/FirstHeader.h @@ -0,0 +1,14 @@ +#ifndef FIRSTHEADER +#define FIRSTHEADER + +#include "SecondHeader.h" // Just a class which gets in the lazy deserialization chain + +#include "stl_map.h" +#include "vector" +typedef std::map<int>::iterator el; + +inline void func() { + std::vector<int>::func(); +} + +#endif diff --git a/test/Modules/Inputs/PR20399/SecondHeader.h b/test/Modules/Inputs/PR20399/SecondHeader.h new file mode 100644 index 0000000000000..92815e996482c --- /dev/null +++ b/test/Modules/Inputs/PR20399/SecondHeader.h @@ -0,0 +1,13 @@ +#ifndef SECONDHEADER +#define SECONDHEADER + +#include "vector" + +template <class T> +struct Address {}; + +template <> +struct Address<std::vector<bool>> + : Address<std::vector<bool>::iterator> {}; + +#endif diff --git a/test/Modules/Inputs/PR20399/module.modulemap b/test/Modules/Inputs/PR20399/module.modulemap new file mode 100644 index 0000000000000..223434adba19b --- /dev/null +++ b/test/Modules/Inputs/PR20399/module.modulemap @@ -0,0 +1,18 @@ +module stdlib [system] { + header "stl_map.h" + header "vector" + } + +module libCore { + header "SecondHeader.h" + use stdlib + export * +} + +module libGdml { + header "FirstHeader.h" + use libCore + use stdlib + export * +} + diff --git a/test/Modules/Inputs/PR20399/stl_map.h b/test/Modules/Inputs/PR20399/stl_map.h new file mode 100644 index 0000000000000..334f8b308f405 --- /dev/null +++ b/test/Modules/Inputs/PR20399/stl_map.h @@ -0,0 +1,13 @@ +namespace std { +struct reverse_iterator {}; + +inline void +operator-(int __x, reverse_iterator __y) {} + +template <typename _Key> +struct map { + typedef int iterator; + + friend bool operator<(const map &, const map &); +}; +} // namespace std diff --git a/test/Modules/Inputs/PR20399/vector b/test/Modules/Inputs/PR20399/vector new file mode 100644 index 0000000000000..1e1b6705f51bc --- /dev/null +++ b/test/Modules/Inputs/PR20399/vector @@ -0,0 +1,17 @@ +namespace std { +template <typename _Tp, typename _Alloc = int> +struct vector { + static void func() { vector *i, *j; i - j; } +}; + +struct bit_iterator { ~bit_iterator() {} }; + +inline void operator-(int __x, const bit_iterator &__y) { +} + +template <typename _Alloc> +struct vector<bool, _Alloc> : bit_iterator { + typedef bit_iterator iterator; +}; + +} // namespace std diff --git a/test/Modules/Inputs/PR20786/TBranchProxy.h b/test/Modules/Inputs/PR20786/TBranchProxy.h new file mode 100644 index 0000000000000..91f3730c3b88e --- /dev/null +++ b/test/Modules/Inputs/PR20786/TBranchProxy.h @@ -0,0 +1,2 @@ +#include "random.h" +#include "TFormula.h" diff --git a/test/Modules/Inputs/PR20786/TFormula.h b/test/Modules/Inputs/PR20786/TFormula.h new file mode 100644 index 0000000000000..316e3ad7222b0 --- /dev/null +++ b/test/Modules/Inputs/PR20786/TFormula.h @@ -0,0 +1 @@ +#include "TMath.h" diff --git a/test/Modules/Inputs/PR20786/TMath.h b/test/Modules/Inputs/PR20786/TMath.h new file mode 100644 index 0000000000000..b7dba620f7d1c --- /dev/null +++ b/test/Modules/Inputs/PR20786/TMath.h @@ -0,0 +1 @@ +#include "random.h" diff --git a/test/Modules/Inputs/PR20786/module.modulemap b/test/Modules/Inputs/PR20786/module.modulemap new file mode 100644 index 0000000000000..daf78cd0cd3f4 --- /dev/null +++ b/test/Modules/Inputs/PR20786/module.modulemap @@ -0,0 +1,3 @@ +module TMath { header "TMath.h" } +module TFormula { header "TFormula.h" } +module TBranchProxy { header "TBranchProxy.h" } diff --git a/test/Modules/Inputs/PR20786/random.h b/test/Modules/Inputs/PR20786/random.h new file mode 100644 index 0000000000000..86a7d83c19c08 --- /dev/null +++ b/test/Modules/Inputs/PR20786/random.h @@ -0,0 +1,12 @@ +namespace std { + template<typename> struct mersenne_twister_engine { + friend bool operator==(const mersenne_twister_engine &, + const mersenne_twister_engine &) { + return false; + } + }; + struct random_device { + mersenne_twister_engine<int> mt; // require complete type + }; +} + diff --git a/test/Modules/Inputs/StdDef/include_again.h b/test/Modules/Inputs/StdDef/include_again.h new file mode 100644 index 0000000000000..f29f6366cc69d --- /dev/null +++ b/test/Modules/Inputs/StdDef/include_again.h @@ -0,0 +1,2 @@ +#include <stddef.h> + diff --git a/test/Modules/Inputs/StdDef/module.map b/test/Modules/Inputs/StdDef/module.map index 69c69eac35b51..5c4e0dae7ba6a 100644 --- a/test/Modules/Inputs/StdDef/module.map +++ b/test/Modules/Inputs/StdDef/module.map @@ -8,4 +8,14 @@ module StdDef { header "other.h" export * } + + module PtrDiffT { + header "ptrdiff_t.h" + export * + } + + module IncludeAgain { + header "include_again.h" + export * + } } diff --git a/test/Modules/Inputs/StdDef/ptrdiff_t.h b/test/Modules/Inputs/StdDef/ptrdiff_t.h new file mode 100644 index 0000000000000..acb0ab81ffc7d --- /dev/null +++ b/test/Modules/Inputs/StdDef/ptrdiff_t.h @@ -0,0 +1,2 @@ +#define __need_ptrdiff_t +#include <stddef.h> diff --git a/test/Modules/Inputs/attr-unavailable/module.modulemap b/test/Modules/Inputs/attr-unavailable/module.modulemap new file mode 100644 index 0000000000000..a5159420c22ca --- /dev/null +++ b/test/Modules/Inputs/attr-unavailable/module.modulemap @@ -0,0 +1,4 @@ +module two { header "two.h" } +module oneA { header "oneA.h" } +module oneB { header "oneB.h" export oneA } +module oneC { header "oneC.h" } diff --git a/test/Modules/Inputs/attr-unavailable/oneA.h b/test/Modules/Inputs/attr-unavailable/oneA.h new file mode 100644 index 0000000000000..a4e572ffacd98 --- /dev/null +++ b/test/Modules/Inputs/attr-unavailable/oneA.h @@ -0,0 +1,4 @@ +@interface C +-(void)method2 __attribute__((unavailable)); +-(void)method3 __attribute__((unavailable)); +@end diff --git a/test/Modules/Inputs/attr-unavailable/oneB.h b/test/Modules/Inputs/attr-unavailable/oneB.h new file mode 100644 index 0000000000000..b9536ad15ba7e --- /dev/null +++ b/test/Modules/Inputs/attr-unavailable/oneB.h @@ -0,0 +1,5 @@ +@import oneA; + +@interface D +-(void)method2; +@end diff --git a/test/Modules/Inputs/attr-unavailable/oneC.h b/test/Modules/Inputs/attr-unavailable/oneC.h new file mode 100644 index 0000000000000..9dc305e70fb42 --- /dev/null +++ b/test/Modules/Inputs/attr-unavailable/oneC.h @@ -0,0 +1,3 @@ +@interface E +-(void)method3; +@end diff --git a/test/Modules/Inputs/attr-unavailable/two.h b/test/Modules/Inputs/attr-unavailable/two.h new file mode 100644 index 0000000000000..0423f610108d2 --- /dev/null +++ b/test/Modules/Inputs/attr-unavailable/two.h @@ -0,0 +1,6 @@ +@interface A +-(void)method1; +@end +@interface B +-(void)method1 __attribute__((unavailable)); +@end diff --git a/test/Modules/Inputs/cxx-decls-imported.h b/test/Modules/Inputs/cxx-decls-imported.h index 38cc00d863f2f..8c1e74f17c3cc 100644 --- a/test/Modules/Inputs/cxx-decls-imported.h +++ b/test/Modules/Inputs/cxx-decls-imported.h @@ -23,3 +23,27 @@ void *operator new[](__SIZE_TYPE__); extern int mergeUsedFlag; inline int getMergeUsedFlag() { return mergeUsedFlag; } + +typedef struct { + int n; + int m; +} NameForLinkage; + +struct HasVirtualFunctions { + virtual void f(); +}; +struct OverridesVirtualFunctions : HasVirtualFunctions { + void f(); +}; +extern "C" void ExternCFunction(); + +typedef struct { + struct Inner { + int n; + }; +} NameForLinkage2; +auto name_for_linkage2_inner_a = NameForLinkage2::Inner(); +typedef decltype(name_for_linkage2_inner_a) NameForLinkage2Inner; + +namespace Aliased { extern int a; } +namespace Alias = Aliased; diff --git a/test/Modules/Inputs/cxx-decls-merged.h b/test/Modules/Inputs/cxx-decls-merged.h index ccc3b01548726..86e81a9bb681f 100644 --- a/test/Modules/Inputs/cxx-decls-merged.h +++ b/test/Modules/Inputs/cxx-decls-merged.h @@ -1 +1,27 @@ extern int mergeUsedFlag; + +typedef struct { + int n; + int m; +} NameForLinkage; +extern NameForLinkage name_for_linkage; + +struct HasVirtualFunctions { + virtual void f(); +}; +struct OverridesVirtualFunctions : HasVirtualFunctions { + void f(); +}; +extern OverridesVirtualFunctions overrides_virtual_functions; +extern "C" void ExternCFunction(); + +typedef struct { + struct Inner { + int n; + }; +} NameForLinkage2; +auto name_for_linkage2_inner_b = NameForLinkage2::Inner(); +typedef decltype(name_for_linkage2_inner_b) NameForLinkage2Inner; + +namespace Aliased { extern int b; } +namespace Alias = Aliased; diff --git a/test/Modules/Inputs/cxx-decls-premerged.h b/test/Modules/Inputs/cxx-decls-premerged.h new file mode 100644 index 0000000000000..064fb9ea67bba --- /dev/null +++ b/test/Modules/Inputs/cxx-decls-premerged.h @@ -0,0 +1,3 @@ +extern "C" void ExternCFunction(); + +#include "cxx-decls-imported.h" diff --git a/test/Modules/Inputs/cxx-irgen-left.h b/test/Modules/Inputs/cxx-irgen-left.h index ceb50846bbf4e..31ae805c9a19b 100644 --- a/test/Modules/Inputs/cxx-irgen-left.h +++ b/test/Modules/Inputs/cxx-irgen-left.h @@ -9,3 +9,18 @@ inline int instantiate_min() { inline int instantiate_CtorInit(CtorInit<int> i = CtorInit<int>()) { return i.a; } + +namespace ImplicitSpecialMembers { + inline void create_left() { + // Trigger declaration, but not definition, of special members. + B b(0); C c(0); D d(0); + // Trigger definition of copy constructor. + C c2(c); D d2(d); + } +} + +namespace OperatorDeleteLookup { + // Trigger definition of A::~A() and lookup of operator delete. + // Likewise for B<int>::~B(). + inline void f() { A a; B<int> b; } +} diff --git a/test/Modules/Inputs/cxx-irgen-right.h b/test/Modules/Inputs/cxx-irgen-right.h index 4400c760f07a2..30686a12479a2 100644 --- a/test/Modules/Inputs/cxx-irgen-right.h +++ b/test/Modules/Inputs/cxx-irgen-right.h @@ -1,3 +1,13 @@ #include "cxx-irgen-top.h" inline int h() { return S<int>::f(); } + +namespace ImplicitSpecialMembers { + inline void create_right() { + // Trigger declaration, but not definition, of special members. + B b(0); C c(0); D d(0); + // Trigger definition of move constructor. + B b2(static_cast<B&&>(b)); + D d2(static_cast<D&&>(d)); + } +} diff --git a/test/Modules/Inputs/cxx-irgen-top.h b/test/Modules/Inputs/cxx-irgen-top.h index 8753d8daa3dcd..f1a0bee212503 100644 --- a/test/Modules/Inputs/cxx-irgen-top.h +++ b/test/Modules/Inputs/cxx-irgen-top.h @@ -14,3 +14,38 @@ template<typename T> struct CtorInit { int a; CtorInit() : a(f()) {} }; + +namespace ImplicitSpecialMembers { + struct A { + A(const A&); + }; + struct B { + A a; + B(int); + }; + struct C { + A a; + C(int); + }; + struct D { + A a; + D(int); + }; +} + +namespace OperatorDeleteLookup { + struct A { void operator delete(void*); virtual ~A() = default; }; + template<typename T> struct B { void operator delete(void*); virtual ~B() {} typedef int t; }; + typedef B<int>::t b_int_instantated; +} + +namespace EmitInlineMethods { + struct A { + void f() {} + void g(); + }; + struct B { + void f(); + void g() {} + }; +} diff --git a/test/Modules/Inputs/cxx-lookup/a.h b/test/Modules/Inputs/cxx-lookup/a.h new file mode 100644 index 0000000000000..25f614fe50b9c --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/a.h @@ -0,0 +1,2 @@ +// a +namespace llvm { class GlobalValue; } diff --git a/test/Modules/Inputs/cxx-lookup/b.h b/test/Modules/Inputs/cxx-lookup/b.h new file mode 100644 index 0000000000000..c2ede9f28dc22 --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/b.h @@ -0,0 +1,3 @@ +// b +namespace llvm { class GlobalValue; } +#include "y.h" diff --git a/test/Modules/Inputs/cxx-lookup/c1.h b/test/Modules/Inputs/cxx-lookup/c1.h new file mode 100644 index 0000000000000..dba4a4c0a00eb --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/c1.h @@ -0,0 +1,3 @@ +// c1 +#include "a.h" +#include "b.h" diff --git a/test/Modules/Inputs/cxx-lookup/c2.h b/test/Modules/Inputs/cxx-lookup/c2.h new file mode 100644 index 0000000000000..463e270e267ad --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/c2.h @@ -0,0 +1,2 @@ +// c2 +namespace llvm { class GlobalValue; } diff --git a/test/Modules/Inputs/cxx-lookup/module.modulemap b/test/Modules/Inputs/cxx-lookup/module.modulemap new file mode 100644 index 0000000000000..6d397af250c8f --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/module.modulemap @@ -0,0 +1,8 @@ +module A { header "a.h" export * } +module B { header "b.h" export * } +module C { + module C2 { header "c2.h" export * } + module C1 { header "c1.h" export * } +} +module X { header "x.h" export * } +module Y { header "y.h" export * } diff --git a/test/Modules/Inputs/cxx-lookup/x.h b/test/Modules/Inputs/cxx-lookup/x.h new file mode 100644 index 0000000000000..a8826e0058175 --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/x.h @@ -0,0 +1,2 @@ +template <class T> class allocator; +struct X { virtual allocator<char> f(); }; diff --git a/test/Modules/Inputs/cxx-lookup/y.h b/test/Modules/Inputs/cxx-lookup/y.h new file mode 100644 index 0000000000000..8867e8a8becd0 --- /dev/null +++ b/test/Modules/Inputs/cxx-lookup/y.h @@ -0,0 +1,5 @@ +#include "x.h" +namespace llvm { + struct ulittle32_t; + extern allocator<ulittle32_t> *x; +} diff --git a/test/Modules/Inputs/cxx-templates-a.h b/test/Modules/Inputs/cxx-templates-a.h index c95dc6325e499..4340910d1e2a4 100644 --- a/test/Modules/Inputs/cxx-templates-a.h +++ b/test/Modules/Inputs/cxx-templates-a.h @@ -29,6 +29,8 @@ void use_some_template_a() { SomeTemplate<char[2]> a; SomeTemplate<char[1]> b, c; b = c; + + (void)&WithImplicitSpecialMembers<int>::n; } template<int> struct MergeTemplates; @@ -56,6 +58,7 @@ template<typename T> struct WithPartialSpecialization<T*> { T &f() { static T t; return t; } }; typedef WithPartialSpecializationUse::type WithPartialSpecializationInstantiate; +typedef WithPartialSpecialization<void(int)>::type WithPartialSpecializationInstantiate2; template<> struct WithExplicitSpecialization<int> { int n; @@ -73,3 +76,31 @@ template<typename T> struct MergeTemplateDefinitions { static constexpr int g(); }; template<typename T> constexpr int MergeTemplateDefinitions<T>::f() { return 1; } + +template<typename T> using AliasTemplate = T; + +template<typename T> struct PartiallyInstantiatePartialSpec {}; +template<typename T> struct PartiallyInstantiatePartialSpec<T*> { + static T *foo() { return reinterpret_cast<T*>(0); } + static T *bar() { return reinterpret_cast<T*>(0); } +}; +typedef PartiallyInstantiatePartialSpec<int*> PartiallyInstantiatePartialSpecHelper; + +void InstantiateWithAliasTemplate(WithAliasTemplate<int>::X<char>); +inline int InstantiateWithAnonymousDeclsA(WithAnonymousDecls<int> x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; } +inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls<char> x); + + +template<typename T1 = int> +struct MergeAnonUnionMember { + MergeAnonUnionMember() { (void)values.t1; } + union { int t1; } values; +}; +inline MergeAnonUnionMember<> maum_a() { return {}; } + +template<typename T> struct DontWalkPreviousDeclAfterMerging { struct Inner { typedef T type; }; }; + +namespace TestInjectedClassName { + template<typename T> struct X { X(); }; + typedef X<char[1]> A; +} diff --git a/test/Modules/Inputs/cxx-templates-b.h b/test/Modules/Inputs/cxx-templates-b.h index efd07c617e528..d763c8040ba3d 100644 --- a/test/Modules/Inputs/cxx-templates-b.h +++ b/test/Modules/Inputs/cxx-templates-b.h @@ -24,6 +24,11 @@ template<typename T> template<typename U> constexpr int Outer<T>::Inner<U>::g() { return 2; } static_assert(Outer<int>::Inner<int>::g() == 2, ""); +namespace TestInjectedClassName { + template<typename T> struct X { X(); }; + typedef X<char[2]> B; +} + @import cxx_templates_b_impl; template<typename T, typename> struct Identity { typedef T type; }; @@ -46,6 +51,8 @@ void use_some_template_b() { SomeTemplate<char[1]> a; SomeTemplate<char[2]> b, c; b = c; + + WithImplicitSpecialMembers<int> wism1, wism2(wism1); } auto enum_b_from_b = CommonTemplate<int>::b; @@ -55,6 +62,8 @@ template<int> struct UseInt; template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>); constexpr void (*UseRedeclaredEnumB)(UseInt<1>) = UseRedeclaredEnum<int>; +typedef WithPartialSpecialization<void(int)>::type WithPartialSpecializationInstantiate3; + template<typename> struct MergeSpecializations; template<typename T> struct MergeSpecializations<T&> { typedef int partially_specialized_in_b; @@ -63,6 +72,16 @@ template<> struct MergeSpecializations<double> { typedef int explicitly_specialized_in_b; }; +template<typename U> using AliasTemplate = U; + +void InstantiateWithAliasTemplate(WithAliasTemplate<int>::X<char>); +inline int InstantiateWithAnonymousDeclsB(WithAnonymousDecls<int> x) { + return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; +} +inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls<char> x) { + return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; +} + @import cxx_templates_a; template<typename T> void UseDefinedInBImplIndirectly(T &v) { PerformDelayedLookup(v); @@ -71,4 +90,6 @@ template<typename T> void UseDefinedInBImplIndirectly(T &v) { void TriggerInstantiation() { UseDefinedInBImpl<void>(); Std::f<int>(); + PartiallyInstantiatePartialSpec<int*>::foo(); + WithPartialSpecialization<void(int)>::type x; } diff --git a/test/Modules/Inputs/cxx-templates-c.h b/test/Modules/Inputs/cxx-templates-c.h index 6daffadc6cede..e5395b6c7ed83 100644 --- a/test/Modules/Inputs/cxx-templates-c.h +++ b/test/Modules/Inputs/cxx-templates-c.h @@ -11,3 +11,18 @@ template<typename T> struct MergeTemplateDefinitions { static constexpr int g(); }; template<typename T> constexpr int MergeTemplateDefinitions<T>::g() { return 2; } + +template<typename T1 = int> +struct MergeAnonUnionMember { + MergeAnonUnionMember() { (void)values.t1; } + union { int t1; } values; +}; +inline MergeAnonUnionMember<> maum_c() { return {}; } + +template<typename T> struct DontWalkPreviousDeclAfterMerging { struct Inner { typedef T type; }; }; +typedef DontWalkPreviousDeclAfterMerging<char>::Inner dwpdam_typedef; + +namespace TestInjectedClassName { + template<typename T> struct X { X(); }; + typedef X<char[3]> C; +} diff --git a/test/Modules/Inputs/cxx-templates-common.h b/test/Modules/Inputs/cxx-templates-common.h index 682ef939cec0f..a9ca624486718 100644 --- a/test/Modules/Inputs/cxx-templates-common.h +++ b/test/Modules/Inputs/cxx-templates-common.h @@ -32,7 +32,25 @@ template<typename T> struct Outer { }; template<typename T> struct WithPartialSpecialization {}; +template<typename T> struct WithPartialSpecialization<void(T)> { typedef int type; }; typedef WithPartialSpecialization<int*> WithPartialSpecializationUse; +typedef WithPartialSpecialization<void(int)> WithPartialSpecializationUse2; template<typename T> struct WithExplicitSpecialization; typedef WithExplicitSpecialization<int> WithExplicitSpecializationUse; + +template<typename T> struct WithImplicitSpecialMembers { int n; }; + +template<typename T> struct WithAliasTemplate { + template<typename> using X = T; +}; + +template<typename T> struct WithAnonymousDecls { + struct { bool k; }; + union { int a, b; }; + struct { int c, d; } s; + enum { e = 123 }; + typedef int X; +}; + +#include "cxx-templates-textual.h" diff --git a/test/Modules/Inputs/cxx-templates-d.h b/test/Modules/Inputs/cxx-templates-d.h new file mode 100644 index 0000000000000..1fb1a2282b96f --- /dev/null +++ b/test/Modules/Inputs/cxx-templates-d.h @@ -0,0 +1,9 @@ +@import cxx_templates_common; + +inline int InstantiateWithAnonymousDeclsD(WithAnonymousDecls<char> x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; } + +namespace TestInjectedClassName { + template<typename T> struct X { X(); }; + typedef X<int> D; + inline D UseD() { return D(); } +} diff --git a/test/Modules/Inputs/cxx-templates-textual.h b/test/Modules/Inputs/cxx-templates-textual.h new file mode 100644 index 0000000000000..8bffb8eddc28b --- /dev/null +++ b/test/Modules/Inputs/cxx-templates-textual.h @@ -0,0 +1,2 @@ +template<typename T> struct MergeClassTemplateSpecializations_basic_string {}; +typedef MergeClassTemplateSpecializations_basic_string<char> MergeClassTemplateSpecializations_string; diff --git a/test/Modules/Inputs/declare-use/k.h b/test/Modules/Inputs/declare-use/k.h new file mode 100644 index 0000000000000..338178e86cb34 --- /dev/null +++ b/test/Modules/Inputs/declare-use/k.h @@ -0,0 +1,8 @@ +#ifdef GIMME_A_K + +#ifndef K_H +#define K_H +const int k = 42; +#endif + +#endif diff --git a/test/Modules/Inputs/declare-use/l.h b/test/Modules/Inputs/declare-use/l.h new file mode 100644 index 0000000000000..a43fd1a3d0638 --- /dev/null +++ b/test/Modules/Inputs/declare-use/l.h @@ -0,0 +1,8 @@ +#ifdef GIMME_AN_L + +#ifndef L_H +#define L_H +const int l = 42; +#endif + +#endif diff --git a/test/Modules/Inputs/declare-use/m.h b/test/Modules/Inputs/declare-use/m.h new file mode 100644 index 0000000000000..e9089ab725d5b --- /dev/null +++ b/test/Modules/Inputs/declare-use/m.h @@ -0,0 +1,8 @@ +#ifdef GIMME_AN_M + +#ifndef M_H +#define M_H +const int m = 42; +#endif + +#endif diff --git a/test/Modules/Inputs/declare-use/m2.h b/test/Modules/Inputs/declare-use/m2.h new file mode 100644 index 0000000000000..9e72835c3bcea --- /dev/null +++ b/test/Modules/Inputs/declare-use/m2.h @@ -0,0 +1 @@ +#include "m.h" diff --git a/test/Modules/Inputs/declare-use/module.map b/test/Modules/Inputs/declare-use/module.map index a176fb3a141fc..ae8615278aca3 100644 --- a/test/Modules/Inputs/declare-use/module.map +++ b/test/Modules/Inputs/declare-use/module.map @@ -38,6 +38,7 @@ module XG { use XC use XE use XJ + use XK } module XH { @@ -52,5 +53,18 @@ module XJ { header "j.h" } +module XK { + textual header "k.h" +} + +module XL { + textual header "l.h" +} + +module XM { + private textual header "m.h" + textual header "m2.h" +} + module XS { } diff --git a/test/Modules/Inputs/dependency-gen-base.modulemap b/test/Modules/Inputs/dependency-gen-base.modulemap new file mode 100644 index 0000000000000..8b30ffa67455e --- /dev/null +++ b/test/Modules/Inputs/dependency-gen-base.modulemap @@ -0,0 +1,6 @@ +module "test-base" { + export * + header "Inputs/dependency-gen-included.h" + use "test-base2" +} +extern module "test-base2" "Inputs/dependency-gen-base2.modulemap" diff --git a/test/Modules/Inputs/dependency-gen-base2.modulemap b/test/Modules/Inputs/dependency-gen-base2.modulemap new file mode 100644 index 0000000000000..7808c8041aec0 --- /dev/null +++ b/test/Modules/Inputs/dependency-gen-base2.modulemap @@ -0,0 +1,4 @@ +module "test-base2" { + export * + textual header "Inputs/dependency-gen-included2.h" +} diff --git a/test/Modules/Inputs/dependency-gen-included.h b/test/Modules/Inputs/dependency-gen-included.h new file mode 100644 index 0000000000000..0e1cdfcd1e18e --- /dev/null +++ b/test/Modules/Inputs/dependency-gen-included.h @@ -0,0 +1,9 @@ +//#ifndef DEPENDENCY_GEN_INCLUDED_H +//#define DEPENDENCY_GEN_INCLUDED_H + +#include "Inputs/dependency-gen-included2.h" + +void g() { +} + +//#endif diff --git a/test/Modules/Inputs/dependency-gen-included2.h b/test/Modules/Inputs/dependency-gen-included2.h new file mode 100644 index 0000000000000..fcd8f12ba5ade --- /dev/null +++ b/test/Modules/Inputs/dependency-gen-included2.h @@ -0,0 +1,7 @@ +#ifndef DEPENDENCY_GEN_INCLUDED2_H +#define DEPENDENCY_GEN_INCLUDED2_H + +void h() { +} + +#endif diff --git a/test/Modules/Inputs/dependency-gen.h b/test/Modules/Inputs/dependency-gen.h new file mode 100644 index 0000000000000..2671e262c6ace --- /dev/null +++ b/test/Modules/Inputs/dependency-gen.h @@ -0,0 +1,11 @@ +//#ifndef DEPENDENCY_GEN_H +//#define DEPENDENCY_GEN_H + +#include "dependency-gen-included.h" + +void f() { + g(); + h(); +} + +//#endif diff --git a/test/Modules/Inputs/diamond_left.h b/test/Modules/Inputs/diamond_left.h index fce2e48882f8f..6494551e4bfa0 100644 --- a/test/Modules/Inputs/diamond_left.h +++ b/test/Modules/Inputs/diamond_left.h @@ -1,3 +1,5 @@ +int top_left_before(void *); + @import diamond_top; float left(float *); diff --git a/test/Modules/Inputs/diamond_top.h b/test/Modules/Inputs/diamond_top.h index 34998cd4324b9..30da14f6449b5 100644 --- a/test/Modules/Inputs/diamond_top.h +++ b/test/Modules/Inputs/diamond_top.h @@ -2,3 +2,4 @@ int top(int *); int top_left(char *c); +int top_left_before(void *); diff --git a/test/Modules/Inputs/explicit-build/a.h b/test/Modules/Inputs/explicit-build/a.h new file mode 100644 index 0000000000000..5e3602f58ffe7 --- /dev/null +++ b/test/Modules/Inputs/explicit-build/a.h @@ -0,0 +1,5 @@ +#if !__building_module(a) +#error "should only get here when building module a" +#endif + +const int a = 1; diff --git a/test/Modules/Inputs/explicit-build/b.h b/test/Modules/Inputs/explicit-build/b.h new file mode 100644 index 0000000000000..449b3859ab45c --- /dev/null +++ b/test/Modules/Inputs/explicit-build/b.h @@ -0,0 +1,7 @@ +#include "a.h" + +#if !__building_module(b) +#error "should only get here when building module b" +#endif + +const int b = 2; diff --git a/test/Modules/Inputs/explicit-build/c.h b/test/Modules/Inputs/explicit-build/c.h new file mode 100644 index 0000000000000..2c66a23e8927a --- /dev/null +++ b/test/Modules/Inputs/explicit-build/c.h @@ -0,0 +1,7 @@ +#include "b.h" + +#if !__building_module(c) +#error "should only get here when building module c" +#endif + +const int c = 3; diff --git a/test/Modules/Inputs/explicit-build/module.modulemap b/test/Modules/Inputs/explicit-build/module.modulemap new file mode 100644 index 0000000000000..bd6ea830c2d41 --- /dev/null +++ b/test/Modules/Inputs/explicit-build/module.modulemap @@ -0,0 +1,3 @@ +module a { header "a.h" } +module b { header "b.h" export * } +module c { header "c.h" export * } diff --git a/test/Modules/Inputs/filename/a.h b/test/Modules/Inputs/filename/a.h new file mode 100644 index 0000000000000..8f896a9ba8f41 --- /dev/null +++ b/test/Modules/Inputs/filename/a.h @@ -0,0 +1 @@ +const char *p = __FILE__; diff --git a/test/Modules/Inputs/filename/module.map b/test/Modules/Inputs/filename/module.map new file mode 100644 index 0000000000000..ff164ad7bac8e --- /dev/null +++ b/test/Modules/Inputs/filename/module.map @@ -0,0 +1,3 @@ +module "A" { + header "a.h" +} diff --git a/test/Modules/Inputs/include_next/x/a.h b/test/Modules/Inputs/include_next/x/a.h new file mode 100644 index 0000000000000..71822876313a8 --- /dev/null +++ b/test/Modules/Inputs/include_next/x/a.h @@ -0,0 +1,2 @@ +#include_next "a.h" +enum { ax = 1 }; diff --git a/test/Modules/Inputs/include_next/x/module.modulemap b/test/Modules/Inputs/include_next/x/module.modulemap new file mode 100644 index 0000000000000..d0956d98ab84a --- /dev/null +++ b/test/Modules/Inputs/include_next/x/module.modulemap @@ -0,0 +1,2 @@ +module xa { header "a.h" export * } +module xb { header "subdir/b.h" export * } diff --git a/test/Modules/Inputs/include_next/x/subdir/b.h b/test/Modules/Inputs/include_next/x/subdir/b.h new file mode 100644 index 0000000000000..d9449e11a32fb --- /dev/null +++ b/test/Modules/Inputs/include_next/x/subdir/b.h @@ -0,0 +1,2 @@ +#include_next <b.h> +enum { bx = 3 }; diff --git a/test/Modules/Inputs/include_next/y/a.h b/test/Modules/Inputs/include_next/y/a.h new file mode 100644 index 0000000000000..703ec958785d7 --- /dev/null +++ b/test/Modules/Inputs/include_next/y/a.h @@ -0,0 +1 @@ +enum { ay = 2 }; diff --git a/test/Modules/Inputs/include_next/y/b.h b/test/Modules/Inputs/include_next/y/b.h new file mode 100644 index 0000000000000..629e7fde1fe29 --- /dev/null +++ b/test/Modules/Inputs/include_next/y/b.h @@ -0,0 +1 @@ +enum { by = 4 }; diff --git a/test/Modules/Inputs/include_next/y/module.modulemap b/test/Modules/Inputs/include_next/y/module.modulemap new file mode 100644 index 0000000000000..5dc3c535cefcf --- /dev/null +++ b/test/Modules/Inputs/include_next/y/module.modulemap @@ -0,0 +1,2 @@ +module ya { header "a.h" export * } +module yb { header "b.h" export * } diff --git a/test/Modules/Inputs/inferred-attr/InferredExternC.framework/Headers/InferredExternC.h b/test/Modules/Inputs/inferred-attr/InferredExternC.framework/Headers/InferredExternC.h new file mode 100644 index 0000000000000..63242fae9a113 --- /dev/null +++ b/test/Modules/Inputs/inferred-attr/InferredExternC.framework/Headers/InferredExternC.h @@ -0,0 +1 @@ +// InferredExternC.h diff --git a/test/Modules/Inputs/inferred-attr/module.modulemap b/test/Modules/Inputs/inferred-attr/module.modulemap new file mode 100644 index 0000000000000..beb6ea159de3a --- /dev/null +++ b/test/Modules/Inputs/inferred-attr/module.modulemap @@ -0,0 +1 @@ +framework module * [extern_c] { } diff --git a/test/Modules/Inputs/macros_bottom.h b/test/Modules/Inputs/macros_bottom.h new file mode 100644 index 0000000000000..fc0a78e462076 --- /dev/null +++ b/test/Modules/Inputs/macros_bottom.h @@ -0,0 +1,3 @@ +@import macros_right; + +extern TOP_DEF_RIGHT_UNDEF *TDRUp; diff --git a/test/Modules/Inputs/macros_right_undef.h b/test/Modules/Inputs/macros_right_undef.h index 15a83666a1369..5084561e108bc 100644 --- a/test/Modules/Inputs/macros_right_undef.h +++ b/test/Modules/Inputs/macros_right_undef.h @@ -2,3 +2,4 @@ @import macros_top; #undef TOP_OTHER_DEF_RIGHT_UNDEF +#undef TOP_DEF_RIGHT_UNDEF diff --git a/test/Modules/Inputs/macros_top.h b/test/Modules/Inputs/macros_top.h index 10935043e2a16..e063133a172d0 100644 --- a/test/Modules/Inputs/macros_top.h +++ b/test/Modules/Inputs/macros_top.h @@ -22,3 +22,4 @@ #define TOP_OTHER_DEF_RIGHT_UNDEF void #define TOP_REDEF_IN_SUBMODULES 0 +#define TOP_DEF_RIGHT_UNDEF void diff --git a/test/Modules/Inputs/malformed/c.h b/test/Modules/Inputs/malformed/c.h new file mode 100644 index 0000000000000..2cce2ca9caa23 --- /dev/null +++ b/test/Modules/Inputs/malformed/c.h @@ -0,0 +1 @@ +template<typename T> void f() { T::error; } diff --git a/test/Modules/Inputs/malformed/module.map b/test/Modules/Inputs/malformed/module.map index 5277ffa41edd0..3f088d1431d90 100644 --- a/test/Modules/Inputs/malformed/module.map +++ b/test/Modules/Inputs/malformed/module.map @@ -6,3 +6,4 @@ module malformed_b { module b1 { header "b1.h" } module b2 { header "b2.h" } } +module c { header "c.h" } diff --git a/test/Modules/Inputs/merge-typedefs/a1.h b/test/Modules/Inputs/merge-typedefs/a1.h new file mode 100644 index 0000000000000..cacc530c3d0a9 --- /dev/null +++ b/test/Modules/Inputs/merge-typedefs/a1.h @@ -0,0 +1,11 @@ +#ifndef A1_H +#define A1_H +namespace llvm { +class MachineBasicBlock; +template <class NodeT> class DomTreeNodeBase; +typedef DomTreeNodeBase<MachineBasicBlock> MachineDomTreeNode; +} + +typedef struct {} foo_t; +typedef foo_t foo2_t; +#endif diff --git a/test/Modules/Inputs/merge-typedefs/a2.h b/test/Modules/Inputs/merge-typedefs/a2.h new file mode 100644 index 0000000000000..ba306663e3b53 --- /dev/null +++ b/test/Modules/Inputs/merge-typedefs/a2.h @@ -0,0 +1,3 @@ +#ifndef A2_H +#define A2_H +#endif diff --git a/test/Modules/Inputs/merge-typedefs/b1.h b/test/Modules/Inputs/merge-typedefs/b1.h new file mode 100644 index 0000000000000..8dde5f6fbaddf --- /dev/null +++ b/test/Modules/Inputs/merge-typedefs/b1.h @@ -0,0 +1,11 @@ +#ifndef B1_H +#define B1_H +typedef struct {} foo_t; +typedef foo_t foo2_t; +#include "a2.h" +namespace llvm { +class MachineBasicBlock; +template <class NodeT> class DomTreeNodeBase; +typedef DomTreeNodeBase<MachineBasicBlock> MachineDomTreeNode; +} +#endif diff --git a/test/Modules/Inputs/merge-typedefs/b2.h b/test/Modules/Inputs/merge-typedefs/b2.h new file mode 100644 index 0000000000000..75bd63affb16c --- /dev/null +++ b/test/Modules/Inputs/merge-typedefs/b2.h @@ -0,0 +1,3 @@ +#ifndef B2_H +#define B2_H +#endif diff --git a/test/Modules/Inputs/merge-typedefs/module.modulemap b/test/Modules/Inputs/merge-typedefs/module.modulemap new file mode 100644 index 0000000000000..4858f1be63ac1 --- /dev/null +++ b/test/Modules/Inputs/merge-typedefs/module.modulemap @@ -0,0 +1,9 @@ +module A { + module A1 { header "a1.h" export * } + module A2 { header "a2.h" export * } +} + +module B { + module B1 { header "b1.h" export * } + module B2 { header "b2.h" export * } +} diff --git a/test/Modules/Inputs/merge-using-decls/a.h b/test/Modules/Inputs/merge-using-decls/a.h new file mode 100644 index 0000000000000..0fe0067bf23c4 --- /dev/null +++ b/test/Modules/Inputs/merge-using-decls/a.h @@ -0,0 +1,43 @@ +struct X { + int v; + typedef int t; +}; + +struct YA { + int value; + typedef int type; +}; + +template<typename T> struct C : X, T { + using T::value; + using typename T::type; + using X::v; + using typename X::t; +}; + +template<typename T> struct D : X, T { + using T::value; + using typename T::type; + using X::v; + using typename X::t; +}; + +template<typename T> struct E : X, T { + using T::value; + using typename T::type; + using X::v; + using typename X::t; +}; + +template<typename T> struct F : X, T { + using T::value; + using typename T::type; + using X::v; + using typename X::t; +}; + +// Force instantiation. +typedef C<YA>::type I; +typedef D<YA>::type I; +typedef E<YA>::type I; +typedef F<YA>::type I; diff --git a/test/Modules/Inputs/merge-using-decls/b.h b/test/Modules/Inputs/merge-using-decls/b.h new file mode 100644 index 0000000000000..359555570a43e --- /dev/null +++ b/test/Modules/Inputs/merge-using-decls/b.h @@ -0,0 +1,50 @@ +struct X { + int v; + typedef int t; +}; + +struct YB { + typedef YB Y; + int value; + typedef int type; +}; + +struct YBRev { + typedef int value; + int type; +}; + +template<typename T> struct C : X, T { + using T::value; + using typename T::type; + using X::v; + using typename X::t; +}; + +template<typename T> struct D : X, T { + // Mismatch in type/non-type-ness. + using typename T::value; + using T::type; + using X::v; + using typename X::t; +}; + +template<typename T> struct E : X, T { + // Mismatch in using/access-declaration-ness. + T::value; + X::v; +}; + +template<typename T> struct F : X, T { + // Mismatch in nested-name-specifier. + using T::Y::value; + using typename T::Y::type; + using ::X::v; + using typename ::X::t; +}; + +// Force instantiation. +typedef C<YB>::type I; +typedef D<YBRev>::t I; +typedef E<YB>::type I; +typedef F<YB>::type I; diff --git a/test/Modules/Inputs/merge-using-decls/module.modulemap b/test/Modules/Inputs/merge-using-decls/module.modulemap new file mode 100644 index 0000000000000..a415527813c73 --- /dev/null +++ b/test/Modules/Inputs/merge-using-decls/module.modulemap @@ -0,0 +1,2 @@ +module A { header "a.h" } +module B { header "b.h" } diff --git a/test/Modules/Inputs/modular_maps-moduleb-cwd.map b/test/Modules/Inputs/modular_maps-moduleb-cwd.map new file mode 100644 index 0000000000000..1ff307f4b3dfe --- /dev/null +++ b/test/Modules/Inputs/modular_maps-moduleb-cwd.map @@ -0,0 +1,4 @@ +module B { + header "Inputs/modular_maps/common.h" + private header "Inputs/modular_maps/b.h" +} diff --git a/test/Modules/Inputs/modular_maps/c.h b/test/Modules/Inputs/modular_maps/c.h new file mode 100644 index 0000000000000..6e3468e726029 --- /dev/null +++ b/test/Modules/Inputs/modular_maps/c.h @@ -0,0 +1,4 @@ +#ifndef C_H +#define C_H +const int c = 5; +#endif diff --git a/test/Modules/Inputs/modular_maps/common.h b/test/Modules/Inputs/modular_maps/common.h index f690bcbd399b2..349bf5f7c4734 100644 --- a/test/Modules/Inputs/modular_maps/common.h +++ b/test/Modules/Inputs/modular_maps/common.h @@ -1,4 +1,4 @@ #ifndef COMMON_H #define COMMON_H -const int c = 2; +const int x = 2; #endif diff --git a/test/Modules/Inputs/modular_maps/modulea-cwd.map b/test/Modules/Inputs/modular_maps/modulea-cwd.map new file mode 100644 index 0000000000000..10be5237fc7ac --- /dev/null +++ b/test/Modules/Inputs/modular_maps/modulea-cwd.map @@ -0,0 +1,7 @@ +module A { + header "Inputs/modular_maps/common.h" + header "Inputs/modular_maps/a.h" +} + +extern module B "Inputs/modular_maps-moduleb-cwd.map" + diff --git a/test/Modules/Inputs/modular_maps/modulec-cwd.map b/test/Modules/Inputs/modular_maps/modulec-cwd.map new file mode 100644 index 0000000000000..ca38b542df4ab --- /dev/null +++ b/test/Modules/Inputs/modular_maps/modulec-cwd.map @@ -0,0 +1,3 @@ +module C { + header "Inputs/modular_maps/c.h" +} diff --git a/test/Modules/Inputs/modular_maps/modulec.map b/test/Modules/Inputs/modular_maps/modulec.map new file mode 100644 index 0000000000000..c5a1ffe4577c5 --- /dev/null +++ b/test/Modules/Inputs/modular_maps/modulec.map @@ -0,0 +1,3 @@ +module C { + header "c.h" +} diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index fea12015233b6..7040ee7e5ab61 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -40,6 +40,10 @@ module macros_right { header "macros_right_undef.h" } } +module macros_bottom { + header "macros_bottom.h" + export * +} module macros { header "macros.h" } module macros_other { header "macros_other.h" } module category_top { header "category_top.h" } @@ -229,6 +233,10 @@ module cxx_templates_c { header "cxx-templates-c.h" } +module cxx_templates_d { + header "cxx-templates-d.h" +} + module cxx_decls { module unimported { header "cxx-decls-unimported.h" @@ -238,6 +246,10 @@ module cxx_decls { } } +module cxx_decls_premerged { + header "cxx-decls-premerged.h" +} + module cxx_decls_merged { header "cxx-decls-merged.h" } @@ -280,6 +292,10 @@ module warning { header "warning.h" } +module warn_unused_local_typedef { + header "warn-unused-local-typedef.h" +} + module initializer_list { header "initializer_list" } diff --git a/test/Modules/Inputs/odr/a.h b/test/Modules/Inputs/odr/a.h index 26144b86e8d1f..5a3f52409486e 100644 --- a/test/Modules/Inputs/odr/a.h +++ b/test/Modules/Inputs/odr/a.h @@ -8,6 +8,12 @@ struct X { int n; } x1; +template<typename T> +struct F { + int n; + friend bool operator==(const F &a, const F &b) { return a.n == b.n; } +}; + int f() { return y1.n + e1 + y1.f + x1.n; } diff --git a/test/Modules/Inputs/odr/b.h b/test/Modules/Inputs/odr/b.h index b4063979474f6..a4a693df2bf1c 100644 --- a/test/Modules/Inputs/odr/b.h +++ b/test/Modules/Inputs/odr/b.h @@ -4,6 +4,12 @@ struct Y { } y2; enum E { e2 }; +template<typename T> +struct F { + int n; + friend bool operator==(const F &a, const F &b) { return a.n == b.n; } +}; + int g() { - return y2.m + e2 + y2.f; + return y2.m + e2 + y2.f + (F<int>{0} == F<int>{1}); } diff --git a/test/Modules/Inputs/pch-used.h b/test/Modules/Inputs/pch-used.h index 60e0097ea909e..bc53bb37a9df3 100644 --- a/test/Modules/Inputs/pch-used.h +++ b/test/Modules/Inputs/pch-used.h @@ -1,2 +1,3 @@ @import cstd.stdio; +@import other_constants.dbl_max; static inline void SPXTrace() { fprintf(__stderrp, ""); } diff --git a/test/Modules/Inputs/pr19692/AIX.h b/test/Modules/Inputs/pr19692/AIX.h new file mode 100644 index 0000000000000..710871e21f21d --- /dev/null +++ b/test/Modules/Inputs/pr19692/AIX.h @@ -0,0 +1,2 @@ + #undef INT64_MAX + diff --git a/test/Modules/Inputs/pr19692/Blah.h b/test/Modules/Inputs/pr19692/Blah.h new file mode 100644 index 0000000000000..bdaa83a5a3638 --- /dev/null +++ b/test/Modules/Inputs/pr19692/Blah.h @@ -0,0 +1,2 @@ + #include "stdint.h" + diff --git a/test/Modules/Inputs/pr19692/TBlah.h b/test/Modules/Inputs/pr19692/TBlah.h new file mode 100644 index 0000000000000..a045a8bd73773 --- /dev/null +++ b/test/Modules/Inputs/pr19692/TBlah.h @@ -0,0 +1,3 @@ +#include "Blah.h" + int use = INT64_MAX; + diff --git a/test/Modules/Inputs/pr19692/TFoo.h b/test/Modules/Inputs/pr19692/TFoo.h new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/test/Modules/Inputs/pr19692/TFoo.h @@ -0,0 +1 @@ + diff --git a/test/Modules/Inputs/pr19692/module.map b/test/Modules/Inputs/pr19692/module.map new file mode 100644 index 0000000000000..f4120dce6f8cd --- /dev/null +++ b/test/Modules/Inputs/pr19692/module.map @@ -0,0 +1,3 @@ +module cstd { module stdint { header "stdint.h" } } +module LLVMSupport { module Blah { header "Blah.h" export * } module AIX { header "AIX.h" } } +module LLVMTarget { module Blah { header "TBlah.h" export * } module Foo { header "TFoo.h" } } diff --git a/test/Modules/Inputs/pr19692/stdint.h b/test/Modules/Inputs/pr19692/stdint.h new file mode 100644 index 0000000000000..7615e832495d4 --- /dev/null +++ b/test/Modules/Inputs/pr19692/stdint.h @@ -0,0 +1,2 @@ + #define INT64_MAX 42 + diff --git a/test/Modules/Inputs/preprocess-prefix.h b/test/Modules/Inputs/preprocess-prefix.h new file mode 100644 index 0000000000000..04d01758320b3 --- /dev/null +++ b/test/Modules/Inputs/preprocess-prefix.h @@ -0,0 +1,2 @@ +int left_and_right(int *); +#import "diamond_left.h" diff --git a/test/Modules/Inputs/relative-dep-gen-1.h b/test/Modules/Inputs/relative-dep-gen-1.h new file mode 100644 index 0000000000000..deb56982bb820 --- /dev/null +++ b/test/Modules/Inputs/relative-dep-gen-1.h @@ -0,0 +1 @@ +// empty 1 diff --git a/test/Modules/Inputs/relative-dep-gen-2.h b/test/Modules/Inputs/relative-dep-gen-2.h new file mode 100644 index 0000000000000..2b9517d9787db --- /dev/null +++ b/test/Modules/Inputs/relative-dep-gen-2.h @@ -0,0 +1 @@ +// empty 2 diff --git a/test/Modules/Inputs/relative-dep-gen-cwd.modulemap b/test/Modules/Inputs/relative-dep-gen-cwd.modulemap new file mode 100644 index 0000000000000..b8678d309d6b8 --- /dev/null +++ b/test/Modules/Inputs/relative-dep-gen-cwd.modulemap @@ -0,0 +1,4 @@ +module "relative-dep-gen" { + header "Inputs/relative-dep-gen-1.h" + header "Inputs/relative-dep-gen-2.h" +} diff --git a/test/Modules/Inputs/relative-dep-gen.modulemap b/test/Modules/Inputs/relative-dep-gen.modulemap new file mode 100644 index 0000000000000..4c821e19ae552 --- /dev/null +++ b/test/Modules/Inputs/relative-dep-gen.modulemap @@ -0,0 +1,4 @@ +module "relative-dep-gen" { + header "relative-dep-gen-1.h" + header "relative-dep-gen-2.h" +} diff --git a/test/Modules/Inputs/templates-left.h b/test/Modules/Inputs/templates-left.h index 2bd79be945848..cbe89434f9f39 100644 --- a/test/Modules/Inputs/templates-left.h +++ b/test/Modules/Inputs/templates-left.h @@ -60,3 +60,13 @@ template<typename T> void testDelayUpdates(DelayUpdates<T> *p = 0) {} void outOfLineInlineUseLeftF(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::f); void outOfLineInlineUseLeftG(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::g); void outOfLineInlineUseLeftH(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::h); + +namespace EmitDefaultedSpecialMembers { + inline void f() { + SmallString<256> SS; + }; +} + +inline int *getStaticDataMemberLeft() { + return WithUndefinedStaticDataMember<int[]>::undefined; +} diff --git a/test/Modules/Inputs/templates-right.h b/test/Modules/Inputs/templates-right.h index 5907cbca73eed..daea97b86b884 100644 --- a/test/Modules/Inputs/templates-right.h +++ b/test/Modules/Inputs/templates-right.h @@ -43,3 +43,7 @@ template<typename T> struct MergePatternDecl; void outOfLineInlineUseRightF(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::f); void outOfLineInlineUseRightG(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::g); void outOfLineInlineUseRightH(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::h); + +inline int *getStaticDataMemberRight() { + return WithUndefinedStaticDataMember<int[]>::undefined; +} diff --git a/test/Modules/Inputs/templates-top.h b/test/Modules/Inputs/templates-top.h index 1216266f34fbf..31f5e41992819 100644 --- a/test/Modules/Inputs/templates-top.h +++ b/test/Modules/Inputs/templates-top.h @@ -40,3 +40,20 @@ template<typename T> struct OutOfLineInline { template<typename T> inline void OutOfLineInline<T>::f() {} template<typename T> inline void OutOfLineInline<T>::g() {} template<typename T> inline void OutOfLineInline<T>::h() {} + +namespace EmitDefaultedSpecialMembers { + template<typename T> struct SmallVectorImpl { + SmallVectorImpl() {} + ~SmallVectorImpl() {} // non-trivial dtor + }; + template<typename T, unsigned N> struct SmallVector : SmallVectorImpl<T> { + // trivial dtor + }; + template<unsigned N> struct SmallString : SmallVector<char, N> { + // trivial dtor + }; +} + +template<typename T> struct WithUndefinedStaticDataMember { + static T undefined; +}; diff --git a/test/Modules/Inputs/va_list/module.modulemap b/test/Modules/Inputs/va_list/module.modulemap new file mode 100644 index 0000000000000..870f38bb0ecdc --- /dev/null +++ b/test/Modules/Inputs/va_list/module.modulemap @@ -0,0 +1,2 @@ +module va_list_a { header "va_list_a.h" } +module va_list_b { header "va_list_b.h" } diff --git a/test/Modules/Inputs/va_list/va_list_a.h b/test/Modules/Inputs/va_list/va_list_a.h new file mode 100644 index 0000000000000..7193ca2ec3409 --- /dev/null +++ b/test/Modules/Inputs/va_list/va_list_a.h @@ -0,0 +1 @@ +int vprintf(const char * __restrict, va_list); diff --git a/test/Modules/Inputs/va_list/va_list_b.h b/test/Modules/Inputs/va_list/va_list_b.h new file mode 100644 index 0000000000000..b7f9b3d367c5b --- /dev/null +++ b/test/Modules/Inputs/va_list/va_list_b.h @@ -0,0 +1,2 @@ +@import va_list_a; +void NSLogv(id, va_list); diff --git a/test/Modules/Inputs/warn-unused-local-typedef.h b/test/Modules/Inputs/warn-unused-local-typedef.h new file mode 100644 index 0000000000000..6006de0cc8cc3 --- /dev/null +++ b/test/Modules/Inputs/warn-unused-local-typedef.h @@ -0,0 +1 @@ +inline void myfun() { typedef int a; } diff --git a/test/Modules/Rmodule-build.m b/test/Modules/Rmodule-build.m index b8abc01c2c1a4..e8f293535178f 100644 --- a/test/Modules/Rmodule-build.m +++ b/test/Modules/Rmodule-build.m @@ -1,34 +1,41 @@ -// REQUIRES: shell // RUN: rm -rf %t // RUN: mkdir %t // RUN: echo '// A' > %t/A.h -// RUN: echo '// B' > %t/B.h +// RUN: echo '#include "C.h"' > %t/B.h +// RUN: echo '// C' > %t/C.h // RUN: echo 'module A { header "A.h" }' > %t/module.modulemap // RUN: echo 'module B { header "B.h" }' >> %t/module.modulemap +// RUN: echo 'module C { header "C.h" }' >> %t/module.modulemap // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -verify \ // RUN: -I %t -Rmodule-build -@import A; // expected-remark{{building module 'A' as}} -@import B; // expected-remark{{building module 'B' as}} +@import A; // expected-remark{{building module 'A' as}} expected-remark {{finished building module 'A'}} +@import B; // expected-remark{{building module 'B' as}} expected-remark {{finished building module 'B'}} @import A; // no diagnostic @import B; // no diagnostic -// RUN: echo ' ' >> %t/B.h +// RUN: echo ' ' >> %t/C.h // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \ // RUN: -Rmodule-build 2>&1 | FileCheck %s -// RUN: echo ' ' >> %t/B.h +// RUN: echo ' ' >> %t/C.h // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \ // RUN: -Reverything 2>&1 | FileCheck %s // RUN: echo ' ' >> %t/B.h // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \ -// RUN: 2>&1 | count 0 +// RUN: 2>&1 | FileCheck -allow-empty -check-prefix=NO-REMARKS %s // RUN: echo ' ' >> %t/B.h // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \ -// RUN: -Rmodule-build -Rno-everything 2>&1 | count 0 +// RUN: -Rmodule-build -Rno-everything 2>&1 | \ +// RUN: FileCheck -allow-empty -check-prefix=NO-REMARKS %s // CHECK-NOT: building module 'A' // CHECK: building module 'B' +// CHECK: building module 'C' +// CHECK: finished building module 'C' +// CHECK: finished building module 'B' +// NO-REMARKS-NOT: building module 'A' +// NO-REMARKS-NOT: building module 'B' diff --git a/test/Modules/Werror-Wsystem-headers.m b/test/Modules/Werror-Wsystem-headers.m index c4cd1a6378ccf..4391aa0279778 100644 --- a/test/Modules/Werror-Wsystem-headers.m +++ b/test/Modules/Werror-Wsystem-headers.m @@ -1,21 +1,20 @@ -// REQUIRES: shell // RUN: rm -rf %t // RUN: rm -rf %t-saved // RUN: mkdir %t-saved // Initial module build // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \ -// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify +// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify // RUN: cp %t/cstd.pcm %t-saved/cstd.pcm // Even with -Werror don't rebuild a system module // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \ -// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify -Werror +// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify -Werror // RUN: diff %t/cstd.pcm %t-saved/cstd.pcm // Unless -Wsystem-headers is on // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \ -// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify \ +// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify \ // RUN: -Werror=unused -Wsystem-headers // RUN: not diff %t/cstd.pcm %t-saved/cstd.pcm diff --git a/test/Modules/Werror.m b/test/Modules/Werror.m index 94a98a5a198d0..6444ea513b81c 100644 --- a/test/Modules/Werror.m +++ b/test/Modules/Werror.m @@ -1,4 +1,3 @@ -// REQUIRES: shell // RUN: rm -rf %t // RUN: rm -rf %t-saved // RUN: mkdir -p %t-saved diff --git a/test/Modules/add-remove-private.m b/test/Modules/add-remove-private.m new file mode 100644 index 0000000000000..49e81e11141d9 --- /dev/null +++ b/test/Modules/add-remove-private.m @@ -0,0 +1,28 @@ +// RUN: rm -rf %t +// RUN: rm -rf %t.mcp +// RUN: mkdir -p %t +// RUN: cp -r %S/Inputs/AddRemovePrivate.framework %t/AddRemovePrivate.framework + +// Build with module.private.modulemap +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fdisable-module-hash -F %t %s -verify -DP +// RUN: cp %t.mcp/AddRemovePrivate.pcm %t/with.pcm + +// Build without module.private.modulemap +// RUN: rm %t/AddRemovePrivate.framework/Modules/module.private.modulemap +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fdisable-module-hash -F %t %s -verify +// RUN: not diff %t.mcp/AddRemovePrivate.pcm %t/with.pcm +// RUN: cp %t.mcp/AddRemovePrivate.pcm %t/without.pcm +// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fdisable-module-hash -F %t %s -DP 2>&1 | FileCheck %s +// CHECK: no submodule named 'Private' + +// Build with module.private.modulemap (again) +// RUN: cp %S/Inputs/AddRemovePrivate.framework/Modules/module.private.modulemap %t/AddRemovePrivate.framework/Modules/module.private.modulemap +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fdisable-module-hash -F %t %s -verify -DP +// RUN: not diff %t.mcp/AddRemovePrivate.pcm %t/without.pcm + +// expected-no-diagnostics + +@import AddRemovePrivate; +#ifdef P +@import AddRemovePrivate.Private; +#endif diff --git a/test/Modules/attr-unavailable.m b/test/Modules/attr-unavailable.m new file mode 100644 index 0000000000000..0188a84d98161 --- /dev/null +++ b/test/Modules/attr-unavailable.m @@ -0,0 +1,25 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/attr-unavailable %s -fsyntax-only -verify + +@import two; +void f(id x) { + [x method1]; +} + +@import oneA; +void g(id x) { + [x method2]; // expected-error{{'method2' is unavailable}} + // expected-note@oneA.h:2 {{'method2' has been explicitly marked unavailable here}} + [x method3]; // expected-error{{'method3' is unavailable}} + // expected-note@oneA.h:3 {{'method3' has been explicitly marked unavailable here}} +} + +@import oneB; +void h(id x) { + [x method2]; // could be from interface D in module oneB +} + +@import oneC; +void i(id x) { + [x method3]; // could be from interface E in module oncC +} diff --git a/test/Modules/autolink.m b/test/Modules/autolink.m index 47eda3f80e011..5f2e9bd20208f 100644 --- a/test/Modules/autolink.m +++ b/test/Modules/autolink.m @@ -37,14 +37,14 @@ int use_autolink_sub3() { // NOTE: "autolink_sub" is intentionally not linked. // CHECK: !llvm.module.flags = !{{{.*}}} -// CHECK: !{{[0-9]+}} = metadata !{i32 6, metadata !"Linker Options", metadata ![[AUTOLINK_OPTIONS:[0-9]+]]} -// CHECK: ![[AUTOLINK_OPTIONS]] = metadata !{metadata ![[AUTOLINK_PCH:[0-9]+]], metadata ![[AUTOLINK_FRAMEWORK:[0-9]+]], metadata ![[AUTOLINK:[0-9]+]], metadata ![[DEPENDSONMODULE:[0-9]+]], metadata ![[MODULE:[0-9]+]], metadata ![[NOUMBRELLA:[0-9]+]]} -// CHECK: ![[AUTOLINK_PCH]] = metadata !{metadata !"{{(-l|/DEFAULTLIB:)}}autolink_from_pch{{(\.lib)?}}"} -// CHECK: ![[AUTOLINK_FRAMEWORK]] = metadata !{metadata !"-framework", metadata !"autolink_framework"} -// CHECK: ![[AUTOLINK]] = metadata !{metadata !"{{(-l|/DEFAULTLIB:)}}autolink{{(\.lib)?}}"} -// CHECK: ![[DEPENDSONMODULE]] = metadata !{metadata !"-framework", metadata !"DependsOnModule"} -// CHECK: ![[MODULE]] = metadata !{metadata !"-framework", metadata !"Module"} -// CHECK: ![[NOUMBRELLA]] = metadata !{metadata !"-framework", metadata !"NoUmbrella"} +// 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_FRAMEWORK]] = !{!"-framework", !"autolink_framework"} +// CHECK: ![[AUTOLINK]] = !{!"{{(-l|/DEFAULTLIB:)}}autolink{{(\.lib)?}}"} +// CHECK: ![[DEPENDSONMODULE]] = !{!"-framework", !"DependsOnModule"} +// CHECK: ![[MODULE]] = !{!"-framework", !"Module"} +// CHECK: ![[NOUMBRELLA]] = !{!"-framework", !"NoUmbrella"} // CHECK-AUTOLINK-DISABLED: !llvm.module.flags // CHECK-AUTOLINK-DISABLED-NOT: "Linker Options" diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m index 3d1dcf38e33cd..24bca19b7aa9a 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 -fmodules -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s +// 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 @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 5498b47fc9fe8..109306ed79dfd 100644 --- a/test/Modules/cxx-decls.cpp +++ b/test/Modules/cxx-decls.cpp @@ -30,7 +30,27 @@ void use_implicit_new_again() { operator new[](3); } int importMergeUsedFlag = getMergeUsedFlag(); +int use_name_for_linkage(NameForLinkage &nfl) { + return nfl.n + nfl.m; +} +int use_overrides_virtual_functions(OverridesVirtualFunctions ovf) { return 0; } + @import cxx_decls_merged; +NameForLinkage2Inner use_name_for_linkage2_inner; +NameForLinkage2 use_name_for_linkage2; + +int name_for_linkage_test = use_name_for_linkage(name_for_linkage); +int overrides_virtual_functions_test = + use_overrides_virtual_functions(overrides_virtual_functions); + +void use_extern_c_function() { ExternCFunction(); } + +int use_namespace_alias() { return Alias::a + Alias::b; } + +@import cxx_decls_premerged; + +void use_extern_c_function_2() { ExternCFunction(); } + // 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-irgen.cpp b/test/Modules/cxx-irgen.cpp index 4c61a3a3583be..ecaf704b87bba 100644 --- a/test/Modules/cxx-irgen.cpp +++ b/test/Modules/cxx-irgen.cpp @@ -1,5 +1,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-optzns -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fmodules -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-optzns -emit-llvm -g -o - %s | FileCheck %s // FIXME: When we have a syntax for modules in C++, use that. @import cxx_irgen_top; @@ -10,13 +11,66 @@ CtorInit<int> x; @import cxx_irgen_left; @import cxx_irgen_right; +// Keep these two namespace definitions separate; merging them hides the bug. +namespace EmitInlineMethods { + // CHECK-DAG: define linkonce_odr [[CC:(x86_thiscallcc[ ]+)?]]void @_ZN17EmitInlineMethods1C1fEPNS_1AE( + // CHECK-DAG: declare [[CC]]void @_ZN17EmitInlineMethods1A1gEv( + struct C { + __attribute__((used)) void f(A *p) { p->g(); } + }; +} +namespace EmitInlineMethods { + // CHECK-DAG: define linkonce_odr [[CC]]void @_ZN17EmitInlineMethods1D1fEPNS_1BE( + // CHECK-DAG: define linkonce_odr [[CC]]void @_ZN17EmitInlineMethods1B1gEv( + struct D { + __attribute__((used)) void f(B *p) { p->g(); } + }; +} + // CHECK-DAG: define available_externally hidden {{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[ALWAYS_INLINE:.*]] align int a = S<int>::g(); -// CHECK-DAG: define available_externally {{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align int b = h(); // CHECK-DAG: define linkonce_odr {{signext i32|i32}} @_Z3minIiET_S0_S0_(i32 int c = min(1, 2); +// CHECK-LABEL: define {{.*}} @_ZN20OperatorDeleteLookup1AD0Ev( +// CHECK: call void @_ZN20OperatorDeleteLookup1AdlEPv( + +namespace ImplicitSpecialMembers { + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2EOS0_( + // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2ERKS0_( + // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2EOS0_( + // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2ERKS0_( + // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2EOS0_( + // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( + // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_( + // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_( + + extern B b1; + B b2(b1); + B b3(static_cast<B&&>(b1)); + + extern C c1; + C c2(c1); + C c3(static_cast<C&&>(c1)); + + extern D d1; + D d2(d1); + D d3(static_cast<D&&>(d1)); +} + +namespace OperatorDeleteLookup { + // Trigger emission of B's vtable and deleting dtor. + // This requires us to know what operator delete was selected. + 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 new file mode 100644 index 0000000000000..47c879dbb636d --- /dev/null +++ b/test/Modules/cxx-lookup.cpp @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -I%S/Inputs/cxx-lookup -verify +// expected-no-diagnostics +namespace llvm {} +#include "c2.h" +llvm::GlobalValue *p; diff --git a/test/Modules/cxx-templates.cpp b/test/Modules/cxx-templates.cpp index cbe9f35089515..d9c8a8c27d0d8 100644 --- a/test/Modules/cxx-templates.cpp +++ b/test/Modules/cxx-templates.cpp @@ -1,12 +1,18 @@ // 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 -ast-dump-lookups | FileCheck %s --check-prefix=CHECK-GLOBAL -// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups -ast-dump-filter N | FileCheck %s --check-prefix=CHECK-NAMESPACE-N +// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump-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: %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 + +#ifdef EARLY_IMPORT +#include "cxx-templates-textual.h" +#endif @import cxx_templates_a; @import cxx_templates_b; @import cxx_templates_c; +@import cxx_templates_d; @import cxx_templates_common; template<typename, char> struct Tmpl_T_C {}; @@ -22,15 +28,21 @@ 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); N::f<int>(); N::f(); // expected-error {{no matching function}} - // expected-note@Inputs/cxx-templates-a.h:6 {{couldn't infer template argument}} - // expected-note@Inputs/cxx-templates-a.h:7 {{requires 1 argument}} + // expected-note@Inputs/cxx-templates-b.h:6 {{couldn't infer template argument}} + // expected-note@Inputs/cxx-templates-b.h:7 {{requires single argument}} template_param_kinds_1<0>(); // ok, from cxx-templates-a.h template_param_kinds_1<int>(); // ok, from cxx-templates-b.h @@ -105,11 +117,22 @@ void g() { int &p = WithPartialSpecializationUse().f(); int &q = WithExplicitSpecializationUse().inner_template<int>(); + int *r = PartiallyInstantiatePartialSpec<int*>::bar(); + + (void)&WithImplicitSpecialMembers<int>::n; + + MergeClassTemplateSpecializations_string s; + + extern TestInjectedClassName::A *use_a; + extern TestInjectedClassName::C *use_c; + TestInjectedClassName::UseD(); } 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, ""); @@ -123,6 +146,21 @@ 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; +dwpdam_typedef::type dwpdam_typedef_use; +DontWalkPreviousDeclAfterMerging<int>::Inner::type dwpdam; + +using AliasTemplateMergingTest = WithAliasTemplate<int>::X<char>; + +int AnonymousDeclsMergingTest(WithAnonymousDecls<int> WAD, WithAnonymousDecls<char> WADC) { + return InstantiateWithAnonymousDeclsA(WAD) + + InstantiateWithAnonymousDeclsB(WAD) + + InstantiateWithAnonymousDeclsB2(WADC) + + InstantiateWithAnonymousDeclsD(WADC); +} @import cxx_templates_common; diff --git a/test/Modules/dependency-gen.m b/test/Modules/dependency-gen.m index dec83848f061e..d3d66bfaab218 100644 --- a/test/Modules/dependency-gen.m +++ b/test/Modules/dependency-gen.m @@ -1,7 +1,7 @@ // RUN: rm -rf %t-mcp // RUN: mkdir -p %t-mcp -// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s +// RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s // RUN: FileCheck %s < %t.d.1 // CHECK: dependency-gen.m // CHECK: Inputs{{.}}diamond_top.h @@ -10,7 +10,7 @@ // CHECK-NOT: stdint.h -// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s +// RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s // RUN: FileCheck %s -check-prefix=CHECK-SYS < %t.d.2 // CHECK-SYS: dependency-gen.m // CHECK-SYS: Inputs{{.}}diamond_top.h diff --git a/test/Modules/dependency-gen.modulemap.cpp b/test/Modules/dependency-gen.modulemap.cpp new file mode 100644 index 0000000000000..c49714c14ed94 --- /dev/null +++ b/test/Modules/dependency-gen.modulemap.cpp @@ -0,0 +1,18 @@ +// 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: FileCheck %s < %t.d +module "test" { + export * + header "Inputs/dependency-gen.h" + use "test-base" + use "test-base2" +} +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 diff --git a/test/Modules/explicit-build-flags.cpp b/test/Modules/explicit-build-flags.cpp new file mode 100644 index 0000000000000..6ced215a06d1b --- /dev/null +++ b/test/Modules/explicit-build-flags.cpp @@ -0,0 +1,49 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo 'module tmp { header "tmp.h" }' > %t/map +// RUN: touch %t/tmp.h +// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp.pcm + +// Can use the module. +// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s + +// Can use the module if an input file is newer. (This happens on +// remote file systems.) +// RUN: sleep 1 +// RUN: touch %t/tmp.h +// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s + +// Can use the module if -D flags change. +// RUN: %clang_cc1 -fmodules -DFOO=2 -DBAR=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s +// RUN: %clang_cc1 -fmodules -DBAR=2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s + +// Can use the module if -W flags change. +// RUN: %clang_cc1 -fmodules -DBAR=2 -Wextra -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s + +// Can use the module if -I flags change. +// RUN: %clang_cc1 -fmodules -DBAR=2 -I. -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s + +// Can use the module if -O flags change. +// RUN: %clang_cc1 -fmodules -DBAR=2 -Os -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s +// +// RUN: %clang_cc1 -fmodules -DFOO=1 -O2 -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp-O2.pcm +// RUN: %clang_cc1 -fmodules -DBAR=2 -O0 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-O2.pcm -verify -I%t %s +// RUN: %clang_cc1 -fmodules -DBAR=2 -Os -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-O2.pcm -verify -I%t %s + +#include "tmp.h" // expected-no-diagnostics + +#ifndef BAR +#if FOO != 1 +#error bad FOO from command line and module +#endif +#elif BAR == 1 +#if FOO != 2 +#error bad FOO from command line overriding module +#endif +#elif BAR == 2 +#ifdef FOO +#error FOO leaked from module +#endif +#else +#error bad BAR +#endif diff --git a/test/Modules/explicit-build-relpath.cpp b/test/Modules/explicit-build-relpath.cpp new file mode 100644 index 0000000000000..d9c15660b6adc --- /dev/null +++ b/test/Modules/explicit-build-relpath.cpp @@ -0,0 +1,49 @@ +// REQUIRES: shell +// +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: cd %t + +// ---------------------- +// Build modules A and B. +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o a.pcm +// +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=a.pcm \ +// RUN: -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o b-rel.pcm +// +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o b-abs.pcm + +// ------------------------------------------ +// Mix and match relative and absolute paths. +// RUN: %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/a.pcm \ +// RUN: -fmodule-file=a.pcm \ +// RUN: -verify %s +// +// RUN: %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/a.pcm \ +// RUN: -fmodule-file=b-rel.pcm \ +// RUN: -verify %s +// +// RUN: %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=a.pcm \ +// RUN: -fmodule-file=b-abs.pcm \ +// RUN: -verify %s +// +// 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=b-rel.pcm \ +// RUN: -fmodule-file=b-abs.pcm \ +// RUN: -verify %s 2>&1 | FileCheck %s +// CHECK: module 'b' is defined in both '{{.*}}b-rel.pcm' and '{{.*}}b-abs.pcm' + +#include "a.h" +static_assert(a == 1, ""); +// expected-no-diagnostics diff --git a/test/Modules/explicit-build.cpp b/test/Modules/explicit-build.cpp new file mode 100644 index 0000000000000..ce3a1af416261 --- /dev/null +++ b/test/Modules/explicit-build.cpp @@ -0,0 +1,175 @@ +// RUN: rm -rf %t + +// ------------------------------- +// Build chained modules A, B, and C +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a.pcm \ +// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty +// +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/b.pcm \ +// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty +// +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/b.pcm \ +// RUN: -fmodule-name=c -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/c.pcm \ +// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty +// +// CHECK-NO-IMPLICIT-BUILD-NOT: building module + +// ------------------------------- +// Build B with an implicit build of A +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/b-not-a.pcm \ +// RUN: 2>&1 | FileCheck --check-prefix=CHECK-B-NO-A %s +// +// CHECK-B-NO-A: While building module 'b': +// CHECK-B-NO-A: building module 'a' as + +// ------------------------------- +// Check that we can use the explicitly-built A, B, and C modules. +// RUN: %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/a.pcm \ +// RUN: -verify %s -DHAVE_A +// +// RUN: %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-map-file=%S/Inputs/explicit-build/module.modulemap \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -verify %s -DHAVE_A +// +// RUN: %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/b.pcm \ +// RUN: -verify %s -DHAVE_A -DHAVE_B +// +// RUN: %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/a.pcm \ +// RUN: -fmodule-file=%t/b.pcm \ +// RUN: -verify %s -DHAVE_A -DHAVE_B +// +// RUN: %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/a.pcm \ +// RUN: -fmodule-file=%t/b.pcm \ +// RUN: -fmodule-file=%t/c.pcm \ +// RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C +// +// RUN: %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/a.pcm \ +// RUN: -fmodule-file=%t/c.pcm \ +// RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C + +#if HAVE_A + #include "a.h" + static_assert(a == 1, ""); +#else + const int use_a = a; // expected-error {{undeclared identifier}} +#endif + +#if HAVE_B + #include "b.h" + static_assert(b == 2, ""); +#else + const int use_b = b; // expected-error {{undeclared identifier}} +#endif + +#if HAVE_C + #include "c.h" + static_assert(c == 3, ""); +#else + const int use_c = c; // expected-error {{undeclared identifier}} +#endif + +#if HAVE_A && HAVE_B && HAVE_C +// expected-no-diagnostics +#endif + +// ------------------------------- +// Check that we can use a mixture of implicit and explicit modules. +// RUN: %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/b-not-a.pcm \ +// RUN: -verify %s -DHAVE_A -DHAVE_B + +// ------------------------------- +// Try to use two different flavors of the 'a' module. +// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-file=%t/b-not-a.pcm \ +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s +// +// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-file=%t/b-not-a.pcm \ +// RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s +// +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a-alt.pcm \ +// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty +// +// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-file=%t/a-alt.pcm \ +// RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s +// +// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/a-alt.pcm \ +// RUN: -fmodule-file=%t/a.pcm \ +// RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s +// +// CHECK-MULTIPLE-AS: error: module 'a' is defined in both '{{.*}}/a{{.*}}.pcm' and '{{.*[/\\]}}a{{.*}}.pcm' + +// ------------------------------- +// Try to import a PCH with -fmodule-file= +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-name=a -emit-pch %S/Inputs/explicit-build/a.h -o %t/a.pch \ +// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty +// +// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/a.pch \ +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-A-AS-PCH %s +// +// CHECK-A-AS-PCH: fatal error: AST file '{{.*}}a.pch' was not built as a module + +// ------------------------------- +// Try to import a non-AST file with -fmodule-file= +// +// RUN: touch %t/not.pcm +// +// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ +// RUN: -fmodule-file=%t/not.pcm \ +// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s +// +// 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 +// +// CHECK-BAD-FILE: fatal error: file '{{.*}}t.pcm' is not a precompiled module file + +// ------------------------------- +// Check that we don't get upset if B's timestamp is newer than C's. +// RUN: touch %t/b.pcm +// +// RUN: %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: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C +// +// ... but that we do get upset if our B is different from the B that C expects. +// +// RUN: cp %t/b-not-a.pcm %t/b.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 -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck --check-prefix=CHECK-MISMATCHED-B %s +// +// CHECK-MISMATCHED-B: fatal error: malformed or corrupted AST file: {{.*}}b.pcm": module file out of date diff --git a/test/Modules/filename.cpp b/test/Modules/filename.cpp new file mode 100644 index 0000000000000..66891a04b7449 --- /dev/null +++ b/test/Modules/filename.cpp @@ -0,0 +1,9 @@ +// 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" + +// Make sure that headers that are referenced by module maps have __FILE__ +// reflect the include path they were found with. +// CHECK: const char *p = "./Inputs/filename/a.h" diff --git a/test/Modules/fmodules-validate-once-per-build-session.c b/test/Modules/fmodules-validate-once-per-build-session.c index 346d5a72c3e87..dcbd0db3cbfe5 100644 --- a/test/Modules/fmodules-validate-once-per-build-session.c +++ b/test/Modules/fmodules-validate-once-per-build-session.c @@ -6,39 +6,53 @@ // RUN: mkdir -p %t/modules-to-compare // === -// Create a module with system headers. +// Create a module. We will use -I or -isystem to determine whether to treat +// foo.h as a system header. // RUN: echo 'void meow(void);' > %t/Inputs/foo.h -// RUN: echo 'module Foo [system] { header "foo.h" }' > %t/Inputs/module.map +// RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.map // === // Compile the module. -// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s +// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s +// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp +// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm +// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm // === // Use it, and make sure that we did not recompile it. -// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s +// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s +// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp +// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm +// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm +// RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm // === // Change the sources. // RUN: echo 'void meow2(void);' > %t/Inputs/foo.h // === -// Use the module, and make sure that we did not recompile it, even though the sources changed. -// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s +// Use the module, and make sure that we did not recompile it if foo.h is a +// system header, even though the sources changed. +// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s +// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp +// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm +// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm +// When foo.h is a user header, we will always validate it. +// RUN: not diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm // === // Recompile the module if the today's date is before 01 January 2030. -// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s +// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm diff --git a/test/Modules/implementation-of-module.m b/test/Modules/implementation-of-module.m new file mode 100644 index 0000000000000..b398404201560 --- /dev/null +++ b/test/Modules/implementation-of-module.m @@ -0,0 +1,29 @@ +// RUN: not %clang_cc1 -fmodule-implementation-of Foo -fmodule-name=Bar %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-IMPL-OF-ERR %s +// CHECK-IMPL-OF-ERR: conflicting module names specified: '-fmodule-name=Bar' and '-fmodule-implementation-of Foo' + +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \ +// RUN: -fmodule-implementation-of category_right -fsyntax-only + +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \ +// RUN: -fmodule-implementation-of category_right -dM -E -o - 2>&1 | FileCheck %s +// CHECK-NOT: __building_module + +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \ +// RUN: -fmodule-implementation-of category_left -verify + +// 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 + +#ifndef WITH_PREFIX + +@import category_left; // expected-error{{@import of module 'category_left' in implementation of 'category_left'; use #import}} +@import category_left.sub; // expected-error{{@import of module 'category_left.sub' in implementation of 'category_left'; use #import}} +#import "category_right.h" // expected-error{{treating}} +#import "category_right_sub.h" // expected-error{{treating}} + +#endif + diff --git a/test/Modules/include_next.c b/test/Modules/include_next.c new file mode 100644 index 0000000000000..f2dafb4a91de5 --- /dev/null +++ b/test/Modules/include_next.c @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -I%S/Inputs/include_next/x -I%S/Inputs/include_next/y -verify %s +// RUN: %clang_cc1 -I%S/Inputs/include_next/x -I%S/Inputs/include_next/y -verify %s -fmodules -fmodules-cache-path=%t + +// expected-no-diagnostics +#include "a.h" +#include "subdir/b.h" +_Static_assert(ax == 1, ""); +_Static_assert(ay == 2, ""); +_Static_assert(bx == 3, ""); +_Static_assert(by == 4, ""); diff --git a/test/Modules/incomplete-module.m b/test/Modules/incomplete-module.m index 8edaea983cb99..8181ae863de9e 100644 --- a/test/Modules/incomplete-module.m +++ b/test/Modules/incomplete-module.m @@ -2,4 +2,8 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules-cache-path=%t -Wincomplete-module -fmodules -I %S/Inputs %s 2>&1 | FileCheck %s -// CHECK: {{warning: header '.*incomplete_mod_missing.h' is included in module 'incomplete_mod' but not listed in module map}} +// CHECK: warning: include of non-modular header inside module 'incomplete_mod' + +// RUN: rm -rf %t +// RUN: not %clang_cc1 -fmodules-cache-path=%t -fmodules-strict-decluse -fmodules -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=DECLUSE +// DECLUSE: error: module incomplete_mod does not depend on a module exporting {{'.*incomplete_mod_missing.h'}} diff --git a/test/Modules/inferred-attributes.mm b/test/Modules/inferred-attributes.mm new file mode 100644 index 0000000000000..5fc1d623f396f --- /dev/null +++ b/test/Modules/inferred-attributes.mm @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -F %S/Inputs/inferred-attr -fsyntax-only -verify %s +// expected-no-diagnostics +extern "C" { +@import InferredExternC; +} diff --git a/test/Modules/load-after-failure.m b/test/Modules/load-after-failure.m index f471fd88d505f..38d4a3653205d 100644 --- a/test/Modules/load-after-failure.m +++ b/test/Modules/load-after-failure.m @@ -1,4 +1,3 @@ -// REQUIRES: shell // RUN: rm -rf %t // RUN: mkdir -p %t diff --git a/test/Modules/macro-reexport/c1.h b/test/Modules/macro-reexport/c1.h index d6a20e7419c19..b63c278577f6c 100644 --- a/test/Modules/macro-reexport/c1.h +++ b/test/Modules/macro-reexport/c1.h @@ -1,2 +1,4 @@ +#pragma once + #include "b1.h" #define assert(x) c diff --git a/test/Modules/macro-reexport/d1.h b/test/Modules/macro-reexport/d1.h index fbd68d5de5821..99abd24815972 100644 --- a/test/Modules/macro-reexport/d1.h +++ b/test/Modules/macro-reexport/d1.h @@ -1,2 +1,5 @@ +#pragma once + #include "c1.h" +#undef assert #define assert(x) d diff --git a/test/Modules/macro-reexport/e1.h b/test/Modules/macro-reexport/e1.h new file mode 100644 index 0000000000000..6c6829df36546 --- /dev/null +++ b/test/Modules/macro-reexport/e1.h @@ -0,0 +1,2 @@ +#include "c1.h" +#undef assert diff --git a/test/Modules/macro-reexport/e2.h b/test/Modules/macro-reexport/e2.h new file mode 100644 index 0000000000000..7bc0b4972d2cc --- /dev/null +++ b/test/Modules/macro-reexport/e2.h @@ -0,0 +1,2 @@ +#include "d1.h" +#undef assert diff --git a/test/Modules/macro-reexport/f1.h b/test/Modules/macro-reexport/f1.h new file mode 100644 index 0000000000000..f8f6502a90c68 --- /dev/null +++ b/test/Modules/macro-reexport/f1.h @@ -0,0 +1,3 @@ +#include "e1.h" +#include "d1.h" + diff --git a/test/Modules/macro-reexport/macro-reexport.cpp b/test/Modules/macro-reexport/macro-reexport.cpp index 47b15c2740bd5..af2ec847ce078 100644 --- a/test/Modules/macro-reexport/macro-reexport.cpp +++ b/test/Modules/macro-reexport/macro-reexport.cpp @@ -1,13 +1,30 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fsyntax-only -DD2 -I. %s -fmodules-cache-path=%t -verify -// RUN: %clang_cc1 -fsyntax-only -DD2 -I. -fmodules %s -fmodules-cache-path=%t -verify // RUN: %clang_cc1 -fsyntax-only -DC1 -I. %s -fmodules-cache-path=%t -verify // RUN: %clang_cc1 -fsyntax-only -DC1 -I. -fmodules %s -fmodules-cache-path=%t -verify +// 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 -#ifdef D2 +#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 'c'}} +void f() { return assert(true); } // expected-error {{undeclared identifier 'assert'}} #endif diff --git a/test/Modules/macro-reexport/module.modulemap b/test/Modules/macro-reexport/module.modulemap index 21585b692e3f9..896bda041c308 100644 --- a/test/Modules/macro-reexport/module.modulemap +++ b/test/Modules/macro-reexport/module.modulemap @@ -13,3 +13,11 @@ module d { module d1 { header "d1.h" export * } module d2 { header "d2.h" export * } } +module e { + module e1 { header "e1.h" export * } + module e2 { header "e2.h" export * } +} +module f { + module f1 { header "f1.h" export * } + module f2 { header "f2.h" export * } +} diff --git a/test/Modules/macros.c b/test/Modules/macros.c index 7a7e570ca256b..92ea88a480203 100644 --- a/test/Modules/macros.c +++ b/test/Modules/macros.c @@ -130,8 +130,14 @@ void test3() { # error TOP_RIGHT_UNDEF should still be defined #endif +@import macros_bottom; + +TOP_DEF_RIGHT_UNDEF *TDRUf() { return TDRUp; } + @import macros_right.undef; +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. diff --git a/test/Modules/malformed.cpp b/test/Modules/malformed.cpp index cd7b33493998b..2554c3a8729f8 100644 --- a/test/Modules/malformed.cpp +++ b/test/Modules/malformed.cpp @@ -1,23 +1,37 @@ +// 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: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/malformed -DHEADER="a1.h" %s 2>&1 | FileCheck %s --check-prefix=CHECK-A -// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/malformed -DHEADER="b1.h" %s 2>&1 | FileCheck %s --check-prefix=CHECK-B +// 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 +// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I Inputs/malformed -DHEADER="b1.h" %s 2>&1 | FileCheck %s --check-prefix=CHECK-B +// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I Inputs/malformed -DHEADER="c.h" malformed.cpp 2>&1 | FileCheck %s --check-prefix=CHECK-C #define STR2(x) #x #define STR(x) STR2(x) #include STR(HEADER) // CHECK-A: While building module 'malformed_a' -// CHECK-A: a1.h:1:{{.*}} error: expected '}' -// CHECK-A: a1.h:1:{{.*}} note: to match this '{' +// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} error: expected '}' +// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} note: to match this '{' // // CHECK-A: While building module 'malformed_a' -// CHECK-A: a2.h:1:{{.*}} error: extraneous closing brace +// CHECK-A: {{^}}Inputs/malformed/a2.h:1:{{.*}} error: extraneous closing brace // CHECK-B: While building module 'malformed_b' -// CHECK-B: b1.h:2:{{.*}} error: expected '}' -// CHECK-B: b1.h:1:{{.*}} note: to match this '{' -// CHECK-B: b1.h:3:{{.*}} error: extraneous closing brace ('}') +// CHECK-B: {{^}}Inputs/malformed/b1.h:2:{{.*}} error: expected '}' +// CHECK-B: {{^}}Inputs/malformed/b1.h:1:{{.*}} note: to match this '{' +// CHECK-B: {{^}}Inputs/malformed/b1.h:3:{{.*}} error: extraneous closing brace ('}') // // CHECK-B: While building module 'malformed_b' -// CHECK-B: b2.h:1:{{.*}} error: redefinition of 'g' -// CHECK-B: b2.h:1:{{.*}} note: previous definition is here +// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} error: redefinition of 'g' +// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} note: previous definition is here + +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: {{^}}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-typedefs.cpp b/test/Modules/merge-typedefs.cpp new file mode 100644 index 0000000000000..607f8c5ad0ec7 --- /dev/null +++ b/test/Modules/merge-typedefs.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -I%S/Inputs/merge-typedefs -verify %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-typedefs -verify %s + +#include "b2.h" +#include "a1.h" + +// expected-no-diagnostics +llvm::MachineDomTreeNode *p; +foo2_t f2t; diff --git a/test/Modules/merge-using-decls.cpp b/test/Modules/merge-using-decls.cpp new file mode 100644 index 0000000000000..3b84d0e5a3a0d --- /dev/null +++ b/test/Modules/merge-using-decls.cpp @@ -0,0 +1,69 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=1 +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2 + +#if ORDER == 1 +#include "a.h" +#include "b.h" +#else +#include "b.h" +#include "a.h" +#endif + +struct Y { + int value; // expected-note 0-1{{target of using}} + typedef int type; // expected-note 0-1{{target of using}} +}; + +template<typename T> int Use() { + int k = T().v + T().value; // expected-note 0-2{{instantiation of}} + typedef typename T::type I; + typedef typename T::t I; + typedef int I; + return k; +} + +template<typename T> int UseAll() { + return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}} +} + +template int UseAll<YA>(); +template int UseAll<YB>(); +template int UseAll<Y>(); + +#if ORDER == 1 +// Here, we're instantiating the definition from 'A' and merging the definition +// from 'B' into it. + +// expected-error@b.h:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}} +// expected-error@b.h:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}} + +// expected-error@b.h:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}} +// expected-error@b.h:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}} +// expected-error@b.h:* {{'F::value' from module 'B' is not present in definition of 'F<T>' in module 'A'}} +// expected-error@b.h:* {{'F::v' from module 'B' is not present in definition of 'F<T>' in module 'A'}} + +// expected-note@a.h:* +{{does not match}} +#else +// Here, we're instantiating the definition from 'B' and merging the definition +// from 'A' into it. + +// expected-error@a.h:* {{'D::type' from module 'A' is not present in definition of 'D<T>' in module 'B'}} +// expected-error@a.h:* {{'D::value' from module 'A' is not present in definition of 'D<T>' in module 'B'}} +// expected-error@b.h:* 2{{'typename' keyword used on a non-type}} +// expected-error@b.h:* 2{{dependent using declaration resolved to type without 'typename'}} + +// expected-error@a.h:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}} +// expected-error@a.h:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}} +// expected-error@a.h:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}} +// expected-error@a.h:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}} +// expected-note@b.h:* 2{{definition has no member}} + +// expected-error@a.h:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}} +// expected-error@a.h:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}} +// expected-error@a.h:* {{'F::value' from module 'A' is not present in definition of 'F<T>' in module 'B'}} +// expected-error@a.h:* {{'F::v' from module 'A' is not present in definition of 'F<T>' in module 'B'}} + +// expected-note@b.h:* +{{does not match}} +// expected-note@b.h:* +{{target of using}} +#endif diff --git a/test/Modules/modular_maps.cpp b/test/Modules/modular_maps.cpp index 9c9aba85a9183..606c979c4c2f4 100644 --- a/test/Modules/modular_maps.cpp +++ b/test/Modules/modular_maps.cpp @@ -1,8 +1,22 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -I %S/Inputs/modular_maps %s -verify +// +// RxN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -fmodule-map-file=%S/Inputs/modular_maps/modulec.map -I %S/Inputs/modular_maps %s -verify +// RxN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulec.map -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -I %S/Inputs/modular_maps %s -verify +// +// RxN: cd %S +// RxN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=Inputs/modular_maps/modulea.map -fmodule-map-file=Inputs/modular_maps/modulec.map -I Inputs/modular_maps %s -verify +// RxN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=Inputs/modular_maps/modulec.map -fmodule-map-file=Inputs/modular_maps/modulea.map -I Inputs/modular_maps %s -verify +// +// RUN: cd %S +// 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}} -const int v = a + c; -const int val = a + b + c; // expected-error {{undeclared identifier}} +@import C; +const int v = a + c + x; +const int val = a + b + c + x; // expected-error {{undeclared identifier}} diff --git a/test/Modules/module_file_info.m b/test/Modules/module_file_info.m index 2447a747e3ddd..1b0a838bf8238 100644 --- a/test/Modules/module_file_info.m +++ b/test/Modules/module_file_info.m @@ -17,8 +17,8 @@ // CHECK: Target options: // CHECK: Triple: -// CHECK: CPU: -// CHECK: ABI: +// CHECK: CPU: +// CHECK: ABI: // CHECK: Diagnostic options: // CHECK: IgnoreWarnings: Yes @@ -28,7 +28,7 @@ // CHECK: Header search options: // CHECK: System root [-isysroot=]: '/' // CHECK: Use builtin include directories [-nobuiltininc]: Yes -// CHECK: Use standard system include directories [-nostdinc]: Yes +// CHECK: Use standard system include directories [-nostdinc]: No // CHECK: Use standard C++ include directories [-nostdinc++]: Yes // CHECK: Use libc++ (rather than libstdc++) [-stdlib=]: diff --git a/test/Modules/modules-with-same-name.m b/test/Modules/modules-with-same-name.m index c90aa5d7d842d..d362f756a60a8 100644 --- a/test/Modules/modules-with-same-name.m +++ b/test/Modules/modules-with-same-name.m @@ -1,4 +1,3 @@ -// REQUIRES: shell // RUN: rm -rf %t // A from path 1 diff --git a/test/Modules/no-implicit-maps.cpp b/test/Modules/no-implicit-maps.cpp new file mode 100644 index 0000000000000..cb270a05014ea --- /dev/null +++ b/test/Modules/no-implicit-maps.cpp @@ -0,0 +1,3 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x objective-c -fno-modules-implicit-maps -fmodules-cache-path=%t -fmodules -I %S/Inputs/private %s -verify +@import libPrivate1; // expected-error {{not found}} diff --git a/test/Modules/no-stale-modtime.m b/test/Modules/no-stale-modtime.m index 1bff2b017a430..53512126a1b65 100644 --- a/test/Modules/no-stale-modtime.m +++ b/test/Modules/no-stale-modtime.m @@ -1,7 +1,6 @@ // Ensure that when rebuilding a module we don't save its old modtime when // building modules that depend on it. -// REQUIRES: shell // RUN: rm -rf %t // RUN: mkdir -p %t // This could be replaced by diamond_*, except we want to modify the top header diff --git a/test/Modules/odr.cpp b/test/Modules/odr.cpp index 5ab10d2ce4190..120ca20e0a873 100644 --- a/test/Modules/odr.cpp +++ b/test/Modules/odr.cpp @@ -6,6 +6,9 @@ struct X { // expected-note {{definition has no member 'n'}} }; @import a; + +bool b = F<int>{0} == F<int>{1}; + @import b; // Trigger the declarations from a and b to be imported. diff --git a/test/Modules/pch-used.m b/test/Modules/pch-used.m index 56961ba404cc4..74f21f5dac0f1 100644 --- a/test/Modules/pch-used.m +++ b/test/Modules/pch-used.m @@ -4,5 +4,6 @@ // RUN: %clang_cc1 %s -include-pch %t/pch-used.h.pch -fmodules -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include -emit-llvm -o - | FileCheck %s void f() { SPXTrace(); } +void g() { double x = DBL_MAX; } // CHECK: define internal void @SPXTrace diff --git a/test/Modules/pr19692.cpp b/test/Modules/pr19692.cpp new file mode 100644 index 0000000000000..6cc515312f006 --- /dev/null +++ b/test/Modules/pr19692.cpp @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -I%S/Inputs/pr19692 -verify %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/pr19692 -verify %s +#include "TFoo.h" +#include "stdint.h" + +int k = INT64_MAX; // expected-no-diagnostics diff --git a/test/Modules/pr20399.cpp b/test/Modules/pr20399.cpp new file mode 100644 index 0000000000000..4f4a02561fc21 --- /dev/null +++ b/test/Modules/pr20399.cpp @@ -0,0 +1,2 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-name=libGdml -emit-module -x c++ -std=c++11 %S/Inputs/PR20399/module.modulemap diff --git a/test/Modules/pr20786.cpp b/test/Modules/pr20786.cpp new file mode 100644 index 0000000000000..4c0426ed5e58e --- /dev/null +++ b/test/Modules/pr20786.cpp @@ -0,0 +1,2 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-name=TBranchProxy -emit-module -x c++ %S/Inputs/PR20786/module.modulemap diff --git a/test/Modules/pr21217.cpp b/test/Modules/pr21217.cpp new file mode 100644 index 0000000000000..a439c97e9577e --- /dev/null +++ b/test/Modules/pr21217.cpp @@ -0,0 +1,3 @@ +// RUN: not %clang_cc1 -fmodules -fmodule-map-file=does-not-exist.modulemap -verify %s 2>&1 | FileCheck %s + +// CHECK: module map file 'does-not-exist.modulemap' not found diff --git a/test/Modules/preprocess.m b/test/Modules/preprocess.m new file mode 100644 index 0000000000000..5c32997f62fb8 --- /dev/null +++ b/test/Modules/preprocess.m @@ -0,0 +1,21 @@ +// 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 +#import "diamond_right.h" +#import "diamond_right.h" // to check that imports get their own line +void test() { + top_left_before(); + left_and_right(); +} + + +// CHECK: int left_and_right(int *);{{$}} +// CHECK-NEXT: @import diamond_left; /* clang -E: implicit import for "{{.*}}diamond_left.h" */{{$}} + +// 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-NEXT: void test() {{{$}} +// CHECK-NEXT: top_left_before();{{$}} +// CHECK-NEXT: left_and_right();{{$}} +// CHECK-NEXT: }{{$}} diff --git a/test/Modules/rebuild.m b/test/Modules/rebuild.m new file mode 100644 index 0000000000000..4d4d05529e7d3 --- /dev/null +++ b/test/Modules/rebuild.m @@ -0,0 +1,45 @@ +// RUN: rm -rf %t + +// Build Module and set its timestamp +// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c - +// RUN: touch -m -a -t 201101010000 %t/Module.pcm +// RUN: cp %t/Module.pcm %t/Module.pcm.saved +// RUN: wc -c %t/Module.pcm > %t/Module.size.saved + +// Build DependsOnModule +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s +// RUN: diff %t/Module.pcm %t/Module.pcm.saved +// RUN: cp %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved + +// Rebuild Module, reset its timestamp, and verify its size hasn't changed +// RUN: rm %t/Module.pcm +// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c - +// RUN: touch -m -a -t 201101010000 %t/Module.pcm +// RUN: wc -c %t/Module.pcm > %t/Module.size +// RUN: diff %t/Module.size %t/Module.size.saved +// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2 + +// But the signature at least is expected to change, so we rebuild DependsOnModule. +// NOTE: if we change how the signature is created, this test may need updating. +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s +// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2 +// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved + +// Rebuild Module, reset its timestamp, and verify its size hasn't changed +// RUN: rm %t/Module.pcm +// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c - +// RUN: touch -m -a -t 201101010000 %t/Module.pcm +// RUN: wc -c %t/Module.pcm > %t/Module.size +// RUN: diff %t/Module.size %t/Module.size.saved +// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2 + +// Verify again with Module pre-imported. +// NOTE: if we change how the signature is created, this test may need updating. +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s +// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2 +// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved + +#ifdef PREIMPORT +@import Module; +#endif +@import DependsOnModule; diff --git a/test/Modules/relative-dep-gen.cpp b/test/Modules/relative-dep-gen.cpp new file mode 100644 index 0000000000000..c8171777154a8 --- /dev/null +++ b/test/Modules/relative-dep-gen.cpp @@ -0,0 +1,26 @@ +// 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: 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: FileCheck --check-prefix=CHECK-BUILD %s < %t/build-cwd.d +// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit-cwd.d +// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-implicit-cwd.d + +#include "Inputs/relative-dep-gen-1.h" + +// CHECK-BUILD: mod.pcm: Inputs/relative-dep-gen-1.h Inputs/relative-dep-gen-2.h +// CHECK-USE: use.o: relative-dep-gen.cpp Inputs/relative-dep-gen-1.h diff --git a/test/Modules/require-modular-includes.m b/test/Modules/require-modular-includes.m index 835a35243396f..302e4cd191cd9 100644 --- a/test/Modules/require-modular-includes.m +++ b/test/Modules/require-modular-includes.m @@ -1,5 +1,4 @@ // RUN: rm -rf %t -// REQUIRES: shell // Including a header from the imported module // RUN: echo '@import FromImportedModuleOK;' | \ diff --git a/test/Modules/resolution-change.m b/test/Modules/resolution-change.m index 011782eec2bf6..6882fe44c5cbf 100644 --- a/test/Modules/resolution-change.m +++ b/test/Modules/resolution-change.m @@ -11,15 +11,15 @@ // Use the PCH with no way to resolve DependsOnA // RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NODOA %s -// CHECK-NODOA: module 'DependsOnA' imported by AST file '{{.*A.pch}}' not found +// CHECK-NODOA: module 'DependsOnA' in AST file '{{.*DependsOnA.*pcm}}' (imported by AST file '{{.*A.pch}}') is not defined in any loaded module map // Use the PCH with no way to resolve A // RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NOA %s -// CHECK-NOA: module 'A' imported by AST file '{{.*DependsOnA.*pcm}}' not found +// CHECK-NOA: module 'A' in AST file '{{.*A.*pcm}}' (imported by AST file '{{.*DependsOnA.*pcm}}') is not defined in any loaded module map -// Use the PCH and have it resolve the the other A +// Use the PCH and have it resolve to the other A // RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path2/A -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-WRONGA %s -// CHECK-WRONGA: module 'A' imported by AST file '{{.*DependsOnA.*pcm}}' found in a different module map file ({{.*path2.*}}) than when the importing AST file was built ({{.*path1.*}}) +// CHECK-WRONGA: module 'A' was built in directory '{{.*Inputs.modules-with-same-name.path1.A}}' but now resides in directory '{{.*Inputs.modules-with-same-name.path2.A}}' #ifndef HEADER #define HEADER diff --git a/test/Modules/stddef.c b/test/Modules/stddef.c new file mode 100644 index 0000000000000..aefc90f9a1178 --- /dev/null +++ b/test/Modules/stddef.c @@ -0,0 +1,13 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify -fno-modules-error-recovery + +#include "ptrdiff_t.h" + +ptrdiff_t pdt; + +size_t st; // expected-error {{must be imported}} +// expected-note@stddef.h:* {{previous}} + +#include "include_again.h" + +size_t st2; diff --git a/test/Modules/system_headers.m b/test/Modules/system_headers.m index 39b13ca5fc4a1..8adc7e857699b 100644 --- a/test/Modules/system_headers.m +++ b/test/Modules/system_headers.m @@ -1,8 +1,13 @@ // Test that system-headerness works for building modules. // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -isystem %S/Inputs -pedantic -Werror %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -isystem %S/Inputs -pedantic -Werror %s -verify -std=c11 // expected-no-diagnostics @import warning; int i = bigger_than_int; + +#include <stddef.h> + +#define __need_size_t +#include <stddef.h> diff --git a/test/Modules/system_version.m b/test/Modules/system_version.m index bc82bf8bc17b2..55174ef1506c4 100644 --- a/test/Modules/system_version.m +++ b/test/Modules/system_version.m @@ -1,6 +1,5 @@ // Test checking that we're hashing a system version file in the // module hash. -// REQUIRES: shell // First, build a system root. // RUN: rm -rf %t diff --git a/test/Modules/templates-2.mm b/test/Modules/templates-2.mm new file mode 100644 index 0000000000000..b7ceafbbc5baa --- /dev/null +++ b/test/Modules/templates-2.mm @@ -0,0 +1,36 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs -verify %s -Wno-objc-root-class +// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class | FileCheck %s +// expected-no-diagnostics + +@import templates_top; + +struct TestEmitDefaultedSpecialMembers { + EmitDefaultedSpecialMembers::SmallVector<char, 256> V; +}; + +@import templates_left; + +void testEmitDefaultedSpecialMembers() { + EmitDefaultedSpecialMembers::SmallString<256> V; + // CHECK: call {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EEC1Ev( + // CHECK: call {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED1Ev( +} + +// CHECK-LABEL: define {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EEC1Ev( +// CHECK: call {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EEC2Ev( + +// 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( diff --git a/test/Modules/templates.mm b/test/Modules/templates.mm index 78348af41e778..d60b873d0f385 100644 --- a/test/Modules/templates.mm +++ b/test/Modules/templates.mm @@ -12,10 +12,11 @@ void testInlineRedeclEarly() { @import templates_right; -// CHECK: @list_left = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 8, -// CHECK: @list_right = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 12, -// CHECK: @_ZZ15testMixedStructvE1l = {{.*}} constant { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 1, -// CHECK: @_ZZ15testMixedStructvE1r = {{.*}} constant { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 2, +// CHECK-DAG: @list_left = global %class.List { %"struct.List<int>::node"* null, i32 8 }, align 8 +// CHECK-DAG: @list_right = global %class.List { %"struct.List<int>::node"* null, i32 12 }, align 8 +// CHECK-DAG: @_ZZ15testMixedStructvE1l = {{.*}} constant %class.List { %{{.*}}* null, i32 1 }, align 8 +// CHECK-DAG: @_ZZ15testMixedStructvE1r = {{.*}} constant %class.List { %{{.*}}* null, i32 2 }, align 8 +// CHECK-DAG: @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE = external global void testTemplateClasses() { Vector<int> vec_int; @@ -100,3 +101,17 @@ template struct ExplicitInstantiation<false, true>; template struct ExplicitInstantiation<true, true>; void testDelayUpdatesImpl() { testDelayUpdates<int>(); } + +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) + (void) getStaticDataMemberLeft(); + + // CHECK-LABEL: define linkonce_odr i32* @_Z24getStaticDataMemberRightv( + // CHECK: ret i32* getelementptr inbounds ([0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0) + (void) getStaticDataMemberRight(); +} + + diff --git a/test/Modules/textual-headers.cpp b/test/Modules/textual-headers.cpp new file mode 100644 index 0000000000000..cab9991e32916 --- /dev/null +++ b/test/Modules/textual-headers.cpp @@ -0,0 +1,18 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodule-maps -fmodules-cache-path=%t -fmodules-strict-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-strict-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify -fno-modules-error-recovery + +#define GIMME_A_K +#include "k.h" + +#define GIMME_AN_L +#include "l.h" // expected-error {{module XG does not depend on a module exporting 'l.h'}} + +#include "m2.h" // expected-error {{module XG does not depend on a module exporting 'm2.h'}} +const int use_m = m; // expected-error {{undeclared identifier}} + +#define GIMME_AN_M +#include "m.h" // expected-error {{use of private header from outside its module: 'm.h'}} +const int use_m_2 = m; + +const int g = k + l; diff --git a/test/Modules/va_list.m b/test/Modules/va_list.m new file mode 100644 index 0000000000000..5a305180fcfa7 --- /dev/null +++ b/test/Modules/va_list.m @@ -0,0 +1,27 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \ +// RUN: -x objective-c-header %s -o %t.pch -emit-pch + +// Include the pch, as a sanity check. +// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch %t.pch \ +// RUN: -x objective-c %s -fsyntax-only + +// Repeat the previous emit-pch, but not we will have a global module index. +// For some reason, this results in an identifier for __va_list_tag being +// emitted into the pch. +// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \ +// RUN: -x objective-c-header %s -o %t.pch -emit-pch + +// Include the pch, which now has __va_list_tag in it, which needs to be merged. +// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \ +// RUN: -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch %t.pch \ +// RUN: -x objective-c %s -fsyntax-only + +// rdar://18039719 + +#ifdef PREFIX +@import va_list_b; +#endif diff --git a/test/Modules/validate-system-headers.m b/test/Modules/validate-system-headers.m index 48ea64c5a938f..8cdc886322bd8 100644 --- a/test/Modules/validate-system-headers.m +++ b/test/Modules/validate-system-headers.m @@ -5,39 +5,37 @@ //// // Build a module using a system header -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s // RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved //// // Modify the system header, and confirm that we don't notice without -fmodules-validate-system-headers. // The pcm file in the cache should fail to validate. // RUN: echo ' ' >> %t/Inputs/usr/include/foo.h -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved //// // Now make sure we rebuild the module when -fmodules-validate-system-headers is set. -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s // RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved //// // This should override -fmodules-validate-once-per-build-session // RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved // Modify the system header... // RUN: echo ' ' >> %t/Inputs/usr/include/foo.h // Don't recompile due to -fmodules-validate-once-per-build-session -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved // Now add -fmodules-validate-system-headers and rebuild -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session // RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved -// REQUIRES: shell - @import Foo; diff --git a/test/Modules/warn-unused-local-typedef.cpp b/test/Modules/warn-unused-local-typedef.cpp new file mode 100644 index 0000000000000..60e0612d6ce78 --- /dev/null +++ b/test/Modules/warn-unused-local-typedef.cpp @@ -0,0 +1,9 @@ +// 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 + +// For modules, the warning should only fire the first time, when the module is +// built. +// CHECK_1: warning: unused typedef +// CHECK_2-NOT: warning: unused typedef +@import warn_unused_local_typedef; |