From 60f9320fc5a24d95cdb637e8376d9714933d3e68 Mon Sep 17 00:00:00 2001 From: Nate Begeman Date: Thu, 15 May 2008 01:23:11 +0000 Subject: Move the operator new and operator delete out of line. This fixes an issue with operator new() referring to the static initTags function, which has to be in the same linkage unit as any file including User.h. llvm-svn: 51136 --- llvm/lib/VMCore/Value.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'llvm/lib/VMCore/Value.cpp') diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp index ff056ba74ac..919f4b00e87 100644 --- a/llvm/lib/VMCore/Value.cpp +++ b/llvm/lib/VMCore/Value.cpp @@ -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(Storage); + Use *End = Start + Us; + User *Obj = reinterpret_cast(End); + Obj->OperandList = Start; + Obj->NumOperands = Us; + Use::initTags(Start, End); + return Obj; +} + +void User::operator delete(void *Usr) { + User *Start = static_cast(Usr); + Use *Storage = static_cast(Usr) - Start->NumOperands; + ::operator delete(Storage == Start->OperandList + ? Storage + : Usr); +} -- cgit v1.2.3