1 // RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout
2 // RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.layout %s
19 extern id opaque_id(void);
22 __block int byref_int = 0;
27 const id bar = (id) opaque_id();
29 __strong void *strong_void_sta;
30 __block id byref_bab = (id)0;
31 __block void *bl_var1;
34 // The patterns here are a sequence of bytes, each saying first how
35 // many sizeof(void*) chunks to skip (high nibble) and then how many
36 // to scan (low nibble). A zero byte says that we've reached the end
39 // All of these patterns start with 01 3x because the block header on
40 // LP64 consists of an isa pointer (which we're supposed to scan for
41 // some reason) followed by three words (2 ints, a function pointer,
42 // and a descriptor pointer).
44 // FIXME: do these really have to be named L_OBJC_CLASS_NAME_xxx?
45 // FIXME: sequences should never end in x0 00 instead of just 00
48 // byref int, short, char, char, char, id, id, strong void*, byref id
49 // CHECK-LP64: block variable layout for block: 0x01, 0x35, 0x10, 0x00
51 byref_int = sh + ch+ch1+ch2 ;
54 x((id)strong_void_sta);
60 // byref int, short, char, char, char, id, id, strong void*, byref void*, byref id
62 // CHECK-LP64: block variable layout for block: 0x01, 0x36, 0x10, 0x00
64 byref_int = sh + ch+ch1+ch2 ;
67 x((id)strong_void_sta);
75 // byref int, short, char, char, char, id, id, byref void*, int, double, byref id
77 // FIXME: we'd get a better format here if we sorted by scannability, not just alignment
78 // CHECK-LP64: block variable layout for block: 0x01, 0x35, 0x30, 0x00
80 byref_int = sh + ch+ch1+ch2 ;
91 // struct S (int, id, int, id, int, id)
93 // CHECK-LP64: block variable layout for block: 0x01, 0x41, 0x11, 0x11, 0x00
101 // Test 5 (unions/structs and their nesting):
129 // struct s2 (int, id, int, id, int, id?), union u2 (id?)
131 // CHECK-LP64: block variable layout for block: 0x01, 0x41, 0x11, 0x12, 0x00
140 void notifyBlock(id dependentBlock) {
141 id singleObservationToken;
145 // id, id, void(^)(void)
147 // CHECK-LP64: block variable layout for block: 0x01, 0x33, 0x00
148 void (^wrapperBlock)(void) = ^(void) {
149 CFRelease(singleObservationToken);
150 CFRelease(singleObservationToken);
152 CFRelease(singleObservationToken);
158 void test_empty_block(void) {
160 // CHECK-LP64: block variable layout for block: 0x01, 0x30, 0x00
161 void (^wrapperBlock)(void) = ^(void) {
166 typedef union { char ch[8]; } SS;
167 typedef struct { SS s[4]; } CS;
168 void test_union_in_layout(void) {