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