diff options
author | Devang Patel <dpatel@apple.com> | 2010-02-18 20:53:16 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-02-18 20:53:16 +0000 |
commit | 82ab3f8727b9f8468ef7dc76d9badadf75f300e6 (patch) | |
tree | e748d4c2abc32cc17b6e3e17b2c05fe3922625a0 /llvm/lib/VMCore/Metadata.cpp | |
parent | ffcfecdc1f2f0f92d2a5b41ec0725b2e92fe8622 (diff) | |
download | bcm5719-llvm-82ab3f8727b9f8468ef7dc76d9badadf75f300e6.tar.gz bcm5719-llvm-82ab3f8727b9f8468ef7dc76d9badadf75f300e6.zip |
Destroy MDNodes gracefully while deleting llvm context.
llvm-svn: 96609
Diffstat (limited to 'llvm/lib/VMCore/Metadata.cpp')
-rw-r--r-- | llvm/lib/VMCore/Metadata.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp index 07a5f3c5398..a08c45480b6 100644 --- a/llvm/lib/VMCore/Metadata.cpp +++ b/llvm/lib/VMCore/Metadata.cpp @@ -257,6 +257,13 @@ void MDNode::Profile(FoldingSetNodeID &ID) const { ID.AddPointer(getOperand(i)); } +// replaceAllOperandsWithNull - This is used while destroying llvm context to +// gracefully delete all nodes. This method replaces all operands with null. +void MDNode::replaceAllOperandsWithNull() { + for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands; + Op != E; ++Op) + replaceOperand(Op, 0); +} // Replace value from this node's operand list. void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) { |