Add NamedMDNode destructor.

llvm-svn: 77959
This commit is contained in:
Devang Patel 2009-08-03 06:19:01 +00:00
parent 14781bacfe
commit b770039c5b
2 changed files with 26 additions and 0 deletions

View File

@ -200,6 +200,15 @@ public:
return new NamedMDNode(N, MDs, NumMDs, M);
}
/// eraseFromParent - Drop all references and remove the node from parent
/// module.
void eraseFromParent();
/// dropAllReferences - Remove all uses and clear node vector.
void dropAllReferences();
~NamedMDNode();
typedef SmallVectorImpl<WeakMetadataVH>::const_iterator const_elem_iterator;
/// getParent - Get the module that holds this named metadata collection.

View File

@ -83,3 +83,20 @@ NamedMDNode::NamedMDNode(const Twine &N, MetadataBase*const* MDs,
if (ParentModule)
ParentModule->getNamedMDList().push_back(this);
}
/// eraseFromParent - Drop all references and remove the node from parent
/// module.
void NamedMDNode::eraseFromParent() {
dropAllReferences();
getParent()->getNamedMDList().erase(this);
}
/// dropAllReferences - Remove all uses and clear node vector.
void NamedMDNode::dropAllReferences() {
// FIXME: Update metadata use list.
Node.clear();
}
NamedMDNode::~NamedMDNode() {
dropAllReferences();
}