diff options
Diffstat (limited to 'test/Modules')
172 files changed, 1220 insertions, 84 deletions
diff --git a/test/Modules/ExtDebugInfo.cpp b/test/Modules/ExtDebugInfo.cpp index dbf79f4ff148..c39bce950664 100644 --- a/test/Modules/ExtDebugInfo.cpp +++ b/test/Modules/ExtDebugInfo.cpp @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// Test that only forward declarations are emitted for types dfined in modules. +// Test that only forward declarations are emitted for types defined in modules. // Modules: // RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=standalone \ @@ -63,24 +63,22 @@ struct Specialized<int>::Member definedLocally2; template <class T> struct FwdDeclTemplateMember<T>::Member { T t; }; TypedefFwdDeclTemplateMember tdfdtm; +SpecializedBase definedLocally3; +extern template class WithSpecializedBase<int>; +WithSpecializedBase<int> definedLocally4; + void foo() { anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum; } - -// CHECK: ![[STRUCT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Struct", +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", // CHECK-SAME: scope: ![[NS:[0-9]+]], // CHECK-SAME: flags: DIFlagFwdDecl, -// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE") +// CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE") // CHECK: ![[NS]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]], // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX -// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", -// CHECK-SAME: scope: ![[NS]], -// CHECK-SAME: flags: DIFlagFwdDecl, -// CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE") - // This type is anchored in the module by an explicit template instantiation. // CHECK: !DICompositeType(tag: DW_TAG_class_type, // CHECK-SAME: name: "Template<long, DebugCXX::traits<long> >", @@ -103,6 +101,7 @@ void foo() { // CHECK: !DICompositeType(tag: DW_TAG_class_type, // CHECK-SAME: name: "Template<float, DebugCXX::traits<float> >", // CHECK-SAME: scope: ![[NS]], +// CHECK-SAME: elements: // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE") @@ -112,14 +111,20 @@ void foo() { // CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIfEE") -// This type is anchored in the module by an explicit template instantiation. +// This type is anchored in the module via a function argument, +// but we don't know this (yet). // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>", // CHECK-SAME: scope: ![[NS]], -// CHECK-SAME: flags: DIFlagFwdDecl, +// CHECK-SAME: elements: // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE") // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member", -// CHECK-SAME: scope: ![[STRUCT]] +// CHECK-SAME: scope: ![[STRUCT:[0-9]*]] + +// CHECK: ![[STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Struct", +// CHECK-SAME: scope: ![[NS]], +// CHECK-SAME: flags: DIFlagFwdDecl, +// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE") // CHECK: !DICompositeType(tag: DW_TAG_union_type, // CHECK-SAME: flags: DIFlagFwdDecl, @@ -133,6 +138,7 @@ void foo() { // This one isn't. // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<void *>", +// CHECK-SAME: elements: // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTS9Template1IPvE") @@ -142,6 +148,7 @@ void foo() { // CHECK-SAME: identifier: "_ZTS9Template1IiE") // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate<int>", +// CHECK-SAME: elements: // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE") @@ -160,6 +167,19 @@ void foo() { // CHECK-SAME: elements: // CHECK-SAME: identifier: "_ZTSN21FwdDeclTemplateMemberIiE6MemberE") +// This type is defined locally and forward-declared in the module. +// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "SpecializedBase", +// CHECK-SAME: baseType: ![[SPECIALIZEDBASE:.*]]) +// CHECK: ![[SPECIALIZEDBASE]] = +// CHECK-SAME: !DICompositeType(tag: DW_TAG_class_type, +// CHECK-SAME: name: "WithSpecializedBase<float>", +// CHECK-SAME: elements: +// CHECK-SAME: identifier: "_ZTS19WithSpecializedBaseIfE") + +// This type is explicitly specialized locally. +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "WithSpecializedBase<int>", +// CHECK-SAME: elements: +// CHECK-SAME: identifier: "_ZTS19WithSpecializedBaseIiE") // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]] // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]], @@ -181,7 +201,7 @@ void foo() { // CHECK-SAME: name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl) -// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: ![[STRUCT]], line: 27) +// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !{{[0-9]+}}, entity: ![[STRUCT]], line: 27) // CHECK: !DICompileUnit( // CHECK-SAME: splitDebugFilename: diff --git a/test/Modules/ExtDebugInfo.m b/test/Modules/ExtDebugInfo.m index 71ca853fb7d9..41247b00a49f 100644 --- a/test/Modules/ExtDebugInfo.m +++ b/test/Modules/ExtDebugInfo.m @@ -34,14 +34,8 @@ int foo(ObjCClass *c) { return [c property]; } -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars", -// CHECK-SAME: flags: DIFlagObjcClassComplete - // CHECK: ![[MOD:.*]] = !DIModule(scope: null, name: "DebugObjC -// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "hidden_ivar", -// CHECK-SAME: flags: DIFlagPrivate) - // CHECK: !DIGlobalVariable(name: "GlobalUnion", // CHECK-SAME: type: ![[GLOBAL_UNION:[0-9]+]] // CHECK: ![[GLOBAL_UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type, @@ -52,10 +46,11 @@ int foo(ObjCClass *c) { // CHECK: ![[GLOBAL_STRUCT]] = distinct !DICompositeType(tag: DW_TAG_structure_type, // CHECK-SAME: elements: !{{[0-9]+}}) -// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion", -// CHECK-SAME: baseType: ![[TD_UNION:.*]]) -// CHECK: ![[TD_UNION]] = !DICompositeType(tag: DW_TAG_union_type, -// CHECK-SAME: flags: DIFlagFwdDecl) +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars", +// CHECK-SAME: flags: DIFlagObjcClassComplete + +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "hidden_ivar", +// CHECK-SAME: flags: DIFlagPrivate) // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefEnum", // CHECK-SAME: baseType: ![[TD_ENUM:.*]]) @@ -67,6 +62,11 @@ int foo(ObjCClass *c) { // CHECK: ![[TD_STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type, // CHECK-SAME: flags: DIFlagFwdDecl) +// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion", +// CHECK-SAME: baseType: ![[TD_UNION:.*]]) +// CHECK: ![[TD_UNION]] = !DICompositeType(tag: DW_TAG_union_type, +// CHECK-SAME: flags: DIFlagFwdDecl) + // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MOD]], // CHECK-SAME: flags: DIFlagFwdDecl) diff --git a/test/Modules/Inputs/DebugCXX.h b/test/Modules/Inputs/DebugCXX.h index 793ad209f8bf..c9cd68f30c46 100644 --- a/test/Modules/Inputs/DebugCXX.h +++ b/test/Modules/Inputs/DebugCXX.h @@ -105,3 +105,9 @@ template <> struct Specialized<int> { template <class T> struct FwdDeclTemplateMember { struct Member; }; typedef FwdDeclTemplateMember<int>::Member TypedefFwdDeclTemplateMember; + +// Base class specialized on the class itself. +template <typename Derived> class BaseTemplate {}; +template <typename T> +class WithSpecializedBase : public BaseTemplate<WithSpecializedBase<T>> {}; +typedef WithSpecializedBase<float> SpecializedBase; diff --git a/test/Modules/Inputs/DebugNestedA.h b/test/Modules/Inputs/DebugNestedA.h new file mode 100644 index 000000000000..58dc2a7df749 --- /dev/null +++ b/test/Modules/Inputs/DebugNestedA.h @@ -0,0 +1,8 @@ +/* -*- C++ -*- */ +template <typename T> class Base {}; +template <typename T> struct A : public Base<A<T>> { + void f(); +}; + +class F {}; +typedef A<F> AF; diff --git a/test/Modules/Inputs/DebugNestedB.h b/test/Modules/Inputs/DebugNestedB.h new file mode 100644 index 000000000000..7f75d0946e20 --- /dev/null +++ b/test/Modules/Inputs/DebugNestedB.h @@ -0,0 +1,7 @@ +/* -*- C++ -*- */ +#include "DebugNestedA.h" +class C { + void run(AF &af) { + af.f(); + } +}; diff --git a/test/Modules/Inputs/DiagOutOfDate.h b/test/Modules/Inputs/DiagOutOfDate.h new file mode 100644 index 000000000000..f86587a83964 --- /dev/null +++ b/test/Modules/Inputs/DiagOutOfDate.h @@ -0,0 +1 @@ +const int a = 1; diff --git a/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h new file mode 100644 index 000000000000..7978a767e633 --- /dev/null +++ b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h @@ -0,0 +1 @@ +// NeedsGNUInlineAsm.h diff --git a/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h new file mode 100644 index 000000000000..da52f829c372 --- /dev/null +++ b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h @@ -0,0 +1 @@ +__asm("foo"); diff --git a/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map new file mode 100644 index 000000000000..a9536100d611 --- /dev/null +++ b/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map @@ -0,0 +1,8 @@ +framework module NeedsGNUInlineAsm { + header "NeedsGNUInlineAsm.h" + + explicit module Asm { + requires gnuinlineasm + header "asm.h" + } +} diff --git a/test/Modules/Inputs/PR27699/Subdir/a.h b/test/Modules/Inputs/PR27699/Subdir/a.h new file mode 100644 index 000000000000..6c36a1a100be --- /dev/null +++ b/test/Modules/Inputs/PR27699/Subdir/a.h @@ -0,0 +1 @@ +#include "streambuf" diff --git a/test/Modules/Inputs/PR27699/Subdir/b.h b/test/Modules/Inputs/PR27699/Subdir/b.h new file mode 100644 index 000000000000..6c36a1a100be --- /dev/null +++ b/test/Modules/Inputs/PR27699/Subdir/b.h @@ -0,0 +1 @@ +#include "streambuf" diff --git a/test/Modules/Inputs/PR27699/module.modulemap b/test/Modules/Inputs/PR27699/module.modulemap new file mode 100644 index 000000000000..1f58ca06753e --- /dev/null +++ b/test/Modules/Inputs/PR27699/module.modulemap @@ -0,0 +1 @@ +module a { umbrella "Subdir" module * {export *} } diff --git a/test/Modules/Inputs/PR27699/streambuf b/test/Modules/Inputs/PR27699/streambuf new file mode 100644 index 000000000000..30ea73d230d1 --- /dev/null +++ b/test/Modules/Inputs/PR27699/streambuf @@ -0,0 +1,7 @@ + #ifndef STREAMBUF + #define STREAMBUF + template <typename> struct basic_streambuf { + basic_streambuf(const basic_streambuf &); + }; +template <typename T> basic_streambuf<T>::basic_streambuf(const basic_streambuf &) = default; +#endif diff --git a/test/Modules/Inputs/PR28438/a.h b/test/Modules/Inputs/PR28438/a.h new file mode 100644 index 000000000000..a7e26ac6cdb1 --- /dev/null +++ b/test/Modules/Inputs/PR28438/a.h @@ -0,0 +1 @@ +#define FOO diff --git a/test/Modules/Inputs/PR28438/b1.h b/test/Modules/Inputs/PR28438/b1.h new file mode 100644 index 000000000000..262976e357fb --- /dev/null +++ b/test/Modules/Inputs/PR28438/b1.h @@ -0,0 +1,2 @@ +#define FOO +#include "a.h" diff --git a/test/Modules/Inputs/PR28438/b2.h b/test/Modules/Inputs/PR28438/b2.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Modules/Inputs/PR28438/b2.h diff --git a/test/Modules/Inputs/PR28438/module.modulemap b/test/Modules/Inputs/PR28438/module.modulemap new file mode 100644 index 000000000000..cb77d47b6cec --- /dev/null +++ b/test/Modules/Inputs/PR28438/module.modulemap @@ -0,0 +1,2 @@ +module A { header "a.h" export * } +module B { module B1 { header "b1.h" export * } module B2 { header "b2.h" export * } } diff --git a/test/Modules/Inputs/PR28752/Subdir1/b.h b/test/Modules/Inputs/PR28752/Subdir1/b.h new file mode 100644 index 000000000000..4d8de217d77d --- /dev/null +++ b/test/Modules/Inputs/PR28752/Subdir1/b.h @@ -0,0 +1,4 @@ +#include <vector> + +template<typename T> struct A { static bool b; }; +template<typename T> bool A<T>::b; diff --git a/test/Modules/Inputs/PR28752/Subdir1/c.h b/test/Modules/Inputs/PR28752/Subdir1/c.h new file mode 100644 index 000000000000..38822fb9cf21 --- /dev/null +++ b/test/Modules/Inputs/PR28752/Subdir1/c.h @@ -0,0 +1,2 @@ +template<typename T> struct A { static bool b; }; +template<typename T> bool A<T>::b; diff --git a/test/Modules/Inputs/PR28752/Subdir1/module.modulemap b/test/Modules/Inputs/PR28752/Subdir1/module.modulemap new file mode 100644 index 000000000000..8d3bfe996f5f --- /dev/null +++ b/test/Modules/Inputs/PR28752/Subdir1/module.modulemap @@ -0,0 +1,5 @@ +module b { + module "b.h" { header "b.h" export * } + module "c.h" { header "c.h" export * } + export * +} diff --git a/test/Modules/Inputs/PR28752/a.h b/test/Modules/Inputs/PR28752/a.h new file mode 100644 index 000000000000..3b3a25f213f2 --- /dev/null +++ b/test/Modules/Inputs/PR28752/a.h @@ -0,0 +1 @@ +#include <vector> diff --git a/test/Modules/Inputs/PR28752/module.modulemap b/test/Modules/Inputs/PR28752/module.modulemap new file mode 100644 index 000000000000..caf888fc474c --- /dev/null +++ b/test/Modules/Inputs/PR28752/module.modulemap @@ -0,0 +1 @@ +module a { header "a.h" export * } diff --git a/test/Modules/Inputs/PR28752/vector b/test/Modules/Inputs/PR28752/vector new file mode 100644 index 000000000000..fc5dafae1f91 --- /dev/null +++ b/test/Modules/Inputs/PR28752/vector @@ -0,0 +1,28 @@ +#ifndef VECTOR +#define VECTOR +template <bool, typename> struct B; +template <typename _Tp> struct B<true, _Tp> { typedef _Tp type; }; +namespace std { +template <typename> struct D { + + template <typename _Alloc2> struct F { + static const bool value = 0; + }; + + template <typename _Alloc2> + typename B<F<_Alloc2>::value, _Alloc2>::type _S_select(_Alloc2); + template <typename _Alloc2> + static + typename B<!F<_Alloc2>::value, _Alloc2>::type _S_select(_Alloc2); +}; +template <typename _Alloc> +template <typename _Alloc2> +const bool D<_Alloc>::F<_Alloc2>::value; + +template <typename> class vector { +public: + vector(int); + vector(vector &) : vector(D<bool>::_S_select((bool)0)) {} +}; +} +#endif // VECTOR
\ No newline at end of file diff --git a/test/Modules/Inputs/PR28794/LibAHeader.h b/test/Modules/Inputs/PR28794/LibAHeader.h new file mode 100644 index 000000000000..31aa02e848bd --- /dev/null +++ b/test/Modules/Inputs/PR28794/LibAHeader.h @@ -0,0 +1,12 @@ +#ifndef LIB_A_HEADER +#define LIB_A_HEADER + +typedef __SIZE_TYPE__ size_t; + +template <typename = int, size_t SlabSize = 4096, size_t = SlabSize> +class BumpPtrAllocatorImpl; + +template <typename T, size_t SlabSize, size_t SizeThreshold> +void * operator new(size_t, BumpPtrAllocatorImpl<T, SlabSize, SizeThreshold> &); + +#endif // LIB_A_HEADER diff --git a/test/Modules/Inputs/PR28794/Subdir/Empty.h b/test/Modules/Inputs/PR28794/Subdir/Empty.h new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/test/Modules/Inputs/PR28794/Subdir/Empty.h @@ -0,0 +1 @@ + diff --git a/test/Modules/Inputs/PR28794/Subdir/LibBHeader.h b/test/Modules/Inputs/PR28794/Subdir/LibBHeader.h new file mode 100644 index 000000000000..811c2404fac6 --- /dev/null +++ b/test/Modules/Inputs/PR28794/Subdir/LibBHeader.h @@ -0,0 +1,12 @@ +#ifndef LIB_B_HEADER +#define LIB_B_HEADER + +#include "LibAHeader.h" + +template <typename T, size_t SlabSize, size_t SizeThreshold> +void *operator new(size_t, BumpPtrAllocatorImpl<T, SlabSize, SizeThreshold> &) { + struct S {}; + return (void*)0xdead; +} + +#endif // LIB_B_HEADER diff --git a/test/Modules/Inputs/PR28794/module.modulemap b/test/Modules/Inputs/PR28794/module.modulemap new file mode 100644 index 000000000000..389c01acfd9c --- /dev/null +++ b/test/Modules/Inputs/PR28794/module.modulemap @@ -0,0 +1,3 @@ +module M { + umbrella "Subdir" module * {export *} +} diff --git a/test/Modules/Inputs/PR28812/Textual.h b/test/Modules/Inputs/PR28812/Textual.h new file mode 100644 index 000000000000..769962e08792 --- /dev/null +++ b/test/Modules/Inputs/PR28812/Textual.h @@ -0,0 +1,11 @@ +#ifndef T_H +#define T_H + +template <typename ValueType> struct VarStreamArray; + +template <typename ValueType> struct VarStreamArrayIterator { + VarStreamArrayIterator(VarStreamArray<ValueType>) {} + bool HasError{}; +}; + +#endif // T_H diff --git a/test/Modules/Inputs/PR28812/a.h b/test/Modules/Inputs/PR28812/a.h new file mode 100644 index 000000000000..0d9da60c91c2 --- /dev/null +++ b/test/Modules/Inputs/PR28812/a.h @@ -0,0 +1 @@ +#include "Textual.h" diff --git a/test/Modules/Inputs/PR28812/b.h b/test/Modules/Inputs/PR28812/b.h new file mode 100644 index 000000000000..0d9da60c91c2 --- /dev/null +++ b/test/Modules/Inputs/PR28812/b.h @@ -0,0 +1 @@ +#include "Textual.h" diff --git a/test/Modules/Inputs/PR28812/module.modulemap b/test/Modules/Inputs/PR28812/module.modulemap new file mode 100644 index 000000000000..d2d2b4a0c345 --- /dev/null +++ b/test/Modules/Inputs/PR28812/module.modulemap @@ -0,0 +1,6 @@ +module "A" { + header "a.h" +} +module "B" { + header "b.h" +} diff --git a/test/Modules/Inputs/cxx-header.h b/test/Modules/Inputs/cxx-header.h index 7ed777512290..ee52c639116a 100644 --- a/test/Modules/Inputs/cxx-header.h +++ b/test/Modules/Inputs/cxx-header.h @@ -1 +1,4 @@ -int f(); +#ifndef CXX_HEADER_H +#define CXX_HEADER_H +inline int f() { return 0; } +#endif diff --git a/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h b/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h new file mode 100644 index 000000000000..8b4b1987450a --- /dev/null +++ b/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h @@ -0,0 +1 @@ +extern int APUBLIC; diff --git a/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h b/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h new file mode 100644 index 000000000000..760d901aa366 --- /dev/null +++ b/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h @@ -0,0 +1 @@ +extern int APRIVATE; diff --git a/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap b/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap new file mode 100644 index 000000000000..95eabf90a968 --- /dev/null +++ b/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap @@ -0,0 +1,4 @@ +framework module A { + header "a.h" + export * +} diff --git a/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap b/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap new file mode 100644 index 000000000000..020d5d31d856 --- /dev/null +++ b/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap @@ -0,0 +1,4 @@ +framework module APrivate { + header "aprivate.h" + export * +} diff --git a/test/Modules/Inputs/libc-libcxx/include/c++/math.h b/test/Modules/Inputs/libc-libcxx/include/c++/math.h new file mode 100644 index 000000000000..890db371de66 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/include/c++/math.h @@ -0,0 +1,2 @@ +#include_next <math.h> +template<typename T> T abs(T t) { return (t < 0) ? -t : t; } diff --git a/test/Modules/Inputs/libc-libcxx/include/c++/module.modulemap b/test/Modules/Inputs/libc-libcxx/include/c++/module.modulemap new file mode 100644 index 000000000000..fd15779e934a --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/include/c++/module.modulemap @@ -0,0 +1,4 @@ +module "libc++" { + module math { header "math.h" export * } + module stdlib { header "stdlib.h" export * } +} diff --git a/test/Modules/Inputs/libc-libcxx/include/c++/stdlib.h b/test/Modules/Inputs/libc-libcxx/include/c++/stdlib.h new file mode 100644 index 000000000000..6e736cbbaa06 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/include/c++/stdlib.h @@ -0,0 +1 @@ +#include_next "stdlib.h" diff --git a/test/Modules/Inputs/libc-libcxx/include/math.h b/test/Modules/Inputs/libc-libcxx/include/math.h new file mode 100644 index 000000000000..380ab41ca0a2 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/include/math.h @@ -0,0 +1 @@ +int abs(int); diff --git a/test/Modules/Inputs/libc-libcxx/include/module.modulemap b/test/Modules/Inputs/libc-libcxx/include/module.modulemap new file mode 100644 index 000000000000..744f5450b11a --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/include/module.modulemap @@ -0,0 +1,4 @@ +module libc [no_undeclared_includes] { + module math { header "math.h" export * } + module stdlib { header "stdlib.h" export * } +} diff --git a/test/Modules/Inputs/libc-libcxx/include/stdlib.h b/test/Modules/Inputs/libc-libcxx/include/stdlib.h new file mode 100644 index 000000000000..a84546e5bc83 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/include/stdlib.h @@ -0,0 +1 @@ +#include <math.h> diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h b/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h new file mode 100644 index 000000000000..2ee00c1129a3 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/A.h @@ -0,0 +1,15 @@ +#ifndef __my_a +#define __my_a + +#include <A/int.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef int_fast32_t my_a; +} + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h b/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h new file mode 100644 index 000000000000..340315ed9f56 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Headers/int.h @@ -0,0 +1,14 @@ +#ifndef __my_int +#define __my_int + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef int_fast32_t myint; +} + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap b/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap new file mode 100644 index 000000000000..1e91233a90ce --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/Frameworks/A.framework/Modules/module.modulemap @@ -0,0 +1,4 @@ +framework module A [extern_c] { + umbrella header "A.h" + export * +} diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/__config b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/__config new file mode 100644 index 000000000000..eacda4840060 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/__config @@ -0,0 +1,6 @@ +#ifndef _LIBCPP_CONFIG +#define _LIBCPP_CONFIG + +#define __LIBCXX_CONFIG + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h new file mode 100644 index 000000000000..f761b910f3ef --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h @@ -0,0 +1,7 @@ +#ifndef LIBCXX_MATH_H +#define LIBCXX_MATH_H + +#include_next <math.h> +template<typename T> T abs(T t) { return (t < 0) ? -t : t; } + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap new file mode 100644 index 000000000000..b06142a61a20 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap @@ -0,0 +1,10 @@ +module "libc++" { + module math { header "math.h" export * } + module stdlib { header "stdlib.h" export * } + module stddef { header "stddef.h" export * } + module stdio { textual header "stdio.h" export * } + // FIXME: remove "textual" from stdint module below once the issue + // between umbrella headers and builtins is resolved. + module stdint { textual header "stdint.h" export * } + module __config { header "__config" export * } +} diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h new file mode 100644 index 000000000000..bd42008e1695 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h @@ -0,0 +1,6 @@ +#ifndef LIBCXX_STDDEF_H +#define LIBCXX_STDDEF_H + +#include <__config> + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h new file mode 100644 index 000000000000..7a68441bc3d2 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdint.h @@ -0,0 +1,6 @@ +#ifndef LIBCXX_STDINT_H +#define LIBCXX_STDINT_H + +#include_next "stdint.h" + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdio.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdio.h new file mode 100644 index 000000000000..399fce17534d --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdio.h @@ -0,0 +1,6 @@ +#ifndef LIBCXX_STDIO_H +#define LIBCXX_STDIO_H + +#include <__config> + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdlib.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdlib.h new file mode 100644 index 000000000000..5053e0581b0c --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdlib.h @@ -0,0 +1,6 @@ +#ifndef LIBCXX_STDLIB_H +#define LIBCXX_STDLIB_H + +#include_next "stdlib.h" + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/math.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/math.h new file mode 100644 index 000000000000..380ab41ca0a2 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/math.h @@ -0,0 +1 @@ +int abs(int); diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap new file mode 100644 index 000000000000..7244cb0987e7 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap @@ -0,0 +1,8 @@ +module libc [no_undeclared_includes] { + module math { header "math.h" export * } + module stdlib { header "stdlib.h" export * } + module stddef { header "stddef.h" export * } + module stdint { header "stdint.h" export * } + module stdio { header "stdio.h" export * } + module util { header "util.h" export * } +} diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h new file mode 100644 index 000000000000..eca72412a651 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h @@ -0,0 +1 @@ +// stddef.h diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdint.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdint.h new file mode 100644 index 000000000000..8d6c6fe237da --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdint.h @@ -0,0 +1,22 @@ +typedef char int_least8_t; +typedef short int_least16_t; +typedef int int_least32_t; +typedef long long int int_least64_t; +typedef unsigned char uint_least8_t; +typedef unsigned short uint_least16_t; +typedef unsigned int uint_least32_t; +typedef unsigned long long uint_least64_t; + +typedef char int_fast8_t; +typedef short int_fast16_t; +typedef int int_fast32_t; +typedef long long int int_fast64_t; +typedef unsigned char uint_fast8_t; +typedef unsigned short uint_fast16_t; +typedef unsigned int uint_fast32_t; +typedef unsigned long long uint_fast64_t; + +typedef int * intptr_t; +typedef unsigned int * uintptr_t; +typedef int intmax_t; +typedef unsigned int uintmax_t; diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdio.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdio.h new file mode 100644 index 000000000000..0b7bdeba9e11 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdio.h @@ -0,0 +1,4 @@ +#ifndef DARWIN_STDIO_H +#define DARWIN_STDIO_H + +#endif diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdlib.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdlib.h new file mode 100644 index 000000000000..a84546e5bc83 --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stdlib.h @@ -0,0 +1 @@ +#include <math.h> diff --git a/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/util.h b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/util.h new file mode 100644 index 000000000000..22e95fcf9b6e --- /dev/null +++ b/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/util.h @@ -0,0 +1,6 @@ +#ifndef DARWIN_UTIL_H +#define DARWIN_UTIL_H + +#include <stdio.h> + +#endif diff --git a/test/Modules/Inputs/lookup-assert/Base.h b/test/Modules/Inputs/lookup-assert/Base.h new file mode 100644 index 000000000000..67e66183ca1a --- /dev/null +++ b/test/Modules/Inputs/lookup-assert/Base.h @@ -0,0 +1,3 @@ +@interface BaseInterface +- (void) test; +@end diff --git a/test/Modules/Inputs/lookup-assert/Derive.h b/test/Modules/Inputs/lookup-assert/Derive.h new file mode 100644 index 000000000000..313a96188d2e --- /dev/null +++ b/test/Modules/Inputs/lookup-assert/Derive.h @@ -0,0 +1,3 @@ +#include "Base.h" +@interface DerivedInterface : BaseInterface +@end diff --git a/test/Modules/Inputs/lookup-assert/H3.h b/test/Modules/Inputs/lookup-assert/H3.h new file mode 100644 index 000000000000..3d8f878905df --- /dev/null +++ b/test/Modules/Inputs/lookup-assert/H3.h @@ -0,0 +1 @@ +#include "Base.h" diff --git a/test/Modules/Inputs/lookup-assert/module.map b/test/Modules/Inputs/lookup-assert/module.map new file mode 100644 index 000000000000..e8a89eb095a4 --- /dev/null +++ b/test/Modules/Inputs/lookup-assert/module.map @@ -0,0 +1,4 @@ +module X { + header "H3.h" + export * +} diff --git a/test/Modules/Inputs/merge-decl-context/a.h b/test/Modules/Inputs/merge-decl-context/a.h index 7be90b1535de..a0b58a7d6ddc 100644 --- a/test/Modules/Inputs/merge-decl-context/a.h +++ b/test/Modules/Inputs/merge-decl-context/a.h @@ -24,5 +24,6 @@ inline A<int> ff(int i) { struct Aggregate { int member; }; +bool operator==(Aggregate, Aggregate) = delete; #endif diff --git a/test/Modules/Inputs/merge-fn-prototype-tags/a.h b/test/Modules/Inputs/merge-fn-prototype-tags/a.h new file mode 100644 index 000000000000..8dd717cba624 --- /dev/null +++ b/test/Modules/Inputs/merge-fn-prototype-tags/a.h @@ -0,0 +1,2 @@ +#include "c.h" +void ftw(struct stat); diff --git a/test/Modules/Inputs/merge-fn-prototype-tags/b.h b/test/Modules/Inputs/merge-fn-prototype-tags/b.h new file mode 100644 index 000000000000..566381f2edf5 --- /dev/null +++ b/test/Modules/Inputs/merge-fn-prototype-tags/b.h @@ -0,0 +1 @@ +struct stat; diff --git a/test/Modules/Inputs/merge-fn-prototype-tags/c.h b/test/Modules/Inputs/merge-fn-prototype-tags/c.h new file mode 100644 index 000000000000..cb5262417434 --- /dev/null +++ b/test/Modules/Inputs/merge-fn-prototype-tags/c.h @@ -0,0 +1,4 @@ +#ifndef _STAT_H_ +#define _STAT_H_ +struct stat {}; +#endif diff --git a/test/Modules/Inputs/merge-fn-prototype-tags/module.modulemap b/test/Modules/Inputs/merge-fn-prototype-tags/module.modulemap new file mode 100644 index 000000000000..b324f05abf1a --- /dev/null +++ b/test/Modules/Inputs/merge-fn-prototype-tags/module.modulemap @@ -0,0 +1,5 @@ +module M { + header "a.h" + module mod_c { header "c.h" } + header "b.h" +} diff --git a/test/Modules/Inputs/merge-template-pattern-visibility/a.h b/test/Modules/Inputs/merge-template-pattern-visibility/a.h index 7f9b6497e725..e6592027611c 100644 --- a/test/Modules/Inputs/merge-template-pattern-visibility/a.h +++ b/test/Modules/Inputs/merge-template-pattern-visibility/a.h @@ -3,3 +3,4 @@ template<typename T> struct B; template<typename, typename> struct A {}; template<typename T> struct B : A<T> {}; +template<typename T> inline auto C(T) {} diff --git a/test/Modules/Inputs/merge-template-pattern-visibility/b.h b/test/Modules/Inputs/merge-template-pattern-visibility/b.h index 5ed18e7e7c5d..41b52d5e6abb 100644 --- a/test/Modules/Inputs/merge-template-pattern-visibility/b.h +++ b/test/Modules/Inputs/merge-template-pattern-visibility/b.h @@ -3,7 +3,18 @@ template<typename T> struct B; template<typename, typename> struct A {}; template<typename T> struct B : A<T> {}; +template<typename T> inline auto C(T) {} inline void f() { B<int> bi; + C(0); +} + +namespace CrossModuleMerge { + template<typename, typename = int> struct A; + template<typename T> struct B; + + template<typename, typename> struct A {}; + template<typename T> struct B : A<T> {}; + template<typename T> inline auto C(T) {} } diff --git a/test/Modules/Inputs/merge-template-pattern-visibility/c.h b/test/Modules/Inputs/merge-template-pattern-visibility/c.h new file mode 100644 index 000000000000..db80eda1ea6d --- /dev/null +++ b/test/Modules/Inputs/merge-template-pattern-visibility/c.h @@ -0,0 +1,9 @@ +namespace CrossModuleMerge { + template<typename, typename = int> struct A; + template<typename T> struct B; + + template<typename, typename> struct A {}; + template<typename T> struct B : A<T> {}; + template<typename T> inline auto C(T) {} +} + diff --git a/test/Modules/Inputs/merge-template-pattern-visibility/d.h b/test/Modules/Inputs/merge-template-pattern-visibility/d.h new file mode 100644 index 000000000000..464f0f5bbed9 --- /dev/null +++ b/test/Modules/Inputs/merge-template-pattern-visibility/d.h @@ -0,0 +1 @@ +// d.h: empty diff --git a/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap b/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap index ba97abbaa8ec..e00d1b9551ee 100644 --- a/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap +++ b/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap @@ -2,3 +2,7 @@ module X { module A { header "a.h" } module B { header "b.h" } } +module Y { + module C { header "c.h" } + module D { header "d.h" } +} diff --git a/test/Modules/Inputs/merge-template-specializations/a.h b/test/Modules/Inputs/merge-template-specializations/a.h new file mode 100644 index 000000000000..fb05647c0aa9 --- /dev/null +++ b/test/Modules/Inputs/merge-template-specializations/a.h @@ -0,0 +1 @@ +template<unsigned> class SmallString {}; diff --git a/test/Modules/Inputs/merge-template-specializations/b.h b/test/Modules/Inputs/merge-template-specializations/b.h new file mode 100644 index 000000000000..96ce2bb1d8d6 --- /dev/null +++ b/test/Modules/Inputs/merge-template-specializations/b.h @@ -0,0 +1,2 @@ +#include "a.h" +void f(SmallString<256>&); diff --git a/test/Modules/Inputs/merge-template-specializations/c.h b/test/Modules/Inputs/merge-template-specializations/c.h new file mode 100644 index 000000000000..100463a2f7f2 --- /dev/null +++ b/test/Modules/Inputs/merge-template-specializations/c.h @@ -0,0 +1,3 @@ +#include "a.h" +struct X { SmallString<256> ss; }; +#include "b.h" diff --git a/test/Modules/Inputs/merge-template-specializations/module.modulemap b/test/Modules/Inputs/merge-template-specializations/module.modulemap new file mode 100644 index 000000000000..77e0a89e39a0 --- /dev/null +++ b/test/Modules/Inputs/merge-template-specializations/module.modulemap @@ -0,0 +1,3 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } +module c { header "c.h" export * } diff --git a/test/Modules/Inputs/merge-var-template-def/a.h b/test/Modules/Inputs/merge-var-template-def/a.h new file mode 100644 index 000000000000..6b414b3031fb --- /dev/null +++ b/test/Modules/Inputs/merge-var-template-def/a.h @@ -0,0 +1,8 @@ +#ifndef A_H +#define A_H +template<typename T, T v> +struct S { static constexpr T value = v; }; +template<typename T, T v> +constexpr T S<T, v>::value; + +#endif diff --git a/test/Modules/Inputs/merge-var-template-def/b1.h b/test/Modules/Inputs/merge-var-template-def/b1.h new file mode 100644 index 000000000000..35cab9d01c8e --- /dev/null +++ b/test/Modules/Inputs/merge-var-template-def/b1.h @@ -0,0 +1,9 @@ +#ifndef B1_H +#define B1_H +template<typename T, T v> +struct S { static constexpr T value = v; }; +template<typename T, T v> +constexpr T S<T, v>::value; + +#include "a.h" +#endif diff --git a/test/Modules/Inputs/merge-var-template-def/b2.h b/test/Modules/Inputs/merge-var-template-def/b2.h new file mode 100644 index 000000000000..6ab87c2fa718 --- /dev/null +++ b/test/Modules/Inputs/merge-var-template-def/b2.h @@ -0,0 +1,9 @@ +#ifndef B2_H +#define B2_H + +template<typename T, T v> +struct S { static constexpr T value = v; }; +template<typename T, T v> +constexpr T S<T, v>::value; + +#endif diff --git a/test/Modules/Inputs/merge-var-template-def/module.modulemap b/test/Modules/Inputs/merge-var-template-def/module.modulemap new file mode 100644 index 000000000000..b2c96bd82177 --- /dev/null +++ b/test/Modules/Inputs/merge-var-template-def/module.modulemap @@ -0,0 +1,5 @@ +module a { header "a.h" export * } +module b { + module b1 { header "b1.h" export * } + module b2 { header "b2.h" export * } +} diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index 6846690c8498..2beb942861a4 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -418,3 +418,17 @@ module Empty {} module MacroFabs1 { header "MacroFabs1.h" } + +module DiagOutOfDate { + header "DiagOutOfDate.h" +} + +module DebugNestedA { + header "DebugNestedA.h" + export * +} + +module DebugNestedB { + header "DebugNestedB.h" + export * +} diff --git a/test/Modules/Inputs/objc-category-2/Base.h b/test/Modules/Inputs/objc-category-2/Base.h new file mode 100644 index 000000000000..9bd8b17a87e6 --- /dev/null +++ b/test/Modules/Inputs/objc-category-2/Base.h @@ -0,0 +1,3 @@ +@interface DVTSourceModel // expected-error {{duplicate interface definition for class}} \ + // expected-note {{previous definition is here}} +@end diff --git a/test/Modules/Inputs/objc-category-2/Category.h b/test/Modules/Inputs/objc-category-2/Category.h new file mode 100644 index 000000000000..7cde9fb64cc7 --- /dev/null +++ b/test/Modules/Inputs/objc-category-2/Category.h @@ -0,0 +1,4 @@ +#include "Base.h" +@interface DVTSourceModel(Additions) +- (int)test:(int)item; +@end diff --git a/test/Modules/Inputs/objc-category-2/H3.h b/test/Modules/Inputs/objc-category-2/H3.h new file mode 100644 index 000000000000..3d8f878905df --- /dev/null +++ b/test/Modules/Inputs/objc-category-2/H3.h @@ -0,0 +1 @@ +#include "Base.h" diff --git a/test/Modules/Inputs/objc-category-2/module.map b/test/Modules/Inputs/objc-category-2/module.map new file mode 100644 index 000000000000..833b189a338a --- /dev/null +++ b/test/Modules/Inputs/objc-category-2/module.map @@ -0,0 +1,4 @@ +module X { + header "Category.h" + export * +} diff --git a/test/Modules/Inputs/objc-category-3/Base.h b/test/Modules/Inputs/objc-category-3/Base.h new file mode 100644 index 000000000000..44094643b348 --- /dev/null +++ b/test/Modules/Inputs/objc-category-3/Base.h @@ -0,0 +1,2 @@ +@interface DVTSourceModel +@end diff --git a/test/Modules/Inputs/objc-category-3/Category.h b/test/Modules/Inputs/objc-category-3/Category.h new file mode 100644 index 000000000000..7cde9fb64cc7 --- /dev/null +++ b/test/Modules/Inputs/objc-category-3/Category.h @@ -0,0 +1,4 @@ +#include "Base.h" +@interface DVTSourceModel(Additions) +- (int)test:(int)item; +@end diff --git a/test/Modules/Inputs/objc-category-3/Category_B.h b/test/Modules/Inputs/objc-category-3/Category_B.h new file mode 100644 index 000000000000..d67f94b3a9c6 --- /dev/null +++ b/test/Modules/Inputs/objc-category-3/Category_B.h @@ -0,0 +1,4 @@ +#include "Base.h" +@interface DVTSourceModel(AdditionsB) +- (int)testB:(int)item matchingMask:(int)mask; +@end diff --git a/test/Modules/Inputs/objc-category-3/H3.h b/test/Modules/Inputs/objc-category-3/H3.h new file mode 100644 index 000000000000..3d8f878905df --- /dev/null +++ b/test/Modules/Inputs/objc-category-3/H3.h @@ -0,0 +1 @@ +#include "Base.h" diff --git a/test/Modules/Inputs/objc-category-3/module.map b/test/Modules/Inputs/objc-category-3/module.map new file mode 100644 index 000000000000..c53d5dc6efaa --- /dev/null +++ b/test/Modules/Inputs/objc-category-3/module.map @@ -0,0 +1,4 @@ +module X { + header "Category_B.h" + export * +} diff --git a/test/Modules/Inputs/objc-category/Base.h b/test/Modules/Inputs/objc-category/Base.h new file mode 100644 index 000000000000..44094643b348 --- /dev/null +++ b/test/Modules/Inputs/objc-category/Base.h @@ -0,0 +1,2 @@ +@interface DVTSourceModel +@end diff --git a/test/Modules/Inputs/objc-category/Category.h b/test/Modules/Inputs/objc-category/Category.h new file mode 100644 index 000000000000..7cde9fb64cc7 --- /dev/null +++ b/test/Modules/Inputs/objc-category/Category.h @@ -0,0 +1,4 @@ +#include "Base.h" +@interface DVTSourceModel(Additions) +- (int)test:(int)item; +@end diff --git a/test/Modules/Inputs/objc-category/H3.h b/test/Modules/Inputs/objc-category/H3.h new file mode 100644 index 000000000000..3d8f878905df --- /dev/null +++ b/test/Modules/Inputs/objc-category/H3.h @@ -0,0 +1 @@ +#include "Base.h" diff --git a/test/Modules/Inputs/objc-category/module.map b/test/Modules/Inputs/objc-category/module.map new file mode 100644 index 000000000000..e8a89eb095a4 --- /dev/null +++ b/test/Modules/Inputs/objc-category/module.map @@ -0,0 +1,4 @@ +module X { + header "H3.h" + export * +} diff --git a/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h b/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h new file mode 100644 index 000000000000..2ae08a3e5915 --- /dev/null +++ b/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h @@ -0,0 +1,7 @@ +#include <X.h> + +__attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))) +@interface UnavailableObjCClass : NSObject +- (void)someMethod; +@end + diff --git a/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap b/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap new file mode 100644 index 000000000000..e99c0fa5059e --- /dev/null +++ b/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap @@ -0,0 +1,5 @@ +framework module FakeUnavailableObjCFramework { + umbrella header "FakeUnavailableObjCFramework.h" + // Do not export to test hidden decls. + // export * +} diff --git a/test/Modules/Inputs/objc-hidden/System/X.h b/test/Modules/Inputs/objc-hidden/System/X.h new file mode 100644 index 000000000000..c86cc58a1ebb --- /dev/null +++ b/test/Modules/Inputs/objc-hidden/System/X.h @@ -0,0 +1,5 @@ +@protocol NSObject +@property (readonly) int hash; +@end +@interface NSObject <NSObject> +@end diff --git a/test/Modules/Inputs/objc-hidden/System/module.map b/test/Modules/Inputs/objc-hidden/System/module.map new file mode 100644 index 000000000000..8fe4c92a1738 --- /dev/null +++ b/test/Modules/Inputs/objc-hidden/System/module.map @@ -0,0 +1,4 @@ +module X { + header "X.h" + export * +} diff --git a/test/Modules/Inputs/objc-initializer/X.h b/test/Modules/Inputs/objc-initializer/X.h new file mode 100644 index 000000000000..e7182a89f6b4 --- /dev/null +++ b/test/Modules/Inputs/objc-initializer/X.h @@ -0,0 +1,3 @@ +@interface NSString +@end +static const NSString * const kSimDeviceIOGetInterface = @"simdeviceio_get_interface"; diff --git a/test/Modules/Inputs/objc-initializer/module.modulemap b/test/Modules/Inputs/objc-initializer/module.modulemap new file mode 100644 index 000000000000..bc76ace10654 --- /dev/null +++ b/test/Modules/Inputs/objc-initializer/module.modulemap @@ -0,0 +1,7 @@ +module X { + module T { + header "X.h" + export * + } + export * +} diff --git a/test/Modules/Inputs/objc-method-redecl.h b/test/Modules/Inputs/objc-method-redecl.h new file mode 100644 index 000000000000..95c6533fad9e --- /dev/null +++ b/test/Modules/Inputs/objc-method-redecl.h @@ -0,0 +1,4 @@ +@interface T +- (void)test; +- (void)test; +@end diff --git a/test/Modules/Inputs/pch-import-module-out-of-date.pch b/test/Modules/Inputs/pch-import-module-out-of-date.pch new file mode 100644 index 000000000000..93a446cbcf2f --- /dev/null +++ b/test/Modules/Inputs/pch-import-module-out-of-date.pch @@ -0,0 +1 @@ +@import DiagOutOfDate; diff --git a/test/Modules/Inputs/prebuilt-module/a.h b/test/Modules/Inputs/prebuilt-module/a.h new file mode 100644 index 000000000000..f86587a83964 --- /dev/null +++ b/test/Modules/Inputs/prebuilt-module/a.h @@ -0,0 +1 @@ +const int a = 1; diff --git a/test/Modules/Inputs/prebuilt-module/module.modulemap b/test/Modules/Inputs/prebuilt-module/module.modulemap new file mode 100644 index 000000000000..54459bde5ba3 --- /dev/null +++ b/test/Modules/Inputs/prebuilt-module/module.modulemap @@ -0,0 +1 @@ +module prebuilt { header "a.h" } diff --git a/test/Modules/Inputs/templates-left.h b/test/Modules/Inputs/templates-left.h index cbe89434f9f3..4f7abeef1fa0 100644 --- a/test/Modules/Inputs/templates-left.h +++ b/test/Modules/Inputs/templates-left.h @@ -70,3 +70,5 @@ namespace EmitDefaultedSpecialMembers { inline int *getStaticDataMemberLeft() { return WithUndefinedStaticDataMember<int[]>::undefined; } + +inline WithAttributes<int> make_with_attributes_left() { return WithAttributes<int>(); } diff --git a/test/Modules/Inputs/templates-right.h b/test/Modules/Inputs/templates-right.h index 32487c60c269..bb3f7c30182a 100644 --- a/test/Modules/Inputs/templates-right.h +++ b/test/Modules/Inputs/templates-right.h @@ -51,3 +51,5 @@ void outOfLineInlineUseRightH(void (OutOfLineInline<int>::*)() = &OutOfLineInlin inline int *getStaticDataMemberRight() { return WithUndefinedStaticDataMember<int[]>::undefined; } + +inline WithAttributes<int> make_with_attributes_right() { return WithAttributes<int>(); } diff --git a/test/Modules/Inputs/templates-top.h b/test/Modules/Inputs/templates-top.h index a08268352399..207d705432e8 100644 --- a/test/Modules/Inputs/templates-top.h +++ b/test/Modules/Inputs/templates-top.h @@ -58,3 +58,8 @@ namespace EmitDefaultedSpecialMembers { template<typename T> struct WithUndefinedStaticDataMember { static T undefined; }; + +template<typename T> struct __attribute__((packed, aligned(2))) WithAttributes { + T value; +}; +WithAttributes<int> *get_with_attributes(); diff --git a/test/Modules/Inputs/unused-global-init/init.h b/test/Modules/Inputs/unused-global-init/init.h new file mode 100644 index 000000000000..29a932ae65b4 --- /dev/null +++ b/test/Modules/Inputs/unused-global-init/init.h @@ -0,0 +1 @@ +struct Init { Init(); ~Init(); } init; diff --git a/test/Modules/Inputs/unused-global-init/module.modulemap b/test/Modules/Inputs/unused-global-init/module.modulemap new file mode 100644 index 000000000000..c40f0efeb5e3 --- /dev/null +++ b/test/Modules/Inputs/unused-global-init/module.modulemap @@ -0,0 +1,3 @@ +module used { header "used.h" } +module unused { header "unused.h" } +module init { module a { header "init.h" } module b { header "other.h" } } diff --git a/test/Modules/Inputs/unused-global-init/other.h b/test/Modules/Inputs/unused-global-init/other.h new file mode 100644 index 000000000000..c6be1ad4c43d --- /dev/null +++ b/test/Modules/Inputs/unused-global-init/other.h @@ -0,0 +1 @@ +// other.h diff --git a/test/Modules/Inputs/unused-global-init/unused.h b/test/Modules/Inputs/unused-global-init/unused.h new file mode 100644 index 000000000000..06c2a44ba21f --- /dev/null +++ b/test/Modules/Inputs/unused-global-init/unused.h @@ -0,0 +1 @@ +// unused.h diff --git a/test/Modules/Inputs/unused-global-init/used.h b/test/Modules/Inputs/unused-global-init/used.h new file mode 100644 index 000000000000..689a13f4c8d3 --- /dev/null +++ b/test/Modules/Inputs/unused-global-init/used.h @@ -0,0 +1,2 @@ +// used.h +#include "init.h" diff --git a/test/Modules/ModuleDebugInfo.cpp b/test/Modules/ModuleDebugInfo.cpp index 998d36327ef5..71b05e5aeb8b 100644 --- a/test/Modules/ModuleDebugInfo.cpp +++ b/test/Modules/ModuleDebugInfo.cpp @@ -1,7 +1,7 @@ // Test that (the same) debug info is emitted for an Objective-C++ // module and a C++ precompiled header. -// REQUIRES: asserts, shell +// REQUIRES: asserts // Modules: // RUN: rm -rf %t @@ -49,6 +49,7 @@ // This type is anchored by a function parameter. // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>" +// CHECK-SAME: elements: // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE") @@ -58,6 +59,7 @@ // This type is anchored by an explicit template instantiation. // CHECK: !DICompositeType(tag: DW_TAG_class_type, // CHECK-SAME: name: "Template<int, DebugCXX::traits<int> >" +// CHECK-SAME: elements: // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE") @@ -66,11 +68,13 @@ // CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIiEE") // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<float>" +// CHECK-SAME: elements: // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIfEE") // CHECK: !DICompositeType(tag: DW_TAG_class_type, // CHECK-SAME: name: "Template<long, DebugCXX::traits<long> >" +// CHECK-SAME: elements: // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE") @@ -121,7 +125,7 @@ // CHECK-SAME: flags: DIFlagFwdDecl, // CHECK-SAME: identifier: "_ZTS9Template1IPvE") -// Explicit instatiation. +// Explicit instantiation. // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<int>", // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTS9Template1IiE") @@ -135,4 +139,10 @@ // CHECK-SAME: flags: DIFlagFwdDecl // CHECK-SAME: identifier: "_ZTSN21FwdDeclTemplateMemberIiE6MemberE") +// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "SpecializedBase", +// CHECK-SAME: baseType: ![[SPECIALIZEDBASE:.*]]) +// CHECK: ![[SPECIALIZEDBASE]] = !DICompositeType(tag: DW_TAG_class_type, +// CHECK-SAME: name: "WithSpecializedBase<float>", +// CHECK-SAME: flags: DIFlagFwdDecl, + // CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl" diff --git a/test/Modules/ModuleDebugInfo.m b/test/Modules/ModuleDebugInfo.m index ce35c7c8361f..d1a0e8d5e80a 100644 --- a/test/Modules/ModuleDebugInfo.m +++ b/test/Modules/ModuleDebugInfo.m @@ -1,7 +1,7 @@ // Test that debug info is emitted for an Objective-C module and // a precompiled header. -// REQUIRES: asserts, shell +// REQUIRES: asserts // Modules: // RUN: rm -rf %t diff --git a/test/Modules/ModuleModuleDebugInfo.cpp b/test/Modules/ModuleModuleDebugInfo.cpp new file mode 100644 index 000000000000..abc4bfd56b15 --- /dev/null +++ b/test/Modules/ModuleModuleDebugInfo.cpp @@ -0,0 +1,18 @@ +// RUN: rm -rf %t + +// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=standalone \ +// RUN: -dwarf-ext-refs -fmodules \ +// RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \ +// RUN: -triple %itanium_abi_triple \ +// RUN: -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o - \ +// RUN: | FileCheck %s + +#include "DebugNestedB.h" +AF af; // This type is not anchored in the module. + +// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "AF", +// CHECK-SAME: baseType: ![[AF:.*]]) + +// CHECK: ![[AF]] = {{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "A<F>", +// CHECK-SAME: elements: + diff --git a/test/Modules/compiler_builtins.m b/test/Modules/compiler_builtins.m index bffbcc6ddee5..a5e6315cedc8 100644 --- a/test/Modules/compiler_builtins.m +++ b/test/Modules/compiler_builtins.m @@ -1,6 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify // RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify +// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify // expected-no-diagnostics #ifdef __SSE__ diff --git a/test/Modules/compiler_builtins_x86.c b/test/Modules/compiler_builtins_x86.c new file mode 100644 index 000000000000..1b4d42177ab0 --- /dev/null +++ b/test/Modules/compiler_builtins_x86.c @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding +// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -verify -ffreestanding +// expected-no-diagnostics + +#include<x86intrin.h> + diff --git a/test/Modules/config-mismatch.cpp b/test/Modules/config-mismatch.cpp new file mode 100644 index 000000000000..9ddc513cd178 --- /dev/null +++ b/test/Modules/config-mismatch.cpp @@ -0,0 +1,13 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo 'module M { header "foo.h" header "bar.h" }' > %t/map +// RUN: echo 'template<typename T> void f(T t) { int n; t.f(n); }' > %t/foo.h +// RUN: touch %t/bar.h +// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -x c++ %t/map -emit-module -fmodule-name=M -o %t/pcm +// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodule-map-file=%t/map -fmodule-file=%t/pcm -I%t %s -fsyntax-only -fexceptions -Wno-module-file-config-mismatch -verify +// RUN: rm %t/bar.h +// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodule-map-file=%t/map -fmodule-file=%t/pcm -I%t %s -fsyntax-only -fexceptions -Wno-module-file-config-mismatch -verify +#include "foo.h" +namespace n { // expected-note {{begins here}} +#include "foo.h" // expected-error {{redundant #include of module 'M' appears within namespace}} +} diff --git a/test/Modules/crash-vfs-headermaps.m b/test/Modules/crash-vfs-headermaps.m new file mode 100644 index 000000000000..4f88f3ba1197 --- /dev/null +++ b/test/Modules/crash-vfs-headermaps.m @@ -0,0 +1,55 @@ +// REQUIRES: crash-recovery, shell, system-darwin + +// This uses a headermap with this entry: +// Foo.h -> Foo/Foo.h + +// Copy out the headermap from test/Preprocessor/Inputs/headermap-rel and avoid +// adding another binary format to the repository. + +// RUN: rm -rf %t +// RUN: mkdir -p %t/m +// RUN: cp -a %S/../Preprocessor/Inputs/headermap-rel %t/i +// RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h + +// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ +// RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \ +// RUN: -I %t/i/foo.hmap -F %t/i 2>&1 | FileCheck %s + +// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh +// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \ +// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml + +#include "Foo.h" +#include "Foo.h" + +// CHECK: Preprocessed source(s) and associated run script(s) are located at: +// CHECK-NEXT: note: diagnostic msg: {{.*}}.m +// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache + +// CHECKSH: # Crash reproducer +// CHECKSH-NEXT: # Driver args: "-fsyntax-only" +// CHECKSH-NEXT: # Original command: {{.*$}} +// CHECKSH-NEXT: "-cc1" +// CHECKSH: "-I" "/[[INCPATH:.*]]/foo.hmap" +// CHECKSH: "crash-vfs-{{[^ ]*}}.m" +// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" + +// CHECKYAML: 'case-sensitive': +// CHECKYAML-NEXT: 'use-external-names': 'false', +// CHECKYAML-NEXT: 'overlay-relative': 'true', +// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false' +// CHECKYAML: 'type': 'directory' +// CHECKYAML: 'name': "/[[PATH:.*]]/Foo.framework/Headers", +// CHECKYAML-NEXT: 'contents': [ +// CHECKYAML-NEXT: { +// CHECKYAML-NEXT: 'type': 'file', +// CHECKYAML-NEXT: 'name': "Foo.h", +// CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Foo.framework/Headers/Foo.h" +// CHECKYAML: 'type': 'directory' +// CHECKYAML: 'name': "/[[PATH:.*]]/i", +// CHECKYAML-NEXT: 'contents': [ +// CHECKYAML-NEXT: { +// CHECKYAML-NEXT: 'type': 'file', +// CHECKYAML-NEXT: 'name': "foo.hmap", +// CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/i/foo.hmap" diff --git a/test/Modules/crash-vfs-include-pch.m b/test/Modules/crash-vfs-include-pch.m new file mode 100644 index 000000000000..78a8e149a41b --- /dev/null +++ b/test/Modules/crash-vfs-include-pch.m @@ -0,0 +1,43 @@ +// REQUIRES: crash-recovery, shell, system-darwin +// +// RUN: rm -rf %t +// RUN: mkdir -p %t/m %t/out + +// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h \ +// RUN: -o %t/out/pch-used.h.pch -fmodules -fimplicit-module-maps \ +// RUN: -fmodules-cache-path=%t/cache -O0 \ +// RUN: -isystem %S/Inputs/System/usr/include + +// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ +// RUN: %clang %s -E -include-pch %t/out/pch-used.h.pch -fmodules -nostdlibinc \ +// RUN: -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 \ +// RUN: -Xclang -fno-validate-pch -isystem %S/Inputs/System/usr/include \ +// RUN: -o %t/output.E 2>&1 | FileCheck %s + +// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh +// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \ +// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml + +void f() { SPXTrace(); } +void g() { double x = DBL_MAX; } + +// CHECK: Preprocessed source(s) and associated run script(s) are located at: +// CHECK-NEXT: note: diagnostic msg: {{.*}}.m +// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache + +// CHECKSH: "-include-pch" "/[[INCPATH:.*]]/out/pch-used.h.pch" +// CHECKSH: "crash-vfs-{{[^ ]*}}.m" +// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" + +// CHECKYAML: 'case-sensitive': +// CHECKYAML-NEXT: 'use-external-names': 'false', +// CHECKYAML-NEXT: 'overlay-relative': 'true', +// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false' +// CHECKYAML: 'type': 'directory' +// CHECKYAML: 'name': "/[[PATH:.*]]/out", +// CHECKYAML-NEXT: 'contents': [ +// CHECKYAML-NEXT: { +// CHECKYAML-NEXT: 'type': 'file', +// CHECKYAML-NEXT: 'name': "pch-used.h.pch", +// CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/out/pch-used.h.pch" diff --git a/test/Modules/crash-vfs-ivfsoverlay.m b/test/Modules/crash-vfs-ivfsoverlay.m new file mode 100644 index 000000000000..abbc0151a8cf --- /dev/null +++ b/test/Modules/crash-vfs-ivfsoverlay.m @@ -0,0 +1,45 @@ +// REQUIRES: crash-recovery, shell, system-darwin + +// RUN: rm -rf %t +// RUN: mkdir -p %t/m +// RUN: cp %S/../VFS/Inputs/actual_module2.map %t/actual_module2.map +// RUN: sed -e "s:INPUT_DIR:%t:g" -e "s:OUT_DIR:%t/example:g" \ +// RUN: %S/../VFS/Inputs/vfsoverlay2.yaml > %t/srcvfs.yaml + +// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ +// RUN: %clang -fsyntax-only -nostdinc %s \ +// RUN: -I %S/Inputs/crash-recovery/usr/include \ +// RUN: -ivfsoverlay %t/srcvfs.yaml \ +// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s + +// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh +// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \ +// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml +// RUN: find %t/crash-vfs-*.cache/vfs | \ +// RUN: grep "%t/actual_module2.map" | count 1 + +#include <stdio.h> + +// CHECK: Preprocessed source(s) and associated run script(s) are located at: +// CHECK-NEXT: note: diagnostic msg: {{.*}}.m +// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache + +// CHECKSH: # Crash reproducer +// CHECKSH-NEXT: # Driver args: "-fsyntax-only" +// CHECKSH-NEXT: # Original command: {{.*$}} +// CHECKSH-NEXT: "-cc1" +// CHECKSH: "crash-vfs-{{[^ ]*}}.m" +// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" + +// CHECKYAML: 'case-sensitive': +// CHECKYAML-NEXT: 'use-external-names': 'false', +// CHECKYAML-NEXT: 'overlay-relative': 'true', +// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false' +// CHECKYAML: 'type': 'directory' +// CHECKYAML: 'name': "/[[PATH:.*]]/example" +// CHECKYAML: 'contents': [ +// CHECKYAML-NEXT: { +// CHECKYAML-NEXT: 'type': 'file', +// CHECKYAML-NEXT: 'name': "module.map", +// CHECKYAML-NEXT: 'external-contents': "/[[OTHERPATH:.*]]/actual_module2.map" diff --git a/test/Modules/crash-vfs-path-emptydir-entries.m b/test/Modules/crash-vfs-path-emptydir-entries.m index 01560984ff71..e44714bee7f6 100644 --- a/test/Modules/crash-vfs-path-emptydir-entries.m +++ b/test/Modules/crash-vfs-path-emptydir-entries.m @@ -37,7 +37,7 @@ // CHECKSH-NOT: "-fmodules-cache-path=" // CHECKSH: "crash-vfs-{{[^ ]*}}.m" // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" -// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" // CHECKYAML: 'type': 'directory', // CHECKYAML: 'name': "", diff --git a/test/Modules/crash-vfs-path-symlink-component.m b/test/Modules/crash-vfs-path-symlink-component.m index 6a41188b271a..5be492514a09 100644 --- a/test/Modules/crash-vfs-path-symlink-component.m +++ b/test/Modules/crash-vfs-path-symlink-component.m @@ -38,7 +38,7 @@ // CHECKSH-NOT: "-fmodules-cache-path=" // CHECKSH: "crash-vfs-{{[^ ]*}}.m" // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" -// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" // CHECKYAML: 'case-sensitive': // CHECKYAML-NEXT: 'use-external-names': 'false', diff --git a/test/Modules/crash-vfs-path-symlink-topheader.m b/test/Modules/crash-vfs-path-symlink-topheader.m index 72b666a8127c..51a14c69c077 100644 --- a/test/Modules/crash-vfs-path-symlink-topheader.m +++ b/test/Modules/crash-vfs-path-symlink-topheader.m @@ -39,7 +39,7 @@ // CHECKSH-NOT: "-fmodules-cache-path=" // CHECKSH: "crash-vfs-{{[^ ]*}}.m" // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" -// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" // CHECKYAML: 'type': 'directory', // CHECKYAML: 'name': "", diff --git a/test/Modules/crash-vfs-path-traversal.m b/test/Modules/crash-vfs-path-traversal.m index 3377de47d0b2..cc56e53cf1bf 100644 --- a/test/Modules/crash-vfs-path-traversal.m +++ b/test/Modules/crash-vfs-path-traversal.m @@ -35,7 +35,7 @@ // CHECKSH-NOT: "-fmodules-cache-path=" // CHECKSH: "crash-vfs-{{[^ ]*}}.m" // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" -// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" // CHECKYAML: 'case-sensitive': // CHECKYAML-NEXT: 'use-external-names': 'false', diff --git a/test/Modules/crash-vfs-relative-incdir.m b/test/Modules/crash-vfs-relative-incdir.m new file mode 100644 index 000000000000..63cd9827c013 --- /dev/null +++ b/test/Modules/crash-vfs-relative-incdir.m @@ -0,0 +1,57 @@ +// REQUIRES: crash-recovery, shell, system-darwin + +// RUN: rm -rf %t +// RUN: mkdir -p %t/m +// RUN: cd %S/Inputs/crash-recovery/usr + +// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ +// RUN: %clang -fsyntax-only -nostdinc %s -Iinclude \ +// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s + +// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m +// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh +// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \ +// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml +// RUN: find %t/crash-vfs-*.cache/vfs | \ +// RUN: grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1 + +#include <stdio.h> + +// CHECK: Preprocessed source(s) and associated run script(s) are located at: +// CHECK-NEXT: note: diagnostic msg: {{.*}}.m +// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache + +// CHECKSRC: @import cstd.stdio; + +// CHECKSH: # Crash reproducer +// CHECKSH-NEXT: # Driver args: "-fsyntax-only" +// CHECKSH-NEXT: # Original command: {{.*$}} +// CHECKSH-NEXT: "-cc1" +// CHECKSH: "-resource-dir" +// CHECKSH: "-I" "/[[INCPATH:.*]]/include" +// CHECKSH: "crash-vfs-{{[^ ]*}}.m" +// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" + +// CHECKYAML: 'case-sensitive': +// CHECKYAML-NEXT: 'use-external-names': 'false', +// CHECKYAML-NEXT: 'overlay-relative': 'true', +// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false' +// CHECKYAML: 'type': 'directory' +// CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include", +// CHECKYAML-NEXT: 'contents': [ +// CHECKYAML-NEXT: { +// CHECKYAML-NEXT: 'type': 'file', +// CHECKYAML-NEXT: 'name': "module.map", +// CHECKYAML-NOT: 'external-contents': "{{[^ ]*}}.cache +// CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map" +// CHECKYAML-NEXT: }, + +// Run the reproducer script - regular exit code is enough to test it works. +// Note that we don't yet support reusing the modules pcm; what we do +// support is re-building the modules relying solely on the header files dumped +// inside .cache/vfs, mapped by .cache/vfs/vfs.yaml. + +// RUN: cd %t +// RUN: chmod 755 crash-vfs-*.sh +// RUN: ./crash-vfs-*.sh diff --git a/test/Modules/crash-vfs-relative-overlay.m b/test/Modules/crash-vfs-relative-overlay.m index 870987c58abd..54ba13bbca39 100644 --- a/test/Modules/crash-vfs-relative-overlay.m +++ b/test/Modules/crash-vfs-relative-overlay.m @@ -34,7 +34,7 @@ // CHECKSH: "-isysroot" "{{[^"]*}}/i/" // CHECKSH: "crash-vfs-{{[^ ]*}}.m" // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" -// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" // CHECKYAML: 'case-sensitive': // CHECKYAML-NEXT: 'use-external-names': 'false', diff --git a/test/Modules/crash-vfs-run-reproducer.m b/test/Modules/crash-vfs-run-reproducer.m index d0eaa931c976..72771a2f9479 100644 --- a/test/Modules/crash-vfs-run-reproducer.m +++ b/test/Modules/crash-vfs-run-reproducer.m @@ -31,11 +31,12 @@ // CHECKSH: "-isysroot" "{{[^"]*}}/i/" // CHECKSH: "crash-vfs-{{[^ ]*}}.m" // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" -// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" +// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" // CHECKYAML: 'case-sensitive': // CHECKYAML-NEXT: 'use-external-names': 'false', // CHECKYAML-NEXT: 'overlay-relative': 'true', +// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false' // CHECKYAML: 'type': 'directory' // CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include", // CHECKYAML-NEXT: 'contents': [ @@ -52,6 +53,5 @@ // inside .cache/vfs, mapped by .cache/vfs/vfs.yaml. // RUN: cd %t -// RUN: rm -rf crash-vfs-run-reproducer-*.cache/modules/* // RUN: chmod 755 crash-vfs-*.sh // RUN: ./crash-vfs-*.sh diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m index 7df727d2efcb..2182140d5db0 100644 --- a/test/Modules/cstd.m +++ b/test/Modules/cstd.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fsyntax-only -isystem %S/Inputs/System/usr/include -ffreestanding -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s +// RUN: %clang_cc1 -fsyntax-only -internal-isystem %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps -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-irgen.cpp b/test/Modules/cxx-irgen.cpp index 75fb2c1495e9..6cc32adc5254 100644 --- a/test/Modules/cxx-irgen.cpp +++ b/test/Modules/cxx-irgen.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -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 -fimplicit-module-maps -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-optzns -emit-llvm -debug-info-kind=limited -o - %s | FileCheck %s +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-passes -emit-llvm -debug-info-kind=limited -o - %s | FileCheck %s // FIXME: When we have a syntax for modules in C++, use that. @import cxx_irgen_top; diff --git a/test/Modules/cxx-templates.cpp b/test/Modules/cxx-templates.cpp index 12dfdd0546eb..401b7704900b 100644 --- a/test/Modules/cxx-templates.cpp +++ b/test/Modules/cxx-templates.cpp @@ -195,8 +195,8 @@ namespace hidden_specializations { cls<void>::nested_cls_t<int> *nk2; // ok cls<void>::nested_cls_t<char> *nk3; // ok cls<int> uk1; // expected-error 1+{{explicit specialization of 'cls<int>' must be imported}} expected-error 1+{{definition of}} - cls<int*> uk3; // expected-error 1+{{partial specialization of 'cls<type-parameter-0-0 *>' must be imported}} expected-error 1+{{definition of}} - cls<char*> uk4; // expected-error 1+{{partial specialization of 'cls<type-parameter-0-0 *>' must be imported}} expected-error 1+{{definition of}} + cls<int*> uk3; // expected-error 1+{{partial specialization of 'cls<T *>' must be imported}} expected-error 1+{{definition of}} + cls<char*> uk4; // expected-error 1+{{partial specialization of 'cls<T *>' must be imported}} expected-error 1+{{definition of}} cls<void>::nested_cls unk1; // expected-error 1+{{explicit specialization of 'nested_cls' must be imported}} expected-error 1+{{definition of}} cls<void>::nested_cls_t<int> unk2; // expected-error 1+{{explicit specialization of 'nested_cls_t' must be imported}} expected-error 1+{{definition of}} cls<void>::nested_cls_t<char> unk3; // expected-error 1+{{explicit specialization of 'nested_cls_t' must be imported}} @@ -211,8 +211,8 @@ namespace hidden_specializations { (void)sizeof(var<void>); // ok (void)sizeof(var<char>); // ok (void)sizeof(var<int>); // expected-error 1+{{explicit specialization of 'var<int>' must be imported}} - (void)sizeof(var<int*>); // expected-error 1+{{partial specialization of 'var<type-parameter-0-0 *>' must be imported}} - (void)sizeof(var<char*>); // expected-error 1+{{partial specialization of 'var<type-parameter-0-0 *>' must be imported}} + (void)sizeof(var<int*>); // expected-error 1+{{partial specialization of 'var<T *>' must be imported}} + (void)sizeof(var<char*>); // expected-error 1+{{partial specialization of 'var<T *>' must be imported}} (void)sizeof(cls<void>::nested_var); // ok (void)cls<void>::nested_var; // expected-error 1+{{explicit specialization of 'nested_var' must be imported}} (void)sizeof(cls<void>::nested_var_t<int>); // expected-error 1+{{explicit specialization of 'nested_var_t' must be imported}} @@ -224,10 +224,10 @@ namespace hidden_specializations { int cls<int>::nested_var; // expected-error 1+{{explicit specialization of 'cls<int>' must be imported}} expected-error 1+{{definition of}} enum cls<int>::nested_enum : int {}; // expected-error 1+{{explicit specialization of 'cls<int>' must be imported}} expected-error 1+{{definition of}} - template<typename T> void cls<T*>::nested_fn() {} // expected-error 1+{{partial specialization of 'cls<type-parameter-0-0 *>' must be imported}} - template<typename T> struct cls<T*>::nested_cls {}; // expected-error 1+{{partial specialization of 'cls<type-parameter-0-0 *>' must be imported}} - template<typename T> int cls<T*>::nested_var; // expected-error 1+{{partial specialization of 'cls<type-parameter-0-0 *>' must be imported}} - template<typename T> enum cls<T*>::nested_enum : int {}; // expected-error 1+{{partial specialization of 'cls<type-parameter-0-0 *>' must be imported}} + template<typename T> void cls<T*>::nested_fn() {} // expected-error 1+{{partial specialization of 'cls<T *>' must be imported}} + template<typename T> struct cls<T*>::nested_cls {}; // expected-error 1+{{partial specialization of 'cls<T *>' must be imported}} + template<typename T> int cls<T*>::nested_var; // expected-error 1+{{partial specialization of 'cls<T *>' must be imported}} + template<typename T> enum cls<T*>::nested_enum : int {}; // expected-error 1+{{partial specialization of 'cls<T *>' must be imported}} } namespace Std { @@ -249,10 +249,10 @@ namespace Std { // CHECK-DUMP: ClassTemplateDecl {{.*}} <{{.*[/\\]}}cxx-templates-common.h:1:1, {{.*}}> col:{{.*}} in cxx_templates_common SomeTemplate // CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate -// CHECK-DUMP-NEXT: TemplateArgument type 'char [1]' -// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition -// CHECK-DUMP-NEXT: TemplateArgument type 'char [1]' -// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate // CHECK-DUMP-NEXT: TemplateArgument type 'char [2]' // CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition // CHECK-DUMP-NEXT: TemplateArgument type 'char [2]' +// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate +// CHECK-DUMP-NEXT: TemplateArgument type 'char [1]' +// CHECK-DUMP: ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition +// CHECK-DUMP-NEXT: TemplateArgument type 'char [1]' diff --git a/test/Modules/dependency-dump-dependent-module.m b/test/Modules/dependency-dump-dependent-module.m index df7f5326bb6c..2430726d3ae5 100644 --- a/test/Modules/dependency-dump-dependent-module.m +++ b/test/Modules/dependency-dump-dependent-module.m @@ -14,9 +14,3 @@ // VFS: 'name': "Sub2.h" @import AlsoDependsOnModule; - -// FIXME: This fails on win32 due to ERROR_FILENAME_EXCED_RANGE -// if the working directory is too deep. -// We should make Win32/Path.inc capable of long pathnames with '\\?\'. -// For now, this is suppressed on win32. -// REQUIRES: shell diff --git a/test/Modules/diagnostic-options-out-of-date.m b/test/Modules/diagnostic-options-out-of-date.m new file mode 100644 index 000000000000..ed9e8e1fe183 --- /dev/null +++ b/test/Modules/diagnostic-options-out-of-date.m @@ -0,0 +1,12 @@ +// RUN: rm -rf %t +// Build A.pcm +// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation +// Build pch that imports A.pcm +// RUN: %clang_cc1 -Werror -Wno-conversion -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/pch-import-module-out-of-date.pch -fmodules-disable-diagnostic-validation +// Make sure that we don't rebuild A.pcm and overwrite the original A.pcm that the pch imports +// RUN: %clang_cc1 -Werror -Wconversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation +// Make sure we don't error out when using the pch +// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify -fmodules-disable-diagnostic-validation +// expected-no-diagnostics + +@import DiagOutOfDate; diff --git a/test/Modules/embed-files.cpp b/test/Modules/embed-files.cpp index f300558dd7f7..8e5a16e54400 100644 --- a/test/Modules/embed-files.cpp +++ b/test/Modules/embed-files.cpp @@ -10,6 +10,10 @@ // // RUN: %clang_cc1 -fmodules -I%t -fmodules-embed-all-files %t/modulemap -fmodule-name=a -x c++ -emit-module -o %t/a.pcm // RUN: %clang_cc1 -fmodules -I%t -fmodules-embed-all-files %t/modulemap -fmodule-name=b -x c++ -emit-module -o %t/b.pcm +// FIXME: This test is flaky on Windows because attempting to delete a file +// after writing it just doesn't seem to work well, at least not in the lit +// shell. +// REQUIRES: shell // RUN: rm %t/x.h // RUN: %clang_cc1 -fmodules -I%t -fmodule-map-file=%t/modulemap -fmodule-file=%t/a.pcm -fmodule-file=%t/b.pcm %s -verify #include "a.h" @@ -19,3 +23,4 @@ char t; // expected-error {{different type}} #include "b.h" char t; // expected-error {{different type}} // expected-note@t.h:1 {{here}} + diff --git a/test/Modules/empty.modulemap b/test/Modules/empty.modulemap index 0d1718409d55..aa9eba66a4f8 100644 --- a/test/Modules/empty.modulemap +++ b/test/Modules/empty.modulemap @@ -14,7 +14,6 @@ // RUN: diff %t/base.pcm %t/check.pcm // // We expect an empty module to be less than 30KB (and at least 10K, for now). -// REQUIRES: shell // RUN: wc -c %t/base.pcm | FileCheck --check-prefix=CHECK-SIZE %s // CHECK-SIZE: {{(^|[^0-9])[12][0-9][0-9][0-9][0-9]($|[^0-9])}} diff --git a/test/Modules/explicit-build-extra-files.cpp b/test/Modules/explicit-build-extra-files.cpp index 6cec420832d6..965aea13ae13 100644 --- a/test/Modules/explicit-build-extra-files.cpp +++ b/test/Modules/explicit-build-extra-files.cpp @@ -1,5 +1,3 @@ -// REQUIRES: shell -// // RUN: rm -rf %t // RUN: mkdir %t // RUN: cd %t diff --git a/test/Modules/explicit-build.cpp b/test/Modules/explicit-build.cpp index a6f6a6268c15..16eb604708c9 100644 --- a/test/Modules/explicit-build.cpp +++ b/test/Modules/explicit-build.cpp @@ -167,7 +167,7 @@ // RUN: -fmodule-file=%t/nonexistent.pcm \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-FILE %s // -// CHECK-NO-FILE: fatal error: module file '{{.*}}nonexistent.pcm' not found +// CHECK-NO-FILE: fatal error: module file '{{.*}}nonexistent.pcm' not found: module file not found // RUN: mv %t/a.pcm %t/a-tmp.pcm // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ @@ -199,6 +199,6 @@ // 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: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt +// CHECK-MISMATCHED-B: fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt: module file out of date // CHECK-MISMATCHED-B-NEXT: note: imported by module 'c' // CHECK-MISMATCHED-B-NOT: note: diff --git a/test/Modules/global-init.cpp b/test/Modules/global-init.cpp new file mode 100644 index 000000000000..fb42464dcc92 --- /dev/null +++ b/test/Modules/global-init.cpp @@ -0,0 +1,19 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// +// RUN: echo '#pragma once' > %t/a.h +// RUN: echo 'struct A { A() {} int f() const; } const a;' >> %t/a.h +// +// RUN: echo '#include "a.h"' > %t/b.h +// +// RUN: echo 'module M { module b { header "b.h" export * } module a { header "a.h" export * } }' > %t/map +// +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%t/map -I%t %s -emit-llvm -o - -triple %itanium_abi_triple | FileCheck %s + +#include "b.h" + +// CHECK: @_ZL1a = internal global +// CHECK: call {{.*}} @_ZN1AC1Ev({{.*}}@_ZL1a +// CHECK: call {{.*}} @_ZNK1A1fEv({{.*}}@_ZL1a +// CHECK: store {{.*}} @x +int x = a.f(); diff --git a/test/Modules/implicit-private-with-different-name.m b/test/Modules/implicit-private-with-different-name.m new file mode 100644 index 000000000000..3d8f937973f0 --- /dev/null +++ b/test/Modules/implicit-private-with-different-name.m @@ -0,0 +1,20 @@ +// RUN: rm -rf %t + +// Build PCH using A, with adjacent private module APrivate, which winds up being implicitly referenced +// RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -emit-pch -o %t-A.pch %s + +// Use the PCH with no explicit way to resolve PrivateA, still pick it up through MODULE_DIRECTORY reference in PCH control block +// RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -include-pch %t-A.pch %s -fsyntax-only + +// Check the fixit +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -include-pch %t-A.pch %s -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s + +// expected-warning@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{top-level module 'APrivate' in private module map, expected a submodule of 'A'}} +// expected-note@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{make 'APrivate' a submodule of 'A' to ensure it can be found by name}} +// CHECK: fix-it:"{{.*}}module.private.modulemap":{1:18-1:26}:"A.Private" + +#ifndef HEADER +#define HEADER +#import "A/aprivate.h" +const int *y = &APRIVATE; +#endif diff --git a/test/Modules/incomplete-module.m b/test/Modules/incomplete-module.m index e338a40c9ab5..ffb2708c6f81 100644 --- a/test/Modules/incomplete-module.m +++ b/test/Modules/incomplete-module.m @@ -2,7 +2,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules-cache-path=%t -Wincomplete-module -fmodules -fimplicit-module-maps -I %S/Inputs %s 2>&1 | FileCheck %s -// CHECK: warning: include of non-modular header inside module 'incomplete_mod' +// CHECK: warning: include of non-modular header inside module 'incomplete_mod': {{'.*incomplete_mod_missing.h'}} // RUN: rm -rf %t // RUN: not %clang_cc1 -fmodules-cache-path=%t -fmodules-strict-decluse -fmodules -fimplicit-module-maps -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=DECLUSE diff --git a/test/Modules/lambda-context.cpp b/test/Modules/lambda-context.cpp new file mode 100644 index 000000000000..6ce482c2b763 --- /dev/null +++ b/test/Modules/lambda-context.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -fmodules -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fmodules -std=c++11 -include-pch %t %s -verify +// +// This test checks for a bug in the deserialization code that was only +// reachable with modules enabled, but actually building and using modules is +// not necessary in order to trigger it, so we just use PCH here to make the +// test simpler. + +#ifndef HEADER_INCLUDED +#define HEADER_INCLUDED + +struct X { template <typename T> X(T) {} }; +struct Y { Y(X x = [] {}); }; + +#else + +// This triggers us to load the specialization of X::X for Y's lambda. That +// lambda's context decl must not be loaded as a result of loading the lambda, +// as that would hit a deserialization cycle. +X x = [] {}; // expected-no-diagnostics + +#endif diff --git a/test/Modules/libc-libcxx.cpp b/test/Modules/libc-libcxx.cpp new file mode 100644 index 000000000000..1f6a86b7782a --- /dev/null +++ b/test/Modules/libc-libcxx.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/libc-libcxx/include/c++ -I %S/Inputs/libc-libcxx/include %s -verify +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -nostdinc++ -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem %S/Inputs/libc-libcxx/sysroot/usr/include -fsyntax-only %s -verify +// expected-no-diagnostics + +#include "math.h" + +int n = abs(0); +float f = abs<float>(0.f); diff --git a/test/Modules/lookup-assert.m b/test/Modules/lookup-assert.m new file mode 100644 index 000000000000..2697fb15d018 --- /dev/null +++ b/test/Modules/lookup-assert.m @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/lookup-assert %s -verify +// expected-no-diagnostics + +#include "Derive.h" +#import <H3.h> +@implementation DerivedInterface +- (void)test { +} +@end diff --git a/test/Modules/merge-fn-prototype-tags.c b/test/Modules/merge-fn-prototype-tags.c new file mode 100644 index 000000000000..f43f1dc49d9e --- /dev/null +++ b/test/Modules/merge-fn-prototype-tags.c @@ -0,0 +1,8 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c -I%S/Inputs/merge-fn-prototype-tags -verify %s +// RUN: %clang_cc1 -fmodules -fmodule-map-file=%S/Inputs/merge-fn-prototype-tags/module.modulemap -fmodules-cache-path=%t -x c -I%S/Inputs/merge-fn-prototype-tags -verify %s + +#include "c.h" +void mmalloc_attach() { struct stat sbuf; } + +// expected-no-diagnostics diff --git a/test/Modules/merge-name-for-linkage.cpp b/test/Modules/merge-name-for-linkage.cpp index da1664ca343d..75534bd661b9 100644 --- a/test/Modules/merge-name-for-linkage.cpp +++ b/test/Modules/merge-name-for-linkage.cpp @@ -2,6 +2,7 @@ // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/merge-name-for-linkage -verify %s // expected-no-diagnostics typedef union {} pthread_mutex_t; +typedef pthread_mutex_t pthread_mutex_t; #include "a.h" pthread_mutex_t x; #include "b.h" diff --git a/test/Modules/merge-template-pattern-visibility.cpp b/test/Modules/merge-template-pattern-visibility.cpp index db759b5a46a1..ec5aa26c68d8 100644 --- a/test/Modules/merge-template-pattern-visibility.cpp +++ b/test/Modules/merge-template-pattern-visibility.cpp @@ -1,4 +1,18 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fno-modules-error-recovery \ +// RUN: %clang_cc1 -fmodules -fno-modules-error-recovery -std=c++14 \ // RUN: -fmodule-name=X -emit-module %S/Inputs/merge-template-pattern-visibility/module.modulemap -x c++ \ -// RUN: -fmodules-local-submodule-visibility +// RUN: -fmodules-local-submodule-visibility -o %t/X.pcm +// RUN: %clang_cc1 -fmodules -fno-modules-error-recovery -std=c++14 \ +// RUN: -fmodule-name=Y -emit-module %S/Inputs/merge-template-pattern-visibility/module.modulemap -x c++ \ +// RUN: -fmodules-local-submodule-visibility -o %t/Y.pcm +// RUN: %clang_cc1 -fmodules -fno-modules-error-recovery -std=c++14 -fmodule-file=%t/X.pcm -fmodule-file=%t/Y.pcm \ +// RUN: -fmodules-local-submodule-visibility -verify %s -I%S/Inputs/merge-template-pattern-visibility + +#include "b.h" +#include "d.h" + +// expected-no-diagnostics +void g() { + CrossModuleMerge::B<int> bi; + CrossModuleMerge::C(0); +} diff --git a/test/Modules/merge-template-specializations.cpp b/test/Modules/merge-template-specializations.cpp new file mode 100644 index 000000000000..25db93fbbb20 --- /dev/null +++ b/test/Modules/merge-template-specializations.cpp @@ -0,0 +1,5 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -fmodules-local-submodule-visibility -I%S/Inputs/merge-template-specializations -std=c++11 -verify %s +// expected-no-diagnostics +#include "c.h" +X x; diff --git a/test/Modules/merge-var-template-def.cpp b/test/Modules/merge-var-template-def.cpp new file mode 100644 index 000000000000..97a72a194d9d --- /dev/null +++ b/test/Modules/merge-var-template-def.cpp @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s +// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s +// expected-no-diagnostics + +#include "b2.h" +const bool *y = &S<bool, false>::value; diff --git a/test/Modules/module-file-modified.c b/test/Modules/module-file-modified.c new file mode 100644 index 000000000000..85018b521e28 --- /dev/null +++ b/test/Modules/module-file-modified.c @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo 'int foo = 0;' > %t/a.h +// RUN: echo 'module A { header "a.h" }' > %t/m.modulemap +// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=A -x c %t/m.modulemap -o %t/m.pcm +// RUN: echo 'int bar;' > %t/a.h +// RUN: not %clang_cc1 -fmodules -fmodule-file=%t/m.pcm -fmodule-map-file=%t/m.modulemap -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s +#include "a.h" +int foo = 0; // redefinition of 'foo' +// CHECK: fatal error: file {{.*}} has been modified since the module file {{.*}} was built +// REQUIRES: shell diff --git a/test/Modules/module_file_info.m b/test/Modules/module_file_info.m index 8693d2b89497..fa841b75926c 100644 --- a/test/Modules/module_file_info.m +++ b/test/Modules/module_file_info.m @@ -1,10 +1,17 @@ @import DependsOnModule; -// RUN: rm -rf %t -// RUN: %clang_cc1 -w -Wunused -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t -F %S/Inputs -DBLARG -DWIBBLE=WOBBLE -fmodule-feature myfeature %s +// RUN: rm -rf %t %t-obj +// RUN: %clang_cc1 -w -Wunused -fmodules -fmodule-format=raw -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t -F %S/Inputs -DBLARG -DWIBBLE=WOBBLE -fmodule-feature myfeature %s // RUN: %clang_cc1 -module-file-info %t/DependsOnModule.pcm | FileCheck %s +// RUN: %clang_cc1 -module-file-info %t/DependsOnModule.pcm | FileCheck %s --check-prefix=RAW +// RUN: %clang_cc1 -w -Wunused -fmodules -fmodule-format=obj -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t-obj -F %S/Inputs -DBLARG -DWIBBLE=WOBBLE -fmodule-feature myfeature %s +// RUN: %clang_cc1 -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s +// RUN: %clang_cc1 -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s --check-prefix=OBJ + +// RAW: Module format: raw +// OBJ: Module format: obj // CHECK: Generated by this Clang: // CHECK: Module name: DependsOnModule diff --git a/test/Modules/no-stale-modtime.m b/test/Modules/no-stale-modtime.m index b90daf123ef0..c7ff21c22a9f 100644 --- a/test/Modules/no-stale-modtime.m +++ b/test/Modules/no-stale-modtime.m @@ -7,9 +7,13 @@ // RUN: echo '@import l; @import r;' > %t/b.h // RUN: echo '@import t; // fromt l' > %t/l.h // RUN: echo '@import t; // fromt r' > %t/r.h -// RUN: echo '// top' > %t/t.h -// RUN: echo 'module b { header "b.h" } module l { header "l.h" }' > %t/module.map -// RUN: echo 'module r { header "r.h" } module t { header "t.h" }' >> %t/module.map + +// RUN: echo '// top' > %t/t.h-1 +// RUN: cat %t/t.h-1 > %t/t.h + +// RUN: echo 'module b { header "b.h" } module l { header "l.h" }' > %t/module.map-1 +// RUN: echo 'module r { header "r.h" } module t { header "t.h" }' > %t/module.map-2 +// RUN: cat %t/module.map-1 %t/module.map-2 > %t/module.map // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \ // RUN: -I %t -fsyntax-only %s -Rmodule-build 2>&1 \ @@ -18,7 +22,9 @@ // RUN: -I %t -fsyntax-only %s -Rmodule-build -verify // Add an identifier to ensure everything depending on t is out of date -// RUN: echo 'extern int a;' >> %t/t.h +// RUN: echo 'extern int a;' > %t/t.h-2 +// RUN: cat %t/t.h-1 %t/t.h-2 > %t/t.h + // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \ // RUN: -I %t -fsyntax-only %s -Rmodule-build 2>&1 \ // RUN: | FileCheck -check-prefix=REBUILD-ALL %s diff --git a/test/Modules/objc-category-2.m b/test/Modules/objc-category-2.m new file mode 100644 index 000000000000..3a6f52d6105a --- /dev/null +++ b/test/Modules/objc-category-2.m @@ -0,0 +1,12 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/objc-category-2 %s -verify -fobjc-arc + +// We have a definition of category and the base interface imported from a +// module, definition for the base interface is also textually included. +// Currently we emit an error "duplicate interface definition". +#import <Category.h> +#include "H3.h" + +void test(DVTSourceModel *m) { + [m test:1]; +} diff --git a/test/Modules/objc-category-3.m b/test/Modules/objc-category-3.m new file mode 100644 index 000000000000..b5162bffbfef --- /dev/null +++ b/test/Modules/objc-category-3.m @@ -0,0 +1,14 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/objc-category-3 %s -verify -fobjc-arc +// expected-no-diagnostics + +// We have a definition of the base interface textually included from +// Category.h, the definition is also in the module that includes the base +// interface. We should be able to see both categories in the TU. +#include "Category.h" +#import <Category_B.h> + +void test(DVTSourceModel *m) { + [m test:1]; + [m testB:1 matchingMask:2]; +} diff --git a/test/Modules/objc-category.m b/test/Modules/objc-category.m new file mode 100644 index 000000000000..944c7ea625dc --- /dev/null +++ b/test/Modules/objc-category.m @@ -0,0 +1,13 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/objc-category %s -verify -fobjc-arc +// expected-no-diagnostics + +// We have a definition of the base interface textually included from +// Category.h, the definition is also in the module that includes the base +// interface. We should be able to see the category in the TU. +#include "Category.h" +#import <H3.h> + +void test(DVTSourceModel *m) { + [m test:1]; +} diff --git a/test/Modules/objc-hidden.m b/test/Modules/objc-hidden.m new file mode 100644 index 000000000000..6e40e0d7d191 --- /dev/null +++ b/test/Modules/objc-hidden.m @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fsyntax-only -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/objc-hidden/System -F %S/Inputs/objc-hidden -verify -x objective-c %s +// expected-no-diagnostics + +// Make sure we don't crash with hidden decls. +@import FakeUnavailableObjCFramework; + +@implementation UnavailableObjCClass +- (void)someMethod { } +@end + diff --git a/test/Modules/objc-initializer.m b/test/Modules/objc-initializer.m new file mode 100644 index 000000000000..adb7a06a2bf6 --- /dev/null +++ b/test/Modules/objc-initializer.m @@ -0,0 +1,15 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/objc-initializer %s -emit-llvm -o - -fobjc-arc | FileCheck %s +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/objc-initializer %s -emit-llvm -o - -fobjc-arc -DIMPORT_TOP | FileCheck %s +// CHECK: kSimDeviceIOGetInterface = internal constant {{.*}} bitcast + +#ifdef IMPORT_TOP +@import X; +#else +#import <X.h> +#endif + +void test2(const NSString*); +void test() { + test2(kSimDeviceIOGetInterface); +} diff --git a/test/Modules/objc-method-redecl.m b/test/Modules/objc-method-redecl.m new file mode 100644 index 000000000000..f7acda5450d6 --- /dev/null +++ b/test/Modules/objc-method-redecl.m @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c-header -emit-pch %S/Inputs/objc-method-redecl.h -o %t.pch -Wno-objc-root-class +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -include-pch %t.pch %s -verify -Wno-objc-root-class +// expected-no-diagnostics + +@implementation T +- (void)test { +} +@end diff --git a/test/Modules/odr.cpp b/test/Modules/odr.cpp index 30143968ffb2..9cdbb4f0806d 100644 --- a/test/Modules/odr.cpp +++ b/test/Modules/odr.cpp @@ -15,9 +15,9 @@ bool b = F<int>{0} == F<int>{1}; int x = f() + g(); // expected-note@a.h:5 {{definition has no member 'e2'}} -// expected-note@b.h:3 {{declaration of 'f' does not match}} -// expected-note@b.h:1 {{definition has no member 'n'}} +// expected-note@a.h:3 {{declaration of 'f' does not match}} +// expected-note@a.h:1 {{definition has no member 'm'}} // expected-error@b.h:5 {{'E::e2' from module 'b' is not present in definition of 'E' in module 'a'}} -// expected-error@a.h:3 {{'Y::f' from module 'a' is not present in definition of 'Y' in module 'b'}} -// expected-error@a.h:2 {{'Y::n' from module 'a' is not present in definition of 'Y' in module 'b'}} +// expected-error@b.h:3 {{'Y::f' from module 'b' is not present in definition of 'Y' in module 'a'}} +// expected-error@b.h:2 {{'Y::m' from module 'b' is not present in definition of 'Y' in module 'a'}} diff --git a/test/Modules/pr27699.cpp b/test/Modules/pr27699.cpp new file mode 100644 index 000000000000..0a17fcba56ff --- /dev/null +++ b/test/Modules/pr27699.cpp @@ -0,0 +1,9 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR27699 -verify %s +// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR27699/module.modulemap -fmodules-cache-path=%t -fmodules-local-submodule-visibility -I%S/Inputs/PR27699 -verify %s + +#include "Subdir/a.h" +#include "Subdir/b.h" + +// expected-no-diagnostics + diff --git a/test/Modules/pr28438.cpp b/test/Modules/pr28438.cpp new file mode 100644 index 000000000000..43c9ea549da5 --- /dev/null +++ b/test/Modules/pr28438.cpp @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fsyntax-only -verify %s -fmodules -fmodules-cache-path=%t -I%S/Inputs/PR28438 -fimplicit-module-maps + +#include "a.h" +#include "b2.h" + +FOO // expected-no-diagnostics diff --git a/test/Modules/pr28752.cpp b/test/Modules/pr28752.cpp new file mode 100644 index 000000000000..1c7896152c9f --- /dev/null +++ b/test/Modules/pr28752.cpp @@ -0,0 +1,22 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s +// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s -fmodules-local-submodule-visibility + +#include "a.h" +#include "Subdir1/c.h" +#include <vector> + +class TClingClassInfo { + std::vector<int> fIterStack; +}; + +TClingClassInfo *a; +class TClingBaseClassInfo { + TClingBaseClassInfo() { new TClingClassInfo(*a); } +}; + +namespace { struct Q; } +bool *p = &A<Q>::b; + +// expected-no-diagnostics + diff --git a/test/Modules/pr28812.cpp b/test/Modules/pr28812.cpp new file mode 100644 index 000000000000..78267d2a4b44 --- /dev/null +++ b/test/Modules/pr28812.cpp @@ -0,0 +1,22 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28812 -verify %s +// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fimplicit-module-maps \ +// RUN: -fmodules-cache-path=%t -I%S/Inputs/PR28812 -verify %s + +template <typename> struct VarStreamArrayIterator; +template <typename ValueType> +struct VarStreamArray { + typedef VarStreamArrayIterator<ValueType> Iterator; + Iterator begin() { return Iterator(*this); } +}; + +#include "Textual.h" + +#include "a.h" +#include "b.h" + +VarStreamArray<int> a; +auto b = a.begin(); + +// expected-no-diagnostics + diff --git a/test/Modules/prebuilt-module.m b/test/Modules/prebuilt-module.m new file mode 100644 index 000000000000..d5012e0e85f3 --- /dev/null +++ b/test/Modules/prebuilt-module.m @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// +// RUN: %clang_cc1 -fmodules -x objective-c -I %S/Inputs/prebuilt-module -emit-module %S/Inputs/prebuilt-module/module.modulemap -fmodule-name=prebuilt -o %t/prebuilt.pcm +// RUN: %clang_cc1 -fmodules -fprebuilt-module-path=%t/ -fdisable-module-hash %s -verify + +// expected-no-diagnostics +@import prebuilt; +int test() { + return a; +} diff --git a/test/Modules/prune.m b/test/Modules/prune.m index 6676407c9acd..58992f9c006d 100644 --- a/test/Modules/prune.m +++ b/test/Modules/prune.m @@ -5,9 +5,6 @@ @import Module; #endif -// We need 'touch' and 'find' for this test to work. -// REQUIRES: shell - // Clear out the module cache // RUN: rm -rf %t // Run Clang twice so we end up creating the timestamp file (the second time). @@ -28,7 +25,7 @@ // Set the DependsOnModule access time back more than four days. // This shouldn't prune anything, because the timestamp has been updated, so // the pruning mechanism won't fire. -// RUN: find %t -name DependsOnModule*.pcm | xargs touch -a -t 201101010000 +// RUN: find %t -name DependsOnModule*.pcm | sed -e 's/\\/\//g' | xargs touch -a -t 201101010000 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify // RUN: ls %t | grep modules.timestamp // RUN: ls -R %t | grep ^Module.*pcm @@ -37,7 +34,7 @@ // Set both timestamp and DependsOnModule.pcm back beyond the cutoff. // This should trigger pruning, which will remove DependsOnModule but not Module. // RUN: touch -m -a -t 201101010000 %t/modules.timestamp -// RUN: find %t -name DependsOnModule*.pcm | xargs touch -a -t 201101010000 +// RUN: find %t -name DependsOnModule*.pcm | sed -e 's/\\/\//g' | xargs touch -a -t 201101010000 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify // RUN: ls %t | grep modules.timestamp // RUN: ls -R %t | grep ^Module.*pcm diff --git a/test/Modules/redundant-include.mm b/test/Modules/redundant-include.mm new file mode 100644 index 000000000000..d736022699c3 --- /dev/null +++ b/test/Modules/redundant-include.mm @@ -0,0 +1,12 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I%S/Inputs %s -verify +// RUN: %clang_cc1 -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs %s -verify + +#include "cxx-header.h" +void includeNotAtTopLevel() { // expected-note {{function 'includeNotAtTopLevel' begins here}} + #include "cxx-header.h" // expected-error {{redundant #include of module 'cxx_library' appears within function 'includeNotAtTopLevel'}} +} + +namespace NS { // expected-note {{begins here}} + #include "cxx-header.h" // expected-error {{redundant #include of module 'cxx_library' appears within namespace 'NS'}} +} diff --git a/test/Modules/requires-gnuinlineasm.m b/test/Modules/requires-gnuinlineasm.m new file mode 100644 index 000000000000..80b1b18d0742 --- /dev/null +++ b/test/Modules/requires-gnuinlineasm.m @@ -0,0 +1,16 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules \ +// RUN: -fimplicit-module-maps -F %S/Inputs/GNUAsm %s \ +// RUN: -fno-gnu-inline-asm -DNO_ASM_INLINE -verify +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules \ +// RUN: -fimplicit-module-maps -F %S/Inputs/GNUAsm %s \ +// RUN: -DASM_INLINE -verify + +#ifdef NO_ASM_INLINE +@import NeedsGNUInlineAsm.Asm; // expected-error{{module 'NeedsGNUInlineAsm.Asm' requires feature 'gnuinlineasm'}} +#endif + +#ifdef ASM_INLINE +@import NeedsGNUInlineAsm.Asm; // expected-no-diagnostics +#endif diff --git a/test/Modules/signal.m b/test/Modules/signal.m index 37a35506447d..4d0885e56c8b 100644 --- a/test/Modules/signal.m +++ b/test/Modules/signal.m @@ -1,4 +1,4 @@ -// REQUIRES: crash-recovery,shell +// REQUIRES: crash-recovery // RUN: rm -rf %t // Crash building module. diff --git a/test/Modules/stress-objc.m b/test/Modules/stress-objc.m new file mode 100644 index 000000000000..edbebd3576a9 --- /dev/null +++ b/test/Modules/stress-objc.m @@ -0,0 +1,22 @@ +// RUN: cd %S + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00.pch -fno-pch-timestamp +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_1.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_1.pch + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_2.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_2.pch + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_3.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_3.pch + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_4.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_4.pch + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_5.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_5.pch + +@protocol NSObject +- (void)doesNotRecognizeSelector:(SEL)aSelector; +- (id)forwardingTargetForSelector:(SEL)aSelector; +@end diff --git a/test/Modules/templates.mm b/test/Modules/templates.mm index 190084ad2b74..79e975a1ad12 100644 --- a/test/Modules/templates.mm +++ b/test/Modules/templates.mm @@ -12,10 +12,10 @@ void testInlineRedeclEarly() { @import templates_right; -// 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: @list_left = global %[[LIST:.*]] { %[[LISTNODE:.*]]* null, i32 8 }, align 8 +// CHECK-DAG: @list_right = global %[[LIST]] { %[[LISTNODE]]* null, i32 12 }, align 8 +// CHECK-DAG: @_ZZ15testMixedStructvE1l = {{.*}} constant %[[LIST]] { %{{.*}}* null, i32 1 }, align 8 +// CHECK-DAG: @_ZZ15testMixedStructvE1r = {{.*}} constant %[[LIST]] { %{{.*}}* null, i32 2 }, align 8 // CHECK-DAG: @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE = external global void testTemplateClasses() { @@ -116,4 +116,9 @@ void testStaticDataMember() { (void) getStaticDataMemberRight(); } - +void testWithAttributes() { + auto a = make_with_attributes_left(); + auto b = make_with_attributes_right(); + static_assert(alignof(decltype(a)) == 2, ""); + static_assert(alignof(decltype(b)) == 2, ""); +} diff --git a/test/Modules/umbrella-header-include-builtin.mm b/test/Modules/umbrella-header-include-builtin.mm new file mode 100644 index 000000000000..75b9c905ff00 --- /dev/null +++ b/test/Modules/umbrella-header-include-builtin.mm @@ -0,0 +1,6 @@ +// REQUIRES: system-darwin + +// RUN: rm -rf %t +// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s + +#include <A/A.h> diff --git a/test/Modules/unused-global-init.cpp b/test/Modules/unused-global-init.cpp new file mode 100644 index 000000000000..3bd7a7f5a627 --- /dev/null +++ b/test/Modules/unused-global-init.cpp @@ -0,0 +1,37 @@ +// RUN: rm -rf %t +// +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-module %S/Inputs/unused-global-init/module.modulemap -fmodule-name=init -o %t/init.pcm +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-module %S/Inputs/unused-global-init/module.modulemap -fmodule-name=unused -o %t/unused.pcm -fmodule-file=%t/init.pcm +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-module %S/Inputs/unused-global-init/module.modulemap -fmodule-name=used -o %t/used.pcm -fmodule-file=%t/init.pcm +// +// No module file: init.h performs init. +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-llvm -o - %s -DINIT | FileCheck --check-prefix=CHECK-INIT %s +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-llvm -o - %s -DUSED | FileCheck --check-prefix=CHECK-INIT %s +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-llvm -o - %s -DOTHER -DUNUSED | FileCheck --check-prefix=CHECK-NO-INIT %s +// +// With module files: if there is a transitive import of any part of the +// module, we run its global initializers (even if the imported piece is not +// visible here). +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-llvm -o - %s -fmodule-file=%t/used.pcm -fmodule-file=%t/unused.pcm -DINIT | FileCheck --check-prefix=CHECK-INIT %s +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-llvm -o - %s -fmodule-file=%t/used.pcm -fmodule-file=%t/unused.pcm -DOTHER | FileCheck --check-prefix=CHECK-NO-INIT %s +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-llvm -o - %s -fmodule-file=%t/used.pcm -fmodule-file=%t/unused.pcm -DUSED | FileCheck --check-prefix=CHECK-INIT %s +// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c++ -I %S/Inputs/unused-global-init -triple %itanium_abi_triple -emit-llvm -o - %s -fmodule-file=%t/used.pcm -fmodule-file=%t/unused.pcm -DUNUSED | FileCheck --check-prefix=CHECK-NO-INIT %s + +#ifdef INIT +#include "init.h" +#endif + +#ifdef OTHER +#include "other.h" +#endif + +#ifdef USED +#include "used.h" +#endif + +#ifdef UNUSED +#include "unused.h" +#endif + +// CHECK-INIT: call {{.*}}@_ZN4InitC +// CHECK-NO-INIT-NOT: call {{.*}}@_ZN4InitC |
