diff options
author | John McCall <rjmccall@apple.com> | 2011-02-07 18:37:40 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-02-07 18:37:40 +0000 |
commit | bb699b07426be017056c2c549ac3ffb488cab6e3 (patch) | |
tree | 6d3ec9769d1b0abf44bde9041c465f0c0c93274e /lib/CodeGen/CGBlocks.cpp | |
parent | 1b528445016c2dba23babeea07e352ca8b816262 (diff) |
When copy-capturing values for a nested capture, use a BlockDeclRefExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125021 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r-- | lib/CodeGen/CGBlocks.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index bdbc9d3b55..1a7abd242a 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -583,10 +583,18 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const BlockExpr *blockExpr) { // Otherwise, fake up a POD copy into the block field. } else { - DeclRefExpr declRef(const_cast<VarDecl*>(variable), type, VK_LValue, - SourceLocation()); + // We use one of these or the other depending on whether the + // reference is nested. + DeclRefExpr notNested(const_cast<VarDecl*>(variable), type, VK_LValue, + SourceLocation()); + BlockDeclRefExpr nested(const_cast<VarDecl*>(variable), type, + VK_LValue, SourceLocation(), /*byref*/ false); + + Expr *declRef = + (ci->isNested() ? static_cast<Expr*>(&nested) : ¬Nested); + ImplicitCastExpr l2r(ImplicitCastExpr::OnStack, type, CK_LValueToRValue, - &declRef, VK_RValue); + declRef, VK_RValue); EmitAnyExprToMem(&l2r, blockField, /*volatile*/ false, /*init*/ true); } |