diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index 8b30fd709dd..147fd5c9b9b 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -1100,8 +1100,8 @@ bool MatchableInfo::validate(StringRef CommentDelimiter, bool IsAlias) const { static std::string getEnumNameForToken(StringRef Str) { std::string Res; - for (StringRef::iterator it = Str.begin(), ie = Str.end(); it != ie; ++it) { - switch (*it) { + for (char C : Str) { + switch (C) { case '*': Res += "_STAR_"; break; case '%': Res += "_PCT_"; break; case ':': Res += "_COLON_"; break; @@ -1112,10 +1112,10 @@ static std::string getEnumNameForToken(StringRef Str) { case '-': Res += "_MINUS_"; break; case '#': Res += "_HASH_"; break; default: - if (isAlnum(*it)) - Res += *it; + if (isAlnum(C)) + Res += C; else - Res += "_" + utostr((unsigned) *it) + "_"; + Res += "_" + utostr((unsigned)C) + "_"; } } diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 53bf953b13c..3b77f09d9b7 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -461,9 +461,7 @@ void CodeEmitterGen::run(raw_ostream &o) { std::map> CaseMap; // Construct all cases statement for each opcode - for (std::vector::iterator IC = Insts.begin(), EC = Insts.end(); - IC != EC; ++IC) { - Record *R = *IC; + for (Record *R : Insts) { if (R->getValueAsString("Namespace") == "TargetOpcode" || R->getValueAsBit("isPseudo")) continue; diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index 01a6335a163..669b3d367fd 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/utils/TableGen/CodeGenDAGPatterns.cpp @@ -4032,8 +4032,7 @@ void CodeGenDAGPatterns::InferInstructionFlags() { /// Verify instruction flags against pattern node properties. void CodeGenDAGPatterns::VerifyInstructionFlags() { unsigned Errors = 0; - for (ptm_iterator I = ptm_begin(), E = ptm_end(); I != E; ++I) { - const PatternToMatch &PTM = *I; + for (const PatternToMatch &PTM : ptms()) { SmallVector Instrs; getInstructionsInTree(PTM.getDstPattern(), Instrs); if (Instrs.empty()) diff --git a/utils/TableGen/CodeGenRegisters.h b/utils/TableGen/CodeGenRegisters.h index f1712d663dd..6a0696011a4 100644 --- a/utils/TableGen/CodeGenRegisters.h +++ b/utils/TableGen/CodeGenRegisters.h @@ -738,9 +738,8 @@ namespace llvm { // Get the sum of unit weights. unsigned getRegUnitSetWeight(const std::vector &Units) const { unsigned Weight = 0; - for (std::vector::const_iterator - I = Units.begin(), E = Units.end(); I != E; ++I) - Weight += getRegUnit(*I).Weight; + for (unsigned Unit : Units) + Weight += getRegUnit(Unit).Weight; return Weight; } diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index 32ed0bf9874..b9762f9972a 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -153,9 +153,8 @@ void DAGISelEmitter::run(raw_ostream &OS) { // Add all the patterns to a temporary list so we can sort them. Records.startTimer("Sort patterns"); std::vector Patterns; - for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(), E = CGP.ptm_end(); - I != E; ++I) - Patterns.push_back(&*I); + for (const PatternToMatch &PTM : CGP.ptms()) + Patterns.push_back(&PTM); // We want to process the matches in order of minimal cost. Sort the patterns // so the least cost one is at the start. diff --git a/utils/TableGen/SubtargetEmitter.cpp b/utils/TableGen/SubtargetEmitter.cpp index 7d2b4b929df..94cde1c12b8 100644 --- a/utils/TableGen/SubtargetEmitter.cpp +++ b/utils/TableGen/SubtargetEmitter.cpp @@ -179,8 +179,8 @@ void SubtargetEmitter::Enumeration(raw_ostream &OS, static void printFeatureMask(raw_ostream &OS, RecVec &FeatureList, const DenseMap &FeatureMap) { std::array Mask = {}; - for (unsigned j = 0, M = FeatureList.size(); j < M; ++j) { - unsigned Bit = FeatureMap.lookup(FeatureList[j]); + for (const Record *Feature : FeatureList) { + unsigned Bit = FeatureMap.lookup(Feature); Mask[Bit / 64] |= 1ULL << (Bit % 64); } @@ -215,10 +215,8 @@ unsigned SubtargetEmitter::FeatureKeyValues( // For each feature unsigned NumFeatures = 0; - for (unsigned i = 0, N = FeatureList.size(); i < N; ++i) { + for (const Record *Feature : FeatureList) { // Next feature - Record *Feature = FeatureList[i]; - StringRef Name = Feature->getName(); StringRef CommandLineName = Feature->getValueAsString("Name"); StringRef Desc = Feature->getValueAsString("Desc");