https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/108155
>From ab898a3e176d0366fc15f6aad4b627d6e999753d Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Wed, 11 Sep 2024 01:15:21 +0100 Subject: [PATCH 1/4] [lldb][test] Add test for no_unique_address when mixed with bitfields 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. --- .../no_unique_address-with-bitfields.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp 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; >From 3a8a1ecf16267d1304b1491803412702f258ce4c Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Wed, 11 Sep 2024 08:44:59 +0100 Subject: [PATCH 2/4] fixup! fix typo; don't link --- .../SymbolFile/DWARF/no_unique_address-with-bitfields.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 950bd9585baa22..b26da25ac5d2fe 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp @@ -1,10 +1,10 @@ // LLDB currently erroneously adds an unnamed bitfield -// into the AST when a overlapping no_unique_address +// into the AST when an overlapping no_unique_address // field precedes a bitfield. // XFAIL: * -// RUN: %clangxx_host -gdwarf -o %t %s +// RUN: %clangxx_host -c -gdwarf -o %t %s // RUN: %lldb %t \ // RUN: -o "target var global" \ // RUN: -o "image dump ast" \ >From 2749ad639b9f1bcb75e41e44ee3e07e0f5d0848e Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Wed, 11 Sep 2024 08:46:35 +0100 Subject: [PATCH 3/4] fixup! fix AST expectation; no need for the XFAIL --- .../SymbolFile/DWARF/no_unique_address-with-bitfields.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 index b26da25ac5d2fe..4877a69006a8e9 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp @@ -2,8 +2,6 @@ // into the AST when an overlapping no_unique_address // field precedes a bitfield. -// XFAIL: * - // RUN: %clangxx_host -c -gdwarf -o %t %s // RUN: %lldb %t \ // RUN: -o "target var global" \ @@ -11,12 +9,12 @@ // RUN: -o exit | FileCheck %s // CHECK: (lldb) image dump ast -// CHECK-NEXT: CXXRecordDecl {{.*}} struct Foo definition +// 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> mem 'unsigned long' +// CHECK-NEXT: `-FieldDecl {{.*}} sloc> flag 'unsigned long' // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1 struct Empty {}; >From 735f59516c01e1b9af855d1d8121bd8b7e9a765a Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Wed, 11 Sep 2024 09:37:45 +0100 Subject: [PATCH 4/4] fixup! added triple --- .../Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 4877a69006a8e9..1c9cc36a711b47 100644 --- a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp +++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-with-bitfields.cpp @@ -2,7 +2,7 @@ // into the AST when an overlapping no_unique_address // field precedes a bitfield. -// RUN: %clangxx_host -c -gdwarf -o %t %s +// 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" \ _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits