[TableGen] Use range-based for loops. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238808 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2015-06-02 06:19:28 +00:00
parent 77c7578426
commit caa40ec228
2 changed files with 20 additions and 22 deletions

View File

@ -1239,8 +1239,8 @@ public:
ArrayRef<SMRange> getSuperClassRanges() const { return SuperClassRanges; } ArrayRef<SMRange> getSuperClassRanges() const { return SuperClassRanges; }
bool isTemplateArg(Init *Name) const { bool isTemplateArg(Init *Name) const {
for (unsigned i = 0, e = TemplateArgs.size(); i != e; ++i) for (Init *TA : TemplateArgs)
if (TemplateArgs[i] == Name) return true; if (TA == Name) return true;
return false; return false;
} }
bool isTemplateArg(StringRef Name) const { bool isTemplateArg(StringRef Name) const {
@ -1248,16 +1248,16 @@ public:
} }
const RecordVal *getValue(const Init *Name) const { const RecordVal *getValue(const Init *Name) const {
for (unsigned i = 0, e = Values.size(); i != e; ++i) for (const RecordVal &Val : Values)
if (Values[i].getNameInit() == Name) return &Values[i]; if (Val.getNameInit() == Name) return &Val;
return nullptr; return nullptr;
} }
const RecordVal *getValue(StringRef Name) const { const RecordVal *getValue(StringRef Name) const {
return getValue(StringInit::get(Name)); return getValue(StringInit::get(Name));
} }
RecordVal *getValue(const Init *Name) { RecordVal *getValue(const Init *Name) {
for (unsigned i = 0, e = Values.size(); i != e; ++i) for (RecordVal &Val : Values)
if (Values[i].getNameInit() == Name) return &Values[i]; if (Val.getNameInit() == Name) return &Val;
return nullptr; return nullptr;
} }
RecordVal *getValue(StringRef Name) { RecordVal *getValue(StringRef Name) {
@ -1298,15 +1298,15 @@ public:
} }
bool isSubClassOf(const Record *R) const { bool isSubClassOf(const Record *R) const {
for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i) for (const Record *SC : SuperClasses)
if (SuperClasses[i] == R) if (SC == R)
return true; return true;
return false; return false;
} }
bool isSubClassOf(StringRef Name) const { bool isSubClassOf(StringRef Name) const {
for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i) for (const Record *SC : SuperClasses)
if (SuperClasses[i]->getNameInitAsString() == Name) if (SC->getNameInitAsString() == Name)
return true; return true;
return false; return false;
} }

View File

@ -148,9 +148,8 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName,
bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) { bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) {
Record *SC = SubClass.Rec; Record *SC = SubClass.Rec;
// Add all of the values in the subclass into the current class. // Add all of the values in the subclass into the current class.
const std::vector<RecordVal> &Vals = SC->getValues(); for (const RecordVal &Val : SC->getValues())
for (unsigned i = 0, e = Vals.size(); i != e; ++i) if (AddValue(CurRec, SubClass.RefRange.Start, Val))
if (AddValue(CurRec, SubClass.RefRange.Start, Vals[i]))
return true; return true;
const std::vector<Init *> &TArgs = SC->getTemplateArgs(); const std::vector<Init *> &TArgs = SC->getTemplateArgs();
@ -325,9 +324,9 @@ bool TGParser::ProcessForeachDefs(Record *CurRec, SMLoc Loc, IterSet &IterVals){
auto IterRec = make_unique<Record>(*CurRec); auto IterRec = make_unique<Record>(*CurRec);
// Set the iterator values now. // Set the iterator values now.
for (unsigned i = 0, e = IterVals.size(); i != e; ++i) { for (IterRecord &IR : IterVals) {
VarInit *IterVar = IterVals[i].IterVar; VarInit *IterVar = IR.IterVar;
TypedInit *IVal = dyn_cast<TypedInit>(IterVals[i].IterValue); TypedInit *IVal = dyn_cast<TypedInit>(IR.IterValue);
if (!IVal) if (!IVal)
return Error(Loc, "foreach iterator value is untyped"); return Error(Loc, "foreach iterator value is untyped");
@ -1807,8 +1806,8 @@ VarInit *TGParser::ParseForeachDeclaration(ListInit *&ForeachListValue) {
assert(!IterType && "Type already initialized?"); assert(!IterType && "Type already initialized?");
IterType = IntRecTy::get(); IterType = IntRecTy::get();
std::vector<Init*> Values; std::vector<Init*> Values;
for (unsigned i = 0, e = Ranges.size(); i != e; ++i) for (unsigned R : Ranges)
Values.push_back(IntInit::get(Ranges[i])); Values.push_back(IntInit::get(R));
ForeachListValue = ListInit::get(Values, IterType); ForeachListValue = ListInit::get(Values, IterType);
} }
@ -1934,10 +1933,9 @@ bool TGParser::ParseBody(Record *CurRec) {
/// \brief Apply the current let bindings to \a CurRec. /// \brief Apply the current let bindings to \a CurRec.
/// \returns true on error, false otherwise. /// \returns true on error, false otherwise.
bool TGParser::ApplyLetStack(Record *CurRec) { bool TGParser::ApplyLetStack(Record *CurRec) {
for (unsigned i = 0, e = LetStack.size(); i != e; ++i) for (std::vector<LetRecord> &LetInfo : LetStack)
for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j) for (LetRecord &LR : LetInfo)
if (SetValue(CurRec, LetStack[i][j].Loc, LetStack[i][j].Name, if (SetValue(CurRec, LR.Loc, LR.Name, LR.Bits, LR.Value))
LetStack[i][j].Bits, LetStack[i][j].Value))
return true; return true;
return false; return false;
} }