Add NamedMDNode destructor.
authorDevang Patel <dpatel@apple.com>
Mon, 3 Aug 2009 06:19:01 +0000 (06:19 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 3 Aug 2009 06:19:01 +0000 (06:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77959 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Metadata.h
lib/VMCore/Metadata.cpp

index 95100c27496aff6c42a621f4c8c5f52cd5d302a1..7b48d8afbfad359b4be4dfd46611c7252a7dda78 100644 (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.
index bf0611f9e468c67c3165710daa5bcce12393a7a8..f548e549441f82a361eade32f2b16619d7410022 100644 (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();
+}