[cfe-commits] r72835 - in /cfe/trunk/lib/CodeGen: CGCXXTemp.cpp CodeGenFunction.h

Anders Carlsson andersca at mac.com
Wed Jun 3 19:22:12 PDT 2009


Author: andersca
Date: Wed Jun  3 21:22:12 2009
New Revision: 72835

URL: http://llvm.org/viewvc/llvm-project?rev=72835&view=rev
Log:
Add PushConditionalTempDestruction/PopConditionalTempDestruction.

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

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXTemp.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXXTemp.cpp Wed Jun  3 21:22:12 2009
@@ -67,3 +67,14 @@
 
   return RV;
 }
+
+void 
+CodeGenFunction::PushConditionalTempDestruction() {
+  // Store the current number of live temporaries.
+  ConditionalTempDestructionStack.push_back(LiveTemporaries.size());
+}
+
+void CodeGenFunction::PopConditionalTempDestruction() {
+  ConditionalTempDestructionStack.pop_back();
+}
+  

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Jun  3 21:22:12 2009
@@ -160,6 +160,20 @@
   /// this behavior for branches?
   void EmitBranchThroughCleanup(llvm::BasicBlock *Dest);
 
+  /// PushConditionalTempDestruction - Should be called before a conditional 
+  /// part of an expression is emitted. For example, before the RHS of the
+  /// expression below is emitted:
+  /// 
+  /// b && f(T());
+  ///
+  /// This is used to make sure that any temporaryes created in the conditional
+  /// branch are only destroyed if the branch is taken.
+  void PushConditionalTempDestruction();
+  
+  /// PopConditionalTempDestruction - Should be called after a conditional 
+  /// part of an expression has been emitted.
+  void PopConditionalTempDestruction();
+  
 private:
   CGDebugInfo* DebugInfo;
 
@@ -263,6 +277,11 @@
   };
   
   llvm::SmallVector<CXXLiveTemporaryInfo, 4> LiveTemporaries;
+
+  /// ConditionalTempDestructionStack - Contains the number of live temporaries 
+  /// when PushConditionalTempDestruction was called. This is used so that
+  /// we know how many temporaries were created by a certain expression.
+  llvm::SmallVector<size_t, 4> ConditionalTempDestructionStack;
   
 public:
   CodeGenFunction(CodeGenModule &cgm);





More information about the cfe-commits mailing list