1 // Test that (the same) debug info is emitted for an Objective-C++
2 // module and a C++ precompiled header.
3 
4 // REQUIRES: asserts, shell
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:             templateParams:
53 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX1AIJvEEE")
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:             templateParams:
62 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
63 
64 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<int>"
65 // CHECK-SAME:             flags: DIFlagFwdDecl
66 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX6traitsIiEE")
67 
68 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "traits<float>"
69 // CHECK-SAME:             templateParams:
70 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX6traitsIfEE")
71 
72 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
73 // CHECK-SAME:             name: "Template<long, DebugCXX::traits<long> >"
74 // CHECK-SAME:             templateParams:
75 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE")
76 
77 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation"
78 // no mangled name here yet.
79 
80 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
81 // CHECK-SAME:             name: "Template<float, DebugCXX::traits<float> >"
82 // CHECK-SAME:             flags: DIFlagFwdDecl
83 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
84 
85 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdVirtual"
86 // CHECK-SAME:             elements:
87 // CHECK-SAME:             identifier: "_ZTS10FwdVirtual")
88 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "_vptr$FwdVirtual"
89 
90 // CHECK: !DICompositeType(tag: DW_TAG_union_type,
91 // CHECK-NOT:              name:
92 // CHECK-SAME:             identifier: "_ZTS12TypedefUnion")
93 
94 // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
95 // CHECK-NOT:              name:
96 // CHECK-SAME:             identifier: "_ZTS13TypedefStruct")
97 
98 // CHECK: !DICompositeType(tag: DW_TAG_union_type,
99 // CHECK-NOT:              name:
100 // CHECK-SAME:             )
101 
102 // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
103 // CHECK-NOT:              name:
104 // CHECK-SAME:             )
105 
106 // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
107 // CHECK-SAME:             name: "InAnonymousNamespace",
108 // CHECK-SAME:             elements: !{{[0-9]+}})
109 
110 // CHECK: ![[DERIVED:.*]] = {{.*}}!DICompositeType(tag: DW_TAG_class_type, name: "Derived",
111 // CHECK-SAME:                                     identifier: "_ZTS7Derived")
112 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: ![[DERIVED]],
113 // CHECK-SAME:             elements: ![[B_MBRS:.*]], vtableHolder:
114 // CHECK: ![[B_MBRS]] = !{{{.*}}, ![[GET_PARENT:.*]]}
115 // CHECK: ![[GET_PARENT]] = !DISubprogram(name: "getParent"
116 
117 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefTemplate",
118 // CHECK-SAME:           baseType: ![[BASE:.*]])
119 // CHECK: ![[BASE]] = !DICompositeType(tag: DW_TAG_class_type,
120 // CHECK-SAME:                         name: "Template1<void *>",
121 // CHECK-SAME:                         flags: DIFlagFwdDecl,
122 // CHECK-SAME:                         identifier: "_ZTS9Template1IPvE")
123 
124 // Explicit instatiation.
125 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1<int>",
126 // CHECK-SAME:             templateParams:
127 // CHECK-SAME:             identifier: "_ZTS9Template1IiE")
128 
129 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate<int>",
130 // CHECK-SAME:             flags: DIFlagFwdDecl
131 // CHECK-SAME:             identifier: "_ZTS15FwdDeclTemplateIiE")
132 
133 // Forward-declared member of a template.
134 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
135 // CHECK-SAME:             flags: DIFlagFwdDecl
136 // CHECK-SAME:             identifier: "_ZTSN21FwdDeclTemplateMemberIiE6MemberE")
137 
138 // CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"
139