IR: Return unique_ptr from MDNode::getTemporary()

Change `MDTuple::getTemporary()` and `MDLocation::getTemporary()` to
return (effectively) `std::unique_ptr<T, MDNode::deleteTemporary>`, and
clean up call sites.  (For now, `DIBuilder` call sites just call
`release()` immediately.)

There's an accompanying change in each of clang and polly to use the new
API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226504 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-01-19 21:30:18 +00:00
parent a23cc6a1ea
commit f9eaea701d
10 changed files with 77 additions and 81 deletions

View File

@ -541,9 +541,8 @@ void BitcodeReaderMDValueList::AssignValue(Metadata *MD, unsigned Idx) {
}
// If there was a forward reference to this value, replace it.
MDTuple *PrevMD = cast<MDTuple>(OldMD.get());
TempMDTuple PrevMD(cast<MDTuple>(OldMD.get()));
PrevMD->replaceAllUsesWith(MD);
MDNode::deleteTemporary(PrevMD);
--NumFwdRefs;
}
@ -557,7 +556,7 @@ Metadata *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) {
// Create and return a placeholder, which will later be RAUW'd.
AnyFwdRefs = true;
++NumFwdRefs;
Metadata *MD = MDNode::getTemporary(Context, None);
Metadata *MD = MDNode::getTemporary(Context, None).release();
MDValuePtrs[Idx].reset(MD);
return MD;
}