Clang Project

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