mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
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:
@@ -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");
|
||||
|
Reference in New Issue
Block a user