aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-01-10 19:02:56 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-01-10 19:02:56 +0000
commit6a3c70ec59804347c99e96aa13934f63f4fed573 (patch)
treedf913e85b27bebfc601d4a61edf7d22364593b7e /lib/CodeGen/CGException.cpp
parentd8d9b847bd7120ebd5be83a55d31d9c26142962e (diff)
objectiveC++: When throwing c++ exception of
an objectiveC object, use objc_exception_throw to raise the exception. // rdar://12605907 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172091 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGException.cpp')
-rw-r--r--lib/CodeGen/CGException.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 4d4f529f20..5797fd7578 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -15,6 +15,7 @@
#include "CGCleanup.h"
#include "CGObjCRuntime.h"
#include "TargetInfo.h"
+#include "clang/AST/StmtObjC.h"
#include "clang/AST/StmtCXX.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/Support/CallSite.h"
@@ -434,6 +435,17 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
QualType ThrowType = E->getSubExpr()->getType();
+ if (ThrowType->isObjCObjectPointerType()) {
+ const Stmt *ThrowStmt = E->getSubExpr();
+ const ObjCAtThrowStmt S(E->getExprLoc(),
+ const_cast<Stmt *>(ThrowStmt));
+ CGM.getObjCRuntime().EmitThrowStmt(*this, S, false);
+ // This will clear insertion point which was not cleared in
+ // call to EmitThrowStmt.
+ EmitBlock(createBasicBlock("throw.cont"));
+ return;
+ }
+
// Now allocate the exception object.
llvm::Type *SizeTy = ConvertType(getContext().getSizeType());
uint64_t TypeSize = getContext().getTypeSizeInChars(ThrowType).getQuantity();