mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Make RecordKeeper::addClass/addDef take unique_ptrs instead of creating one internally.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222948 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1688,15 +1688,13 @@ public:
|
|||||||
auto I = Defs.find(Name);
|
auto I = Defs.find(Name);
|
||||||
return I == Defs.end() ? nullptr : I->second.get();
|
return I == Defs.end() ? nullptr : I->second.get();
|
||||||
}
|
}
|
||||||
void addClass(Record *_R) {
|
void addClass(std::unique_ptr<Record> R) {
|
||||||
std::unique_ptr<Record> R(_R);
|
|
||||||
bool Ins = Classes.insert(std::make_pair(R->getName(),
|
bool Ins = Classes.insert(std::make_pair(R->getName(),
|
||||||
std::move(R))).second;
|
std::move(R))).second;
|
||||||
(void)Ins;
|
(void)Ins;
|
||||||
assert(Ins && "Class already exists");
|
assert(Ins && "Class already exists");
|
||||||
}
|
}
|
||||||
void addDef(Record *_R) {
|
void addDef(std::unique_ptr<Record> R) {
|
||||||
std::unique_ptr<Record> R(_R);
|
|
||||||
bool Ins = Defs.insert(std::make_pair(R->getName(),
|
bool Ins = Defs.insert(std::make_pair(R->getName(),
|
||||||
std::move(R))).second;
|
std::move(R))).second;
|
||||||
(void)Ins;
|
(void)Ins;
|
||||||
|
@@ -371,7 +371,7 @@ bool TGParser::ProcessForeachDefs(Record *CurRec, SMLoc Loc, IterSet &IterVals){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Record *IterRecSave = IterRec.get(); // Keep a copy before release.
|
Record *IterRecSave = IterRec.get(); // Keep a copy before release.
|
||||||
Records.addDef(IterRec.release());
|
Records.addDef(std::move(IterRec));
|
||||||
IterRecSave->resolveReferences();
|
IterRecSave->resolveReferences();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1252,7 +1252,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
|
|||||||
|
|
||||||
if (!CurMultiClass) {
|
if (!CurMultiClass) {
|
||||||
NewRec->resolveReferences();
|
NewRec->resolveReferences();
|
||||||
Records.addDef(NewRecOwner.release());
|
Records.addDef(std::move(NewRecOwner));
|
||||||
} else {
|
} else {
|
||||||
// This needs to get resolved once the multiclass template arguments are
|
// This needs to get resolved once the multiclass template arguments are
|
||||||
// known before any use.
|
// known before any use.
|
||||||
@@ -2044,7 +2044,7 @@ bool TGParser::ParseDef(MultiClass *CurMultiClass) {
|
|||||||
if (Records.getDef(CurRec->getNameInitAsString()))
|
if (Records.getDef(CurRec->getNameInitAsString()))
|
||||||
return Error(DefLoc, "def '" + CurRec->getNameInitAsString()+
|
return Error(DefLoc, "def '" + CurRec->getNameInitAsString()+
|
||||||
"' already defined");
|
"' already defined");
|
||||||
Records.addDef(CurRecOwner.release());
|
Records.addDef(std::move(CurRecOwner));
|
||||||
|
|
||||||
if (ParseObjectBody(CurRec))
|
if (ParseObjectBody(CurRec))
|
||||||
return true;
|
return true;
|
||||||
@@ -2169,8 +2169,10 @@ bool TGParser::ParseClass() {
|
|||||||
+ "' already defined");
|
+ "' already defined");
|
||||||
} else {
|
} else {
|
||||||
// If this is the first reference to this class, create and add it.
|
// If this is the first reference to this class, create and add it.
|
||||||
CurRec = new Record(Lex.getCurStrVal(), Lex.getLoc(), Records);
|
auto NewRec = make_unique<Record>(Lex.getCurStrVal(), Lex.getLoc(),
|
||||||
Records.addClass(CurRec);
|
Records);
|
||||||
|
CurRec = NewRec.get();
|
||||||
|
Records.addClass(std::move(NewRec));
|
||||||
}
|
}
|
||||||
Lex.Lex(); // eat the name.
|
Lex.Lex(); // eat the name.
|
||||||
|
|
||||||
@@ -2442,7 +2444,7 @@ InstantiateMulticlassDef(MultiClass &MC,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Record *CurRecSave = CurRec.get(); // Keep a copy before we release.
|
Record *CurRecSave = CurRec.get(); // Keep a copy before we release.
|
||||||
Records.addDef(CurRec.release());
|
Records.addDef(std::move(CurRec));
|
||||||
return CurRecSave;
|
return CurRecSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user