Remove MDNode from ValueMap when MDNode is destroyed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78612 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2009-08-10 22:59:46 +00:00
parent af37f341df
commit 286d9e4b9d
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