]> granicus.if.org Git - clang/commitdiff
Fixes a rewriter bug rewriting call to a byref
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 1 Apr 2011 23:08:13 +0000 (23:08 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 1 Apr 2011 23:08:13 +0000 (23:08 +0000)
block pointer nested inside a block. // rdar:// 9204669

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128747 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Rewrite/RewriteObjC.cpp
test/Rewriter/rewrite-block-pointer.mm

index 88703e191738ce5deeded0dcb2e8b10caacbb6c9..13cd671f12361d6e2aa7a3bd9280c4e7615c21a0 100644 (file)
@@ -4330,20 +4330,7 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
       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 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
       }
       else
         Constructor += ", ";
-      if (isTopLevelBlockPointerType((*I)->getType()))
-        Constructor += Name + "((struct __block_impl *)_" 
-                        + Name + "->__forwarding)";
-      else
-        Constructor += Name + "(_" + Name + "->__forwarding)";
+      Constructor += Name + "(_" + Name + "->__forwarding)";
     }
     
     Constructor += " {\n";
index 38a1b7da28dbf932609b4ab4fb6c4e02f8b01365..d010a22484af1bef8099ac5ef9e90772e3839a13 100644 (file)
@@ -97,3 +97,11 @@ void test9204669() {
    addChangeToData();
 }
 
+void test9204669_1() {
+   __attribute__((__blocks__(byref))) void (^addChangeToData)();
+
+   addChangeToData = ^() {
+    addChangeToData();
+   };
+}
+