[cfe-commits] r128747 - in /cfe/trunk: lib/Rewrite/RewriteObjC.cpp test/Rewriter/rewrite-block-pointer.mm

Fariborz Jahanian fjahanian at apple.com
Fri Apr 1 16:08:13 PDT 2011


Author: fjahanian
Date: Fri Apr  1 18:08:13 2011
New Revision: 128747

URL: http://llvm.org/viewvc/llvm-project?rev=128747&view=rev
Log:
Fixes a rewriter bug rewriting call to a byref
block pointer nested inside a block. // rdar:// 9204669


Modified:
    cfe/trunk/lib/Rewrite/RewriteObjC.cpp
    cfe/trunk/test/Rewriter/rewrite-block-pointer.mm

Modified: cfe/trunk/lib/Rewrite/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteObjC.cpp?rev=128747&r1=128746&r2=128747&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteObjC.cpp Fri Apr  1 18:08:13 2011
@@ -4330,20 +4330,7 @@
       S += "  ";
       std::string FieldName = (*I)->getNameAsString();
       std::string ArgName = "_" + FieldName;
-      // Handle nested closure invocation. For example:
-      //
-      //   void (^myImportedBlock)(void);
-      //   myImportedBlock  = ^(void) { setGlobalInt(x + y); };
-      //
-      //   void (^anotherBlock)(void);
-      //   anotherBlock = ^(void) {
-      //     myImportedBlock(); // import and invoke the closure
-      //   };
-      //
-      if (isTopLevelBlockPointerType((*I)->getType())) {
-        S += "struct __block_impl *";
-        Constructor += ", void *" + ArgName;
-      } else {
+      {
         std::string TypeString;
         RewriteByRefString(TypeString, FieldName, (*I));
         TypeString += " *";
@@ -4381,11 +4368,7 @@
       }
       else
         Constructor += ", ";
-      if (isTopLevelBlockPointerType((*I)->getType()))
-        Constructor += Name + "((struct __block_impl *)_" 
-                        + Name + "->__forwarding)";
-      else
-        Constructor += Name + "(_" + Name + "->__forwarding)";
+      Constructor += Name + "(_" + Name + "->__forwarding)";
     }
     
     Constructor += " {\n";

Modified: cfe/trunk/test/Rewriter/rewrite-block-pointer.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-block-pointer.mm?rev=128747&r1=128746&r2=128747&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-block-pointer.mm (original)
+++ cfe/trunk/test/Rewriter/rewrite-block-pointer.mm Fri Apr  1 18:08:13 2011
@@ -97,3 +97,11 @@
    addChangeToData();
 }
 
+void test9204669_1() {
+   __attribute__((__blocks__(byref))) void (^addChangeToData)();
+
+   addChangeToData = ^() {
+    addChangeToData();
+   };
+}
+





More information about the cfe-commits mailing list