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