Remove MDNode from ValueMap when MDNode is destroyed.

llvm-svn: 78612
This commit is contained in:
Devang Patel 2009-08-10 22:59:46 +00:00
parent 9e7c7e748f
commit 9b4ea1c474
2 changed files with 10 additions and 1 deletions

View File

@ -105,7 +105,7 @@ struct LLVMContextImpl {
ValueMap<char, Type, ConstantAggregateZero> AggZeroConstants;
ValueMap<std::vector<Value*>, Type, MDNode> MDNodes;
ValueMap<std::vector<Value*>, Type, MDNode, true /*largekey*/> MDNodes;
typedef ValueMap<std::vector<Constant*>, ArrayType,
ConstantArray, true /*largekey*/> ArrayConstantsTy;

View File

@ -92,8 +92,17 @@ void MDNode::dropAllReferences() {
Node.clear();
}
static std::vector<Value*> getValType(MDNode *N) {
std::vector<Value*> Elements;
Elements.reserve(N->getNumElements());
for (unsigned i = 0, e = N->getNumElements(); i != e; ++i)
Elements.push_back(N->getElement(i));
return Elements;
}
MDNode::~MDNode() {
dropAllReferences();
getType()->getContext().pImpl->MDNodes.remove(this);
}
//===----------------------------------------------------------------------===//
//NamedMDNode implementation