aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-10-16 08:21:07 +0000
committerJohn McCall <rjmccall@apple.com>2010-10-16 08:21:07 +0000
commit7ec404c40e42ce274d956a289ffa91e8f4befc43 (patch)
treeda904abf33ee6e67328983d4daa2eb106089a25e
parentbe04b6df363f083f51636efcf4a8be4c5e8ea038 (diff)
objc_exception_rethrow does not take an exception argument.
rdar://problem/8535238 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116663 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGObjCMac.cpp32
-rw-r--r--test/CodeGenObjC/exceptions-nonfragile.m13
2 files changed, 22 insertions, 23 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 8b3fd499b6..acb3ecebd6 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -462,7 +462,7 @@ public:
// void objc_exception_rethrow(void)
std::vector<const llvm::Type*> Args;
llvm::FunctionType *FTy =
- llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Args, true);
+ llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_exception_rethrow");
}
@@ -6165,32 +6165,18 @@ void CGObjCNonFragileABIMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
/// EmitThrowStmt - Generate code for a throw statement.
void CGObjCNonFragileABIMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
const ObjCAtThrowStmt &S) {
- llvm::Value *Exception;
- llvm::Constant *FunctionThrowOrRethrow;
if (const Expr *ThrowExpr = S.getThrowExpr()) {
- Exception = CGF.EmitScalarExpr(ThrowExpr);
- FunctionThrowOrRethrow = ObjCTypes.getExceptionThrowFn();
- } else {
- assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) &&
- "Unexpected rethrow outside @catch block.");
- Exception = CGF.ObjCEHValueStack.back();
- FunctionThrowOrRethrow = ObjCTypes.getExceptionRethrowFn();
- }
-
- llvm::Value *ExceptionAsObject =
- CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy, "tmp");
- llvm::BasicBlock *InvokeDest = CGF.getInvokeDest();
- if (InvokeDest) {
- CGF.Builder.CreateInvoke(FunctionThrowOrRethrow,
- CGF.getUnreachableBlock(), InvokeDest,
- &ExceptionAsObject, &ExceptionAsObject + 1);
+ llvm::Value *Exception = CGF.EmitScalarExpr(ThrowExpr);
+ llvm::Value *Args[] = { Exception };
+ CGF.EmitCallOrInvoke(ObjCTypes.getExceptionThrowFn(),
+ Args, Args+1)
+ .setDoesNotReturn();
} else {
- CGF.Builder.CreateCall(FunctionThrowOrRethrow, ExceptionAsObject)
- ->setDoesNotReturn();
- CGF.Builder.CreateUnreachable();
+ CGF.EmitCallOrInvoke(ObjCTypes.getExceptionRethrowFn(), 0, 0)
+ .setDoesNotReturn();
}
- // Clear the insertion point to indicate we are in unreachable code.
+ CGF.Builder.CreateUnreachable();
CGF.Builder.ClearInsertionPoint();
}
diff --git a/test/CodeGenObjC/exceptions-nonfragile.m b/test/CodeGenObjC/exceptions-nonfragile.m
new file mode 100644
index 0000000000..41cda2c0a9
--- /dev/null
+++ b/test/CodeGenObjC/exceptions-nonfragile.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-nonfragile-abi -fexceptions -O2 -o - %s | FileCheck %s
+
+// rdar://problem/8535238
+// CHECK: declare void @objc_exception_rethrow()
+
+void protos() {
+ extern void foo();
+ @try {
+ foo();
+ } @catch (id e) {
+ @throw;
+ }
+}