[cfe-commits] r86222 - /cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Anders Carlsson andersca at mac.com
Thu Nov 5 18:55:43 PST 2009


Author: andersca
Date: Thu Nov  5 20:55:43 2009
New Revision: 86222

URL: http://llvm.org/viewvc/llvm-project?rev=86222&view=rev
Log:
Cleanup ctor/dtor emission.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=86222&r1=86221&r2=86222&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Nov  5 20:55:43 2009
@@ -260,19 +260,16 @@
   // 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 @@
         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 =





More information about the cfe-commits mailing list