Move the operator new and operator delete out of line. This fixes an issue with
authorNate Begeman <natebegeman@mac.com>
Thu, 15 May 2008 01:23:11 +0000 (01:23 +0000)
committerNate Begeman <natebegeman@mac.com>
Thu, 15 May 2008 01:23:11 +0000 (01:23 +0000)
operator new() referring to the static initTags function, which has to be in the
same linkage unit as any file including User.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51136 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/User.h
lib/VMCore/Value.cpp

index 145477915481589d85bfb9b283f0179b35f6808c..44beac2ff89e69820f07b851830b0266ce2fa94f 100644 (file)
@@ -227,16 +227,7 @@ protected:
   ///
   unsigned NumOperands;
 
-  void *operator new(size_t s, unsigned Us) {
-    void *Storage = ::operator new(s + sizeof(Use) * Us);
-    Use *Start = static_cast<Use*>(Storage);
-    Use *End = Start + Us;
-    User *Obj = reinterpret_cast<User*>(End);
-    Obj->OperandList = Start;
-    Obj->NumOperands = Us;
-    Use::initTags(Start, End);
-    return Obj;
-  }
+  void *operator new(size_t s, unsigned Us);
   User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
     : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
   Use *allocHungoffUses(unsigned) const;
@@ -251,13 +242,7 @@ public:
   ~User() {
     Use::zap(OperandList, OperandList + NumOperands);
   }
-  void operator delete(void *Usr) {
-    User *Start = static_cast<User*>(Usr);
-    Use *Storage = static_cast<Use*>(Usr) - Start->NumOperands;
-    ::operator delete(Storage == Start->OperandList
-                      ? Storage
-                      : Usr);
-  }
+  void operator delete(void *Usr);
   template <unsigned Idx> Use &Op() {
     return OperandTraits<User>::op_begin(this)[Idx];
   }
index ff056ba74ac8441cf464aaf2c40cbb0e8406ca9e..919f4b00e87319c3df48821e66792b8d14a13de5 100644 (file)
@@ -355,3 +355,22 @@ void User::replaceUsesOfWith(Value *From, Value *To) {
       setOperand(i, To); // Fix it now...
     }
 }
+
+void *User::operator new(size_t s, unsigned Us) {
+  void *Storage = ::operator new(s + sizeof(Use) * Us);
+  Use *Start = static_cast<Use*>(Storage);
+  Use *End = Start + Us;
+  User *Obj = reinterpret_cast<User*>(End);
+  Obj->OperandList = Start;
+  Obj->NumOperands = Us;
+  Use::initTags(Start, End);
+  return Obj;
+}
+
+void User::operator delete(void *Usr) {
+  User *Start = static_cast<User*>(Usr);
+  Use *Storage = static_cast<Use*>(Usr) - Start->NumOperands;
+  ::operator delete(Storage == Start->OperandList
+                    ? Storage
+                    : Usr);
+}