From cd78e805e9c0d1a1b7ccbb67773aa51589c040f7 Mon Sep 17 00:00:00 2001 From: John McCall Date: Sat, 10 Sep 2011 01:16:55 +0000 Subject: 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. llvm-svn: 139451 --- clang/lib/CodeGen/CGExpr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CGExpr.cpp') diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 7ae95331ad5..520b1bbfb8a 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2061,7 +2061,8 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { case CK_AnyPointerToBlockPointerCast: case CK_ObjCProduceObject: case CK_ObjCConsumeObject: - case CK_ObjCReclaimReturnedObject: { + case CK_ObjCReclaimReturnedObject: + case CK_ObjCExtendBlockObject: { // These casts only produce lvalues when we're binding a reference to a // temporary realized from a (converted) pure rvalue. Emit the expression // as a value, copy it into a temporary, and return an lvalue referring to -- cgit v1.2.3