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 3// rdar://12184410 4// rdar://12752901 5 6@class NSString; 7extern void NSLog(NSString *format, ...); 8extern int printf(const char *, ...); 9 10int main() { 11 NSString *strong; 12 unsigned long long eightByte = 0x8001800181818181ull; 13 // Test1 14 // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 15 void (^block1)() = ^{ printf("%#llx", eightByte); NSLog(@"%@", strong); }; 16 17 // Test2 18 int i = 1; 19 // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 20 void (^block2)() = ^{ printf("%#llx, %d", eightByte, i); NSLog(@"%@", strong); }; 21 22 // Test3 23 char ch = 'a'; 24 // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 25 void (^block3)() = ^{ printf("%c %#llx", ch, eightByte); NSLog(@"%@", strong); }; 26 27 // Test4 28 unsigned long fourByte = 0x8001ul; 29 // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 30 void (^block4)() = ^{ printf("%c %#lx", ch, fourByte); NSLog(@"%@", strong); }; 31 32 // Test5 33 // Nothing gets printed here since the descriptor of this block is merged with 34 // the descriptor of Test3's block. 35 void (^block5)() = ^{ NSLog(@"%@", strong); printf("%c %#llx", ch, eightByte); }; 36 37 // Test6 38 // CHECK: Block variable layout: BL_OPERATOR:0 39 void (^block6)() = ^{ printf("%#llx", eightByte); }; 40} 41 42/** 43struct __block_literal_generic { // 32bytes (64bit) and 20 bytes (32bit). 440 void *__isa; 454 int __flags; 468 int __reserved; 4712 void (*__invoke)(void *); 4816 struct __block_descriptor *__descriptor; 49}; 50*/ 51