From 2b1e311009cf682b7b5adb8ba97a0816f727bfb7 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 9 Sep 2008 16:16:55 +0000 Subject: [PATCH] Simple @throw support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55991 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGObjCMac.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index ea34d11318..e060c671f0 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1429,7 +1429,18 @@ void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF, void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S) { - CGF.ErrorUnsupported(&S, "@throw statement"); + llvm::Value *ExceptionAsObject; + + if (const Expr *ThrowExpr = S.getThrowExpr()) { + llvm::Value *Exception = CGF.EmitScalarExpr(ThrowExpr); + ExceptionAsObject = + CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy, "tmp"); + } else { + assert(0 && "FIXME: rethrows not supported!"); + } + + CGF.Builder.CreateCall(ObjCTypes.ExceptionThrowFn, ExceptionAsObject); + } /* *** Private Interface *** */ -- 2.40.0