]> granicus.if.org Git - clang/commitdiff
More temporary work.
authorAnders Carlsson <andersca@mac.com>
Wed, 3 Jun 2009 19:05:16 +0000 (19:05 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 3 Jun 2009 19:05:16 +0000 (19:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72796 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXXTemp.cpp
lib/CodeGen/CodeGenFunction.h

index 59ed3bbc60f7e1d172e693e5cf6c0ee7264547f9..d53a56fa2251c53cca5db7303c10c533f2c5770c 100644 (file)
@@ -17,17 +17,31 @@ using namespace CodeGen;
 
 void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary, 
                                        llvm::Value *Ptr) {
-  LiveTemporaries.push_back(CXXLiveTemporaryInfo(Temporary, Ptr, 0, 0));
+  llvm::BasicBlock *DtorBlock = createBasicBlock("temp.dtor");
+    
+  LiveTemporaries.push_back(CXXLiveTemporaryInfo(Temporary, Ptr, DtorBlock, 0));
+}
+
+void CodeGenFunction::PopCXXTemporary() {
+  const CXXLiveTemporaryInfo& Info = LiveTemporaries.back();
   
-  // Make a cleanup scope and emit the destructor.
-  {
-    CleanupScope Scope(*this);
-   
-    EmitCXXDestructorCall(Temporary->getDestructor(), Dtor_Complete, Ptr);
-  }
+  CleanupBlockInfo CleanupInfo = PopCleanupBlock();
+  assert(CleanupInfo.CleanupBlock == Info.DtorBlock && 
+         "Cleanup block mismatch!");
+  assert(!CleanupInfo.SwitchBlock && 
+         "Should not have a switch block for temporary cleanup!");
+  assert(!CleanupInfo.EndBlock && 
+         "Should not have an end block for temporary cleanup!");
+  
+  EmitBlock(Info.DtorBlock);
+
+  EmitCXXDestructorCall(Info.Temporary->getDestructor(),
+                        Dtor_Complete, Info.ThisPtr);
+
+  LiveTemporaries.pop_back();
 }
 
-RValue 
+RValue
 CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
                                             llvm::Value *AggLoc,
                                             bool isAggLocVolatile) {
index 97ca81bc2b99f80b2954df12d42f18de3b1b877c..c91a052cd5499e4ff0dfe73ff143c6f2ec1efd41 100644 (file)
@@ -256,8 +256,8 @@ private:
     llvm::Value *CondPtr;
     
     CXXLiveTemporaryInfo(const CXXTemporary *temporary,
-                         llvm::Value *thisptr, llvm::Value *condptr,
-                         llvm::BasicBlock *dtorblock) 
+                         llvm::Value *thisptr, llvm::BasicBlock *dtorblock,
+                         llvm::Value *condptr)
       : Temporary(temporary), ThisPtr(thisptr), DtorBlock(dtorblock), 
       CondPtr(condptr) { }
   };
@@ -506,6 +506,7 @@ public:
                              llvm::Value *This);
   
   void PushCXXTemporary(const CXXTemporary *Temporary, llvm::Value *Ptr);
+  void PopCXXTemporary();
   
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);