diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 33aeda69c..b20a3b184 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -974,9 +974,7 @@ std::ostream& operator<<(std::ostream& os, const V3Hash& rhs) { V3Hash::V3Hash(const string& name) { uint32_t val = 0; - for (string::const_iterator it = name.begin(); it != name.end(); ++it) { - val = val * 31 + *it; - } + for (const auto& c : name) val = val * 31 + c; setBoth(1, val); } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 2e7ee6406..4762b37fe 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -632,9 +632,7 @@ AstVar* AstVar::scVarRecurse(AstNode* nodep) { string AstVar::mtasksString() const { std::ostringstream os; os << "all: "; - for (MTaskIdSet::const_iterator it = m_mtaskIds.begin(); it != m_mtaskIds.end(); ++it) { - os << *it << " "; - } + for (const auto& id : m_mtaskIds) os << id << " "; return os.str(); } diff --git a/src/V3Config.cpp b/src/V3Config.cpp index d801d901b..ba2acd323 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -170,10 +170,7 @@ public: void update(const V3ConfigModule& m) { m_tasks.update(m.m_tasks); m_vars.update(m.m_vars); - for (StringSet::const_iterator it = m.m_coverageOffBlocks.begin(); - it != m.m_coverageOffBlocks.end(); ++it) { - m_coverageOffBlocks.insert(*it); - } + for (const string& i : m.m_coverageOffBlocks) m_coverageOffBlocks.insert(i); if (!m_inline) { m_inline = m.m_inline; m_inlineValue = m.m_inlineValue; @@ -210,9 +207,8 @@ public: void applyBlock(AstNodeBlock* nodep) { AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF; if (!nodep->unnamed()) { - for (StringSet::const_iterator it = m_coverageOffBlocks.begin(); - it != m_coverageOffBlocks.end(); ++it) { - if (VString::wildmatch(nodep->name(), *it)) { + for (const string& i : m_coverageOffBlocks) { + if (VString::wildmatch(nodep->name(), i)) { nodep->addStmtsp(new AstPragma(nodep->fileline(), pragma)); } } diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 8dae74a3c..b93b4ef8b 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -2013,8 +2013,7 @@ private: bool inPct = false; AstNode* argp = nodep->exprsp(); string text = nodep->text(); - for (string::const_iterator it = text.begin(); it != text.end(); ++it) { - char ch = *it; + for (const char ch : text) { if (!inPct && ch == '%') { inPct = true; fmt = ch; diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index cb862c6c5..e73709d7a 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -2828,10 +2828,7 @@ void EmitCStmts::emitVarSort(const VarSortMap& vmap, VarVec* sortedp) { for (VarSortMap::const_iterator it = vmap.begin(); it != vmap.end(); ++it) { int size_class = it->first; const VarVec& vec = it->second; - for (VarVec::const_iterator jt = vec.begin(); jt != vec.end(); ++jt) { - const AstVar* varp = *jt; - m2v[varp->mtaskIds()][size_class].push_back(varp); - } + for (const AstVar* varp : vec) { m2v[varp->mtaskIds()][size_class].push_back(varp); } } // Create a TSP sort state for each MTaskIdSet footprint @@ -2908,8 +2905,7 @@ void EmitCStmts::emitSortedVarList(const VarVec& anons, const VarVec& nonanons, } } // Output nonanons - for (VarVec::const_iterator it = nonanons.begin(); it != nonanons.end(); ++it) { - const AstVar* varp = *it; + for (const AstVar* varp : nonanons) { emitVarCmtChg(varp, &curVarCmt); emitVarDecl(varp, prefixIfImp); } diff --git a/src/V3EmitCMake.cpp b/src/V3EmitCMake.cpp index e52f41494..f7f088e3c 100644 --- a/src/V3EmitCMake.cpp +++ b/src/V3EmitCMake.cpp @@ -226,9 +226,7 @@ class CMakeEmitter { } *of << " "; const V3StringList& vFiles = v3Global.opt.vFiles(); - for (V3StringList::const_iterator it = vFiles.begin(); it != vFiles.end(); ++it) { - *of << V3Os::filenameRealPath(*it); - } + for (const string& i : vFiles) *of << V3Os::filenameRealPath(i); *of << " VERILATOR_ARGS "; *of << "-f " << deslash(hblockp->commandArgsFileName(true)) << " -CFLAGS -fPIC" // hierarchical block will be static, but may be linked diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 4b67ba894..f960f50a0 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -193,17 +193,13 @@ public: of.puts("VM_USER_CFLAGS = \\\n"); if (!v3Global.opt.protectLib().empty()) of.puts("\t-fPIC \\\n"); const V3StringList& cFlags = v3Global.opt.cFlags(); - for (V3StringList::const_iterator it = cFlags.begin(); it != cFlags.end(); ++it) { - of.puts("\t" + *it + " \\\n"); - } + for (const string& i : cFlags) of.puts("\t" + i + " \\\n"); of.puts("\n"); of.puts("# User LDLIBS (from -LDFLAGS on Verilator command line)\n"); of.puts("VM_USER_LDLIBS = \\\n"); const V3StringList& ldLibs = v3Global.opt.ldLibs(); - for (V3StringList::const_iterator it = ldLibs.begin(); it != ldLibs.end(); ++it) { - of.puts("\t" + *it + " \\\n"); - } + for (const string& i : ldLibs) of.puts("\t" + i + " \\\n"); of.puts("\n"); V3StringSet dirs; @@ -236,8 +232,7 @@ public: of.puts("\n### Executable rules... (from --exe)\n"); of.puts("VPATH += $(VM_USER_DIR)\n"); of.puts("\n"); - for (V3StringSet::const_iterator it = cppFiles.begin(); it != cppFiles.end(); ++it) { - string cppfile = *it; + for (const string& cppfile : cppFiles) { string basename = V3Os::filenameNonExt(cppfile); // NOLINTNEXTLINE(performance-inefficient-string-concatenation) of.puts(basename + ".o: " + cppfile + "\n"); @@ -292,22 +287,17 @@ class EmitMkHierVerilation { of.puts("VM_HIER_VERILATOR := " + perl_wrapper + "\n"); of.puts("VM_HIER_INPUT_FILES := \\\n"); const V3StringList& vFiles = v3Global.opt.vFiles(); - for (V3StringList::const_iterator it = vFiles.begin(); it != vFiles.end(); ++it) { - of.puts("\t" + V3Os::filenameRealPath(*it) + " \\\n"); - } + for (const string& i : vFiles) of.puts("\t" + V3Os::filenameRealPath(i) + " \\\n"); of.puts("\n"); const V3StringSet& libraryFiles = v3Global.opt.libraryFiles(); of.puts("VM_HIER_VERILOG_LIBS := \\\n"); - for (V3StringSet::const_iterator it = libraryFiles.begin(); it != libraryFiles.end(); - ++it) { - of.puts("\t" + V3Os::filenameRealPath(*it) + " \\\n"); + for (const string& i : libraryFiles) { + of.puts("\t" + V3Os::filenameRealPath(i) + " \\\n"); } of.puts("\n"); } void emitOpts(V3OutMkFile& of, const V3StringList& opts) const { - for (V3StringList::const_iterator it = opts.begin(); it != opts.end(); ++it) { - of.puts("\t\t" + *it + " \\\n"); - } + for (const string& i : opts) { of.puts("\t\t" + i + " \\\n"); } } void emitLaunchVerilator(V3OutMkFile& of, const string& argsFile) const { of.puts("\t@$(MAKE) -C $(VM_HIER_RUN_DIR) -f " + m_makefile diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index c2b0f505f..f4702998f 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -421,16 +421,16 @@ class EmitVBaseVisitor : public EmitCBaseVisitor { // %k Potential line break bool inPct = false; putbs(""); - for (string::const_iterator pos = format.begin(); pos != format.end(); ++pos) { - if (pos[0] == '%') { + for (const char c : format) { + if (c == '%') { inPct = true; } else if (!inPct) { // Normal text string s; - s += pos[0]; + s += c; puts(s); } else { // Format character inPct = false; - switch (*pos) { + switch (c) { case '%': puts("%"); break; case 'f': putfs(nodep, ""); break; case 'k': putbs(""); break; @@ -459,7 +459,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor { iterateAndNextNull(nodep->dtypep()); break; } - default: nodep->v3fatalSrc("Unknown emitVerilog format code: %" << pos[0]); break; + default: nodep->v3fatalSrc("Unknown emitVerilog format code: %" << c); break; } } } diff --git a/src/V3File.cpp b/src/V3File.cpp index b3df18c1a..646c9ba75 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -828,14 +828,12 @@ void V3OutFormatter::putsQuoted(const string& strg) { // Don't use to quote a filename for #include - #include doesn't \ escape. putcNoTracking('"'); string quoted = quoteNameControls(strg); - for (string::const_iterator cp = quoted.begin(); cp != quoted.end(); ++cp) { - putcNoTracking(*cp); - } + for (const char c : quoted) putcNoTracking(c); putcNoTracking('"'); } void V3OutFormatter::putsNoTracking(const string& strg) { // Don't track {}'s, probably because it's a $display format string - for (string::const_iterator cp = strg.begin(); cp != strg.end(); ++cp) putcNoTracking(*cp); + for (const char c : strg) putcNoTracking(c); } void V3OutFormatter::putcNoTracking(char chr) { @@ -864,43 +862,43 @@ string V3OutFormatter::quoteNameControls(const string& namein, V3OutFormatter::L string out; if (lang == LA_XML) { // Encode chars into XML string - for (string::const_iterator pos = namein.begin(); pos != namein.end(); ++pos) { - if (pos[0] == '"') { + for (const char c : namein) { + if (c == '"') { out += string("""); - } else if (pos[0] == '\'') { + } else if (c == '\'') { out += string("'"); - } else if (pos[0] == '<') { + } else if (c == '<') { out += string("<"); - } else if (pos[0] == '>') { + } else if (c == '>') { out += string(">"); - } else if (pos[0] == '&') { + } else if (c == '&') { out += string("&"); - } else if (isprint(pos[0])) { - out += pos[0]; + } else if (isprint(c)) { + out += c; } else { char decimal[10]; - sprintf(decimal, "&#%u;", (unsigned char)pos[0]); + sprintf(decimal, "&#%u;", (unsigned char)c); out += decimal; } } } else { // Encode control chars into C style escapes - for (string::const_iterator pos = namein.begin(); pos != namein.end(); ++pos) { - if (pos[0] == '\\' || pos[0] == '"') { - out += string("\\") + pos[0]; - } else if (pos[0] == '\n') { + for (const char c : namein) { + if (c == '\\' || c == '"') { + out += string("\\") + c; + } else if (c == '\n') { out += "\\n"; - } else if (pos[0] == '\r') { + } else if (c == '\r') { out += "\\r"; - } else if (pos[0] == '\t') { + } else if (c == '\t') { out += "\\t"; - } else if (isprint(pos[0])) { - out += pos[0]; + } else if (isprint(c)) { + out += c; } else { // This will also cover \a etc // Can't use %03o as messes up when signed char octal[10]; - sprintf(octal, "\\%o%o%o", (pos[0] >> 6) & 3, (pos[0] >> 3) & 7, pos[0] & 7); + sprintf(octal, "\\%o%o%o", (c >> 6) & 3, (c >> 3) & 7, c & 7); out += octal; } } @@ -937,9 +935,7 @@ V3OutFile::~V3OutFile() { void V3OutFile::putsForceIncs() { const V3StringList& forceIncs = v3Global.opt.forceIncs(); - for (V3StringList::const_iterator it = forceIncs.begin(); it != forceIncs.end(); ++it) { - puts("#include \"" + *it + "\"\n"); - } + for (const string& i : forceIncs) { puts("#include \"" + i + "\"\n"); } } void V3OutCFile::putsGuard() { diff --git a/src/V3Global.cpp b/src/V3Global.cpp index 7faf26c5d..914ac440b 100644 --- a/src/V3Global.cpp +++ b/src/V3Global.cpp @@ -52,8 +52,7 @@ void V3Global::readFiles() { V3Parse parser(v3Global.rootp(), &filter, &parseSyms); // Read top module const V3StringList& vFiles = v3Global.opt.vFiles(); - for (V3StringList::const_iterator it = vFiles.begin(); it != vFiles.end(); ++it) { - string filename = *it; + for (const string& filename : vFiles) { parser.parseFile(new FileLine(FileLine::commandLineFilename()), filename, false, "Cannot find file containing module: "); } @@ -62,8 +61,7 @@ void V3Global::readFiles() { // To be compatible with other simulators, // this needs to be done after the top file is read const V3StringSet& libraryFiles = v3Global.opt.libraryFiles(); - for (V3StringSet::const_iterator it = libraryFiles.begin(); it != libraryFiles.end(); ++it) { - string filename = *it; + for (const string& filename : libraryFiles) { parser.parseFile(new FileLine(FileLine::commandLineFilename()), filename, true, "Cannot find file containing library module: "); } diff --git a/src/V3GraphAlg.cpp b/src/V3GraphAlg.cpp index 560f475df..504c719cf 100644 --- a/src/V3GraphAlg.cpp +++ b/src/V3GraphAlg.cpp @@ -505,10 +505,7 @@ void V3Graph::sortEdges() { // We know the vector contains all of the edges that were // there originally (didn't delete or add) vertexp->outUnlink(); - for (std::vector::const_iterator it = edges.begin(); it != edges.end(); - ++it) { - (*it)->outPushBack(); - } + for (V3GraphEdge* edgep : edges) edgep->outPushBack(); // Prep for next edges.clear(); } diff --git a/src/V3GraphDfa.cpp b/src/V3GraphDfa.cpp index 40fcaadee..9d2eeb203 100644 --- a/src/V3GraphDfa.cpp +++ b/src/V3GraphDfa.cpp @@ -133,11 +133,7 @@ private: uint32_t hashDfaOrigins(const DfaStates& nfasWithInput) { // Find the NFA states this dfa came from, uint32_t hash = 0; - for (DfaStates::const_iterator nfaIt = nfasWithInput.begin(); nfaIt != nfasWithInput.end(); - ++nfaIt) { - DfaVertex* nfaStatep = *nfaIt; - hash ^= hashVertex(nfaStatep); - } + for (DfaVertex* nfaStatep : nfasWithInput) hash ^= hashVertex(nfaStatep); return hash; } @@ -147,9 +143,7 @@ private: nextStep(); // Mark all input vertexes int num1s = 0; - for (DfaStates::const_iterator nfaIt = nfasWithInput.begin(); nfaIt != nfasWithInput.end(); - ++nfaIt) { - DfaVertex* nfaStatep = *nfaIt; + for (DfaVertex* nfaStatep : nfasWithInput) { nfaStatep->user(m_step); num1s++; } diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index 39435e078..571fdeaf7 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -91,14 +91,10 @@ static string V3HierCommandArgsFileName(const string& prefix, bool forCMake) { static void V3HierWriteCommonInputs(std::ostream* of, bool forCMake) { if (!forCMake) { const V3StringList& vFiles = v3Global.opt.vFiles(); - for (V3StringList::const_iterator it = vFiles.begin(); it != vFiles.end(); ++it) { - *of << *it << "\n"; - } + for (const string& i : vFiles) *of << i << "\n"; } const V3StringSet& libraryFiles = v3Global.opt.libraryFiles(); - for (V3StringSet::const_iterator it = libraryFiles.begin(); it != libraryFiles.end(); ++it) { - *of << "-v " << *it << "\n"; - } + for (const string& i : libraryFiles) *of << "-v " << i << "\n"; } //###################################################################### @@ -211,9 +207,7 @@ void V3HierBlock::writeCommandArgsFile(bool forCMake) const { *of << "-Mdir " << v3Global.opt.makeDir() << "/" << hierPrefix() << " \n"; V3HierWriteCommonInputs(of.get(), forCMake); const V3StringList& commandOpts = commandArgs(false); - for (V3StringList::const_iterator it = commandOpts.begin(); it != commandOpts.end(); ++it) { - *of << (*it) << "\n"; - } + for (const string& opt : commandOpts) *of << opt << "\n"; *of << hierBlockArgs().front() << "\n"; for (HierBlockSet::const_iterator child = m_children.begin(); child != m_children.end(); ++child) { @@ -262,9 +256,7 @@ class HierBlockUsageCollectVisitor : public AstNVisitor { if (nodep->hierBlock()) { m_planp->add(nodep, m_gparams); - for (ModuleSet::const_iterator it = m_referred.begin(); it != m_referred.end(); ++it) { - m_planp->registerUsage(nodep, *it); - } + for (const AstModule* modp : m_referred) m_planp->registerUsage(nodep, modp); m_hierBlockp = prevHierBlockp; m_referred = prevReferred; } @@ -406,9 +398,7 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const { V3HierWriteCommonInputs(of.get(), forCMake); if (!forCMake) { const V3StringSet& cppFiles = v3Global.opt.cppFiles(); - for (V3StringSet::const_iterator it = cppFiles.begin(); it != cppFiles.end(); ++it) { - *of << *it << "\n"; - } + for (const string& i : cppFiles) *of << i << "\n"; *of << "--top-module " << v3Global.rootp()->topModulep()->name() << "\n"; *of << "--prefix " << v3Global.opt.prefix() << "\n"; *of << "-Mdir " << v3Global.opt.makeDir() << "\n"; diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index 410e87229..8b6a7d7e7 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -61,8 +61,7 @@ void V3LinkLevel::modSortByLevel() { << "... Suggest see manual; fix the duplicates, or use " "--top-module to select top." << V3Error::warnContextNone()); - for (ModVec::const_iterator it = tops.begin(); it != tops.end(); ++it) { - AstNode* alsop = *it; + for (AstNode* alsop : tops) { std::cout << secp->warnMore() << "... Top module " << alsop->prettyNameQ() << endl << alsop->warnContextSecondary(); } @@ -74,17 +73,13 @@ void V3LinkLevel::modSortByLevel() { // Reorder the netlist's modules to have modules in level sorted order stable_sort(mods.begin(), mods.end(), CmpLevel()); // Sort the vector UINFO(9, "modSortByLevel() sorted\n"); // Comment required for gcc4.6.3 / bug666 - for (ModVec::const_iterator it = mods.begin(); it != mods.end(); ++it) { - AstNodeModule* nodep = *it; + for (AstNodeModule* nodep : mods) { nodep->clearIter(); // Because we didn't iterate to find the node // pointers, may have a stale m_iterp() needing cleanup nodep->unlinkFrBack(); } UASSERT_OBJ(!v3Global.rootp()->modulesp(), v3Global.rootp(), "Unlink didn't work"); - for (ModVec::const_iterator it = mods.begin(); it != mods.end(); ++it) { - AstNodeModule* nodep = *it; - v3Global.rootp()->addModulep(nodep); - } + for (AstNodeModule* nodep : mods) v3Global.rootp()->addModulep(nodep); UINFO(9, "modSortByLevel() done\n"); // Comment required for gcc4.6.3 / bug666 V3Global::dumpCheckGlobalTree("cells", false, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } @@ -105,8 +100,7 @@ void V3LinkLevel::timescaling(const ModVec& mods) { if (unit.isNone()) unit = VTimescale(VTimescale::TS_DEFAULT); v3Global.rootp()->timeunit(unit); - for (ModVec::const_iterator it = mods.begin(); it != mods.end(); ++it) { - AstNodeModule* nodep = *it; + for (AstNodeModule* nodep : mods) { if (nodep->timeunit().isNone()) { if (modTimedp && !VN_IS(nodep, Iface) && !(VN_IS(nodep, Package) && VN_CAST(nodep, Package)->isDollarUnit())) { diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index f6db3f3f6..b5ad3db70 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -304,8 +304,7 @@ private: bool inPct = false; bool inIgnore = false; string fmt; - for (string::const_iterator it = format.begin(); it != format.end(); ++it) { - char ch = *it; + for (const char ch : format) { if (!inPct && ch == '%') { inPct = true; inIgnore = false; diff --git a/src/V3Options.cpp b/src/V3Options.cpp index ab01ce3ca..109c788cb 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -385,10 +385,9 @@ void V3Options::addArg(const string& arg) { m_impp->m_allArgs.push_back(arg); } string V3Options::allArgsString() const { string out; - for (std::list::const_iterator it = m_impp->m_allArgs.begin(); - it != m_impp->m_allArgs.end(); ++it) { + for (const string& i : m_impp->m_allArgs) { if (out != "") out += " "; - out += *it; + out += i; } return out; } @@ -1706,9 +1705,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) { // Convert to argv style arg list and parse them std::vector argv; argv.reserve(args.size() + 1); - for (std::vector::const_iterator it = args.begin(); it != args.end(); ++it) { - argv.push_back(const_cast(it->c_str())); - } + for (const string& i : args) argv.push_back(const_cast(i.c_str())); argv.push_back(nullptr); // argv is nullptr-terminated parseOptsList(fl, optdir, static_cast(argv.size() - 1), argv.data()); } diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 7828f66fd..96f04b1e6 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -782,15 +782,11 @@ protected: iterateAndNextNull(nodep->ifsp()); - for (ColorSet::const_iterator color = colors.begin(); color != colors.end(); ++color) { - m_addAfter[*color] = clones[*color]->elsesp(); - } + for (const auto& color : colors) m_addAfter[color] = clones[color]->elsesp(); iterateAndNextNull(nodep->elsesp()); - for (ColorSet::const_iterator color = colors.begin(); color != colors.end(); ++color) { - m_addAfter[*color] = clones[*color]; - } + for (const auto& color : colors) m_addAfter[color] = clones[color]; } private: @@ -803,8 +799,7 @@ class RemovePlaceholdersVisitor : public AstNVisitor { public: explicit RemovePlaceholdersVisitor(AstNode* nodep) { iterate(nodep); - for (NodeSet::const_iterator it = m_removeSet.begin(); it != m_removeSet.end(); ++it) { - AstNode* np = *it; + for (AstNode* np : m_removeSet) { np->unlinkFrBack(); // Without next VL_DO_DANGLING(np->deleteTree(), np); } diff --git a/src/V3StatsReport.cpp b/src/V3StatsReport.cpp index d16f8df40..fcbe55dd7 100644 --- a/src/V3StatsReport.cpp +++ b/src/V3StatsReport.cpp @@ -135,12 +135,10 @@ class StatsReport { // Header os << " Stat " << std::left << std::setw(maxWidth - 5 - 2) << ""; - for (Stages::const_iterator it = stages.begin(); it != stages.end(); ++it) { - os << " " << std::left << std::setw(9) << *it; - } + for (const string& i : stages) os << " " << std::left << std::setw(9) << i; os << endl; os << " -------- " << std::left << std::setw(maxWidth - 5 - 2) << ""; - for (Stages::const_iterator it = stages.begin(); it != stages.end(); ++it) { + for (auto it = stages.begin(); it != stages.end(); ++it) { os << " " << std::left << std::setw(9) << "-------"; } // os<::const_iterator it = result.begin(); it != result.end(); ++it) { - cout << *it << " "; - } + for (const string& i : result) cout << i << " "; cout << endl; v3fatalSrc("TSP string self-test fail. Result (above) did not match expectation."); } diff --git a/src/V3Waiver.cpp b/src/V3Waiver.cpp index aedb42391..6cfa87687 100644 --- a/src/V3Waiver.cpp +++ b/src/V3Waiver.cpp @@ -47,10 +47,7 @@ void V3Waiver::write(const std::string& filename) { if (s_waiverList.size() == 0) { *ofp << "// No waivers needed - great!" << endl; } - for (V3Waiver::WaiverList::const_iterator it = s_waiverList.begin(); it != s_waiverList.end(); - ++it) { - *ofp << "// " << *it << std::endl << endl; - } + for (const auto& i : s_waiverList) *ofp << "// " << i << std::endl << endl; } V3Waiver::WaiverList V3Waiver::s_waiverList; diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 70d8197be..9083cb1af 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -3234,8 +3234,7 @@ private: AstNode* argp = nodep->exprsp(); string txt = nodep->text(); string fmt; - for (string::const_iterator it = txt.begin(); it != txt.end(); ++it) { - char ch = *it; + for (char ch : txt) { if (!inPct && ch == '%') { inPct = true; fmt = ch; diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 6244acecb..570f29ff1 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -636,10 +636,8 @@ static string buildMakeCmd(const string& makefile, const string& target) { } else if (jobs > 1) { cmd << " -j " << jobs; } - for (V3StringList::const_iterator it = makeFlags.begin(); it != makeFlags.end(); ++it) { - cmd << ' ' << *it; - } - if (!target.empty()) { cmd << ' ' << target; } + for (const string& flag : makeFlags) cmd << ' ' << flag; + if (!target.empty()) cmd << ' ' << target; return cmd.str(); }