Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ def test(self):
# Verify specified class alignments.
self.expect_expr("alignof(B2)", result_value="8")
self.expect_expr("alignof(EmptyClassAlign8)", result_value="8")
self.expect_expr("alignof(Derived)", result_value="8")
7 changes: 7 additions & 0 deletions lldb/test/API/lang/cpp/alignas_base_class/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ D d3g;
struct alignas(8) EmptyClassAlign8 {
} t;

struct alignas(8) __attribute__((packed)) AlignedAndPackedBase {
} foo;

struct Derived : AlignedAndPackedBase {
} bar;
static_assert(alignof(Derived) == 8);

int main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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() {}
35 changes: 35 additions & 0 deletions lldb/test/Shell/SymbolFile/DWARF/packed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// RUN: %clangxx_host -gdwarf -o %t %s
// RUN: %lldb %t \
// RUN: -o "expr alignof(packed)" \
// RUN: -o "expr sizeof(packed)" \
// RUN: -o "expr alignof(packed_and_aligned)" \
// RUN: -o "expr sizeof(packed_and_aligned)" \
// RUN: -o exit | FileCheck %s

// CHECK: (lldb) expr alignof(packed)
// CHECK-NEXT: ${{.*}} = 1
// CHECK: (lldb) expr sizeof(packed)
// CHECK-NEXT: ${{.*}} = 9

// CHECK: (lldb) expr alignof(packed_and_aligned)
// CHECK-NEXT: ${{.*}} = 16
// CHECK: (lldb) expr sizeof(packed_and_aligned)
// CHECK-NEXT: ${{.*}} = 16

struct __attribute__((packed)) packed {
int x;
char y;
int z;
} g_packed_struct;
static_assert(alignof(packed) == 1);
static_assert(sizeof(packed) == 9);

struct __attribute__((packed, aligned(16))) packed_and_aligned {
int x;
char y;
int z;
} g_packed_and_aligned_struct;
static_assert(alignof(packed_and_aligned) == 16);
static_assert(sizeof(packed_and_aligned) == 16);

int main() {}