1 // UNSUPPORTED: -zos, -aix
2 // Test that (the same) debug info is emitted for an Objective-C++
3 // module and a C++ precompiled header.
4 
5 // REQUIRES: asserts
6 
7 // Modules:
8 // RUN: rm -rf %t
9 // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
10 // RUN: cat %t-mod.ll | FileCheck %s
11 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
12 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
13 
14 // PCH:
15 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  -debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
16 // RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-CXX %s
17 // RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
18 
19 #ifdef MODULES
20 @import DebugCXX;
21 #endif
22 
23 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
24 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
25 
26 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
27 // CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
28 // CHECK-SAME:                    isOptimized: false,
29 // CHECK-NOT:                     splitDebugFilename:
30 // CHECK-SAME:                    dwoId:
31 
32 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum"
33 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX4EnumE")
34 // CHECK: !DINamespace(name: "DebugCXX"
35 
36 // CHECK-MOD: ![[DEBUGCXX:.*]] = !DIModule(scope: null, name: "DebugCXX
37 
38 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
39 // CHECK-NOT:              name:
40 // CHECK-SAME:             )
41 
42 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
43 // CHECK-NOT:              name:
44 // CHECK-SAME:             )
45 
46 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
47 // CHECK-NOT:              name:
48 // CHECK-SAME:             identifier: "_ZTS11TypedefEnum")
49 
50 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
51 // CHECK-NOT:              name:
52 // CHECK-SAME:             )
53 // CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
54 
55 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
56 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX6StructE")
57 
58 // This type is anchored by an explicit template instantiation.
59 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
60 // CHECK-SAME:             name: "Template<int, DebugCXX::traits<int> >"
61 // CHECK-SAME:             elements:
62 // CHECK-SAME:             templateParams:
63 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
64 
65 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<int>"
66 // CHECK-SAME:             flags: DIFlagFwdDecl
67 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX6traitsIiEE")
68 
69 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<float>"
70 // CHECK-SAME:             elements:
71 // CHECK-SAME:             templateParams:
72 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX6traitsIfEE")
73 
74 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
75 // CHECK-SAME:             name: "Template<long, DebugCXX::traits<long> >"
76 // CHECK-SAME:             elements:
77 // CHECK-SAME:             templateParams:
78 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE")
79 
80 // This type is anchored by a function parameter.
81 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>"
82 // CHECK-SAME:             elements:
83 // CHECK-SAME:             templateParams:
84 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX1AIJvEEE")
85 
86 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation"
87 // no mangled name here yet.
88 
89 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
90 // CHECK-SAME:             name: "Template<float, DebugCXX::traits<float> >"
91 // CHECK-SAME:             flags: DIFlagFwdDecl
92 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
93 
94 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
95 // no mangled name here yet.
96 
97 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual"
98 // CHECK-SAME:             elements:
99 // CHECK-SAME:             identifier: "_ZTS7Virtual")
100 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "_vptr$Virtual"
101 
102 // CHECK: !DICompositeType(tag: DW_TAG_union_type,
103 // CHECK-NOT:              name:
104 // CHECK-SAME:             identifier: "_ZTS12TypedefUnion")
105 
106 // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
107 // CHECK-NOT:              name:
108 // CHECK-SAME:             identifier: "_ZTS13TypedefStruct")
109 
110 // CHECK: !DICompositeType(tag: DW_TAG_union_type,
111 // CHECK-NOT:              name:
112 // CHECK-SAME:             )
113 
114 // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
115 // CHECK-NOT:              name:
116 // CHECK-SAME:             )
117 
118 // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
119 // CHECK-SAME:             name: "InAnonymousNamespace",
120 // CHECK-SAME:             elements: !{{[0-9]+}})
121 
122 // CHECK: ![[A:.*]] = {{.*}}!DICompositeType(tag: DW_TAG_class_type, name: "A",
123 // CHECK-SAME:                               elements:
124 // CHECK-SAME:                               vtableHolder: ![[A]])
125 
126 // CHECK: ![[DERIVED:.*]] = {{.*}}!DICompositeType(tag: DW_TAG_class_type, name: "Derived",
127 // CHECK-SAME:                                     identifier: "_ZTS7Derived")
128 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: ![[DERIVED]],
129 // CHECK-SAME:             elements: ![[B_MBRS:.*]], vtableHolder:
130 // CHECK: ![[B_MBRS]] = !{{{.*}}, ![[GET_PARENT:.*]]}
131 // CHECK: ![[GET_PARENT]] = !DISubprogram(name: "getParent"
132 
133 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefTemplate",
134 // CHECK-SAME:           baseType: ![[BASE:.*]])
135 // CHECK: ![[BASE]] = !DICompositeType(tag: DW_TAG_class_type,
136 // CHECK-SAME:                         name: "Template1<void *>",
137 // CHECK-SAME:                         flags: DIFlagFwdDecl
138 // CHECK-SAME:                         identifier: "_ZTS9Template1IPvE")
139 
140 // Explicit instantiation.
141 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<int>",
142 // CHECK-SAME:             templateParams:
143 // CHECK-SAME:             identifier: "_ZTS9Template1IiE")
144 
145 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate<int>",
146 // CHECK-SAME:             flags: DIFlagFwdDecl
147 // CHECK-SAME:             identifier: "_ZTS15FwdDeclTemplateIiE")
148 
149 // Forward-declared member of a template.
150 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
151 // CHECK-SAME:             flags: DIFlagFwdDecl
152 // CHECK-SAME:             identifier: "_ZTSN21FwdDeclTemplateMemberIiE6MemberE")
153 
154 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "SpecializedBase",
155 // CHECK-SAME:           baseType: ![[SPECIALIZEDBASE:.*]])
156 // CHECK: ![[SPECIALIZEDBASE]] = !DICompositeType(tag: DW_TAG_class_type,
157 // CHECK-SAME:                             name: "WithSpecializedBase<float>",
158 // CHECK-SAME:                             flags: DIFlagFwdDecl
159 
160 // CHECK-MOD: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: ![[DEBUGCXX]],
161 // CHECK-MOD-SAME:              entity: ![[DUMMY:[0-9]+]],
162 // CHECK-MOD-SAME:              line: 3)
163 // CHECK-MOD: ![[DUMMY]] = !DIModule(scope: null, name: "dummy",
164 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_ObjC_plus_plus,
165 // CHECK-MOD-SAME:  splitDebugFilename: "{{.*}}dummy{{.*}}.pcm",
166 
167 // CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"
168