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
7 extern id opaque_id(void);
11 __block int byref_int = 0;
16 const id bar = (id) opaque_id();
18 __strong id strong_void_sta;
19 __block id byref_bab = (id)0;
23 // The patterns here are a sequence of bytes, each saying first how
24 // many sizeof(void*) chunks to skip (high nibble) and then how many
25 // to scan (low nibble). A zero byte says that we've reached the end
28 // All of these patterns start with 01 3x because the block header on
29 // LP64 consists of an isa pointer (which we're supposed to scan for
30 // some reason) followed by three words (2 ints, a function pointer,
31 // and a descriptor pointer).
34 // CHECK: Inline block variable layout: 0x0320, BL_STRONG:3, BL_BYREF:2, BL_OPERATOR:0
36 byref_int = sh + ch+ch1+ch2 ;
39 x((id)strong_void_sta);
45 // CHECK: Inline block variable layout: 0x0331, BL_STRONG:3, BL_BYREF:3, BL_WEAK:1, BL_OPERATOR:0
47 byref_int = sh + ch+ch1+ch2 ;
50 x((id)strong_void_sta);
57 @class NSString, NSNumber;
62 __weak id weak_delegate;
66 // CHECK: Inline block variable layout: 0x0401, BL_STRONG:4, BL_WEAK:1, BL_OPERATOR:0
78 // Test 5 (unions/structs and their nesting):
82 __unsafe_unretained id o1;
85 __unsafe_unretained id o2;
90 __unsafe_unretained id o1;
92 __unsafe_unretained id o3;
98 __unsafe_unretained id o1;
100 __unsafe_unretained id o3;
108 block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINE:1, BL_NON_OBJECT_WORD:1,
109 BL_UNRETAINE:1, BL_NON_OBJECT_WORD:3, BL_BYREF:1, BL_OPERATOR:0
111 // 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
120 // Test for array of stuff.
123 __unsafe_unretained id unsafe_unretained_var[4];
126 // CHECK: Block variable layout: BL_UNRETAINED:4, BL_OPERATOR:0
128 x(imported_s.unsafe_unretained_var[2]);
134 // Test2 for array of stuff.
138 __unsafe_unretained id unsafe_unretained_var[4];
141 // CHECK: Block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINED:4, BL_OPERATOR:0
143 x(imported_s.unsafe_unretained_var[2]);
149 // Test3 for array of stuff.
153 __unsafe_unretained id unsafe_unretained_var[0];
156 // CHECK: Block variable layout: BL_OPERATOR:0
158 int i = imported_s.a;
165 // Test4 for array of stuff.
170 __unsafe_unretained id s_f0;
171 __unsafe_unretained id s_f1;
174 __unsafe_unretained id f1;
178 __unsafe_unretained B *f1;
182 // 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
184 id i = captured_s.f0.s_f1;
190 // Test1 bitfield in cpatured aggregate.
200 // CHECK: Block variable layout: BL_OPERATOR:0
207 // Test2 bitfield in cpatured aggregate.
213 // CHECK: Block variable layout: BL_OPERATOR:0
220 // Test3 bitfield in cpatured aggregate.
224 unsigned short _reserved : 16;
226 unsigned char _draggedNodesAreDeletable: 1;
227 unsigned char _draggedOutsideOutlineView : 1;
228 unsigned char _adapterRespondsTo_addRootPaths : 1;
229 unsigned char _adapterRespondsTo_moveDataNodes : 1;
230 unsigned char _adapterRespondsTo_removeRootDataNode : 1;
231 unsigned char _adapterRespondsTo_doubleClickDataNode : 1;
232 unsigned char _adapterRespondsTo_selectDataNode : 1;
233 unsigned char _adapterRespondsTo_textDidEndEditing : 1;
234 unsigned char _adapterRespondsTo_updateAndSaveRoots : 1;
235 unsigned char _adapterRespondsTo_askToDeleteRootNodes : 1;
236 unsigned char _adapterRespondsTo_contextMenuForSelectedNodes : 1;
237 unsigned char _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
238 unsigned char _adapterRespondsTo_writeItemsToPasteboard : 1;
239 unsigned char _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
241 unsigned int _filler : 32;
244 // CHECK: Block variable layout: BL_OPERATOR:0
245 unsigned char (^c)(void) = ^{
246 return _flags._draggedNodesAreDeletable;
252 // Test4 unnamed bitfield
256 unsigned short _reserved : 16;
258 unsigned char _draggedNodesAreDeletable: 1;
259 unsigned char _draggedOutsideOutlineView : 1;
260 unsigned char _adapterRespondsTo_addRootPaths : 1;
261 unsigned char _adapterRespondsTo_moveDataNodes : 1;
262 unsigned char _adapterRespondsTo_removeRootDataNode : 1;
263 unsigned char _adapterRespondsTo_doubleClickDataNode : 1;
264 unsigned char _adapterRespondsTo_selectDataNode : 1;
265 unsigned char _adapterRespondsTo_textDidEndEditing : 1;
267 unsigned long long : 64;
269 unsigned char _adapterRespondsTo_updateAndSaveRoots : 1;
270 unsigned char _adapterRespondsTo_askToDeleteRootNodes : 1;
271 unsigned char _adapterRespondsTo_contextMenuForSelectedNodes : 1;
272 unsigned char _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
273 unsigned char _adapterRespondsTo_writeItemsToPasteboard : 1;
274 unsigned char _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
276 unsigned int _filler : 32;
279 // CHECK: Block variable layout: BL_OPERATOR:0
280 unsigned char (^c)(void) = ^{
281 return _flags._draggedNodesAreDeletable;
289 // Test5 unnamed bitfield.
292 unsigned char flag : 1;
294 unsigned char flag1 : 1;
297 // CHECK: Block variable layout: BL_OPERATOR:0
298 unsigned char (^c)(void) = ^{
306 // Test6 0 length bitfield.
309 unsigned char flag : 1;
311 unsigned char flag1 : 1;
314 // CHECK: Block variable layout: BL_OPERATOR:0
315 unsigned char (^c)(void) = ^{
322 // Test7 large number of captured variables.
325 __weak id wid1, wid2, wid3, wid4;
326 __weak id wid5, wid6, wid7, wid8;
327 __weak id wid9, wid10, wid11, wid12;
328 __weak id wid13, wid14, wid15, wid16;
329 const id bar = (id) opaque_id();
330 // CHECK: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_OPERATOR:0
353 // Test 8 very large number of captured variables.
356 __weak id wid1, wid2, wid3, wid4;
357 __weak id wid5, wid6, wid7, wid8;
358 __weak id wid9, wid10, wid11, wid12;
359 __weak id wid13, wid14, wid15, wid16;
360 __weak id w1, w2, w3, w4;
361 __weak id w5, w6, w7, w8;
362 __weak id w9, w10, w11, w12;
363 __weak id w13, w14, w15, w16;
364 const id bar = (id) opaque_id();
365 // CHECK: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_WEAK:16, BL_WEAK:1, BL_OPERATOR:0