aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-12-17 06:08:47 +0000
committerMike Stump <mrs@apple.com>2009-12-17 06:08:47 +0000
commitf2945c0a74ec15d4d171b34a98e7ef109b9b414b (patch)
tree54cd62a7cf687aa47f9b945713b784338ce3096b /lib/CodeGen/CGException.cpp
parenta2bf105739cef7aea8e4d219629c627fcd11742e (diff)
Ensure we run cleanups for CXXTemporaries on the exceptional edge. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGException.cpp')
-rw-r--r--lib/CodeGen/CGException.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index c66bb46bd8..debebf20ae 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -150,17 +150,37 @@ static void CopyObject(CodeGenFunction &CGF, const Expr *E,
} else if (CXXConstructorDecl *CopyCtor
= RD->getCopyConstructor(CGF.getContext(), 0)) {
llvm::BasicBlock *PrevLandingPad = CGF.getInvokeDest();
+ llvm::Value *CondPtr = 0;
if (CGF.Exceptions) {
CodeGenFunction::EHCleanupBlock Cleanup(CGF);
llvm::Constant *FreeExceptionFn = getFreeExceptionFn(CGF);
+ llvm::BasicBlock *CondBlock = CGF.createBasicBlock("cond.free");
+ llvm::BasicBlock *Cont = CGF.createBasicBlock("cont");
+ CondPtr = CGF.CreateTempAlloca(llvm::Type::getInt1Ty(CGF.getLLVMContext()),
+ "doEHfree");
+
+ CGF.Builder.CreateCondBr(CGF.Builder.CreateLoad(CondPtr),
+ CondBlock, Cont);
+ CGF.EmitBlock(CondBlock);
+
// Load the exception pointer.
llvm::Value *ExceptionPtr = CGF.Builder.CreateLoad(ExceptionPtrPtr);
CGF.Builder.CreateCall(FreeExceptionFn, ExceptionPtr);
+
+ CGF.EmitBlock(Cont);
}
+ if (CondPtr)
+ CGF.Builder.CreateStore(llvm::ConstantInt::getTrue(CGF.getLLVMContext()),
+ CondPtr);
+
llvm::Value *Src = CGF.EmitLValue(E).getAddress();
- CGF.setInvokeDest(PrevLandingPad);
+
+ //CGF.setInvokeDest(PrevLandingPad);
+ if (CondPtr)
+ CGF.Builder.CreateStore(llvm::ConstantInt::getFalse(CGF.getLLVMContext()),
+ CondPtr);
llvm::BasicBlock *TerminateHandler = CGF.getTerminateHandler();
PrevLandingPad = CGF.getInvokeDest();