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

@@ -531,13 +531,13 @@ bool LLParser::ParseMDNodeID(MDNode *&Result) {
}
// Otherwise, create MDNode forward reference.
MDTuple *FwdNode = MDTuple::getTemporary(Context, None);
ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc());
auto &FwdRef = ForwardRefMDNodes[MID];
FwdRef = std::make_pair(MDTuple::getTemporary(Context, None), Lex.getLoc());
if (NumberedMetadata.size() <= MID)
NumberedMetadata.resize(MID+1);
NumberedMetadata[MID].reset(FwdNode);
Result = FwdNode;
Result = FwdRef.first.get();
NumberedMetadata[MID].reset(Result);
return false;
}
@@ -597,9 +597,7 @@ bool LLParser::ParseStandaloneMetadata() {
// See if this was forward referenced, if so, handle it.
auto FI = ForwardRefMDNodes.find(MetadataID);
if (FI != ForwardRefMDNodes.end()) {
MDTuple *Temp = FI->second.first;
Temp->replaceAllUsesWith(Init);
MDNode::deleteTemporary(Temp);
FI->second.first->replaceAllUsesWith(Init);
ForwardRefMDNodes.erase(FI);
assert(NumberedMetadata[MetadataID] == Init && "Tracking VH didn't work");