diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 22d2d0333..f4e8f2bd8 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -495,7 +495,7 @@ private: UINFO(3, __FUNCTION__ << ": " << endl); // Trace all sources and sinks - for (int traceDests = 0; traceDests < 2; ++traceDests) { + for (const bool& traceDests : {false, true}) { UINFO(9, " Trace Direction " << (traceDests ? "dst" : "src") << endl); m_graph.userClearVertices(); // user1: bool - was analyzed for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 49dc1a377..29161330b 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -404,11 +404,11 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { VL_RESTORER(m_curOpp); VL_RESTORER(m_leafp); - for (int i = 0; i < 2; ++i) { + for (const bool& right : {false, true}) { Restorer restorer{*this}; LeafInfo leafInfo; m_leafp = &leafInfo; - m_curOpp = i == 0 ? nodep->lhsp() : nodep->rhsp(); + m_curOpp = right ? nodep->rhsp() : nodep->lhsp(); const bool origFailed = m_failed; iterate(m_curOpp); if (leafInfo.m_constp || m_failed) { diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 412773feb..de012617e 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -631,7 +631,7 @@ void EmitCSyms::emitSymImp() { emitSymImpPreamble(); if (v3Global.opt.savable()) { - for (int de = 0; de < 2; ++de) { + for (const bool& de : {false, true}) { const string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize"; const string funcname = de ? "__Vdeserialize" : "__Vserialize"; const string op = de ? ">>" : "<<"; diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 23e89fea8..b27ef2fbb 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -80,7 +80,7 @@ public: of.puts("\n### Object file lists...\n"); for (int support = 0; support < 3; ++support) { - for (int slow = 0; slow < 2; ++slow) { + for (const bool& slow : {false, true}) { if (support == 2) { of.puts("# Global classes, need linked once per executable"); } else if (support) { diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 0bff6bde5..1b9441c0c 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -996,8 +996,7 @@ static V3GraphEdge* partBlastEdgep(GraphWay way, V3GraphEdge* edgep) { // non-transitive edges only ever increase. static void partMergeEdgesFrom(V3Graph* mtasksp, LogicMTask* recipientp, LogicMTask* donorp, V3Scoreboard* sbp) { - for (unsigned wi = 0; wi < 2; ++wi) { - const GraphWay way = wi ? GraphWay::REVERSE : GraphWay::FORWARD; + for (const auto& way : {GraphWay::FORWARD, GraphWay::REVERSE}) { for (V3GraphEdge* edgep = donorp->beginp(way); edgep; edgep = partBlastEdgep(way, edgep)) { MTaskEdge* tedgep = MTaskEdge::cast(edgep); if (sbp && !tedgep->removedFromSb()) sbp->removeElem(tedgep);