summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-02-07 18:37:40 +0000
committerJohn McCall <rjmccall@apple.com>2011-02-07 18:37:40 +0000
commit93be3f75ccdf0687b06036fbc2975f1c51547980 (patch)
treeefcc4bb1a18dc3cd33d5980234d8aeaea2fc5541 /clang/lib/CodeGen
parent389971b318c16742a6ad407b135cf22dad39db2d (diff)
downloadbcm5719-llvm-93be3f75ccdf0687b06036fbc2975f1c51547980.tar.gz
bcm5719-llvm-93be3f75ccdf0687b06036fbc2975f1c51547980.zip
When copy-capturing values for a nested capture, use a BlockDeclRefExpr.
llvm-svn: 125021
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index bdbc9d3b555..1a7abd242aa 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/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) : &notNested);
+
ImplicitCastExpr l2r(ImplicitCastExpr::OnStack, type, CK_LValueToRValue,
- &declRef, VK_RValue);
+ declRef, VK_RValue);
EmitAnyExprToMem(&l2r, blockField, /*volatile*/ false, /*init*/ true);
}
OpenPOWER on IntegriCloud