aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-02-26 19:05:20 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-02-26 19:05:20 +0000
commite7c5c93e37ad2db5d1bc0b11a3d67c346c02de8a (patch)
tree44d8e6b182c5a26fd84af66e0a433fe36f164abc
parent6190ec29f0895185bbec95a932429b8832917fec (diff)
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
-rw-r--r--lib/Frontend/RewriteObjC.cpp1
-rw-r--r--test/Rewriter/rewrite-nested-blocks.mm18
2 files changed, 19 insertions, 0 deletions
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<BlockDeclRefExpr>(S))
if (!isa<FunctionDecl>(CDRE->getDecl()) &&
!CDRE->isByRef() &&
+ !isa<ParmVarDecl>(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);
+}