71 lines · c
1// RUN: %clang_cc1 %s -emit-llvm -o /dev/null -triple=i686-apple-darwin9 -fdump-record-layouts-simple | FileCheck %s2 3// Test struct layout for x86-darwin target4 5struct STest1 {int x; short y[4]; double z; } st1;6struct STest2 {short a,b; int c,d; } st2;7struct STest3 {char a; short b; int c; } st3;8 9// Bitfields10struct STestB1 {char a; char b:2; } stb1;11struct STestB2 {char a; char b:5; char c:4; } stb2;12struct STestB3 {char a; char b:2; } stb3;13struct STestB4 {char a; short b:2; char c; } stb4;14struct STestB5 {char a; short b:10; char c; } stb5;15struct STestB6 {int a:1; char b; int c:13; } stb6;16 17// Packed struct STestP1 {char a; short b; int c; } __attribute__((__packed__)) stp1;18 19// CHECK-LABEL: LLVMType:%struct.STest1 =20// CHECK-SAME: type { i32, [4 x i16], double }21// CHECK: BitFields:[22// CHECK-NEXT: ]>23 24// CHECK-LABEL: LLVMType:%struct.STest2 =25// CHECK-SAME: type { i16, i16, i32, i32 }26// CHECK: BitFields:[27// CHECK-NEXT: ]>28 29// CHECK-LABEL: LLVMType:%struct.STest3 =30// CHECK-SAME: type { i8, i16, i32 }31// CHECK: BitFields:[32// CHECK-NEXT: ]>33 34// CHECK-LABEL: LLVMType:%struct.STestB1 =35// CHECK-SAME: type { i8, i8 }36// CHECK: BitFields:[37// CHECK-NEXT: <CGBitFieldInfo Offset:0 Size:2 IsSigned:1 StorageSize:8 StorageOffset:138// CHECK-NEXT: ]>39 40// CHECK-LABEL: LLVMType:%struct.STestB2 =41// CHECK-SAME: type <{ i8, i16 }>42// CHECK: BitFields:[43// CHECK-NEXT: <CGBitFieldInfo Offset:0 Size:5 IsSigned:1 StorageSize:16 StorageOffset:144// CHECK-NEXT: <CGBitFieldInfo Offset:8 Size:4 IsSigned:1 StorageSize:16 StorageOffset:145// CHECK-NEXT: ]>46 47// CHECK-LABEL: LLVMType:%struct.STestB3 =48// CHECK-SAME: type { i8, i8 }49// CHECK: BitFields:[50// CHECK-NEXT: <CGBitFieldInfo Offset:0 Size:2 IsSigned:1 StorageSize:8 StorageOffset:151// CHECK-NEXT: ]>52 53// CHECK-LABEL: LLVMType:%struct.STestB4 =54// CHECK-SAME: type { i8, i8, i8, i8 }55// CHECK: BitFields:[56// CHECK-NEXT: <CGBitFieldInfo Offset:0 Size:2 IsSigned:1 StorageSize:8 StorageOffset:157// CHECK-NEXT: ]>58 59// CHECK-LABEL: LLVMType:%struct.STestB5 =60// CHECK-SAME: type { i8, i16, i8 }61// CHECK: BitFields:[62// CHECK-NEXT: <CGBitFieldInfo Offset:0 Size:10 IsSigned:1 StorageSize:16 StorageOffset:263// CHECK-NEXT: ]>64 65// CHECK-LABEL: LLVMType:%struct.STestB6 =66// CHECK-SAME: type { i8, i8, i16 }67// CHECK: BitFields:[68// CHECK-NEXT: <CGBitFieldInfo Offset:0 Size:1 IsSigned:1 StorageSize:8 StorageOffset:069// CHECK-NEXT: <CGBitFieldInfo Offset:0 Size:13 IsSigned:1 StorageSize:16 StorageOffset:270// CHECK-NEXT: ]>71