Adds test that checks whether LLDB correctly infers the alignment of packed structures. Specifically, the `InferAlignment` code-path of the `ItaniumRecordLayoutBuilder` where it assumes that overlapping field offsets imply a packed structure and thus sets alignment to `1`. See discussion in https://github.com/llvm/llvm-project/pull/93809. While here, also added a test-case where we check alignment of a class whose base has an explicit `DW_AT_alignment (those don't get transitively propagated in DWARF, but don't seem like a problem for LLDB). Lastly, also added an XFAIL-ed tests where the aforementioned `InferAlignment` kicks in for overlapping fields (but in this case incorrectly since the structure isn't actually packed).
25 lines
595 B
C++
25 lines
595 B
C++
// XFAIL: *
|
|
|
|
// RUN: %clangxx_host -gdwarf -o %t %s
|
|
// RUN: %lldb %t \
|
|
// RUN: -o "expr alignof(OverlappingFields)" \
|
|
// RUN: -o "expr sizeof(OverlappingFields)" \
|
|
// RUN: -o exit | FileCheck %s
|
|
|
|
// CHECK: (lldb) expr alignof(OverlappingFields)
|
|
// CHECK-NEXT: ${{.*}} = 4
|
|
// CHECK: (lldb) expr sizeof(OverlappingFields)
|
|
// CHECK-NEXT: ${{.*}} = 8
|
|
|
|
struct Empty {};
|
|
|
|
struct OverlappingFields {
|
|
char y;
|
|
[[no_unique_address]] Empty e;
|
|
int z;
|
|
} g_overlapping_struct;
|
|
static_assert(alignof(OverlappingFields) == 4);
|
|
static_assert(sizeof(OverlappingFields) == 8);
|
|
|
|
int main() {}
|