diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-26 19:55:31 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-26 19:55:31 +0000 |
commit | f89c4270c94ddd966819fe6b8306aa572d1e5d83 (patch) | |
tree | 01324535f0a1165df9d2769ac4127b1749a878df /lib/Frontend/RewriteObjC.cpp | |
parent | 19943151b8d01768b42218ae36189aecd41951b0 (diff) |
Fix rewriting of byref variables in nested blocks.
Fixes radar 7692350.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97254 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/RewriteObjC.cpp')
-rw-r--r-- | lib/Frontend/RewriteObjC.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index 26b32478b8..42afe17327 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -4373,7 +4373,6 @@ void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S, // 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 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, 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 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, 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); |