diff options
author | Mike Stump <mrs@apple.com> | 2009-12-17 06:08:47 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-12-17 06:08:47 +0000 |
commit | f2945c0a74ec15d4d171b34a98e7ef109b9b414b (patch) | |
tree | 54cd62a7cf687aa47f9b945713b784338ce3096b /lib/CodeGen/CGTemporaries.cpp | |
parent | a2bf105739cef7aea8e4d219629c627fcd11742e (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/CGTemporaries.cpp')
-rw-r--r-- | lib/CodeGen/CGTemporaries.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/CodeGen/CGTemporaries.cpp b/lib/CodeGen/CGTemporaries.cpp index 884c21230a..8e214b4676 100644 --- a/lib/CodeGen/CGTemporaries.cpp +++ b/lib/CodeGen/CGTemporaries.cpp @@ -41,6 +41,33 @@ void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary, CondPtr)); PushCleanupBlock(DtorBlock); + + if (Exceptions) { + const CXXLiveTemporaryInfo& Info = LiveTemporaries.back(); + llvm::BasicBlock *CondEnd = 0; + + EHCleanupBlock Cleanup(*this); + + // If this is a conditional temporary, we need to check the condition + // boolean and only call the destructor if it's true. + if (Info.CondPtr) { + llvm::BasicBlock *CondBlock = createBasicBlock("cond.dtor.call"); + CondEnd = createBasicBlock("cond.dtor.end"); + + llvm::Value *Cond = Builder.CreateLoad(Info.CondPtr); + Builder.CreateCondBr(Cond, CondBlock, CondEnd); + EmitBlock(CondBlock); + } + + EmitCXXDestructorCall(Info.Temporary->getDestructor(), + Dtor_Complete, Info.ThisPtr); + + if (CondEnd) { + // Reset the condition. to false. + Builder.CreateStore(llvm::ConstantInt::getFalse(VMContext), Info.CondPtr); + EmitBlock(CondEnd); + } + } } void CodeGenFunction::PopCXXTemporary() { |