[cfe-commits] r97254 - in /cfe/trunk: lib/Frontend/RewriteObjC.cpp test/Rewriter/rewrite-byref-in-nested-blocks.mm
Fariborz Jahanian
fjahanian at apple.com
Fri Feb 26 11:55:31 PST 2010
Author: fjahanian
Date: Fri Feb 26 13:55:31 2010
New Revision: 97254
URL: http://llvm.org/viewvc/llvm-project?rev=97254&view=rev
Log:
Fix rewriting of byref variables in nested blocks.
Fixes radar 7692350.
Added:
cfe/trunk/test/Rewriter/rewrite-byref-in-nested-blocks.mm
Modified:
cfe/trunk/lib/Frontend/RewriteObjC.cpp
Modified: cfe/trunk/lib/Frontend/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/RewriteObjC.cpp?rev=97254&r1=97253&r2=97254&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Frontend/RewriteObjC.cpp Fri Feb 26 13:55:31 2010
@@ -4373,7 +4373,6 @@
// Handle specific things.
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());
@@ -4982,7 +4981,7 @@
for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) {
BlockDeclRefExpr *Exp = InnerBlockDeclRefs[i];
ValueDecl *VD = Exp->getDecl();
- if (!BlockByCopyDeclsPtrSet.count(VD)) {
+ if (!Exp->isByRef() && !BlockByCopyDeclsPtrSet.count(VD)) {
// We need to save the copied-in variables in nested
// blocks because it is needed at the end for some of the API generations.
// See SynthesizeBlockLiterals routine.
@@ -4996,6 +4995,14 @@
ImportedBlockDecls.insert(VD);
}
}
+ if (Exp->isByRef() && !BlockByRefDeclsPtrSet.count(VD)) {
+ InnerDeclRefs.push_back(Exp); countOfInnerDecls++;
+ BlockDeclRefs.push_back(Exp);
+ BlockByRefDeclsPtrSet.insert(VD);
+ BlockByRefDecls.push_back(VD);
+ GetBlockCallExprs(Exp);
+ ImportedBlockDecls.insert(VD);
+ }
}
InnerDeclRefsCount.push_back(countOfInnerDecls);
Added: cfe/trunk/test/Rewriter/rewrite-byref-in-nested-blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-byref-in-nested-blocks.mm?rev=97254&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-byref-in-nested-blocks.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-byref-in-nested-blocks.mm Fri Feb 26 13:55:31 2010
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7692350
+
+void f(void (^block)(void));
+
+ at interface X {
+ int y;
+}
+- (void)foo;
+ at end
+
+ at implementation X
+- (void)foo {
+ __block int kerfluffle;
+ f(^{
+ f(^{
+ y = 42;
+ kerfluffle = 1;
+ });
+ });
+}
+ at end
More information about the cfe-commits
mailing list