[Alignment][NFC] Instructions::getLoadStoreAlignment
[llvm-complete.git] / test / tools / dsymutil / X86 / odr-uniquing.cpp
blob4827bd8bc35d448d3b4e50f7d265c9d81abd76f6
1 /* Compile with:
2 clang -g -c odr-uniquing.cpp -o odr-uniquing/1.o
3 cp odr-uniquing/1.o odr-uniquing/2.o
4 The aim of these test is to check that all the 'type types' that
5 should be uniqued through the ODR really are.
7 The resulting object file is linked against itself using a fake
8 debug map. The end result is:
9 - with ODR uniquing: all types (expect for the union for now) in
10 the second CU should point back to the types of the first CU.
11 - without ODR uniquing: all types are re-emited in the second CU
14 // RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/odr-uniquing -y %p/dummy-debug-map.map -o - | llvm-dwarfdump -v -debug-info - | FileCheck -check-prefix=ODR -check-prefix=CHECK %s
15 // RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/odr-uniquing -y %p/dummy-debug-map.map -no-odr -o - | llvm-dwarfdump -v -debug-info - | FileCheck -check-prefix=NOODR -check-prefix=CHECK %s
17 // The first compile unit contains all the types:
18 // CHECK: TAG_compile_unit
19 // CHECK-NOT: DW_TAG
20 // CHECK: AT_name{{.*}}"odr-uniquing.cpp"
22 struct S {
23 struct Nested {};
26 // CHECK: 0x[[S:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type
27 // CHECK-NEXT: DW_AT_name{{.*}}"S"
28 // CHECK-NOT: NULL
29 // CHECK: 0x[[NESTED:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type
30 // CHECK-NOT: DW_TAG
31 // CHECK: DW_AT_name{{.*}}"Nested"
32 // CHECK: NULL
34 namespace N {
35 class C {};
38 // CHECK: DW_TAG_namespace
39 // CHECK-NEXT: DW_AT_name{{.*}}"N"
40 // CHECK-NOT: NULL
41 // CHECK: 0x[[NC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type
42 // CHECK-NEXT: DW_AT_name{{.*}}"C"
43 // CHECK: NULL
45 union U {
46 class C {} C;
47 struct S {} S;
50 // CHECK: 0x[[U:[0-9a-f]*]]:{{.*}}DW_TAG_union_type
51 // CHECK-NEXT: DW_AT_name{{.*}}"U"
52 // CHECK-NOT: NULL
53 // CHECK: 0x[[UC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type
54 // CHECK-NOT: NULL
55 // CHECK: 0x[[US:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type
56 // CHECK: NULL
58 typedef S AliasForS;
60 // CHECK: 0x[[ALIASFORS:[0-9a-f]*]]:{{.*}}DW_TAG_typedef
61 // CHECK-NEXT: DW_AT_type{{.*}}[[S]]
62 // CHECK-NEXT: DW_AT_name{{.*}}"AliasForS"
64 namespace {
65 class AnonC {};
68 // CHECK: DW_TAG_namespace
69 // CHECK-NOT: {{DW_AT_name|NULL|DW_TAG}}
70 // CHECK: 0x[[ANONC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type
71 // CHECK-NEXT: DW_AT_name{{.*}}"AnonC"
73 // This function is only here to hold objects that refer to the above types.
74 void foo() {
75 AliasForS s;
76 S::Nested n;
77 N::C nc;
78 AnonC ac;
79 U u;
82 // The second CU contents depend on whether we disabled ODR uniquing or
83 // not.
85 // CHECK: TAG_compile_unit
86 // CHECK-NOT: DW_TAG
87 // CHECK: AT_name{{.*}}"odr-uniquing.cpp"
89 // The union itself is not uniqued for now (for dsymutil-compatibility),
90 // but the types defined inside it should be.
91 // ODR: DW_TAG_union_type
92 // ODR-NEXT: DW_AT_name{{.*}}"U"
93 // ODR: DW_TAG_member
94 // ODR-NEXT: DW_AT_name{{.*}}"C"
95 // ODR-NOT: DW_TAG
96 // ODR: DW_AT_type{{.*}}[[UC]]
97 // ODR: DW_TAG_member
98 // ODR-NEXT: DW_AT_name{{.*}}"S"
99 // ODR-NOT: DW_TAG
100 // ODR: DW_AT_type{{.*}}[[US]]
102 // Check that the variables point to the right type
103 // ODR: DW_TAG_subprogram
104 // ODR-NOT: DW_TAG
105 // ODR: DW_AT_name{{.*}}"foo"
106 // ODR-NOT: NULL
107 // ODR: DW_TAG_variable
108 // ODR-NOT: DW_TAG
109 // ODR: DW_AT_name{{.*}}"s"
110 // ODR-NOT: DW_TAG
111 // ODR: DW_AT_type{{.*}}[[ALIASFORS]]
112 // ODR: DW_AT_name{{.*}}"n"
113 // ODR-NOT: DW_TAG
114 // ODR: DW_AT_type{{.*}}[[NESTED]]
115 // ODR: DW_TAG_variable
116 // ODR-NOT: DW_TAG
117 // ODR: DW_AT_name{{.*}}"nc"
118 // ODR-NOT: DW_TAG
119 // ODR: DW_AT_type{{.*}}[[NC]]
120 // ODR: DW_TAG_variable
121 // ODR-NOT: DW_TAG
122 // ODR: DW_AT_name{{.*}}"ac"
123 // ODR-NOT: DW_TAG
124 // ODR: DW_AT_type{{.*}}[[ANONC]]
126 // With no ODR uniquing, we should get copies of all the types:
128 // This is "struct S"
129 // NOODR: 0x[[DUP_S:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type
130 // NOODR-NEXT: DW_AT_name{{.*}}"S"
131 // NOODR-NOT: NULL
132 // NOODR: 0x[[DUP_NESTED:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type
133 // NOODR-NOT: DW_TAG
134 // NOODR: DW_AT_name{{.*}}"Nested"
136 // This is "class N::C"
137 // NOODR: DW_TAG_namespace
138 // NOODR-NEXT: DW_AT_name{{.*}}"N"
139 // NOODR: 0x[[DUP_NC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type
140 // NOODR-NEXT: DW_AT_name{{.*}}"C"
142 // This is "union U"
143 // NOODR: 0x[[DUP_U:[0-9a-f]*]]:{{.*}}DW_TAG_union_type
144 // NOODR-NEXT: DW_AT_name{{.*}}"U"
145 // NOODR-NOT: NULL
146 // NOODR: 0x[[DUP_UC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type
147 // NOODR-NOT: NULL
148 // NOODR: 0x[[DUP_US:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type
149 // NOODR: NULL
151 // Check that the variables point to the right type
152 // NOODR: DW_TAG_subprogram
153 // NOODR-NOT: DW_TAG
154 // NOODR: DW_AT_name{{.*}}"foo"
155 // NOODR-NOT: NULL
156 // NOODR: DW_TAG_variable
157 // NOODR-NOT: DW_TAG
158 // NOODR: DW_AT_name{{.*}}"s"
159 // NOODR-NOT: DW_TAG
160 // NOODR: DW_AT_type{{.*}}0x[[DUP_ALIASFORS:[0-9a-f]*]]
161 // NOODR: DW_TAG_variable
162 // NOODR-NOT: DW_TAG
163 // NOODR: DW_AT_name{{.*}}"n"
164 // NOODR-NOT: DW_TAG
165 // NOODR: DW_AT_type{{.*}}[[DUP_NESTED]]
166 // NOODR: DW_TAG_variable
167 // NOODR-NOT: DW_TAG
168 // NOODR: DW_AT_name{{.*}}"nc"
169 // NOODR-NOT: DW_TAG
170 // NOODR: DW_AT_type{{.*}}[[DUP_NC]]
171 // NOODR: DW_TAG_variable
172 // NOODR-NOT: DW_TAG
173 // NOODR: DW_AT_name{{.*}}"ac"
174 // NOODR-NOT: DW_TAG
175 // NOODR: DW_AT_type{{.*}}0x[[DUP_ANONC:[0-9a-f]*]]
177 // This is "AliasForS"
178 // NOODR: 0x[[DUP_ALIASFORS]]:{{.*}}DW_TAG_typedef
179 // NOODR-NOT: DW_TAG
180 // NOODR: DW_AT_name{{.*}}"AliasForS"
182 // This is "(anonymous namespace)::AnonC"
183 // NOODR: DW_TAG_namespace
184 // NOODR-NOT: {{DW_AT_name|NULL|DW_TAG}}
185 // NOODR: 0x[[DUP_ANONC]]:{{.*}}DW_TAG_class_type
186 // NOODR-NEXT: DW_AT_name{{.*}}"AnonC"