1 // UNSUPPORTED: -zos, -aix 2 // RUN: rm -rf %t 3 // Test that only forward declarations are emitted for types defined in modules. 4 5 // Modules: 6 // RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=standalone \ 7 // RUN: -dwarf-ext-refs -fmodules \ 8 // RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \ 9 // RUN: -triple %itanium_abi_triple \ 10 // RUN: -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t-mod.ll 11 // RUN: cat %t-mod.ll | FileCheck %s 12 13 // PCH: 14 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch -I%S/Inputs \ 15 // RUN: -triple %itanium_abi_triple \ 16 // RUN: -o %t.pch %S/Inputs/DebugCXX.h 17 // RUN: %clang_cc1 -std=c++11 -debug-info-kind=standalone \ 18 // RUN: -dwarf-ext-refs -fmodule-format=obj \ 19 // RUN: -triple %itanium_abi_triple \ 20 // RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll 21 // RUN: cat %t-pch.ll | FileCheck %s 22 // RUN: cat %t-pch.ll | FileCheck %s --check-prefix=CHECK-PCH 23 24 #ifdef MODULES 25 @import DebugCXX; 26 #endif 27 28 // Set the line number so that the LIT check expected line number doesn't have to be updated after adding/removing a line in the RUN section. 29 #line 50 30 using DebugCXX::Struct; 31 32 Struct s; 33 DebugCXX::Enum e; 34 35 // Template instantiations. 36 DebugCXX::Template<long> implicitTemplate; 37 DebugCXX::Template<int> explicitTemplate; 38 DebugCXX::FloatInstantiation typedefTemplate; 39 DebugCXX::B anchoredTemplate; 40 41 int Struct::static_member = -1; 42 enum { 43 e3 = -1 44 } conflicting_uid = e3; 45 auto anon_enum = DebugCXX::e2; 46 char _anchor = anon_enum + conflicting_uid; 47 48 TypedefUnion tdu; 49 TypedefEnum tde; 50 TypedefStruct tds; 51 TypedefTemplate tdt; 52 Template1<int> explicitTemplate1; 53 54 template <class T> class FwdDeclTemplate { T t; }; 55 TypedefFwdDeclTemplate tdfdt; 56 57 InAnonymousNamespace anon; 58 59 // Types that are forward-declared in the module and defined here. 60 struct PureFwdDecl { int i; }; 61 PureFwdDecl definedLocally; 62 63 struct Specialized<int>::Member { int i; }; 64 struct Specialized<int>::Member definedLocally2; 65 66 template <class T> struct FwdDeclTemplateMember<T>::Member { T t; }; 67 TypedefFwdDeclTemplateMember tdfdtm; 68 69 SpecializedBase definedLocally3; 70 extern template class WithSpecializedBase<int>; 71 WithSpecializedBase<int> definedLocally4; 72 73 void foo() { 74 anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum; 75 A a; 76 Virtual virt; 77 } 78 79 // CHECK: ![[CPP:.*]] = !DIFile(filename: {{.*}}ExtDebugInfo.cpp" 80 81 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", 82 // CHECK-SAME: scope: ![[NS:[0-9]+]], 83 // CHECK-SAME: flags: DIFlagFwdDecl 84 // CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE") 85 86 // CHECK: ![[NS]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]]) 87 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX 88 89 // This type is not anchored in the module by an explicit template instantiation. 90 // CHECK: !DICompositeType(tag: DW_TAG_class_type, 91 // CHECK-SAME: name: "Template<long, DebugCXX::traits<long> >", 92 // CHECK-SAME: scope: ![[NS]], 93 // CHECK-SAME: elements: 94 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE") 95 96 // This type is anchored in the module by an explicit template instantiation. 97 // CHECK: !DICompositeType(tag: DW_TAG_class_type, 98 // CHECK-SAME: name: "Template<int, DebugCXX::traits<int> >", 99 // CHECK-SAME: scope: ![[NS]], 100 // CHECK-SAME: flags: DIFlagFwdDecl 101 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE") 102 103 // This type isn't, however, even with standalone non-module debug info this 104 // type is a forward declaration. 105 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<int>", 106 107 // This one isn't. 108 // CHECK: !DICompositeType(tag: DW_TAG_class_type, 109 // CHECK-SAME: name: "Template<float, DebugCXX::traits<float> >", 110 // CHECK-SAME: scope: ![[NS]], 111 // CHECK-SAME: elements: 112 // CHECK-SAME: templateParams: 113 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE") 114 115 // This type is anchored in the module by an explicit template instantiation. 116 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<float>", 117 // CHECK-SAME: flags: DIFlagFwdDecl 118 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIfEE") 119 120 121 // This type is anchored in the module via a function argument, 122 // but we don't know this (yet). 123 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>", 124 // CHECK-SAME: scope: ![[NS]], 125 // CHECK-SAME: elements: 126 // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE") 127 128 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member", 129 // CHECK-SAME: scope: ![[STRUCT:[0-9]*]] 130 131 // CHECK: ![[STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Struct", 132 // CHECK-SAME: scope: ![[NS]], 133 // CHECK-SAME: flags: DIFlagFwdDecl 134 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE") 135 136 // CHECK: !DICompositeType(tag: DW_TAG_union_type, 137 // CHECK-SAME: flags: DIFlagFwdDecl 138 // CHECK-SAME: identifier: "_ZTS12TypedefUnion") 139 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, 140 // CHECK-SAME: flags: DIFlagFwdDecl, 141 // CHECK-SAME: identifier: "_ZTS11TypedefEnum") 142 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, 143 // CHECK-SAME: flags: DIFlagFwdDecl, 144 // CHECK-SAME: identifier: "_ZTS13TypedefStruct") 145 146 // This one isn't. 147 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<void *>", 148 // CHECK-SAME: elements: 149 // CHECK-SAME: templateParams: 150 // CHECK-SAME: identifier: "_ZTS9Template1IPvE") 151 152 // This type is anchored in the module by an explicit template instantiation. 153 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<int>", 154 // CHECK-SAME: flags: DIFlagFwdDecl, 155 // CHECK-SAME: identifier: "_ZTS9Template1IiE") 156 157 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate<int>", 158 // CHECK-SAME: elements: 159 // CHECK-SAME: templateParams: 160 // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE") 161 162 // This type is defined locally and forward-declared in the module. 163 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "PureFwdDecl", 164 // CHECK-SAME: elements: 165 // CHECK-SAME: identifier: "_ZTS11PureFwdDecl") 166 167 // This type is defined locally and forward-declared in the module. 168 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member", 169 // CHECK-SAME: elements: 170 // CHECK-SAME: identifier: "_ZTSN11SpecializedIiE6MemberE") 171 172 // This type is defined locally and forward-declared in the module. 173 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member", 174 // CHECK-SAME: elements: 175 // CHECK-SAME: identifier: "_ZTSN21FwdDeclTemplateMemberIiE6MemberE") 176 177 // This type is defined locally and forward-declared in the module. 178 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "SpecializedBase", 179 // CHECK-SAME: baseType: ![[SPECIALIZEDBASE:.*]]) 180 // CHECK: ![[SPECIALIZEDBASE]] = 181 // CHECK-SAME: !DICompositeType(tag: DW_TAG_class_type, 182 // CHECK-SAME: name: "WithSpecializedBase<float>", 183 // CHECK-SAME: elements: 184 // CHECK-SAME: identifier: "_ZTS19WithSpecializedBaseIfE") 185 186 // This type is explicitly specialized locally. 187 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "WithSpecializedBase<int>", 188 // CHECK-SAME: elements: 189 // CHECK-SAME: identifier: "_ZTS19WithSpecializedBaseIiE") 190 191 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]] 192 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]], 193 // CHECK-SAME: line: 19 194 195 // CHECK: !DIGlobalVariable(name: "GlobalUnion", 196 // CHECK-SAME: type: ![[GLOBAL_UNION:[0-9]+]] 197 // CHECK: ![[GLOBAL_UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type, 198 // CHECK-SAME: elements: !{{[0-9]+}}) 199 // CHECK: !DIGlobalVariable(name: "GlobalStruct", 200 // CHECK-SAME: type: ![[GLOBAL_STRUCT:[0-9]+]] 201 // CHECK: ![[GLOBAL_STRUCT]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 202 // CHECK-SAME: elements: !{{[0-9]+}}) 203 204 205 // CHECK: !DIGlobalVariable(name: "anon", 206 // CHECK-SAME: type: ![[GLOBAL_ANON:[0-9]+]] 207 // CHECK: ![[GLOBAL_ANON]] = !DICompositeType(tag: DW_TAG_structure_type, 208 // CHECK-SAME: name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl) 209 210 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 50) 211 212 // CHECK: !DICompileUnit( 213 // CHECK-SAME: splitDebugFilename: 214 // CHECK-SAME: dwoId: 215 // CHECK-PCH: !DICompileUnit({{.*}}splitDebugFilename: 216 // CHECK-PCH: dwoId: 18446744073709551614 217 218 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A", 219 // CHECK-SAME: DIFlagFwdDecl 220 221 // There is a full definition of the type available in the module. 222 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual", 223 // CHECK-SAME: DIFlagFwdDecl 224 // CHECK-SAME: identifier: "_ZTS7Virtual") 225