diff options
author | Anders Carlsson <andersca@mac.com> | 2009-11-06 02:55:43 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-11-06 02:55:43 +0000 |
commit | 4365bba95be15342575b4f030c6583a770a5da3d (patch) | |
tree | be70b43e9a5998d9c19b596e01803a8a839358f9 /lib/CodeGen/CodeGenFunction.cpp | |
parent | a7694087e4abaea261918ffbb3ffe38feb1da489 (diff) |
Cleanup ctor/dtor emission.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86222 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 4be341311c..281aa604fe 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -260,19 +260,16 @@ 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)) + + if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) { EmitCtorPrologue(CD, GD.getCtorType()); - EmitStmt(S); + EmitStmt(S); + } else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(FD)) { + llvm::BasicBlock *DtorEpilogue = createBasicBlock("dtor.epilogue"); + PushCleanupBlock(DtorEpilogue); + + EmitStmt(S); - if (DD) { CleanupBlockInfo Info = PopCleanupBlock(); assert(Info.CleanupBlock == DtorEpilogue && "Block mismatch!"); @@ -283,7 +280,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, EmitBlock(Info.SwitchBlock); if (Info.EndBlock) EmitBlock(Info.EndBlock); + } else { + // Just a regular function, emit its body. + EmitStmt(S); } + FinishFunction(S->getRBracLoc()); } else if (FD->isImplicit()) { const CXXRecordDecl *ClassDecl = |