From: Fariborz Jahanian Date: Fri, 1 Apr 2011 23:08:13 +0000 (+0000) Subject: Fixes a rewriter bug rewriting call to a byref X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=651ba520f9e1b38eeadbfc9bd21d0b7e570d69b7;p=clang Fixes a rewriter bug rewriting call to a byref 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 --- diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 88703e1917..13cd671f12 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -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"; diff --git a/test/Rewriter/rewrite-block-pointer.mm b/test/Rewriter/rewrite-block-pointer.mm index 38a1b7da28..d010a22484 100644 --- a/test/Rewriter/rewrite-block-pointer.mm +++ b/test/Rewriter/rewrite-block-pointer.mm @@ -97,3 +97,11 @@ void test9204669() { addChangeToData(); } +void test9204669_1() { + __attribute__((__blocks__(byref))) void (^addChangeToData)(); + + addChangeToData = ^() { + addChangeToData(); + }; +} +