]> granicus.if.org Git - clang/commitdiff
Rewriting of imported variable from outer
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 26 Feb 2010 19:05:20 +0000 (19:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 26 Feb 2010 19:05:20 +0000 (19:05 +0000)
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

lib/Frontend/RewriteObjC.cpp
test/Rewriter/rewrite-nested-blocks.mm

index 0895585e7960ec57a89f7ac4a3e2f9c944a91845..26b32478b89203dee2cb180b6583a9ce282ae8bf 100644 (file)
@@ -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);
index 95a16bdbb3981355183f3a6d328b8aa443cae909..1a6bcdde61768f1e68adb06e91290d5f74b8f97a 100644 (file)
@@ -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);
+}