[llvm-commits] [llvm] r49407 - /llvm/branches/ggreif/use-diet/include/llvm/User.h

Gabor Greif ggreif at gmail.com
Tue Apr 8 15:54:01 PDT 2008


Author: ggreif
Date: Tue Apr  8 17:54:00 2008
New Revision: 49407

URL: http://llvm.org/viewvc/llvm-project?rev=49407&view=rev
Log:
hackish attempt to implement a corresponding operator delete

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/User.h

Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49407&r1=49406&r2=49407&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/User.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/User.h Tue Apr  8 17:54:00 2008
@@ -195,8 +195,8 @@
   /// OperandList - This is a pointer to the array of Users for this operand.
   /// For nodes of fixed arity (e.g. a binary operator) this array will live
   /// embedded into the derived class.  For nodes of variable arity
-  /// (e.g. ConstantArrays, CallInst, PHINodes, ReturnInst etc), this memory 
-  /// will be dynamically allocated and should be destroyed by the classes 
+  /// (e.g. ConstantArrays, CallInst, PHINodes, ReturnInst etc.), this memory 
+  /// will be dynamically allocated and should be destroyed by the classes' 
   /// virtual dtor.
   Use *OperandList;
 
@@ -213,7 +213,14 @@
   }
   User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
     : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
-
+public:
+  void operator delete(void *Usr) {
+    User *Start = static_cast<User*>(Usr);
+    Use *Storage = static_cast<Use*>(Usr) - Start->NumOperands;
+    if (Storage == Start->OperandList)
+      ::operator delete(Storage); // FIXME: destructors of Uses?
+    else ::operator delete(Usr);
+  }
 public:
   Value *getOperand(unsigned i) const {
     assert(i < NumOperands && "getOperand() out of range!");





More information about the llvm-commits mailing list