From: Daniel Dunbar Date: Mon, 2 Mar 2009 05:20:36 +0000 (+0000) Subject: Make sure to invoke (not call) to objc_exception_throw if necessary. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cec4c77bf422528f4536d30574b82f878bc705b3;p=clang Make sure to invoke (not call) to objc_exception_throw if necessary. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65808 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index b45f1e4dde..eee9d438c6 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -4844,8 +4844,17 @@ void CGObjCNonFragileABIMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, llvm::Value *Exception = CGF.EmitScalarExpr(ThrowExpr); ExceptionAsObject = CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy, "tmp"); - - CGF.Builder.CreateCall(ObjCTypes.ExceptionThrowFn, ExceptionAsObject); + + llvm::BasicBlock *InvokeDest = CGF.getInvokeDest(); + if (InvokeDest) { + llvm::BasicBlock *Cont = CGF.createBasicBlock("invoke.cont"); + CGF.Builder.CreateInvoke(ObjCTypes.ExceptionThrowFn, + Cont, InvokeDest, + &ExceptionAsObject, &ExceptionAsObject + 1); + CGF.EmitBlock(Cont); + } else + CGF.Builder.CreateCall(ObjCTypes.ExceptionThrowFn, ExceptionAsObject); + CGF.Builder.CreateUnreachable(); } else { CGF.ErrorUnsupported(&S, "rethrow statement");