Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -x c -debug-info-kind=limited -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
      2 
      3 // CHECK: %struct.layout0 = type { i8, %struct.size8, i8 }
      4 // CHECK: %struct.layout1 = type <{ i8, %struct.size8_anon, i8, [2 x i8] }>
      5 // CHECK: %struct.layout2 = type <{ i8, %struct.size8_pack1, i8 }>
      6 // CHECK: %struct.layout3 = type <{ i8, [3 x i8], %struct.size8_pack4, i8, [3 x i8] }>
      7 
      8 // ---------------------------------------------------------------------
      9 // Not packed.
     10 // ---------------------------------------------------------------------
     11 struct size8 {
     12   int i : 4;
     13   long long l : 60;
     14 };
     15 struct layout0 {
     16   char l0_ofs0;
     17   struct size8 l0_ofs8;
     18   int l0_ofs16 : 1;
     19 };
     20 // CHECK: l0_ofs0
     21 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs8",
     22 // CHECK-SAME:     {{.*}}size: 64, align: 64, offset: 64)
     23 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs16",
     24 // CHECK-SAME:     {{.*}}size: 1, align: 32, offset: 128, flags: DIFlagBitField, extraData: i64 128)
     25 
     26 
     27 // ---------------------------------------------------------------------
     28 // Implicitly packed.
     29 // ---------------------------------------------------------------------
     30 struct size8_anon {
     31   int : 4;
     32   long long : 60;
     33 };
     34 struct layout1 {
     35   char l1_ofs0;
     36   struct size8_anon l1_ofs1;
     37   int l1_ofs9 : 1;
     38 };
     39 // CHECK: l1_ofs0
     40 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs1",
     41 // CHECK-SAME:     {{.*}}size: 64, align: 8, offset: 8)
     42 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs9",
     43 // CHECK-SAME:     {{.*}}size: 1, align: 32, offset: 72, flags: DIFlagBitField, extraData: i64 72)
     44 
     45 
     46 // ---------------------------------------------------------------------
     47 // Explicitly packed.
     48 // ---------------------------------------------------------------------
     49 #pragma pack(1)
     50 struct size8_pack1 {
     51   int i : 4;
     52   long long l : 60;
     53 };
     54 struct layout2 {
     55   char l2_ofs0;
     56   struct size8_pack1 l2_ofs1;
     57   int l2_ofs9 : 1;
     58 };
     59 #pragma pack()
     60 // CHECK: l2_ofs0
     61 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1",
     62 // CHECK-SAME:     {{.*}}size: 64, align: 8, offset: 8)
     63 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9",
     64 // CHECK-SAME:     {{.*}}size: 1, align: 32, offset: 72, flags: DIFlagBitField, extraData: i64 72)
     65 
     66 
     67 
     68 // ---------------------------------------------------------------------
     69 // Explicitly packed with different alignment.
     70 // ---------------------------------------------------------------------
     71 #pragma pack(4)
     72 struct size8_pack4 {
     73   int i : 4;
     74   long long l : 60;
     75 };
     76 struct layout3 {
     77   char l3_ofs0;
     78   struct size8_pack4 l3_ofs4;
     79   int l3_ofs12 : 1;
     80 };
     81 #pragma pack()
     82 // CHECK: l3_ofs0
     83 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4",
     84 // CHECK-SAME:     {{.*}}size: 64, align: 32, offset: 32)
     85 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12",
     86 // CHECK-SAME:     {{.*}}size: 1, align: 32, offset: 96, flags: DIFlagBitField, extraData: i64 96)
     87 
     88 struct layout0 l0;
     89 struct layout1 l1;
     90 struct layout2 l2;
     91 struct layout3 l3;
     92