Home | History | Annotate | Download | only in Rewriter
      1 // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp
      2 // RUN: FileCheck  -check-prefix CHECK-LP --input-file=%t-rw.cpp %s
      3 // rdar://9846759
      4 
      5 typedef void (^dispatch_block_t)(void);
      6 
      7 extern int printf(const char*, ...);
      8 
      9 extern "C" dispatch_block_t Block_copy(dispatch_block_t aBlock);
     10 
     11 int main (int argc, char *argv[]) {
     12 
     13   dispatch_block_t innerBlock = ^{printf("argc = %d\n", argc); };
     14   id innerObject = 0;
     15 
     16   printf("innerBlock is %x\n", innerBlock);
     17 
     18   dispatch_block_t wrapperBlock = ^{
     19     printf("innerBlock is %x %x\n", innerBlock, innerObject);
     20   };
     21 
     22   wrapperBlock();
     23 
     24   dispatch_block_t copiedBlock = Block_copy(wrapperBlock);
     25   copiedBlock();
     26 
     27   return 0;
     28 }
     29 // CHECK-LP: _Block_object_assign((void*)&dst->innerBlock, (void*)src->innerBlock, 7
     30 // CHECK-LP: _Block_object_dispose((void*)src->innerBlock, 7
     31 // CHECK-LP: _Block_object_assign((void*)&dst->innerObject, (void*)src->innerObject, 3
     32 // CHECK-LP: _Block_object_dispose((void*)src->innerObject, 3
     33