[Lldb-commits] [lldb] da69449 - [lldb][test] Add test for no_unique_address when mixed with bitfields (#108155)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 11 03:36:31 PDT 2024
Author: Michael Buch
Date: 2024-09-11T11:36:27+01:00
New Revision: da6944912baffa430468078c38f65d55fb83dd43
URL: https://github.com/llvm/llvm-project/commit/da6944912baffa430468078c38f65d55fb83dd43
DIFF: https://github.com/llvm/llvm-project/commit/da6944912baffa430468078c38f65d55fb83dd43.diff
LOG: [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 https://github.com/llvm/llvm-project/pull/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.
Added:
lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp
Modified:
Removed:
################################################################################
diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp
new file mode 100644
index 00000000000000..1c9cc36a711b47
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp
@@ -0,0 +1,28 @@
+// LLDB currently erroneously adds an unnamed bitfield
+// into the AST when an overlapping no_unique_address
+// field precedes a bitfield.
+
+// RUN: %clang --target=x86_64-apple-macosx -c -gdwarf -o %t %s
+// RUN: %lldb %t \
+// RUN: -o "target var global" \
+// RUN: -o "image dump ast" \
+// RUN: -o exit | FileCheck %s
+
+// CHECK: (lldb) image dump ast
+// CHECK: CXXRecordDecl {{.*}} struct Foo definition
+// CHECK: |-FieldDecl {{.*}} data 'char[5]'
+// CHECK-NEXT: |-FieldDecl {{.*}} padding 'Empty'
+// CHECK-NEXT: |-FieldDecl {{.*}} 'int'
+// CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 8
+// CHECK-NEXT: `-FieldDecl {{.*}} sloc> flag 'unsigned long'
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+
+struct Empty {};
+
+struct Foo {
+ char data[5];
+ [[no_unique_address]] Empty padding;
+ unsigned long flag : 1;
+};
+
+Foo global;
More information about the lldb-commits
mailing list