Home | History | Annotate | Download | only in CodeGenObjC
      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;
      7 extern void NSLog(NSString *format, ...);
      8 extern int printf(const char *, ...);
      9 
     10 int 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   // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0
     34   void (^block5)() = ^{ NSLog(@"%@", strong); printf("%c %#llx", ch, eightByte); };
     35 
     36   // Test6
     37   // CHECK: Block variable layout: BL_OPERATOR:0
     38   void (^block6)() = ^{ printf("%#llx", eightByte); };
     39 }
     40 
     41 /**
     42 struct __block_literal_generic { // 32bytes (64bit) and 20 bytes (32bit).
     43 0  void *__isa;
     44 4  int __flags;
     45 8  int __reserved;
     46 12  void (*__invoke)(void *);
     47 16  struct __block_descriptor *__descriptor;
     48 };
     49 */
     50