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
20 extern id opaque_id(void);
23 __block int byref_int = 0;
28 const id bar = (id) opaque_id();
30 __strong void *strong_void_sta;
31 __block id byref_bab = (id)0;
32 __block void *bl_var1;
35 // The patterns here are a sequence of bytes, each saying first how
36 // many sizeof(void*) chunks to skip (high nibble) and then how many
37 // to scan (low nibble). A zero byte says that we've reached the end
40 // All of these patterns start with 01 3x because the block header on
41 // LP64 consists of an isa pointer (which we're supposed to scan for
42 // some reason) followed by three words (2 ints, a function pointer,
43 // and a descriptor pointer).
45 // FIXME: do these really have to be named L_OBJC_CLASS_NAME_xxx?
46 // FIXME: sequences should never end in x0 00 instead of just 00
49 // byref int, short, char, char, char, id, id, strong void*, byref id
50 // CHECK-LP64: block variable layout for block: 0x01, 0x35, 0x10, 0x00
52 byref_int = sh + ch+ch1+ch2 ;
55 x((id)strong_void_sta);
61 // byref int, short, char, char, char, id, id, strong void*, byref void*, byref id
63 // CHECK-LP64: block variable layout for block: 0x01, 0x36, 0x10, 0x00
65 byref_int = sh + ch+ch1+ch2 ;
68 x((id)strong_void_sta);
76 // byref int, short, char, char, char, id, id, byref void*, int, double, byref id
78 // FIXME: we'd get a better format here if we sorted by scannability, not just alignment
79 // CHECK-LP64: block variable layout for block: 0x01, 0x35, 0x30, 0x00
81 byref_int = sh + ch+ch1+ch2 ;
92 // struct S (int, id, int, id, int, id)
94 // CHECK-LP64: block variable layout for block: 0x01, 0x41, 0x11, 0x11, 0x00
102 // Test 5 (unions/structs and their nesting):
130 // struct s2 (int, id, int, id, int, id?), union u2 (id?)
132 // CHECK-LP64: block variable layout for block: 0x01, 0x41, 0x11, 0x12, 0x00
142 void notifyBlock(id dependentBlock) {
143 id singleObservationToken;
147 // id, id, void(^)(void)
149 // CHECK-LP64: block variable layout for block: 0x01, 0x33, 0x00
150 void (^wrapperBlock)(void) = ^(void) {
151 CFRelease(singleObservationToken);
152 CFRelease(singleObservationToken);
154 CFRelease(singleObservationToken);
160 void test_empty_block(void) {
162 // CHECK-LP64: block variable layout for block: 0x01, 0x30, 0x00
163 void (^wrapperBlock)(void) = ^(void) {
169 typedef union { char ch[8]; } SS;
170 typedef struct { SS s[4]; } CS;
171 void test_union_in_layout(void) {