diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h index 64ab6b7583e..7cfcb700795 100644 --- a/include/llvm/Metadata.h +++ b/include/llvm/Metadata.h @@ -185,7 +185,7 @@ class NamedMDNode : public Value, public ilist_node { std::string Name; Module *Parent; - void *Operands; // SmallVector, 4> + void *Operands; // SmallVector, 4> void setParent(Module *M) { Parent = M; } protected: diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index b64bde548d1..a89cffd8e0e 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -346,8 +346,8 @@ void ilist_traits::removeNodeFromList(NamedMDNode *N) { ST.remove(N->getName()); } -static SmallVector &getNMDOps(void *Operands) { - return *(SmallVector*)Operands; +static SmallVector, 4> &getNMDOps(void *Operands) { + return *(SmallVector, 4>*)Operands; } NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N, @@ -355,11 +355,11 @@ NamedMDNode::NamedMDNode(LLVMContext &C, const Twine &N, unsigned NumMDs, Module *ParentModule) : Value(Type::getMetadataTy(C), Value::NamedMDNodeVal), Parent(0) { setName(N); - Operands = new SmallVector(); + Operands = new SmallVector, 4>(); - SmallVector &Node = getNMDOps(Operands); + SmallVector, 4> &Node = getNMDOps(Operands); for (unsigned i = 0; i != NumMDs; ++i) - Node.push_back(WeakVH(MDs[i])); + Node.push_back(TrackingVH(MDs[i])); if (ParentModule) ParentModule->getNamedMDList().push_back(this); @@ -389,12 +389,12 @@ unsigned NamedMDNode::getNumOperands() const { /// getOperand - Return specified operand. MDNode *NamedMDNode::getOperand(unsigned i) const { assert(i < getNumOperands() && "Invalid Operand number!"); - return dyn_cast_or_null(getNMDOps(Operands)[i]); + return dyn_cast_or_null(&*getNMDOps(Operands)[i]); } /// addOperand - Add metadata Operand. void NamedMDNode::addOperand(MDNode *M) { - getNMDOps(Operands).push_back(WeakVH(M)); + getNMDOps(Operands).push_back(TrackingVH(M)); } /// eraseFromParent - Drop all references and remove the node from parent