aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-09-10 01:16:55 +0000
committerJohn McCall <rjmccall@apple.com>2011-09-10 01:16:55 +0000
commitdc05b11c67331016473fbc7909827b1b89c9616b (patch)
tree65c8e307e0ccdcb67ebba0c530f476d59f87c09f /lib/CodeGen/CGExprScalar.cpp
parentb3321093f6ead084427eb4a6621832fc4ee2f5de (diff)
When converting a block pointer to an Objective-C pointer type, extend
the lifetime of the block by copying it to the heap, or else we'll get a dangling reference because the code working with the non-block-typed object will not know it needs to copy. There is some danger here, e.g. with assigning a block literal to an unsafe variable, but, well, it's an unsafe variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139451 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 35876d8c31..6741f43366 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -1027,7 +1027,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
ConvertType(CGF.getContext().getPointerType(DestTy)));
return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy));
}
-
+
case CK_CPointerToObjCPointerCast:
case CK_BlockPointerToObjCPointerCast:
case CK_AnyPointerToBlockPointerCast:
@@ -1124,6 +1124,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
value = CGF.EmitARCRetainAutoreleasedReturnValue(value);
return CGF.EmitObjCConsumeObject(E->getType(), value);
}
+ case CK_ObjCExtendBlockObject: {
+ llvm::Value *value = CGF.EmitARCRetainScalarExpr(E);
+ return CGF.EmitObjCConsumeObject(E->getType(), value);
+ }
case CK_FloatingRealToComplex:
case CK_FloatingComplexCast: