diff options
author | Mike Stump <mrs@apple.com> | 2009-12-04 01:51:45 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-12-04 01:51:45 +0000 |
commit | 114ab9f695163cd7df9e8f4f107fe91b543971f9 (patch) | |
tree | d7a08bfb0a859e3441f187b111c4c02f2ae10139 /clang/lib/CodeGen/CGException.cpp | |
parent | b7176a13a452b5154226cfab2cb9720d4667963e (diff) | |
download | bcm5719-llvm-114ab9f695163cd7df9e8f4f107fe91b543971f9.tar.gz bcm5719-llvm-114ab9f695163cd7df9e8f4f107fe91b543971f9.zip |
Fixup reference binding for catch parameters.
Fixup throws and rethrows to use invoke as appropriate.
llvm-svn: 90513
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 692153ed683..d7149110543 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -210,7 +210,13 @@ static void CopyObject(CodeGenFunction &CGF, QualType ObjectType, void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) { if (!E->getSubExpr()) { - Builder.CreateCall(getReThrowFn(*this))->setDoesNotReturn(); + if (getInvokeDest()) { + llvm::BasicBlock *Cont = createBasicBlock("invoke.cont"); + Builder.CreateInvoke(getReThrowFn(*this), Cont, getInvokeDest()) + ->setDoesNotReturn(); + EmitBlock(Cont); + } else + Builder.CreateCall(getReThrowFn(*this))->setDoesNotReturn(); Builder.CreateUnreachable(); // Clear the insertion point to indicate we are in unreachable code. @@ -237,9 +243,18 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) { llvm::Constant *TypeInfo = CGM.GenerateRTTI(ThrowType); llvm::Constant *Dtor = llvm::Constant::getNullValue(Int8PtrTy); - llvm::CallInst *ThrowCall = - Builder.CreateCall3(getThrowFn(*this), ExceptionPtr, TypeInfo, Dtor); - ThrowCall->setDoesNotReturn(); + if (getInvokeDest()) { + llvm::BasicBlock *Cont = createBasicBlock("invoke.cont"); + llvm::InvokeInst *ThrowCall = + Builder.CreateInvoke3(getThrowFn(*this), Cont, getInvokeDest(), + ExceptionPtr, TypeInfo, Dtor); + ThrowCall->setDoesNotReturn(); + EmitBlock(Cont); + } else { + llvm::CallInst *ThrowCall = + Builder.CreateCall3(getThrowFn(*this), ExceptionPtr, TypeInfo, Dtor); + ThrowCall->setDoesNotReturn(); + } Builder.CreateUnreachable(); // Clear the insertion point to indicate we are in unreachable code. @@ -383,7 +398,8 @@ void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) { setInvokeDest(TerminateHandler); bool WasPointer = true; if (!CatchType.getTypePtr()->isPointerType()) { - WasPointer = false; + if (!isa<ReferenceType>(CatchParam->getType())) + WasPointer = false; CatchType = getContext().getPointerType(CatchType); } ExcObject = Builder.CreateBitCast(ExcObject, ConvertType(CatchType)); @@ -428,7 +444,6 @@ void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) { Builder.CreateInvoke(getEndCatchFn(*this), Cont, TerminateHandler, Args.begin(), Args.begin()); - EmitBlock(Cont); if (Info.SwitchBlock) EmitBlock(Info.SwitchBlock); |