1 // RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple i386-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-32.layout
2 // RUN: FileCheck --input-file=%t-32.layout %s
9 extern id opaque_id(void);
13 __block int byref_int = 0;
18 const id bar = (id) opaque_id();
20 __strong id strong_void_sta;
21 __block id byref_bab = (id)0;
25 // The patterns here are a sequence of bytes, each saying first how
26 // many sizeof(void*) chunks to skip (high nibble) and then how many
27 // to scan (low nibble). A zero byte says that we've reached the end
30 // All of these patterns start with 01 3x because the block header on
31 // LP64 consists of an isa pointer (which we're supposed to scan for
32 // some reason) followed by three words (2 ints, a function pointer,
33 // and a descriptor pointer).
36 // CHECK: Inline block variable layout: 0x0320, BL_STRONG:3, BL_BYREF:2, BL_OPERATOR:0
38 byref_int = sh + ch+ch1+ch2 ;
41 x((id)strong_void_sta);
47 // CHECK: Inline block variable layout: 0x0331, BL_STRONG:3, BL_BYREF:3, BL_WEAK:1, BL_OPERATOR:0
49 byref_int = sh + ch+ch1+ch2 ;
52 x((id)strong_void_sta);
59 @class NSString, NSNumber;
64 __weak id weak_delegate;
68 // CHECK: Inline block variable layout: 0x0401, BL_STRONG:4, BL_WEAK:1, BL_OPERATOR:0
80 // Test 5 (unions/structs and their nesting):
84 __unsafe_unretained id o1;
87 __unsafe_unretained id o2;
92 __unsafe_unretained id o1;
94 __unsafe_unretained id o3;
100 __unsafe_unretained id o1;
102 __unsafe_unretained id o3;
110 block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINE:1, BL_NON_OBJECT_WORD:1,
111 BL_UNRETAINE:1, BL_NON_OBJECT_WORD:3, BL_BYREF:1, BL_OPERATOR:0
113 // CHECK: Block variable layout: BL_BYREF:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0
122 // Test for array of stuff.
125 __unsafe_unretained id unsafe_unretained_var[4];
128 // CHECK: Block variable layout: BL_UNRETAINED:4, BL_OPERATOR:0
130 x(imported_s.unsafe_unretained_var[2]);
136 // Test2 for array of stuff.
140 __unsafe_unretained id unsafe_unretained_var[4];
143 // CHECK: Block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINED:4, BL_OPERATOR:0
145 x(imported_s.unsafe_unretained_var[2]);
151 // Test3 for array of stuff.
155 __unsafe_unretained id unsafe_unretained_var[0];
158 // CHECK: Block variable layout: BL_OPERATOR:0
160 int i = imported_s.a;
167 // Test4 for array of stuff.
172 __unsafe_unretained id s_f0;
173 __unsafe_unretained id s_f1;
176 __unsafe_unretained id f1;
180 __unsafe_unretained B *f1;
184 // CHECK: Block variable layout: BL_UNRETAINED:3, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0
186 id i = captured_s.f0.s_f1;
192 // Test1 bitfield in cpatured aggregate.
202 // CHECK: Block variable layout: BL_OPERATOR:0
209 // Test2 bitfield in cpatured aggregate.
215 // CHECK: Block variable layout: BL_OPERATOR:0
222 // Test3 bitfield in cpatured aggregate.
226 unsigned short _reserved : 16;
228 unsigned char _draggedNodesAreDeletable: 1;
229 unsigned char _draggedOutsideOutlineView : 1;
230 unsigned char _adapterRespondsTo_addRootPaths : 1;
231 unsigned char _adapterRespondsTo_moveDataNodes : 1;
232 unsigned char _adapterRespondsTo_removeRootDataNode : 1;
233 unsigned char _adapterRespondsTo_doubleClickDataNode : 1;
234 unsigned char _adapterRespondsTo_selectDataNode : 1;
235 unsigned char _adapterRespondsTo_textDidEndEditing : 1;
236 unsigned char _adapterRespondsTo_updateAndSaveRoots : 1;
237 unsigned char _adapterRespondsTo_askToDeleteRootNodes : 1;
238 unsigned char _adapterRespondsTo_contextMenuForSelectedNodes : 1;
239 unsigned char _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
240 unsigned char _adapterRespondsTo_writeItemsToPasteboard : 1;
241 unsigned char _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
243 unsigned int _filler : 32;
246 // CHECK: Block variable layout: BL_OPERATOR:0
247 unsigned char (^c)(void) = ^{
248 return _flags._draggedNodesAreDeletable;
254 // Test4 unnamed bitfield
258 unsigned short _reserved : 16;
260 unsigned char _draggedNodesAreDeletable: 1;
261 unsigned char _draggedOutsideOutlineView : 1;
262 unsigned char _adapterRespondsTo_addRootPaths : 1;
263 unsigned char _adapterRespondsTo_moveDataNodes : 1;
264 unsigned char _adapterRespondsTo_removeRootDataNode : 1;
265 unsigned char _adapterRespondsTo_doubleClickDataNode : 1;
266 unsigned char _adapterRespondsTo_selectDataNode : 1;
267 unsigned char _adapterRespondsTo_textDidEndEditing : 1;
269 unsigned long long : 64;
271 unsigned char _adapterRespondsTo_updateAndSaveRoots : 1;
272 unsigned char _adapterRespondsTo_askToDeleteRootNodes : 1;
273 unsigned char _adapterRespondsTo_contextMenuForSelectedNodes : 1;
274 unsigned char _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
275 unsigned char _adapterRespondsTo_writeItemsToPasteboard : 1;
276 unsigned char _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
278 unsigned int _filler : 32;
281 // CHECK: Block variable layout: BL_OPERATOR:0
282 unsigned char (^c)(void) = ^{
283 return _flags._draggedNodesAreDeletable;
291 // Test5 unnamed bitfield.
294 unsigned char flag : 1;
296 unsigned char flag1 : 1;
299 // CHECK: Block variable layout: BL_OPERATOR:0
300 unsigned char (^c)(void) = ^{
308 // Test6 0 length bitfield.
311 unsigned char flag : 1;
313 unsigned char flag1 : 1;
316 // CHECK: Block variable layout: BL_OPERATOR:0
317 unsigned char (^c)(void) = ^{
324 // Test7 large number of captured variables.
327 __weak id wid1, wid2, wid3, wid4;
328 __weak id wid5, wid6, wid7, wid8;
329 __weak id wid9, wid10, wid11, wid12;
330 __weak id wid13, wid14, wid15, wid16;
331 const id bar = (id) opaque_id();
332 // CHECK: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_OPERATOR:0
355 // Test 8 very large number of captured variables.
358 __weak id wid1, wid2, wid3, wid4;
359 __weak id wid5, wid6, wid7, wid8;
360 __weak id wid9, wid10, wid11, wid12;
361 __weak id wid13, wid14, wid15, wid16;
362 __weak id w1, w2, w3, w4;
363 __weak id w5, w6, w7, w8;
364 __weak id w9, w10, w11, w12;
365 __weak id w13, w14, w15, w16;
366 const id bar = (id) opaque_id();
367 // CHECK: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_WEAK:16, BL_WEAK:1, BL_OPERATOR:0