diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h index 28f9356ba9f..63601d2d25f 100644 --- a/include/llvm/Metadata.h +++ b/include/llvm/Metadata.h @@ -99,8 +99,8 @@ class MDNode : public MetadataBase, public FoldingSetNode { // Replace each instance of F from the element list of this node with T. void replaceElement(Value *F, Value *T); - MDNodeElement *Node; - unsigned NodeSize; + MDNodeElement *Operands; + unsigned NumOperands; protected: explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, @@ -117,7 +117,7 @@ public: Value *getElement(unsigned i) const; /// getNumElements - Return number of MDNode elements. - unsigned getNumElements() const { return NodeSize; } + unsigned getNumElements() const { return NumOperands; } /// isFunctionLocal - Return whether MDNode is local to a function. /// Note: MDNodes are designated as function-local when created, and keep diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index 8565b9e2459..01b47d67679 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -87,11 +87,12 @@ void MDNodeElement::allUsesReplacedWith(Value *NV) { MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, bool isFunctionLocal) : MetadataBase(Type::getMetadataTy(C), Value::MDNodeVal) { - NodeSize = NumVals; - Node = new MDNodeElement[NodeSize]; - MDNodeElement *Ptr = Node; + NumOperands = NumVals; + Operands = new MDNodeElement[NumOperands]; + MDNodeElement *Ptr = Operands; for (unsigned i = 0; i != NumVals; ++i) - *Ptr++ = MDNodeElement(Vals[i], this); + Ptr[i] = MDNodeElement(Vals[i], this); + if (isFunctionLocal) SubclassData |= FunctionLocalBit; } @@ -122,14 +123,14 @@ MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals, MDNode::~MDNode() { LLVMContextImpl *pImpl = getType()->getContext().pImpl; pImpl->MDNodeSet.RemoveNode(this); - delete [] Node; - Node = NULL; + delete [] Operands; + Operands = NULL; } /// getElement - Return specified element. Value *MDNode::getElement(unsigned i) const { assert(i < getNumElements() && "Invalid element number!"); - return Node[i]; + return Operands[i]; } @@ -161,8 +162,7 @@ void MDNode::replaceElement(Value *From, Value *To) { // Replace From element(s) in place. for (SmallVector::iterator I = Indexes.begin(), E = Indexes.end(); I != E; ++I) { - unsigned Index = *I; - Node[Index] = MDNodeElement(To, this); + Operands[*I] = MDNodeElement(To, this); } // Insert updated "this" into the context's folding node set.