xref: /llvm-project/clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp (revision fae31e283203da9a4a3225e2d016e245d4887c2f)
1 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple aarch64 %s -o - | FileCheck %s
2 
3 struct S0 {
4   unsigned int x : 16;
5   unsigned int y : 16;
6 };
7 
8 // CHECK-LABEL: define dso_local void @_Z3fS0v
9 // CHECK:                        alloca %struct.S0, align 4
10 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S0, align 4
11 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S0_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 16),
12 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S0_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 16, 16),
13 //
fS0()14 void fS0() {
15   S0 s0;
16   auto [a, b] = s0;
17 }
18 
19 struct S1 {
20   volatile unsigned int x : 16;
21   volatile unsigned int y : 16;
22 };
23 
24 // CHECK-LABEL: define dso_local void @_Z3fS1v
25 // CHECK:                        alloca %struct.S1, align 4
26 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S1, align 4
27 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S1_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 16),
28 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S1_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 16, 16),
29 //
fS1()30 void fS1() {
31   S1 s1;
32   auto [a, b] = s1;
33 }
34 
35 struct S2 {
36   unsigned int x : 8;
37   unsigned int y : 8;
38 };
39 
40 // CHECK-LABEL: define dso_local void @_Z3fS2v
41 // CHECK:                        alloca %struct.S2, align 4
42 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S2, align 4
43 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S2_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 8),
44 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S2_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 8, 8),
45 //
fS2()46 void fS2() {
47   S2 s2;
48   auto [a, b] = s2;
49 }
50 
51 struct S3 {
52   volatile unsigned int x : 8;
53   volatile unsigned int y : 8;
54 };
55 
56 // CHECK-LABEL: define dso_local void @_Z3fS3v
57 // CHECK:                        alloca %struct.S3, align 4
58 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S3, align 4
59 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S3_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 8),
60 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S3_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 8, 8),
61 //
fS3()62 void fS3() {
63   S3 s3;
64   auto [a, b] = s3;
65 }
66 
67 struct S4 {
68   unsigned int x : 8;
69   unsigned int y : 16;
70 };
71 
72 // CHECK-LABEL: define dso_local void @_Z3fS4v
73 // CHECK:                        alloca %struct.S4, align 4
74 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S4, align 4
75 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S4_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 8),
76 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S4_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 8, 16),
77 //
fS4()78 void fS4() {
79   S4 s4;
80   auto [a, b] = s4;
81 }
82 
83 struct S5 {
84   volatile unsigned int x : 8;
85   volatile unsigned int y : 16;
86 };
87 
88 // CHECK-LABEL: define dso_local void @_Z3fS5v
89 // CHECK:                        alloca %struct.S5, align 4
90 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S5, align 4
91 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S5_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 8),
92 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S5_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 8, 16),
93 //
fS5()94 void fS5() {
95   S5 s5;
96   auto [a, b] = s5;
97 }
98 
99 struct S6 {
100   unsigned int x : 16;
101   unsigned int y : 8;
102 };
103 
104 // CHECK-LABEL: define dso_local void @_Z3fS6v
105 // CHECK:                        alloca %struct.S6, align 4
106 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S6, align 4
107 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S6_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 16),
108 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S6_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 16, 8),
109 //
fS6()110 void fS6() {
111   S6 s6;
112   auto [a, b] = s6;
113 }
114 
115 struct S7 {
116   volatile unsigned int x : 16;
117   volatile unsigned int y : 8;
118 };
119 
120 // CHECK-LABEL: define dso_local void @_Z3fS7v
121 // CHECK:                        alloca %struct.S7, align 4
122 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S7, align 4
123 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S7_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 16),
124 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S7_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 16, 8),
125 //
fS7()126 void fS7() {
127   S7 s7;
128   auto [a, b] = s7;
129 }
130 
131 struct S8 {
132   unsigned int x : 16;
133   volatile unsigned int y : 16;
134 };
135 
136 // CHECK-LABEL: define dso_local void @_Z3fS8v
137 // CHECK:                        alloca %struct.S8, align 4
138 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S8, align 4
139 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S8_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 16),
140 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S8_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 16, 16),
141 //
fS8()142 void fS8() {
143   S8 s8;
144   auto [a, b] = s8;
145 }
146 
147 struct S9 {
148   unsigned int x : 16;
149   unsigned int y : 32;
150 };
151 
152 // CHECK-LABEL: define dso_local void @_Z3fS9v
153 // CHECK:                        alloca %struct.S9, align 4
154 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S9, align 4
155 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S9_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 16),
156 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S9_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 32, 32),
157 //
fS9()158 void fS9() {
159   S9 s9;
160   auto [a, b] = s9;
161 }
162 
163 struct S10 {
164   const unsigned int x : 8;
165   const volatile unsigned int y : 8;
166 
167 // CHECK-LABEL: define dso_local void @_Z4fS10v
168 // CHECK:                        alloca %struct.S10, align 4
169 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S10, align 4
170 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S10_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 8),
171 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S10_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 8, 8),
172 //
S10S10173   S10() : x(0), y(0) {}
174 };
175 
fS10()176 void fS10() {
177   S10 s10;
178   auto [a, b] = s10;
179 }
180 
181 struct S11 {
182   unsigned int x : 15;
183   unsigned int y : 16;
184 };
185 
186 // CHECK-LABEL: define dso_local void @_Z4fS11v
187 // CHECK:                        alloca %struct.S11, align 4
188 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S11, align 4
189 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S11_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 15),
190 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S11_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 15, 16),
191 //
fS11()192 void fS11() {
193   S11 s11;
194   auto [a, b] = s11;
195 }
196 
197 struct S12 {
198   unsigned int x : 16;
199   unsigned int y : 17;
200 };
201 
202 // CHECK-LABEL: define dso_local void @_Z4fS12v
203 // CHECK:                        alloca %struct.S12, align 4
204 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S12, align 4
205 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S12_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 16),
206 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S12_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 32, 17),
207 //
fS12()208 void fS12() {
209   S12 s12;
210   auto [a, b] = s12;
211 }
212 
213 struct __attribute__((packed)) S13 {
214   unsigned int x : 15;
215   unsigned int y : 16;
216 };
217 
218 // CHECK-LABEL: define dso_local void @_Z4fS13v
219 // CHECK:                        alloca %struct.S13, align 1
220 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S13, align 1
221 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S13_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 0, 15),
222 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S13_B:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_zext, 15, 16),
223 //
fS13()224 void fS13() {
225   S13 s13;
226   auto [a, b] = s13;
227 }
228 
229 struct S14 {
230   signed int x;
231   signed int y : 7;
232 };
233 
234 // CHECK-LABEL: define dso_local void @_Z4fS14v
235 // CHECK:                        alloca %struct.S14, align 4
236 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S14, align 4
237 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S14_A:![0-9]+]], !DIExpression(),
238 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S14_B:![0-9]+]], !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_extract_bits_sext, 0, 7),
239 //
fS14()240 void fS14() {
241   S14 s14;
242   auto [a, b] = s14;
243 }
244 
245 struct S15 {
246   signed int x : 123;
247   unsigned int y : 987;
248 };
249 
250 // CHECK-LABEL: define dso_local void @_Z4fS15v
251 // CHECK:                        alloca %struct.S15, align 8
252 // CHECK-NEXT:    [[TMP0:%.*]] = alloca %struct.S15, align 8
253 // CHECK:         #dbg_declare(ptr [[TMP0]], [[S15_A:![0-9]+]], !DIExpression(DW_OP_LLVM_extract_bits_sext, 0, 32),
254 // CHECK-NEXT:    #dbg_declare(ptr [[TMP0]], [[S15_B:![0-9]+]], !DIExpression(DW_OP_plus_uconst, 16, DW_OP_LLVM_extract_bits_zext, 0, 32),
255 //
fS15()256 void fS15() {
257   S15 s15;
258   auto [a, b] = s15;
259 }
260 
261 // CHECK: [[UINT_TY:![0-9]+]] = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
262 // CHECK: [[S0_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
263 // CHECK: [[S0_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
264 
265 // CHECK: [[VOLATILE_UINT_TY:![0-9]+]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: [[UINT_TY]])
266 // CHECK: [[S1_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY:![0-9]+]])
267 // CHECK: [[S1_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY]])
268 
269 // CHECK: [[S2_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
270 // CHECK: [[S2_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
271 
272 // CHECK: [[S3_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY]])
273 // CHECK: [[S3_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY]])
274 
275 // CHECK: [[S4_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
276 // CHECK: [[S4_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
277 
278 // CHECK: [[S5_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY]])
279 // CHECK: [[S5_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY]])
280 
281 // CHECK: [[S6_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
282 // CHECK: [[S6_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
283 
284 // CHECK: [[S7_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY]])
285 // CHECK: [[S7_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY]])
286 
287 // CHECK: [[S8_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
288 // CHECK: [[S8_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UINT_TY]])
289 
290 // CHECK: [[S9_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
291 // CHECK: [[S9_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
292 
293 // CHECK: [[CONST_UINT_TY:![0-9]+]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: [[UINT_TY]])
294 // CHECK: [[CONST_VOLATILE_UINT_TY:![0-9]+]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: [[VOLATILE_UINT_TY]])
295 // CHECK: [[S10_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[CONST_UINT_TY]])
296 // CHECK: [[S10_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[CONST_VOLATILE_UINT_TY]])
297 
298 // S11
299 // CHECK: [[S11_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
300 // CHECK: [[S11_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
301 
302 // S12
303 // CHECK: [[S12_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
304 // CHECK: [[S12_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
305 
306 // S13
307 // CHECK: [[S13_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
308 // CHECK: [[S13_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
309 
310 // S14
311 // CHECK: [[SINT_TY:![0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
312 // CHECK: [[S14_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[SINT_TY]])
313 // CHECK: [[S14_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[SINT_TY]])
314 
315 // S15
316 // CHECK: [[S15_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[SINT_TY]])
317 // CHECK: [[S15_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
318