-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb][test] Add test for no_unique_address when mixed with bitfields #108155
Conversation
This is the root-cause for the LLDB failures that started occurring after llvm#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.
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) ChangesThis 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 Full diff: https://github.com/llvm/llvm-project/pull/108155.diff 1 Files Affected:
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..950bd9585baa22
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp
@@ -0,0 +1,30 @@
+// LLDB currently erroneously adds an unnamed bitfield
+// into the AST when a overlapping no_unique_address
+// field precedes a bitfield.
+
+// XFAIL: *
+
+// RUN: %clangxx_host -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-NEXT: 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> mem '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;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test will fail on windows because no_unique_address is not a thing there:
$ bin/clang++ -c --target=x86_64-pc-windows -gdwarf -o /tmp/a.out /tmp/a.cc
/tmp/a.cc:23:5: warning: unknown attribute 'no_unique_address' ignored [-Wunknown-attributes]
23 | [[no_unique_address]] Empty padding;
| ^~~~~~~~~~~~~~~~~
I suggest hardcoding the test with your favourite triple.
Seems like that we should spell it as |
Don't think we have coverage for the |
…llvm#108155) This is the root-cause for the LLDB failures that started occurring after llvm#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.
… into helper (llvm#108196) This logic will need adjusting soon for llvm#108155 This patch pulls out the logic for detecting/creating unnamed bitfields out of `ParseSingleMember` to make the latter (in my opinion) more readable. Otherwise we have a large number of similarly named variables in scope.
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 withflag
, and decide we need to introduce an unnamed bitfield into the AST, which is incorrect.