Skip to content

Commit bae410e

Browse files
committed
[NFC][TableGen] Change RecordKeeper::getDef() to return const pointer
1 parent 44df106 commit bae410e

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

llvm/include/llvm/TableGen/Record.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,14 +1991,14 @@ class RecordKeeper {
19911991
}
19921992

19931993
/// Get the concrete record with the specified name.
1994-
Record *getDef(StringRef Name) const {
1994+
const Record *getDef(StringRef Name) const {
19951995
auto I = Defs.find(Name);
19961996
return I == Defs.end() ? nullptr : I->second.get();
19971997
}
19981998

19991999
/// Get the \p Init value of the specified global variable.
20002000
Init *getGlobal(StringRef Name) const {
2001-
if (Record *R = getDef(Name))
2001+
if (const Record *R = getDef(Name))
20022002
return R->getDefInit();
20032003
auto It = ExtraGlobals.find(Name);
20042004
return It == ExtraGlobals.end() ? nullptr : It->second;

llvm/lib/TableGen/Record.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ Init *UnOpInit::Fold(Record *CurRec, bool IsFinal) const {
871871

872872
} else if (isa<RecordRecTy>(getType())) {
873873
if (StringInit *Name = dyn_cast<StringInit>(LHS)) {
874-
Record *D = RK.getDef(Name->getValue());
874+
const Record *D = RK.getDef(Name->getValue());
875875
if (!D && CurRec) {
876876
// Self-references are allowed, but their resolution is delayed until
877877
// the final resolve to ensure that we get the correct type for them.
@@ -2113,7 +2113,7 @@ Init *ExistsOpInit::Fold(Record *CurRec, bool IsFinal) const {
21132113
if (StringInit *Name = dyn_cast<StringInit>(Expr)) {
21142114

21152115
// Look up all defined records to see if we can find one.
2116-
Record *D = CheckType->getRecordKeeper().getDef(Name->getValue());
2116+
const Record *D = CheckType->getRecordKeeper().getDef(Name->getValue());
21172117
if (D) {
21182118
// Check if types are compatible.
21192119
return IntInit::get(getRecordKeeper(),

llvm/lib/TableGen/SetTheory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ struct SequenceOp : public SetTheory::Operator {
222222
std::string Name;
223223
raw_string_ostream OS(Name);
224224
OS << format(Format.c_str(), unsigned(From));
225-
Record *Rec = Records.getDef(Name);
225+
const Record *Rec = Records.getDef(Name);
226226
if (!Rec)
227227
PrintFatalError(Loc, "No def named '" + Name + "': " +
228228
Expr->getAsString());

llvm/lib/TableGen/TGParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ bool TGParser::resolve(const std::vector<RecordsEntry> &Source,
541541
/// Resolve the record fully and add it to the record keeper.
542542
bool TGParser::addDefOne(std::unique_ptr<Record> Rec) {
543543
Init *NewName = nullptr;
544-
if (Record *Prev = Records.getDef(Rec->getNameInitAsString())) {
544+
if (const Record *Prev = Records.getDef(Rec->getNameInitAsString())) {
545545
if (!Rec->isAnonymous()) {
546546
PrintError(Rec->getLoc(),
547547
"def already exists: " + Rec->getNameInitAsString());
@@ -1108,7 +1108,7 @@ const RecTy *TGParser::ParseType() {
11081108
Lex.Lex();
11091109
return I->second;
11101110
}
1111-
if (Record *R = ParseClassID())
1111+
if (const Record *R = ParseClassID())
11121112
return RecordRecTy::get(R);
11131113
TokError("unknown class name");
11141114
return nullptr;

llvm/utils/TableGen/Common/CodeGenSchedule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ void CodeGenSchedModels::collectProcModels() {
532532
ProcModels.reserve(ProcRecords.size() + 1);
533533

534534
// Use idx=0 for NoModel/NoItineraries.
535-
Record *NoModelDef = Records.getDef("NoSchedModel");
536-
Record *NoItinsDef = Records.getDef("NoItineraries");
535+
const Record *NoModelDef = Records.getDef("NoSchedModel");
536+
const Record *NoItinsDef = Records.getDef("NoItineraries");
537537
ProcModels.emplace_back(0, "NoSchedModel", NoModelDef, NoItinsDef);
538538
ProcModelMap[NoModelDef] = 0;
539539

0 commit comments

Comments
 (0)