1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s 2 // RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s && 3 4 // RUN: grep '@"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t 5 // RUN: grep '@"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_ivar", align 8' %t 6 // RUN: grep '@"OBJC_IVAR_$_I4._iv4" = global i64 13, section "__DATA, __objc_ivar", align 8' %t 7 // RUN: grep '@"OBJC_IVAR_$_I5._iv5" = global i64 14, section "__DATA, __objc_ivar", align 8' %t 8 // RUN: grep '@"OBJC_IVAR_$_I5._iv6_synth" = hidden global i64 16, section "__DATA, __objc_ivar", align 8' %t 9 // RUN: grep '@"OBJC_IVAR_$_I5._iv7_synth" = hidden global i64 20, section "__DATA, __objc_ivar", align 8' %t 10 // RUN: grep '@"OBJC_IVAR_$_I6.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t 11 // RUN: grep '@"OBJC_IVAR_$_I8.b" = global i64 8, section "__DATA, __objc_ivar", align 8' %t 12 // RUN: grep '@"OBJC_IVAR_$_I9.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t 13 // RUN: grep '@"OBJC_IVAR_$_I10.iv1" = global i64 4, section "__DATA, __objc_ivar", align 8' %t 14 // RUN: grep '@"OBJC_IVAR_$_I12.iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t 15 // RUN: grep '_OBJC_CLASS_RO_$_I3" = internal global .* { i32 0, i32 8, i32 13, .*' %t 16 // RUN: grep '_OBJC_CLASS_RO_$_I4" = internal global .* { i32 0, i32 13, i32 14, .*' %t 17 // RUN: grep '_OBJC_CLASS_RO_$_I5" = internal global .* { i32 0, i32 14, i32 24, .*' %t 18 // RUN: grep '_OBJC_CLASS_RO_$_I6" = internal global .* { i32 2, i32 0, i32 1, .*' %t 19 // RUN: grep '_OBJC_CLASS_RO_$_I8" = internal global .* { i32 0, i32 8, i32 16, .*' %t 20 // RUN: grep '_OBJC_CLASS_RO_$_I9" = internal global .* { i32 2, i32 0, i32 4, .*' %t 21 // RUN: grep '_OBJC_CLASS_RO_$_I10" = internal global .* { i32 0, i32 4, i32 5, .*' %t 22 // RUN: grep '_OBJC_CLASS_RO_$_I11" = internal global .* { i32 0, i32 5, i32 5, .*' %t 23 // RUN: grep '_OBJC_CLASS_RO_$_I12" = internal global .* { i32 0, i32 8, i32 12, .*' %t 24 25 26 /* 27 Compare to: 28 gcc -m64 -S -o - interface-layout-64.m | grep '^_OBJC_IVAR_$_*.*' -A 1 29 and 30 gcc -m64 -S -o - interface-layout-64.m | grep '^l.*_CLASS_RO_$_I[0-9]*' -A 3 31 */ 32 33 struct s0 { 34 double x; 35 }; 36 37 @interface I2 { 38 struct s0 _iv1; 39 } 40 @end 41 42 @interface I3 : I2 { 43 unsigned int _iv2 :1; 44 unsigned : 0; 45 unsigned int _iv3 : 3; 46 } 47 @end 48 49 @interface I4 : I3 { 50 char _iv4; 51 } 52 @end 53 54 @interface I5 : I4 { 55 char _iv5; 56 } 57 58 @property int prop0; 59 @end 60 61 @implementation I3 62 @end 63 64 @implementation I4 65 @end 66 67 @interface I5 () 68 @property int prop1; 69 @property char prop2; 70 @end 71 72 @implementation I5 73 @synthesize prop0 = _iv6_synth; 74 @synthesize prop1 = _iv7_synth; 75 @synthesize prop2 = _iv5; 76 @end 77 78 // The size rounds up to the next available byte. 79 @interface I6 { 80 unsigned iv0 : 2; 81 } 82 @end 83 @implementation I6 84 @end 85 86 // The start of the subclass includes padding for its own alignment. 87 @interface I7 { 88 char a; 89 } 90 @end 91 @interface I8 : I7 { 92 double b; 93 } 94 @end 95 @implementation I8 96 @end 97 98 // Padding bit-fields 99 @interface I9 { 100 unsigned iv0 : 2; 101 unsigned : 0; 102 } 103 @end 104 @implementation I9 105 @end 106 @interface I10 : I9 { 107 unsigned iv1 : 2; 108 } 109 @end 110 @implementation I10 111 @end 112 113 // Empty structures 114 @interface I11 : I10 115 @end 116 @implementation I11 117 @end 118 @interface I12 : I11 { 119 unsigned iv2; 120 } 121 @end 122 @implementation I12 123 @end 124