llvm.org GIT mirror llvm / caa40ec
[TableGen] Use range-based for loops. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238808 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
2 changed file(s) with 20 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
12381238 ArrayRef getSuperClassRanges() const { return SuperClassRanges; }
12391239
12401240 bool isTemplateArg(Init *Name) const {
1241 for (unsigned i = 0, e = TemplateArgs.size(); i != e; ++i)
1242 if (TemplateArgs[i] == Name) return true;
1241 for (Init *TA : TemplateArgs)
1242 if (TA == Name) return true;
12431243 return false;
12441244 }
12451245 bool isTemplateArg(StringRef Name) const {
12471247 }
12481248
12491249 const RecordVal *getValue(const Init *Name) const {
1250 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1251 if (Values[i].getNameInit() == Name) return &Values[i];
1250 for (const RecordVal &Val : Values)
1251 if (Val.getNameInit() == Name) return &Val;
12521252 return nullptr;
12531253 }
12541254 const RecordVal *getValue(StringRef Name) const {
12551255 return getValue(StringInit::get(Name));
12561256 }
12571257 RecordVal *getValue(const Init *Name) {
1258 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1259 if (Values[i].getNameInit() == Name) return &Values[i];
1258 for (RecordVal &Val : Values)
1259 if (Val.getNameInit() == Name) return &Val;
12601260 return nullptr;
12611261 }
12621262 RecordVal *getValue(StringRef Name) {
12971297 }
12981298
12991299 bool isSubClassOf(const Record *R) const {
1300 for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
1301 if (SuperClasses[i] == R)
1300 for (const Record *SC : SuperClasses)
1301 if (SC == R)
13021302 return true;
13031303 return false;
13041304 }
13051305
13061306 bool isSubClassOf(StringRef Name) const {
1307 for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
1308 if (SuperClasses[i]->getNameInitAsString() == Name)
1307 for (const Record *SC : SuperClasses)
1308 if (SC->getNameInitAsString() == Name)
13091309 return true;
13101310 return false;
13111311 }
147147 bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) {
148148 Record *SC = SubClass.Rec;
149149 // Add all of the values in the subclass into the current class.
150 const std::vector &Vals = SC->getValues();
151 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
152 if (AddValue(CurRec, SubClass.RefRange.Start, Vals[i]))
150 for (const RecordVal &Val : SC->getValues())
151 if (AddValue(CurRec, SubClass.RefRange.Start, Val))
153152 return true;
154153
155154 const std::vector &TArgs = SC->getTemplateArgs();
324323 auto IterRec = make_unique(*CurRec);
325324
326325 // Set the iterator values now.
327 for (unsigned i = 0, e = IterVals.size(); i != e; ++i) {
328 VarInit *IterVar = IterVals[i].IterVar;
329 TypedInit *IVal = dyn_cast(IterVals[i].IterValue);
326 for (IterRecord &IR : IterVals) {
327 VarInit *IterVar = IR.IterVar;
328 TypedInit *IVal = dyn_cast(IR.IterValue);
330329 if (!IVal)
331330 return Error(Loc, "foreach iterator value is untyped");
332331
18061805 assert(!IterType && "Type already initialized?");
18071806 IterType = IntRecTy::get();
18081807 std::vector Values;
1809 for (unsigned i = 0, e = Ranges.size(); i != e; ++i)
1810 Values.push_back(IntInit::get(Ranges[i]));
1808 for (unsigned R : Ranges)
1809 Values.push_back(IntInit::get(R));
18111810 ForeachListValue = ListInit::get(Values, IterType);
18121811 }
18131812
19331932 /// \brief Apply the current let bindings to \a CurRec.
19341933 /// \returns true on error, false otherwise.
19351934 bool TGParser::ApplyLetStack(Record *CurRec) {
1936 for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
1937 for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
1938 if (SetValue(CurRec, LetStack[i][j].Loc, LetStack[i][j].Name,
1939 LetStack[i][j].Bits, LetStack[i][j].Value))
1935 for (std::vector &LetInfo : LetStack)
1936 for (LetRecord &LR : LetInfo)
1937 if (SetValue(CurRec, LR.Loc, LR.Name, LR.Bits, LR.Value))
19401938 return true;
19411939 return false;
19421940 }