| 1 |
// RUN: %clang_cc1 %s -emit-llvm -o /dev/null -triple=i686-apple-darwin9 -fdump-record-layouts-simple | FileCheck %s |
| 2 |
|
| 3 |
// Test struct layout for x86-darwin target |
| 4 |
|
| 5 |
struct STest1 {int x; short y[4]; double z; } st1; |
| 6 |
struct STest2 {short a,b; int c,d; } st2; |
| 7 |
struct STest3 {char a; short b; int c; } st3; |
| 8 |
|
| 9 |
// Bitfields |
| 10 |
struct STestB1 {char a; char b:2; } stb1; |
| 11 |
struct STestB2 {char a; char b:5; char c:4; } stb2; |
| 12 |
struct STestB3 {char a; char b:2; } stb3; |
| 13 |
struct STestB4 {char a; short b:2; char c; } stb4; |
| 14 |
struct STestB5 {char a; short b:10; char c; } stb5; |
| 15 |
struct 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:1 |
| 38 |
// 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:1 |
| 44 |
// CHECK-NEXT: <CGBitFieldInfo Offset:8 Size:4 IsSigned:1 StorageSize:16 StorageOffset:1 |
| 45 |
// 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:1 |
| 51 |
// 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:1 |
| 57 |
// 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:2 |
| 63 |
// 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:0 |
| 69 |
// CHECK-NEXT: <CGBitFieldInfo Offset:0 Size:13 IsSigned:1 StorageSize:16 StorageOffset:2 |
| 70 |
// CHECK-NEXT: ]> |