From: John McCall Date: Sat, 26 Feb 2011 09:48:59 +0000 (+0000) Subject: Don't assume that whoever is asking for a message send is going X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=448d2cdce2dd8360c09f4187cd7bbebf16ff964d;p=clang Don't assume that whoever is asking for a message send is going to give us a non-null return slot. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126544 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index f5befceb0f..8dbd85f8b7 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -46,6 +46,15 @@ using namespace CodeGen; // don't belong in CGObjCRuntime either so we will live with it for // now. +static void EmitNullReturnInitialization(CodeGenFunction &CGF, + ReturnValueSlot &returnSlot, + QualType resultType) { + // Force the return slot to exist. + if (!returnSlot.getValue()) + returnSlot = ReturnValueSlot(CGF.CreateMemTemp(resultType), false); + CGF.EmitNullInitialization(returnSlot.getValue(), resultType); +} + static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *OID, const ObjCImplementationDecl *ID, @@ -1639,7 +1648,7 @@ CGObjCCommonMac::EmitLegacyMessageSend(CodeGen::CodeGenFunction &CGF, llvm::Constant *Fn = NULL; if (CGM.ReturnTypeUsesSRet(FnInfo)) { - CGF.EmitNullInitialization(Return.getValue(), ResultType); + EmitNullReturnInitialization(CGF, Return, ResultType); Fn = (ObjCABI == 2) ? ObjCTypes.getSendStretFn2(IsSuper) : ObjCTypes.getSendStretFn(IsSuper); } else if (CGM.ReturnTypeUsesFPRet(ResultType)) { @@ -5630,7 +5639,7 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend( llvm::Constant *Fn = 0; std::string Name("\01l_"); if (CGM.ReturnTypeUsesSRet(FnInfo)) { - CGF.EmitNullInitialization(Return.getValue(), ResultType); + EmitNullReturnInitialization(CGF, Return, ResultType); if (IsSuper) { Fn = ObjCTypes.getMessageSendSuper2StretFixupFn(); Name += "objc_msgSendSuper2_stret_fixup";