diff options
author | Adrian Prantl <aprantl@apple.com> | 2015-06-26 21:25:18 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2015-06-26 21:25:18 +0000 |
commit | 6192878379bf04121739d4764123776100b9e292 (patch) | |
tree | 5c49a44bb1f52dc75b3efcfe4b4dacd719b1b2e3 | |
parent | 7a260a8081ed55841ac9bd1c7482aead8835b160 (diff) | |
download | clang-6192878379bf04121739d4764123776100b9e292.tar.gz |
Add a testcase for bitfield debug info.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240833 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/CodeGen/debug-info-packed-struct.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/test/CodeGen/debug-info-packed-struct.c b/test/CodeGen/debug-info-packed-struct.c new file mode 100644 index 0000000000..0b5226bf11 --- /dev/null +++ b/test/CodeGen/debug-info-packed-struct.c @@ -0,0 +1,91 @@ +// RUN: %clang_cc1 -x c -g -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s + +// CHECK: %struct.layout0 = type { i8, %struct.size8, i8 } +// CHECK: %struct.layout1 = type <{ i8, %struct.size8_anon, i8, [2 x i8] }> +// CHECK: %struct.layout2 = type <{ i8, %struct.size8_pack1, i8 }> +// CHECK: %struct.layout3 = type <{ i8, [3 x i8], %struct.size8_pack4, i8, [3 x i8] }> + +// --------------------------------------------------------------------- +// Not packed. +// --------------------------------------------------------------------- +struct size8 { + int i : 4; + long long l : 60; +}; +struct layout0 { + char l0_ofs0; + struct size8 l0_ofs8; + int l0_ofs16 : 1; +}; +// CHECK: l0_ofs0 +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs8", +// CHECK-SAME: {{.*}}size: 64, align: 64, offset: 64) +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs16", +// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 128) + + +// --------------------------------------------------------------------- +// Implicitly packed. +// --------------------------------------------------------------------- +struct size8_anon { + int : 4; + long long : 60; +}; +struct layout1 { + char l1_ofs0; + struct size8_anon l1_ofs1; + int l1_ofs9 : 1; +}; +// CHECK: l1_ofs0 +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs1", +// CHECK-SAME: {{.*}}size: 64, align: 8, offset: 8) +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs9", +// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 72) + + +// --------------------------------------------------------------------- +// Explicitly packed. +// --------------------------------------------------------------------- +#pragma pack(1) +struct size8_pack1 { + int i : 4; + long long l : 60; +}; +struct layout2 { + char l2_ofs0; + struct size8_pack1 l2_ofs1; + int l2_ofs9 : 1; +}; +#pragma pack() +// CHECK: l2_ofs0 +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1", +// CHECK-SAME: {{.*}}size: 64, align: 8, offset: 8) +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9", +// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 72) + + + +// --------------------------------------------------------------------- +// Explicitly packed with different alignment. +// --------------------------------------------------------------------- +#pragma pack(4) +struct size8_pack4 { + int i : 4; + long long l : 60; +}; +struct layout3 { + char l3_ofs0; + struct size8_pack4 l3_ofs4; + int l3_ofs12 : 1; +}; +#pragma pack() +// CHECK: l3_ofs0 +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4", +// CHECK-SAME: {{.*}}size: 64, align: 32, offset: 32) +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12", +// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 96) + +struct layout0 l0; +struct layout1 l1; +struct layout2 l2; +struct layout3 l3; |