diff options
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index f9e54b7570..f802068b26 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -233,11 +233,30 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, // FIXME: Support CXXTryStmt here, too. if (const CompoundStmt *S = FD->getCompoundBody()) { StartFunction(GD, FD->getResultType(), Fn, Args, S->getLBracLoc()); + const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(FD); + llvm::BasicBlock *DtorEpilogue = 0; + if (DD) { + DtorEpilogue = createBasicBlock("dtor.epilogue"); + + PushCleanupBlock(DtorEpilogue); + } + if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) EmitCtorPrologue(CD, GD.getCtorType()); EmitStmt(S); - if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(FD)) + + if (DD) { + CleanupBlockInfo Info = PopCleanupBlock(); + + assert(Info.CleanupBlock == DtorEpilogue && "Block mismatch!"); + EmitBlock(DtorEpilogue); EmitDtorEpilogue(DD, GD.getDtorType()); + + if (Info.SwitchBlock) + EmitBlock(Info.SwitchBlock); + if (Info.EndBlock) + EmitBlock(Info.EndBlock); + } FinishFunction(S->getRBracLoc()); } else if (FD->isImplicit()) { const CXXRecordDecl *ClassDecl = |