From: Fariborz Jahanian Date: Fri, 26 Feb 2010 19:05:20 +0000 (+0000) Subject: Rewriting of imported variable from outer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7c5c93e37ad2db5d1bc0b11a3d67c346c02de8a;p=clang Rewriting of imported variable from outer blocks's argument in the inner block requires special treatment. Fixes radar 7692419. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97244 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index 0895585e79..26b32478b8 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -4374,6 +4374,7 @@ void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S, if (BlockDeclRefExpr *CDRE = dyn_cast(S)) if (!isa(CDRE->getDecl()) && !CDRE->isByRef() && + !isa(CDRE->getDecl()) && !InnerBlockValueDecls.count(CDRE->getDecl())) { InnerBlockValueDecls.insert(CDRE->getDecl()); InnerBlockDeclRefs.push_back(CDRE); diff --git a/test/Rewriter/rewrite-nested-blocks.mm b/test/Rewriter/rewrite-nested-blocks.mm index 95a16bdbb3..1a6bcdde61 100644 --- a/test/Rewriter/rewrite-nested-blocks.mm +++ b/test/Rewriter/rewrite-nested-blocks.mm @@ -36,3 +36,21 @@ void foo () { }); }); } + +// radar 7692419 +@interface Bar +@end + +void f(Bar *); +void q(void (^block)(void)); + +void x() { + void (^myblock)(Bar *b) = ^(Bar *b) { + q(^{ + f(b); + }); + }; + + Bar *b = (Bar *)42; + myblock(b); +}