Skip to content

Commit da69449

Browse files
authored
[lldb][test] Add test for no_unique_address when mixed with bitfields (#108155)
This is the root-cause for the LLDB failures that started occurring after #105865. The DWARFASTParserClang has logic to try derive unnamed bitfields from DWARF offsets. In this case we treat `padding` as a 1-byte size field that would overlap with `flag`, and decide we need to introduce an unnamed bitfield into the AST, which is incorrect.
1 parent e1ee07d commit da69449

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// LLDB currently erroneously adds an unnamed bitfield
2+
// into the AST when an overlapping no_unique_address
3+
// field precedes a bitfield.
4+
5+
// RUN: %clang --target=x86_64-apple-macosx -c -gdwarf -o %t %s
6+
// RUN: %lldb %t \
7+
// RUN: -o "target var global" \
8+
// RUN: -o "image dump ast" \
9+
// RUN: -o exit | FileCheck %s
10+
11+
// CHECK: (lldb) image dump ast
12+
// CHECK: CXXRecordDecl {{.*}} struct Foo definition
13+
// CHECK: |-FieldDecl {{.*}} data 'char[5]'
14+
// CHECK-NEXT: |-FieldDecl {{.*}} padding 'Empty'
15+
// CHECK-NEXT: |-FieldDecl {{.*}} 'int'
16+
// CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 8
17+
// CHECK-NEXT: `-FieldDecl {{.*}} sloc> flag 'unsigned long'
18+
// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
19+
20+
struct Empty {};
21+
22+
struct Foo {
23+
char data[5];
24+
[[no_unique_address]] Empty padding;
25+
unsigned long flag : 1;
26+
};
27+
28+
Foo global;

0 commit comments

Comments
 (0)