Disallow null as a named metadata operand.

Make MDNode::destroy private.
Fix the one thing that used MDNode::destroy, outside of MDNode itself.

One should never delete or destroy an MDNode explicitly. MDNodes
implicitly go away when there are no references to them (implementation
details aside).

llvm-svn: 109028
This commit is contained in:
Dan Gohman
2010-07-21 18:54:18 +00:00
parent 99d2cf4838
commit 093cb79d4b
11 changed files with 20 additions and 40 deletions

View File

@@ -558,12 +558,8 @@ static void WriteModuleMetadata(const ValueEnumerator &VE,
Record.clear();
// Write named metadata operands.
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
if (NMD->getOperand(i))
Record.push_back(VE.getValueID(NMD->getOperand(i)));
else
Record.push_back(~0U);
}
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i)
Record.push_back(VE.getValueID(NMD->getOperand(i)));
Stream.EmitRecord(bitc::METADATA_NAMED_NODE, Record, 0);
Record.clear();
}