1// XFAIL: *
2//
3// RUN: %clangxx_host -gdwarf -o %t %s
4// RUN: %lldb %t \
5// RUN: -o "expr alignof(base)" \
6// RUN: -o "expr alignof(packed_base)" \
7// RUN: -o "expr alignof(derived)" \
8// RUN: -o "expr sizeof(derived)" \
9// RUN: -o exit | FileCheck %s
10
11struct __attribute__((packed)) packed {
12 int x;
13 char y;
14 int z;
15} g_packed_struct;
16
17// LLDB incorrectly calculates alignof(base)
18struct foo {};
19struct base : foo { int x; };
20static_assert(alignof(base) == 4);
21
22// CHECK: (lldb) expr alignof(base)
23// CHECK-NEXT: ${{.*}} = 4
24
25// LLDB incorrectly calculates alignof(packed_base)
26struct __attribute__((packed)) packed_base { int x; };
27static_assert(alignof(packed_base) == 1);
28
29// CHECK: (lldb) expr alignof(packed_base)
30// CHECK-NEXT: ${{.*}} = 1
31
32struct derived : packed, packed_base {
33 short s;
34} g_derived;
35static_assert(alignof(derived) == 2);
36static_assert(sizeof(derived) == 16);
37
38// CHECK: (lldb) expr alignof(derived)
39// CHECK-NEXT: ${{.*}} = 2
40// CHECK: (lldb) expr sizeof(derived)
41// CHECK-NEXT: ${{.*}} = 16
42
43int main() {}
44

source code of lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp