llvm.org GIT mirror llvm / 2d07ebf
[FileCheck] Use range-based for loops. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247272 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 4 years ago
1 changed file(s) with 14 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
398398 TmpStr = RegExStr;
399399
400400 unsigned InsertOffset = 0;
401 for (unsigned i = 0, e = VariableUses.size(); i != e; ++i) {
401 for (const auto &VariableUse : VariableUses) {
402402 std::string Value;
403403
404 if (VariableUses[i].first[0] == '@') {
405 if (!EvaluateExpression(VariableUses[i].first, Value))
404 if (VariableUse.first[0] == '@') {
405 if (!EvaluateExpression(VariableUse.first, Value))
406406 return StringRef::npos;
407407 } else {
408408 StringMap::iterator it =
409 VariableTable.find(VariableUses[i].first);
409 VariableTable.find(VariableUse.first);
410410 // If the variable is undefined, return an error.
411411 if (it == VariableTable.end())
412412 return StringRef::npos;
416416 }
417417
418418 // Plop it into the regex at the adjusted offset.
419 TmpStr.insert(TmpStr.begin()+VariableUses[i].second+InsertOffset,
419 TmpStr.insert(TmpStr.begin() + VariableUse.second + InsertOffset,
420420 Value.begin(), Value.end());
421421 InsertOffset += Value.size();
422422 }
435435 StringRef FullMatch = MatchInfo[0];
436436
437437 // If this defines any variables, remember their values.
438 for (std::map::const_iterator I = VariableDefs.begin(),
439 E = VariableDefs.end();
440 I != E; ++I) {
441 assert(I->second < MatchInfo.size() && "Internal paren error");
442 VariableTable[I->first] = MatchInfo[I->second];
438 for (const auto &VariableDef : VariableDefs) {
439 assert(VariableDef.second < MatchInfo.size() && "Internal paren error");
440 VariableTable[VariableDef.first] = MatchInfo[VariableDef.second];
443441 }
444442
445443 MatchLen = FullMatch.size();
469467 // If this was a regular expression using variables, print the current
470468 // variable values.
471469 if (!VariableUses.empty()) {
472 for (unsigned i = 0, e = VariableUses.size(); i != e; ++i) {
470 for (const auto &VariableUse : VariableUses) {
473471 SmallString<256> Msg;
474472 raw_svector_ostream OS(Msg);
475 StringRef Var = VariableUses[i].first;
473 StringRef Var = VariableUse.first;
476474 if (Var[0] == '@') {
477475 std::string Value;
478476 if (EvaluateExpression(Var, Value)) {
760758 CheckTy = Check::CheckNone;
761759 CheckLoc = StringRef::npos;
762760
763 for (prefix_iterator I = CheckPrefixes.begin(), E = CheckPrefixes.end();
764 I != E; ++I) {
765 StringRef Prefix(*I);
761 for (StringRef Prefix : CheckPrefixes) {
766762 size_t PrefixLoc = Buffer.find(Prefix);
767763
768764 if (PrefixLoc == StringRef::npos)
11451141 bool CheckString::CheckNot(const SourceMgr &SM, StringRef Buffer,
11461142 const std::vector &NotStrings,
11471143 StringMap &VariableTable) const {
1148 for (unsigned ChunkNo = 0, e = NotStrings.size();
1149 ChunkNo != e; ++ChunkNo) {
1150 const Pattern *Pat = NotStrings[ChunkNo];
1144 for (const Pattern *Pat : NotStrings) {
11511145 assert((Pat->getCheckTy() == Check::CheckNot) && "Expect CHECK-NOT!");
11521146
11531147 size_t MatchLen = 0;
11751169 size_t LastPos = 0;
11761170 size_t StartPos = LastPos;
11771171
1178 for (unsigned ChunkNo = 0, e = DagNotStrings.size();
1179 ChunkNo != e; ++ChunkNo) {
1180 const Pattern &Pat = DagNotStrings[ChunkNo];
1181
1172 for (const Pattern &Pat : DagNotStrings) {
11821173 assert((Pat.getCheckTy() == Check::CheckDAG ||
11831174 Pat.getCheckTy() == Check::CheckNot) &&
11841175 "Invalid CHECK-DAG or CHECK-NOT!");
12521243 static bool ValidateCheckPrefixes() {
12531244 StringSet<> PrefixSet;
12541245
1255 for (prefix_iterator I = CheckPrefixes.begin(), E = CheckPrefixes.end();
1256 I != E; ++I) {
1257 StringRef Prefix(*I);
1258
1246 for (StringRef Prefix : CheckPrefixes) {
12591247 // Reject empty prefixes.
12601248 if (Prefix == "")
12611249 return false;