1 // RUN: rm -rf %t 2 // Test that only forward declarations are emitted for types dfined in modules. 3 4 // Modules: 5 // RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=standalone \ 6 // RUN: -dwarf-ext-refs -fmodules \ 7 // RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \ 8 // RUN: -triple %itanium_abi_triple \ 9 // RUN: -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t-mod.ll 10 // RUN: cat %t-mod.ll | FileCheck %s 11 12 // PCH: 13 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch -I%S/Inputs \ 14 // RUN: -triple %itanium_abi_triple \ 15 // RUN: -o %t.pch %S/Inputs/DebugCXX.h 16 // RUN: %clang_cc1 -std=c++11 -debug-info-kind=standalone \ 17 // RUN: -dwarf-ext-refs -fmodule-format=obj \ 18 // RUN: -triple %itanium_abi_triple \ 19 // RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s 20 // RUN: cat %t-pch.ll | FileCheck %s 21 // RUN: cat %t-pch.ll | FileCheck %s --check-prefix=CHECK-PCH 22 23 #ifdef MODULES 24 @import DebugCXX; 25 #endif 26 27 using DebugCXX::Struct; 28 29 Struct s; 30 DebugCXX::Enum e; 31 DebugCXX::Template<long> implicitTemplate; 32 DebugCXX::Template<int> explicitTemplate; 33 DebugCXX::FloatInstantiation typedefTemplate; 34 DebugCXX::B anchoredTemplate; 35 36 int Struct::static_member = -1; 37 enum { 38 e3 = -1 39 } conflicting_uid = e3; 40 auto anon_enum = DebugCXX::e2; 41 char _anchor = anon_enum + conflicting_uid; 42 43 TypedefUnion tdu; 44 TypedefEnum tde; 45 TypedefStruct tds; 46 TypedefTemplate tdt; 47 Template1<int> explicitTemplate1; 48 49 template <class T> class FwdDeclTemplate { T t; }; 50 TypedefFwdDeclTemplate tdfdt; 51 52 InAnonymousNamespace anon; 53 54 void foo() { 55 anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum; 56 } 57 58 59 // CHECK: ![[STRUCT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Struct", 60 // CHECK-SAME: scope: ![[NS:[0-9]+]], 61 // CHECK-SAME: flags: DIFlagFwdDecl, 62 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE") 63 64 // CHECK: ![[NS]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]], 65 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX 66 67 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", 68 // CHECK-SAME: scope: ![[NS]], 69 // CHECK-SAME: flags: DIFlagFwdDecl, 70 // CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE") 71 72 // This type is anchored in the module by an explicit template instantiation. 73 // CHECK: !DICompositeType(tag: DW_TAG_class_type, 74 // CHECK-SAME: name: "Template<long, DebugCXX::traits<long> >", 75 // CHECK-SAME: scope: ![[NS]], 76 // CHECK-SAME: flags: DIFlagFwdDecl, 77 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE") 78 79 // This type is anchored in the module by an explicit template instantiation. 80 // CHECK: !DICompositeType(tag: DW_TAG_class_type, 81 // CHECK-SAME: name: "Template<int, DebugCXX::traits<int> >", 82 // CHECK-SAME: scope: ![[NS]], 83 // CHECK-SAME: flags: DIFlagFwdDecl, 84 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE") 85 86 // This type isn't, however, even with standalone non-module debug info this 87 // type is a forward declaration. 88 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<int>", 89 90 // This one isn't. 91 // CHECK: !DICompositeType(tag: DW_TAG_class_type, 92 // CHECK-SAME: name: "Template<float, DebugCXX::traits<float> >", 93 // CHECK-SAME: scope: ![[NS]], 94 // CHECK-SAME: templateParams: 95 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE") 96 97 // This type is anchored in the module by an explicit template instantiation. 98 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<float>", 99 // CHECK-SAME: flags: DIFlagFwdDecl, 100 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIfEE") 101 102 103 // This type is anchored in the module by an explicit template instantiation. 104 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>", 105 // CHECK-SAME: scope: ![[NS]], 106 // CHECK-SAME: flags: DIFlagFwdDecl, 107 // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE") 108 109 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member", 110 // CHECK-SAME: scope: ![[STRUCT]] 111 112 // CHECK: !DICompositeType(tag: DW_TAG_union_type, 113 // CHECK-SAME: flags: DIFlagFwdDecl, 114 // CHECK-SAME: identifier: "_ZTS12TypedefUnion") 115 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, 116 // CHECK-SAME: flags: DIFlagFwdDecl, 117 // CHECK-SAME: identifier: "_ZTS11TypedefEnum") 118 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, 119 // CHECK-SAME: flags: DIFlagFwdDecl, 120 // CHECK-SAME: identifier: "_ZTS13TypedefStruct") 121 122 // This one isn't. 123 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<void *>", 124 // CHECK-SAME: templateParams: 125 // CHECK-SAME: identifier: "_ZTS9Template1IPvE") 126 127 // This type is anchored in the module by an explicit template instantiation. 128 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<int>", 129 // CHECK-SAME: flags: DIFlagFwdDecl, 130 // CHECK-SAME: identifier: "_ZTS9Template1IiE") 131 132 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate<int>", 133 // CHECK-SAME: templateParams: 134 // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE") 135 136 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]] 137 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]], 138 // CHECK-SAME: line: 16 139 140 // CHECK: !DIGlobalVariable(name: "GlobalUnion", 141 // CHECK-SAME: type: ![[GLOBAL_UNION:[0-9]+]] 142 // CHECK: ![[GLOBAL_UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type, 143 // CHECK-SAME: elements: !{{[0-9]+}}) 144 // CHECK: !DIGlobalVariable(name: "GlobalStruct", 145 // CHECK-SAME: type: ![[GLOBAL_STRUCT:[0-9]+]] 146 // CHECK: ![[GLOBAL_STRUCT]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 147 // CHECK-SAME: elements: !{{[0-9]+}}) 148 149 150 // CHECK: !DIGlobalVariable(name: "anon", 151 // CHECK-SAME: type: ![[GLOBAL_ANON:[0-9]+]] 152 // CHECK: ![[GLOBAL_ANON]] = !DICompositeType(tag: DW_TAG_structure_type, 153 // CHECK-SAME: name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl) 154 155 156 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: ![[STRUCT]], line: 27) 157 158 // CHECK: !DICompileUnit( 159 // CHECK-SAME: splitDebugFilename: 160 // CHECK-SAME: dwoId: 161 // CHECK-PCH: !DICompileUnit({{.*}}splitDebugFilename: 162 // CHECK-PCH: dwoId: 18446744073709551614 163