From 8ecdc85cf760d98985a28f450ec7f36e2760afe3 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 11 Jul 2021 18:42:01 -0400 Subject: [PATCH] Internals: C++11 style cleanups. No functional change. --- src/V3Active.cpp | 28 ++++++++++----------- src/V3ActiveTop.cpp | 2 +- src/V3Assert.cpp | 2 +- src/V3AssertPre.cpp | 2 +- src/V3Ast.cpp | 2 +- src/V3AstNodes.h | 6 ++--- src/V3Begin.cpp | 2 +- src/V3Branch.cpp | 2 +- src/V3Broken.cpp | 4 +-- src/V3CCtors.cpp | 49 +++++++++++++++++++------------------ src/V3CUse.cpp | 45 ++++++++++++++++++---------------- src/V3Case.cpp | 4 +-- src/V3Cast.cpp | 7 +++--- src/V3Cdc.cpp | 6 ++--- src/V3Changed.cpp | 6 ++--- src/V3Class.cpp | 2 +- src/V3Clean.cpp | 2 +- src/V3Clock.cpp | 2 +- src/V3Combine.cpp | 2 +- src/V3Const.cpp | 55 +++++++++++++++++++++--------------------- src/V3Coverage.cpp | 2 +- src/V3CoverageJoin.cpp | 2 +- src/V3Dead.cpp | 12 ++++----- src/V3Delayed.cpp | 2 +- src/V3Depth.cpp | 12 ++++----- src/V3DepthBlock.cpp | 2 +- src/V3Descope.cpp | 2 +- src/V3DupFinder.cpp | 2 +- src/V3EmitCMain.cpp | 6 ++--- src/V3EmitCMake.cpp | 4 +-- src/V3EmitCModel.cpp | 4 +-- src/V3EmitCSyms.cpp | 6 ++--- src/V3EmitV.cpp | 6 ++--- src/V3EmitXml.cpp | 6 ++--- src/V3Expand.cpp | 2 +- src/V3File.cpp | 6 ++--- src/V3File.h | 6 ++--- src/V3Gate.cpp | 16 ++++++------ src/V3GenClk.cpp | 4 +-- src/V3Global.h | 4 +-- src/V3Graph.cpp | 2 +- src/V3GraphDfa.h | 4 +-- src/V3Hasher.cpp | 4 +-- src/V3HierBlock.cpp | 4 +-- src/V3Inline.cpp | 10 ++++---- src/V3Inst.cpp | 10 ++++---- src/V3InstrCount.cpp | 2 +- src/V3Life.cpp | 6 ++--- src/V3LifePost.cpp | 4 +-- src/V3LinkCells.cpp | 2 +- src/V3LinkDot.cpp | 12 ++++----- src/V3LinkInc.cpp | 2 +- src/V3LinkJump.cpp | 2 +- src/V3LinkLValue.cpp | 4 +-- src/V3LinkParse.cpp | 2 +- src/V3LinkResolve.cpp | 4 +-- src/V3Localize.cpp | 2 +- src/V3MergeCond.cpp | 8 +++--- src/V3Name.cpp | 2 +- src/V3Options.cpp | 2 +- src/V3Order.cpp | 14 +++++------ src/V3Os.cpp | 6 ++--- src/V3Param.cpp | 2 +- src/V3Partition.cpp | 10 ++++---- src/V3Premit.cpp | 2 +- src/V3Randomize.cpp | 4 +-- src/V3Reloop.cpp | 2 +- src/V3Scope.cpp | 4 +-- src/V3Slice.cpp | 2 +- src/V3Split.cpp | 8 +++--- src/V3SplitAs.cpp | 8 +++--- src/V3SplitVar.cpp | 4 +-- src/V3Stats.cpp | 2 +- src/V3StatsReport.cpp | 2 +- src/V3Subst.cpp | 6 ++--- src/V3SymTable.h | 2 +- src/V3TSP.cpp | 2 +- src/V3Table.cpp | 18 +++++++------- src/V3Task.cpp | 8 +++--- src/V3Trace.cpp | 2 +- src/V3TraceDecl.cpp | 2 +- src/V3Tristate.cpp | 6 ++--- src/V3Undriven.cpp | 2 +- src/V3Unknown.cpp | 2 +- src/V3Waiver.cpp | 2 +- src/V3Width.cpp | 16 ++++++------ src/VlcBucket.h | 2 +- src/VlcOptions.h | 8 +++--- src/VlcPoint.h | 2 +- src/VlcTest.h | 2 +- src/VlcTop.cpp | 18 +++++++------- 91 files changed, 300 insertions(+), 294 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index ee7debb29..d00dce620 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -64,9 +64,9 @@ private: public: LatchDetectGraphVertex(V3Graph* graphp, const string& name, VertexType type = VT_BLOCK) - : V3GraphVertex(graphp) - , m_name(name) - , m_type(type) {} + : V3GraphVertex{graphp} + , m_name{name} + , m_type{type} {} virtual string name() const { return m_name + " " + typestr(); } virtual string dotColor() const { return user() ? "green" : "black"; } virtual int type() const { return m_type; } @@ -142,17 +142,17 @@ public: // Add a new control path and connect it to its parent LatchDetectGraphVertex* addPathVertex(LatchDetectGraphVertex* parent, const string& name, bool branch = false) { - m_curVertexp = new LatchDetectGraphVertex(this, name, + m_curVertexp = new LatchDetectGraphVertex{this, name, branch ? LatchDetectGraphVertex::VT_BRANCH - : LatchDetectGraphVertex::VT_BLOCK); - new V3GraphEdge(this, parent, m_curVertexp, 1); + : LatchDetectGraphVertex::VT_BLOCK}; + new V3GraphEdge{this, parent, m_curVertexp, 1}; return m_curVertexp; } // Add a new output variable vertex and store a pointer to it in the user1 field of the // variables AstNode LatchDetectGraphVertex* addOutputVertex(AstVarRef* nodep) { LatchDetectGraphVertex* outVertexp - = new LatchDetectGraphVertex(this, nodep->name(), LatchDetectGraphVertex::VT_OUTPUT); + = new LatchDetectGraphVertex{this, nodep->name(), LatchDetectGraphVertex::VT_OUTPUT}; nodep->varp()->user1p(outVertexp); m_outputs.push_back(nodep); return outVertexp; @@ -437,7 +437,7 @@ private: virtual void visit(AstInitial* nodep) override { // Relink to IACTIVE, unless already under it UINFO(4, " INITIAL " << nodep << endl); - ActiveDlyVisitor dlyvisitor(nodep, ActiveDlyVisitor::CT_INITIAL); + ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; AstActive* wantactivep = m_namer.getIActive(nodep->fileline()); nodep->unlinkFrBack(); wantactivep->addStmtsp(nodep); @@ -470,7 +470,7 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); return; } - ActiveDlyVisitor dlyvisitor(nodep, ActiveDlyVisitor::CT_INITIAL); + ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; if (!m_scopeFinalp) { m_scopeFinalp = new AstCFunc( nodep->fileline(), "_final_" + m_namer.scopep()->nameDotless(), m_namer.scopep()); @@ -540,14 +540,14 @@ private: // Warn and/or convert any delayed assignments if (combo && !sequent) { - ActiveLatchCheckVisitor latchvisitor(nodep, kwd); + ActiveLatchCheckVisitor latchvisitor{nodep, kwd}; if (kwd == VAlwaysKwd::ALWAYS_LATCH) { - ActiveDlyVisitor dlyvisitor(nodep, ActiveDlyVisitor::CT_LATCH); + ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_LATCH}; } else { - ActiveDlyVisitor dlyvisitor(nodep, ActiveDlyVisitor::CT_COMBO); + ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_COMBO}; } } else if (!combo && sequent) { - ActiveDlyVisitor dlyvisitor(nodep, ActiveDlyVisitor::CT_SEQ); + ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_SEQ}; } } virtual void visit(AstAlways* nodep) override { @@ -620,6 +620,6 @@ public: void V3Active::activeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ActiveVisitor visitor(nodep); } // Destruct before checking + { ActiveVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("active", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index 0745c8ed7..6706dc357 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -136,6 +136,6 @@ public: void V3ActiveTop::activeTopAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ActiveTopVisitor visitor(nodep); } // Destruct before checking + { ActiveTopVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("activetop", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 22ae310ba..40aa060da 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -474,6 +474,6 @@ public: void V3Assert::assertAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { AssertVisitor visitor(nodep); } // Destruct before checking + { AssertVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("assert", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index 9049d6146..12bd7fddc 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -205,6 +205,6 @@ public: void V3AssertPre::assertPreAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { AssertPreVisitor visitor(nodep); } // Destruct before checking + { AssertPreVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("assertpre", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 1f87e4586..ae9cb530c 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1124,7 +1124,7 @@ void AstNode::dumpTreeFile(const string& filename, bool append, bool doDump, boo if (doDump) { { // Write log & close UINFO(2, "Dumping " << filename << endl); - const std::unique_ptr logsp(V3File::new_ofstream(filename, append)); + const std::unique_ptr logsp{V3File::new_ofstream(filename, append)}; if (logsp->fail()) v3fatal("Can't write " << filename); *logsp << "Verilator Tree Dump (format 0x3900) from to \n"; diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index f75c67a82..120121d3b 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -8497,9 +8497,9 @@ private: public: AstNodeCoverOrAssert(AstType t, FileLine* fl, AstNode* propp, AstNode* passsp, bool immediate, const string& name = "") - : AstNodeStmt(t, fl) - , m_immediate(immediate) - , m_name(name) { + : AstNodeStmt{t, fl} + , m_immediate{immediate} + , m_name{name} { addOp1p(propp); addNOp4p(passsp); } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index 5bee0a7f4..404b96803 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -308,7 +308,7 @@ void V3Begin::debeginAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { BeginState state; - { BeginVisitor bvisitor(nodep, &state); } + { BeginVisitor bvisitor{nodep, &state}; } if (state.anyFuncInBegin()) { BeginRelinkVisitor brvisitor(nodep, &state); } } // Destruct before checking V3Global::dumpCheckGlobalTree("begin", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); diff --git a/src/V3Branch.cpp b/src/V3Branch.cpp index b1a5de551..ff3413815 100644 --- a/src/V3Branch.cpp +++ b/src/V3Branch.cpp @@ -123,5 +123,5 @@ public: void V3Branch::branchAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - BranchVisitor visitor(nodep); + BranchVisitor visitor{nodep}; } diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index 49190f2eb..a1b081523 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -342,8 +342,8 @@ void V3Broken::brokenAll(AstNetlist* nodep) { UINFO(1, "Broken called under broken, skipping recursion.\n"); // LCOV_EXCL_LINE } else { inBroken = true; - BrokenMarkVisitor mvisitor(nodep); - BrokenCheckVisitor cvisitor(nodep); + BrokenMarkVisitor mvisitor{nodep}; + BrokenCheckVisitor cvisitor{nodep}; s_allocTable.checkForLeaks(); s_linkableTable.clear(); s_brokenCntGlobal.inc(); diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index 2becaa25d..d1b9daba0 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -60,7 +60,7 @@ private: AstCFunc* makeNewFunc() { const int funcNum = m_newFunctions.size(); const string funcName = m_basename + "_" + cvtToStr(funcNum); - AstCFunc* const funcp = new AstCFunc(m_modp->fileline(), funcName, nullptr, "void"); + AstCFunc* const funcp = new AstCFunc{m_modp->fileline(), funcName, nullptr, "void"}; funcp->isStatic(false); funcp->isLoose(!m_type.isClass()); funcp->declPrivate(true); @@ -74,7 +74,7 @@ private: preventUnusedStmt = "if (false && first) {} // Prevent unused\n"; } if (!preventUnusedStmt.empty()) { - funcp->addStmtsp(new AstCStmt(m_modp->fileline(), preventUnusedStmt)); + funcp->addStmtsp(new AstCStmt{m_modp->fileline(), preventUnusedStmt}); } m_modp->addStmtp(funcp); m_numStmts = 0; @@ -91,9 +91,9 @@ public: } V3CCtorsBuilder(AstNodeModule* nodep, const string& basename, VCtorType type) - : m_modp(nodep) + : m_modp{nodep} , m_basename{basename} - , m_type(type) { + , m_type{type} { // Note: The constructor is always called, even if empty, so we must always create at least // one. m_newFunctions.push_back(makeNewFunc()); @@ -108,7 +108,7 @@ public: AstCFunc* const rootFuncp = makeNewFunc(); rootFuncp->name(m_basename); for (AstCFunc* const funcp : m_newFunctions) { - AstCCall* const callp = new AstCCall(m_modp->fileline(), funcp); + AstCCall* const callp = new AstCCall{m_modp->fileline(), funcp}; if (m_type.isClass()) { callp->argTypes("vlSymsp"); } else { @@ -127,8 +127,9 @@ private: //###################################################################### void V3CCtors::evalAsserts() { - AstNodeModule* modp = v3Global.rootp()->modulesp(); // Top module wrapper - AstCFunc* funcp = new AstCFunc(modp->fileline(), "_eval_debug_assertions", nullptr, "void"); + AstNodeModule* const modp = v3Global.rootp()->modulesp(); // Top module wrapper + AstCFunc* const funcp + = new AstCFunc{modp->fileline(), "_eval_debug_assertions", nullptr, "void"}; funcp->declPrivate(true); funcp->isStatic(false); funcp->isLoose(true); @@ -136,7 +137,7 @@ void V3CCtors::evalAsserts() { funcp->ifdef("VL_DEBUG"); modp->addStmtp(funcp); for (AstNode* np = modp->stmtsp(); np; np = np->nextp()) { - if (AstVar* varp = VN_CAST(np, Var)) { + if (AstVar* const varp = VN_CAST(np, Var)) { if (varp->isPrimaryInish() && !varp->isSc()) { if (AstBasicDType* basicp = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) { const int storedWidth = basicp->widthAlignBytes() * 8; @@ -144,22 +145,22 @@ void V3CCtors::evalAsserts() { if (lastWordWidth != 0) { // if (signal & CONST(upper_non_clean_mask)) { fail; } AstVarRef* const vrefp - = new AstVarRef(varp->fileline(), varp, VAccess::READ); + = new AstVarRef{varp->fileline(), varp, VAccess::READ}; vrefp->selfPointer("this"); AstNode* newp = vrefp; if (varp->isWide()) { - newp = new AstWordSel( + newp = new AstWordSel{ varp->fileline(), newp, - new AstConst(varp->fileline(), varp->widthWords() - 1)); + new AstConst(varp->fileline(), varp->widthWords() - 1)}; } - uint64_t value = VL_MASK_Q(storedWidth) & ~VL_MASK_Q(lastWordWidth); - newp = new AstAnd(varp->fileline(), newp, + const uint64_t value = VL_MASK_Q(storedWidth) & ~VL_MASK_Q(lastWordWidth); + newp = new AstAnd{varp->fileline(), newp, new AstConst(varp->fileline(), AstConst::WidthedValue(), - storedWidth, value)); - AstNodeIf* ifp = new AstIf( + storedWidth, value)}; + AstNodeIf* const ifp = new AstIf{ varp->fileline(), newp, - new AstCStmt(varp->fileline(), "Verilated::overWidthError(\"" - + varp->prettyName() + "\");")); + new AstCStmt{varp->fileline(), "Verilated::overWidthError(\"" + + varp->prettyName() + "\");"}}; ifp->branchPred(VBranchPred::BP_UNLIKELY); newp = ifp; funcp->addStmtsp(newp); @@ -177,20 +178,20 @@ void V3CCtors::cctorsAll() { modp = VN_CAST(modp->nextp(), NodeModule)) { // Process each module in turn { - V3CCtorsBuilder var_reset(modp, "_ctor_var_reset", - VN_IS(modp, Class) ? VCtorType::CLASS : VCtorType::MODULE); + V3CCtorsBuilder var_reset{modp, "_ctor_var_reset", + VN_IS(modp, Class) ? VCtorType::CLASS : VCtorType::MODULE}; for (AstNode* np = modp->stmtsp(); np; np = np->nextp()) { if (AstVar* const varp = VN_CAST(np, Var)) { if (!varp->isIfaceParent() && !varp->isIfaceRef() && !varp->noReset()) { - const auto vrefp = new AstVarRef(varp->fileline(), varp, VAccess::WRITE); - var_reset.add(new AstCReset(varp->fileline(), vrefp)); + const auto vrefp = new AstVarRef{varp->fileline(), varp, VAccess::WRITE}; + var_reset.add(new AstCReset{varp->fileline(), vrefp}); } } } } if (v3Global.opt.coverage()) { - V3CCtorsBuilder configure_coverage(modp, "_configure_coverage", VCtorType::COVERAGE); + V3CCtorsBuilder configure_coverage{modp, "_configure_coverage", VCtorType::COVERAGE}; for (AstNode* np = modp->stmtsp(); np; np = np->nextp()) { if (AstCoverDecl* const coverp = VN_CAST(np, CoverDecl)) { np = coverp->backp(); @@ -198,8 +199,8 @@ void V3CCtors::cctorsAll() { } } } - if (AstClass* classp = VN_CAST(modp, Class)) { - AstCFunc* funcp = new AstCFunc(modp->fileline(), "~", nullptr, ""); + if (AstClass* const classp = VN_CAST(modp, Class)) { + AstCFunc* const funcp = new AstCFunc{modp->fileline(), "~", nullptr, ""}; funcp->isDestructor(true); funcp->isStatic(false); // If can be referred to by base pointer, need virtual delete diff --git a/src/V3CUse.cpp b/src/V3CUse.cpp index 3eb65f13e..2964c2b8f 100644 --- a/src/V3CUse.cpp +++ b/src/V3CUse.cpp @@ -55,9 +55,9 @@ private: public: AstCUse* newUse(AstNode* nodep, VUseType useType, const string& name) { - UseString key(useType, name); + UseString key{useType, name}; if (m_didUse.find(key) == m_didUse.end()) { - AstCUse* newp = new AstCUse(nodep->fileline(), useType, name); + AstCUse* const newp = new AstCUse{nodep->fileline(), useType, name}; m_modInsertp->addStmtp(newp); UINFO(8, "Insert " << newp << endl); m_didUse[key] = newp; @@ -123,46 +123,49 @@ class CUseVisitor final : public AstNVisitor { // Module use builders void makeUseCells(AstNodeModule* nodep) { for (AstNode* itemp = nodep->stmtsp(); itemp; itemp = itemp->nextp()) { - if (AstCell* cellp = VN_CAST(itemp, Cell)) { + if (AstCell* const cellp = VN_CAST(itemp, Cell)) { // Currently no include because we include __Syms which has them all m_state.newUse(nodep, VUseType::INT_FWD_CLASS, cellp->modp()->name()); } } } void makeVlToString(AstClass* nodep) { - AstCFunc* funcp = new AstCFunc(nodep->fileline(), "VL_TO_STRING", nullptr, "std::string"); + AstCFunc* const funcp + = new AstCFunc{nodep->fileline(), "VL_TO_STRING", nullptr, "std::string"}; funcp->argTypes("const VlClassRef<" + EmitCBaseVisitor::prefixNameProtect(nodep) + ">& obj"); funcp->isMethod(false); funcp->isConst(false); funcp->isStatic(false); funcp->protect(false); - AstNode* exprp = new AstCMath(nodep->fileline(), "obj ? obj->to_string() : \"null\"", 0); + AstNode* const exprp + = new AstCMath{nodep->fileline(), "obj ? obj->to_string() : \"null\"", 0}; exprp->dtypeSetString(); - funcp->addStmtsp(new AstCReturn(nodep->fileline(), exprp)); + funcp->addStmtsp(new AstCReturn{nodep->fileline(), exprp}); nodep->addStmtp(funcp); } void makeToString(AstClass* nodep) { - AstCFunc* funcp = new AstCFunc(nodep->fileline(), "to_string", nullptr, "std::string"); + AstCFunc* const funcp + = new AstCFunc{nodep->fileline(), "to_string", nullptr, "std::string"}; funcp->isConst(true); funcp->isStatic(false); funcp->protect(false); - AstNode* exprp = new AstCMath(nodep->fileline(), - R"(std::string("'{") + to_string_middle() + "}")", 0); + AstNode* const exprp = new AstCMath{nodep->fileline(), + R"(std::string("'{") + to_string_middle() + "}")", 0}; exprp->dtypeSetString(); - funcp->addStmtsp(new AstCReturn(nodep->fileline(), exprp)); + funcp->addStmtsp(new AstCReturn{nodep->fileline(), exprp}); nodep->addStmtp(funcp); } void makeToStringMiddle(AstClass* nodep) { - AstCFunc* funcp - = new AstCFunc(nodep->fileline(), "to_string_middle", nullptr, "std::string"); + AstCFunc* const funcp + = new AstCFunc{nodep->fileline(), "to_string_middle", nullptr, "std::string"}; funcp->isConst(true); funcp->isStatic(false); funcp->protect(false); - funcp->addStmtsp(new AstCStmt(nodep->fileline(), "std::string out;\n")); + funcp->addStmtsp(new AstCStmt{nodep->fileline(), "std::string out;\n"}); std::string comma; for (AstNode* itemp = nodep->membersp(); itemp; itemp = itemp->nextp()) { - if (auto* varp = VN_CAST(itemp, Var)) { + if (auto* const varp = VN_CAST(itemp, Var)) { if (!varp->isParam()) { string stmt = "out += \""; stmt += comma; @@ -179,7 +182,7 @@ class CUseVisitor final : public AstNVisitor { stmt += itemp->nameProtect(); stmt += ");\n"; nodep->user1(true); // So what we extend dumps this - funcp->addStmtsp(new AstCStmt(nodep->fileline(), stmt)); + funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt}); } } } @@ -190,22 +193,22 @@ class CUseVisitor final : public AstNVisitor { stmt += nodep->extendsp()->dtypep()->nameProtect(); stmt += "::to_string_middle();\n"; nodep->user1(true); // So what we extend dumps this - funcp->addStmtsp(new AstCStmt(nodep->fileline(), stmt)); + funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt}); } - funcp->addStmtsp(new AstCStmt(nodep->fileline(), "return out;\n")); + funcp->addStmtsp(new AstCStmt{nodep->fileline(), "return out;\n"}); nodep->addStmtp(funcp); } // VISITORS virtual void visit(AstNodeModule* nodep) override { if (v3Global.opt.trace()) { - AstCUse* usep + AstCUse* const usep = m_state.newUse(nodep, VUseType::INT_FWD_CLASS, v3Global.opt.traceClassBase()); usep->protect(false); } makeUseCells(nodep); - { CUseDTypeVisitor dtypeVisitor(nodep, m_state); } - if (AstClass* classp = VN_CAST(nodep, Class)) { + { CUseDTypeVisitor dtypeVisitor{nodep, m_state}; } + if (AstClass* const classp = VN_CAST(nodep, Class)) { makeVlToString(classp); makeToString(classp); makeToStringMiddle(classp); @@ -233,7 +236,7 @@ void V3CUse::cUseAll() { modp = VN_CAST(modp->nextp(), NodeModule)) { // Insert under this module; someday we should e.g. make Ast // for each output file and put under that - CUseVisitor visitor(modp); + CUseVisitor visitor{modp}; } V3Global::dumpCheckGlobalTree("cuse", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 23653a592..843f804d3 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -530,10 +530,10 @@ public: void V3Case::caseAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { CaseVisitor visitor(nodep); } // Destruct before checking + { CaseVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("case", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Case::caseLint(AstNodeCase* nodep) { UINFO(4, __FUNCTION__ << ": " << endl); - CaseLintVisitor visitor(nodep); + CaseLintVisitor visitor{nodep}; } diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index c8e5536cf..0406149c8 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -66,7 +66,8 @@ private: AstNRelinker relinkHandle; nodep->unlinkFrBack(&relinkHandle); // - AstCCast* castp = new AstCCast(nodep->fileline(), nodep, needsize, nodep->widthMin()); + AstCCast* const castp + = new AstCCast{nodep->fileline(), nodep, needsize, nodep->widthMin()}; relinkHandle.relink(castp); // if (debug() > 8) castp->dumpTree(cout, "-castins: "); // @@ -103,7 +104,7 @@ private: if (!VN_IS(nodep->backp(), NullCheck)) { AstNRelinker relinkHandle; nodep->unlinkFrBack(&relinkHandle); - AstNode* newp = new AstNullCheck(nodep->fileline(), nodep); + AstNode* const newp = new AstNullCheck{nodep->fileline(), nodep}; relinkHandle.relink(newp); } } @@ -201,6 +202,6 @@ public: void V3Cast::castAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { CastVisitor visitor(nodep); } // Destruct before checking + { CastVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("cast", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index f4e8f2bd8..98b9168c3 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -337,7 +337,7 @@ private: int filelineWidth() { if (!m_filelineWidth) { - CdcWidthVisitor visitor(v3Global.rootp()); + CdcWidthVisitor visitor{v3Global.rootp()}; m_filelineWidth = visitor.maxWidth(); } return m_filelineWidth; @@ -508,7 +508,7 @@ private: const string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc_edges.txt"; - const std::unique_ptr ofp(V3File::new_ofstream(filename)); + const std::unique_ptr ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); *ofp << "Edge Report for " << v3Global.opt.prefix() << '\n'; @@ -758,5 +758,5 @@ public: void V3Cdc::cdcAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - CdcVisitor visitor(nodep); + CdcVisitor visitor{nodep}; } diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index 79e2ad14d..62957bc21 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -129,7 +129,7 @@ private: AstAssign* initp = new AstAssign(m_vscp->fileline(), m_newLvEqnp->cloneTree(true), m_varEqnp->cloneTree(true)); m_statep->m_chgFuncp->addFinalsp(initp); - EmitCBaseCounterVisitor visitor(initp); + EmitCBaseCounterVisitor visitor{initp}; m_statep->m_numStmts += visitor.count(); } @@ -228,7 +228,7 @@ private: void genChangeDet(AstVarScope* vscp) { vscp->v3warn(IMPERFECTSCH, "Imperfect scheduling of variable: " << vscp->prettyNameQ()); - ChangedInsertVisitor visitor(vscp, m_statep); + ChangedInsertVisitor visitor{vscp, m_statep}; } // VISITORS @@ -288,7 +288,7 @@ void V3Changed::changedAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { ChangedState state; - ChangedVisitor visitor(nodep, &state); + ChangedVisitor visitor{nodep, &state}; } // Destruct before checking V3Global::dumpCheckGlobalTree("changed", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Class.cpp b/src/V3Class.cpp index a47b052d1..da29a24c1 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -153,6 +153,6 @@ public: void V3Class::classAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ClassVisitor visitor(nodep); } // Destruct before checking + { ClassVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("class", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index c9087bab7..5afa46e57 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -314,6 +314,6 @@ public: void V3Clean::cleanAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { CleanVisitor visitor(nodep); } // Destruct before checking + { CleanVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("clean", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index ddb20dec0..6bb9a461c 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -435,6 +435,6 @@ public: void V3Clock::clockAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ClockVisitor visitor(nodep); } // Destruct before checking + { ClockVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("clock", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index b5cd7ff20..71582a60f 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -223,6 +223,6 @@ public: void V3Combine::combineAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { CombineVisitor visitor(nodep); } // Destruct before checking + { CombineVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("combine", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 29161330b..858a043fa 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -95,9 +95,9 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { bool m_polarity; int m_bit; BitPolarityEntry(const LeafInfo& info, bool pol, int bit) - : m_info(info) - , m_polarity(pol) - , m_bit(bit) {} + : m_info{info} + , m_polarity{pol} + , m_bit{bit} {} BitPolarityEntry() = default; }; @@ -111,12 +111,12 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { public: explicit Restorer(ConstBitOpTreeVisitor& visitor) - : m_visitor(visitor) - , m_polaritiesSize(visitor.m_bitPolarities.size()) - , m_frozenSize(visitor.m_frozenNodes.size()) - , m_ops(visitor.m_ops) - , m_polarity(visitor.m_polarity) - , m_restore(true) {} + : m_visitor{visitor} + , m_polaritiesSize{visitor.m_bitPolarities.size()} + , m_frozenSize{visitor.m_frozenNodes.size()} + , m_ops{visitor.m_ops} + , m_polarity{visitor.m_polarity} + , m_restore{true} {} ~Restorer() { UASSERT(m_visitor.m_bitPolarities.size() >= m_polaritiesSize, "m_bitPolarities must grow monotorilaclly"); @@ -222,9 +222,9 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { // CONSTRUCTORS VarInfo(ConstBitOpTreeVisitor* parent, AstVarRef* refp) - : m_parentp(parent) - , m_refp(refp) - , m_bitPolarity(refp, refp->isWide() ? VL_EDATASIZE : refp->width()) { + : m_parentp{parent} + , m_refp{refp} + , m_bitPolarity{refp, refp->isWide() ? VL_EDATASIZE : refp->width()} { m_bitPolarity.setAllBitsX(); } }; @@ -482,8 +482,8 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { // CONSTRUCTORS ConstBitOpTreeVisitor(AstNode* nodep, int ops) - : m_ops(ops) - , m_rootp(nodep) { + : m_ops{ops} + , m_rootp{nodep} { // Fill nullptr at [0] because AstVarScope::user4 is 0 by default m_varInfos.push_back(nullptr); CONST_BITOP_RETURN_IF(!isAndTree() && !isOrTree() && !isXorTree(), nodep); @@ -1495,9 +1495,10 @@ private: // -> EXTEND(nodep) // like a AstExtend{$rhsp}, but we need to set the width correctly from base node arg0p->unlinkFrBack(); - AstNode* newp = (VN_IS(nodep, ExtendS) - ? static_cast(new AstExtendS(nodep->fileline(), arg0p)) - : static_cast(new AstExtend(nodep->fileline(), arg0p))); + AstNode* const newp + = (VN_IS(nodep, ExtendS) + ? static_cast(new AstExtendS{nodep->fileline(), arg0p}) + : static_cast(new AstExtend{nodep->fileline(), arg0p})); newp->dtypeFrom(nodep); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); @@ -1713,8 +1714,8 @@ private: // Note only do this (need user4) when m_warn, which is // done as unique visitor AstUser4InUse m_inuser4; - ConstVarMarkVisitor mark(nodep->lhsp()); - ConstVarFindVisitor find(nodep->rhsp()); + ConstVarMarkVisitor mark{nodep->lhsp()}; + ConstVarFindVisitor find{nodep->rhsp()}; if (find.found()) need_temp = true; } if (need_temp) { @@ -3233,7 +3234,7 @@ AstNode* V3Const::constifyParamsEdit(AstNode* nodep) { // Make sure we've sized everything first nodep = V3Width::widthParamsEdit(nodep); - ConstVisitor visitor(ConstVisitor::PROC_PARAMS); + ConstVisitor visitor{ConstVisitor::PROC_PARAMS}; if (AstVar* varp = VN_CAST(nodep, Var)) { // If a var wants to be constified, it's really a param, and // we want the value to be constant. We aren't passed just the @@ -3263,7 +3264,7 @@ AstNode* V3Const::constifyGenerateParamsEdit(AstNode* nodep) { // Make sure we've sized everything first nodep = V3Width::widthGenerateParamsEdit(nodep); - ConstVisitor visitor(ConstVisitor::PROC_GENERATE); + ConstVisitor visitor{ConstVisitor::PROC_GENERATE}; if (AstVar* varp = VN_CAST(nodep, Var)) { // If a var wants to be constified, it's really a param, and // we want the value to be constant. We aren't passed just the @@ -3281,7 +3282,7 @@ void V3Const::constifyAllLint(AstNetlist* nodep) { // Only call from Verilator.cpp, as it uses user#'s UINFO(2, __FUNCTION__ << ": " << endl); { - ConstVisitor visitor(ConstVisitor::PROC_V_WARN); + ConstVisitor visitor{ConstVisitor::PROC_V_WARN}; (void)visitor.mainAcceptEdit(nodep); } // Destruct before checking V3Global::dumpCheckGlobalTree("const", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); @@ -3290,14 +3291,14 @@ void V3Const::constifyAllLint(AstNetlist* nodep) { void V3Const::constifyCpp(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - ConstVisitor visitor(ConstVisitor::PROC_CPP); + ConstVisitor visitor{ConstVisitor::PROC_CPP}; (void)visitor.mainAcceptEdit(nodep); } // Destruct before checking V3Global::dumpCheckGlobalTree("const_cpp", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } AstNode* V3Const::constifyEdit(AstNode* nodep) { - ConstVisitor visitor(ConstVisitor::PROC_V_NOWARN); + ConstVisitor visitor{ConstVisitor::PROC_V_NOWARN}; nodep = visitor.mainAcceptEdit(nodep); return nodep; } @@ -3308,7 +3309,7 @@ void V3Const::constifyAllLive(AstNetlist* nodep) { // IE doesn't prune dead statements, as we need to do some usability checks after this UINFO(2, __FUNCTION__ << ": " << endl); { - ConstVisitor visitor(ConstVisitor::PROC_LIVE); + ConstVisitor visitor{ConstVisitor::PROC_LIVE}; (void)visitor.mainAcceptEdit(nodep); } // Destruct before checking V3Global::dumpCheckGlobalTree("const", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); @@ -3318,14 +3319,14 @@ void V3Const::constifyAll(AstNetlist* nodep) { // Only call from Verilator.cpp, as it uses user#'s UINFO(2, __FUNCTION__ << ": " << endl); { - ConstVisitor visitor(ConstVisitor::PROC_V_EXPENSIVE); + ConstVisitor visitor{ConstVisitor::PROC_V_EXPENSIVE}; (void)visitor.mainAcceptEdit(nodep); } // Destruct before checking V3Global::dumpCheckGlobalTree("const", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } AstNode* V3Const::constifyExpensiveEdit(AstNode* nodep) { - ConstVisitor visitor(ConstVisitor::PROC_V_EXPENSIVE); + ConstVisitor visitor{ConstVisitor::PROC_V_EXPENSIVE}; nodep = visitor.mainAcceptEdit(nodep); return nodep; } diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 2f9524df8..76dd38fd8 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -543,6 +543,6 @@ public: void V3Coverage::coverage(AstNetlist* rootp) { UINFO(2, __FUNCTION__ << ": " << endl); - { CoverageVisitor visitor(rootp); } // Destruct before checking + { CoverageVisitor visitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("coverage", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index f0f30c098..8ceb3ccd5 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -114,6 +114,6 @@ public: void V3CoverageJoin::coverageJoin(AstNetlist* rootp) { UINFO(2, __FUNCTION__ << ": " << endl); - { CoverageJoinVisitor visitor(rootp); } // Destruct before checking + { CoverageJoinVisitor visitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("coveragejoin", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index b08c5e78c..dafc1110c 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -318,7 +318,7 @@ private: // And its children may now be killable too; correct counts // Recurse, as cells may not be directly under the module but in a generate if (!modp->dead()) { // If was dead didn't increment user1's - DeadModVisitor visitor(modp); + DeadModVisitor visitor{modp}; } VL_DO_DANGLING(modp->unlinkFrBack()->deleteTree(), modp); retry = true; @@ -463,31 +463,31 @@ public: void V3Dead::deadifyModules(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor(nodep, false, false, false, false); } // Destruct before checking + { DeadVisitor visitor{nodep, false, false, false, false}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadModules", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } void V3Dead::deadifyDTypes(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor(nodep, false, true, false, false); } // Destruct before checking + { DeadVisitor visitor{nodep, false, true, false, false}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadDtypes", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Dead::deadifyDTypesScoped(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor(nodep, false, true, true, false); } // Destruct before checking + { DeadVisitor visitor{nodep, false, true, true, false}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadDtypesScoped", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Dead::deadifyAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor(nodep, true, true, false, true); } // Destruct before checking + { DeadVisitor visitor{nodep, true, true, false, true}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadAll", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Dead::deadifyAllScoped(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor(nodep, true, true, true, true); } // Destruct before checking + { DeadVisitor visitor{nodep, true, true, true, true}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadAllScoped", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 3e3cd280f..7b4c0f88b 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -510,6 +510,6 @@ public: void V3Delayed::delayedAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DelayedVisitor visitor(nodep); } // Destruct before checking + { DelayedVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("delayed", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index 9aef1f3b6..05110d509 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -53,16 +53,16 @@ private: // if (debug() >= 9) nodep->dumpTree(cout, "deep:"); const string newvarname = (string("__Vdeeptemp") + cvtToStr(m_modp->varNumGetInc())); - AstVar* varp - = new AstVar(nodep->fileline(), AstVarType::STMTTEMP, newvarname, nodep->dtypep()); + AstVar* const varp + = new AstVar{nodep->fileline(), AstVarType::STMTTEMP, newvarname, nodep->dtypep()}; UASSERT_OBJ(m_cfuncp, nodep, "Deep expression not under a function"); m_cfuncp->addInitsp(varp); // Replace node tree with reference to var - AstVarRef* newp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); + AstVarRef* const newp = new AstVarRef{nodep->fileline(), varp, VAccess::READ}; nodep->replaceWith(newp); // Put assignment before the referencing statement - AstAssign* assp = new AstAssign( - nodep->fileline(), new AstVarRef(nodep->fileline(), varp, VAccess::WRITE), nodep); + AstAssign* const assp = new AstAssign{ + nodep->fileline(), new AstVarRef{nodep->fileline(), varp, VAccess::WRITE}, nodep}; AstNRelinker linker2; m_stmtp->unlinkFrBack(&linker2); assp->addNext(m_stmtp); @@ -158,6 +158,6 @@ public: void V3Depth::depthAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DepthVisitor visitor(nodep); } // Destruct before checking + { DepthVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("depth", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3DepthBlock.cpp b/src/V3DepthBlock.cpp index 54a131a75..5fa2c3804 100644 --- a/src/V3DepthBlock.cpp +++ b/src/V3DepthBlock.cpp @@ -129,6 +129,6 @@ public: void V3DepthBlock::depthBlockAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DepthBlockVisitor visitor(nodep); } // Destruct before checking + { DepthBlockVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deepblock", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 9b2e2cf76..fc10d5879 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -266,6 +266,6 @@ public: void V3Descope::descopeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DescopeVisitor visitor(nodep); } // Destruct before checking + { DescopeVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("descope", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3DupFinder.cpp b/src/V3DupFinder.cpp index 061e659db..9b8187f1a 100644 --- a/src/V3DupFinder.cpp +++ b/src/V3DupFinder.cpp @@ -44,7 +44,7 @@ V3DupFinder::iterator V3DupFinder::findDuplicate(AstNode* nodep, V3DupFinderUser } void V3DupFinder::dumpFile(const string& filename, bool tree) { - const std::unique_ptr logp(V3File::new_ofstream(filename)); + const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); std::unordered_map dist; diff --git a/src/V3EmitCMain.cpp b/src/V3EmitCMain.cpp index 493aca407..e4ace105f 100644 --- a/src/V3EmitCMain.cpp +++ b/src/V3EmitCMain.cpp @@ -35,14 +35,14 @@ class EmitCMain final : EmitCBaseVisitor { public: // CONSTRUCTORS - explicit EmitCMain(AstNetlist*) { emitInt(); } + EmitCMain() { emitInt(); } private: // MAIN METHOD void emitInt() { const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__main.cpp"; newCFile(filename, false /*slow*/, true /*source*/); - V3OutCFile cf(filename); + V3OutCFile cf{filename}; m_ofp = &cf; // Not defining main_time/vl_time_stamp, so @@ -101,5 +101,5 @@ private: void V3EmitCMain::emit() { UINFO(2, __FUNCTION__ << ": " << endl); - EmitCMain(v3Global.rootp()); + { EmitCMain visitor; } } diff --git a/src/V3EmitCMake.cpp b/src/V3EmitCMake.cpp index 82ea3c1f8..890634a86 100644 --- a/src/V3EmitCMake.cpp +++ b/src/V3EmitCMake.cpp @@ -78,8 +78,8 @@ class CMakeEmitter final { } static void emitOverallCMake() { - const std::unique_ptr of( - V3File::new_ofstream(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".cmake")); + const std::unique_ptr of{ + V3File::new_ofstream(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".cmake")}; const string name = v3Global.opt.prefix(); *of << "# Verilated -*- CMake -*-\n"; diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index dd0e6a64c..8796a9c4c 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -588,8 +588,8 @@ class EmitCModel final : public EmitCFunc { + "__Dpi_Export_" + cvtToStr(splitFilenumInc() - 1) + ".cpp"; newCFile(filename, /* slow: */ false, /* source: */ true); - m_ofp = v3Global.opt.systemC() ? new V3OutScFile(filename) - : new V3OutCFile(filename); + m_ofp = v3Global.opt.systemC() ? new V3OutScFile{filename} + : new V3OutCFile{filename}; m_lazyDecls.reset(); m_ofp->putsHeader(); puts( diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index de012617e..335f09426 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -670,7 +670,7 @@ void EmitCSyms::emitSymImp() { + topClassName() + "* modelp)\n"); puts(" : VerilatedSyms{contextp}\n"); puts(" // Setup internal state of the Syms class\n"); - puts(" , __Vm_modelp(modelp)\n"); + puts(" , __Vm_modelp{modelp}\n"); if (v3Global.opt.mtasks()) { // TODO -- For now each model creates its own ThreadPool here, @@ -694,9 +694,9 @@ void EmitCSyms::emitSymImp() { // Note we create N-1 threads in the thread pool. The thread // that calls eval() becomes the final Nth thread for the // duration of the eval call. - puts(" , __Vm_threadPoolp(new VlThreadPool(_vm_contextp__, " + puts(" , __Vm_threadPoolp{new VlThreadPool{_vm_contextp__, " + cvtToStr(v3Global.opt.threads() - 1) + ", " + cvtToStr(v3Global.opt.profThreads()) - + "))\n"); + + "}}\n"); } puts(" // Setup module instances\n"); diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index aad3f2348..28d36222f 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -831,7 +831,7 @@ void V3EmitV::verilogForTree(AstNode* nodep, std::ostream& os) { EmitVStreamVisi void V3EmitV::verilogPrefixedTree(AstNode* nodep, std::ostream& os, const string& prefix, int flWidth, AstSenTree* domainp, bool user3mark) { - EmitVPrefixedVisitor(nodep, os, prefix, flWidth, domainp, user3mark); + EmitVPrefixedVisitor{nodep, os, prefix, flWidth, domainp, user3mark}; } void V3EmitV::emitvFiles() { @@ -843,7 +843,7 @@ void V3EmitV::emitvFiles() { V3OutVFile of(vfilep->name()); of.puts("// DESCR" "IPTION: Verilator generated Verilog\n"); - EmitVFileVisitor visitor(vfilep->tblockp(), &of, true, false); + EmitVFileVisitor visitor{vfilep->tblockp(), &of, true, false}; } } } @@ -853,5 +853,5 @@ void V3EmitV::debugEmitV(const string& stage) { const string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__" + stage + ".v"; V3OutVFile of(filename); - EmitVFileVisitor visitor(v3Global.rootp(), &of, true, true); + EmitVFileVisitor visitor{v3Global.rootp(), &of, true, true}; } diff --git a/src/V3EmitXml.cpp b/src/V3EmitXml.cpp index 1e38e5552..c2facba08 100644 --- a/src/V3EmitXml.cpp +++ b/src/V3EmitXml.cpp @@ -392,10 +392,10 @@ void V3EmitXml::emitxml() { } { std::stringstream sstr; - ModuleFilesXmlVisitor moduleFilesVisitor(v3Global.rootp(), sstr); - HierCellsXmlVisitor cellsVisitor(v3Global.rootp(), sstr); + ModuleFilesXmlVisitor moduleFilesVisitor{v3Global.rootp(), sstr}; + HierCellsXmlVisitor cellsVisitor{v3Global.rootp(), sstr}; of.puts(sstr.str()); } - EmitXmlFileVisitor visitor(v3Global.rootp(), &of); + EmitXmlFileVisitor visitor{v3Global.rootp(), &of}; of.puts("\n"); } diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index ca6353204..8696c02fa 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -945,6 +945,6 @@ public: void V3Expand::expandAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ExpandVisitor visitor(nodep); } // Destruct before checking + { ExpandVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("expand", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3File.cpp b/src/V3File.cpp index fe9550838..f26e60c67 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -145,7 +145,7 @@ V3FileDependImp dependImp; // Depend implementation class // V3FileDependImp inline void V3FileDependImp::writeDepend(const string& filename) { - const std::unique_ptr ofp(V3File::new_ofstream(filename)); + const std::unique_ptr ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); for (const DependFile& i : m_filenameList) { @@ -178,7 +178,7 @@ inline std::vector V3FileDependImp::getAllDeps() const { } inline void V3FileDependImp::writeTimes(const string& filename, const string& cmdlineIn) { - const std::unique_ptr ofp(V3File::new_ofstream(filename)); + const std::unique_ptr ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); const string cmdline = stripQuotes(cmdlineIn); @@ -213,7 +213,7 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm } inline bool V3FileDependImp::checkTimes(const string& filename, const string& cmdlineIn) { - const std::unique_ptr ifp(V3File::new_ifstream_nodepend(filename)); + const std::unique_ptr ifp{V3File::new_ifstream_nodepend(filename)}; if (ifp->fail()) { UINFO(2, " --check-times failed: no input " << filename << endl); return false; diff --git a/src/V3File.h b/src/V3File.h index 785a2d0c9..08abc7607 100644 --- a/src/V3File.h +++ b/src/V3File.h @@ -38,7 +38,7 @@ public: return new_ifstream_nodepend(filename); } static std::ifstream* new_ifstream_nodepend(const string& filename) { - return new std::ifstream(filename.c_str()); + return new std::ifstream{filename.c_str()}; } static std::ofstream* new_ofstream(const string& filename, bool append = false) { addTgtDepend(filename); @@ -47,9 +47,9 @@ public: static std::ofstream* new_ofstream_nodepend(const string& filename, bool append = false) { createMakeDirFor(filename); if (append) { - return new std::ofstream(filename.c_str(), std::ios::app); + return new std::ofstream{filename.c_str(), std::ios::app}; } else { - return new std::ofstream(filename.c_str()); + return new std::ofstream{filename.c_str()}; } } static FILE* new_fopen_w(const string& filename) { diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 867248bb3..9e36482a9 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -570,7 +570,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { AstNode* logicp = logicVertexp->nodep(); if (logicVertexp->reducible()) { // Can we eliminate? - GateOkVisitor okVisitor(logicp, vvertexp->isClock(), false); + GateOkVisitor okVisitor{logicp, vvertexp->isClock(), false}; const bool multiInputs = okVisitor.rhsVarRefs().size() > 1; // Was it ok? bool doit = okVisitor.isSimple(); @@ -884,7 +884,7 @@ public: void GateVisitor::optimizeElimVar(AstVarScope* varscp, AstNode* substp, AstNode* consumerp) { if (debug() >= 5) consumerp->dumpTree(cout, " elimUsePre: "); - GateElimVisitor elimVisitor(consumerp, varscp, substp, nullptr); + GateElimVisitor elimVisitor{consumerp, varscp, substp, nullptr}; if (elimVisitor.didReplace()) { if (debug() >= 9) consumerp->dumpTree(cout, " elimUseCns: "); // Caution: Can't let V3Const change our handle to consumerp, such as by @@ -1148,7 +1148,7 @@ private: UASSERT_OBJ(vvertexp->dedupable(), vvertexp->varScp(), "GateLogicVertex* visit should have returned nullptr " "if consumer var vertex is not dedupable."); - GateOkVisitor okVisitor(lvertexp->nodep(), false, true); + GateOkVisitor okVisitor{lvertexp->nodep(), false, true}; if (okVisitor.isSimple()) { AstVarScope* dupVarScopep = dupVarRefp->varScopep(); GateVarVertex* dupVvertexp @@ -1226,7 +1226,7 @@ public: void GateVisitor::dedupe() { AstNode::user2ClearTree(); - GateDedupeGraphVisitor deduper(&m_graph); + GateDedupeGraphVisitor deduper{&m_graph}; // Traverse starting from each of the clocks UINFO(9, "Gate dedupe() clocks:\n"); for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { @@ -1367,7 +1367,7 @@ public: void GateVisitor::mergeAssigns() { UINFO(6, "mergeAssigns\n"); - GateMergeAssignsGraphVisitor merger(&m_graph); + GateMergeAssignsGraphVisitor merger{&m_graph}; for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { if (GateVarVertex* vvertexp = dynamic_cast(itp)) { merger.mergeAssignsTree(vvertexp); @@ -1553,7 +1553,7 @@ public: void GateVisitor::decomposeClkVectors() { UINFO(9, "Starting clock decomposition" << endl); AstNode::user2ClearTree(); - GateClkDecompGraphVisitor decomposer(&m_graph); + GateClkDecompGraphVisitor decomposer{&m_graph}; for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { if (GateVarVertex* vertp = dynamic_cast(itp)) { AstVarScope* vsp = vertp->varScp(); @@ -1601,8 +1601,8 @@ public: void V3Gate::gateAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - GateVisitor visitor(nodep); - GateDeassignVisitor deassign(nodep); + GateVisitor visitor{nodep}; + GateDeassignVisitor deassign{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("gate", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index dc6dc2ec9..48c39b63d 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -147,7 +147,7 @@ private: { // Make the new clock signals and replace any activate references // See rename, it does some AstNode::userClearTree()'s - GenClkRenameVisitor visitor(nodep, m_topModp); + GenClkRenameVisitor visitor{nodep, m_topModp}; } } virtual void visit(AstNodeModule* nodep) override { @@ -222,6 +222,6 @@ public: void V3GenClk::genClkAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { GenClkReadVisitor visitor(nodep); } // Destruct before checking + { GenClkReadVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("genclk", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Global.h b/src/V3Global.h index b0a35f9e0..2eba07885 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -53,8 +53,8 @@ template class VRestorer { public: explicit VRestorer(T& permr) - : m_ref(permr) - , m_saved(permr) {} + : m_ref{permr} + , m_saved{permr} {} ~VRestorer() { m_ref = m_saved; } VL_UNCOPYABLE(VRestorer); }; diff --git a/src/V3Graph.cpp b/src/V3Graph.cpp index 71070cee2..6cbe5dc65 100644 --- a/src/V3Graph.cpp +++ b/src/V3Graph.cpp @@ -314,7 +314,7 @@ void V3Graph::dumpDotFilePrefixedAlways(const string& nameComment, bool colorAsS void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) const { // This generates a file used by graphviz, https://www.graphviz.org // "hardcoded" parameters: - const std::unique_ptr logp(V3File::new_ofstream(filename)); + const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); // Header diff --git a/src/V3GraphDfa.h b/src/V3GraphDfa.h index 79e6e465e..8550bdad4 100644 --- a/src/V3GraphDfa.h +++ b/src/V3GraphDfa.h @@ -122,8 +122,8 @@ public: // CONSTRUCTORS DfaEdge(DfaGraph* graphp, DfaVertex* fromp, DfaVertex* top, const DfaInput& input) : V3GraphEdge{graphp, fromp, top, 1} - , m_input(input) - , m_complement(false) {} + , m_input{input} + , m_complement{false} {} DfaEdge(DfaGraph* graphp, DfaVertex* fromp, DfaVertex* top, const DfaEdge* copyfrom) : V3GraphEdge{graphp, fromp, top, copyfrom->weight()} , m_input{copyfrom->input()} diff --git a/src/V3Hasher.cpp b/src/V3Hasher.cpp index 775cee846..b83f8386a 100644 --- a/src/V3Hasher.cpp +++ b/src/V3Hasher.cpp @@ -488,11 +488,11 @@ public: // V3Hasher methods V3Hash V3Hasher::operator()(AstNode* nodep) const { - if (!nodep->user4()) { HasherVisitor visitor(nodep); } + if (!nodep->user4()) { HasherVisitor visitor{nodep}; } return V3Hash(nodep->user4()); } V3Hash V3Hasher::uncachedHash(const AstNode* nodep) { - HasherVisitor visitor(nodep); + HasherVisitor visitor{nodep}; return visitor.finalHash(); } diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index a11323d8e..dc7ba5a95 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -208,7 +208,7 @@ string V3HierBlock::vFileIfNecessary() const { } void V3HierBlock::writeCommandArgsFile(bool forCMake) const { - std::unique_ptr of(V3File::new_ofstream(commandArgsFileName(forCMake))); + std::unique_ptr of{V3File::new_ofstream(commandArgsFileName(forCMake))}; *of << "--cc\n"; if (!forCMake) { @@ -398,7 +398,7 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const { it->second->writeCommandArgsFile(forCMake); } // For the top module - std::unique_ptr of(V3File::new_ofstream(topCommandArgsFileName(forCMake))); + std::unique_ptr of{V3File::new_ofstream(topCommandArgsFileName(forCMake))}; if (!forCMake) { // Load wrappers first not to be overwritten by the original HDL for (const_iterator it = begin(); it != end(); ++it) { diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 01b62ae81..680eacfc6 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -548,7 +548,7 @@ private: // Clear var markings and find cell cross references AstNode::user2ClearTree(); AstNode::user4ClearTree(); - { InlineCollectVisitor(nodep->modp()); } // {} to destroy visitor immediately + { InlineCollectVisitor{nodep->modp()}; } // {} to destroy visitor immediately // Create data for dotted variable resolution AstCellInline* inlinep = new AstCellInline(nodep->fileline(), nodep->name(), nodep->modp()->origName(), @@ -591,7 +591,7 @@ private: && pinNewVarp->direction() == VDirection::OUTPUT); } // Cleanup var names, etc, to not conflict - { InlineRelinkVisitor(newmodp, m_modp, nodep); } + { InlineRelinkVisitor{newmodp, m_modp, nodep}; } // Move statements to top module if (debug() >= 9) newmodp->dumpTree(cout, "fixmod:"); AstNode* stmtsp = newmodp->stmtsp(); @@ -713,8 +713,8 @@ void V3Inline::inlineAll(AstNetlist* nodep) { AstUser1InUse m_inuser1; // output of InlineMarkVisitor, // input to InlineVisitor. // Scoped to clean up temp userN's - { InlineMarkVisitor mvisitor(nodep); } - { InlineVisitor visitor(nodep); } + { InlineMarkVisitor mvisitor{nodep}; } + { InlineVisitor visitor{nodep}; } // Remove all modules that were inlined // V3Dead will also clean them up, but if we have debug on, it's a good // idea to avoid dumping the hugely exploded tree. @@ -725,6 +725,6 @@ void V3Inline::inlineAll(AstNetlist* nodep) { VL_DO_DANGLING(modp->unlinkFrBack()->deleteTree(), modp); } } - { InlineIntfRefVisitor crvisitor(nodep); } + { InlineIntfRefVisitor crvisitor{nodep}; } V3Global::dumpCheckGlobalTree("inline", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index ff4a2961c..97508c9f3 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -487,12 +487,12 @@ private: static AstNode* extendOrSel(FileLine* fl, AstNode* rhsp, AstNode* cmpWidthp) { if (cmpWidthp->width() > rhsp->width()) { - rhsp = (rhsp->isSigned() ? static_cast(new AstExtendS(fl, rhsp)) - : static_cast(new AstExtend(fl, rhsp))); + rhsp = (rhsp->isSigned() ? static_cast(new AstExtendS{fl, rhsp}) + : static_cast(new AstExtend{fl, rhsp})); // Need proper widthMin, which may differ from AstSel created above rhsp->dtypeFrom(cmpWidthp); } else if (cmpWidthp->width() < rhsp->width()) { - rhsp = new AstSel(fl, rhsp, 0, cmpWidthp->width()); + rhsp = new AstSel{fl, rhsp, 0, cmpWidthp->width()}; // Need proper widthMin, which may differ from AstSel created above rhsp->dtypeFrom(cmpWidthp); } @@ -610,12 +610,12 @@ void V3Inst::checkOutputShort(AstPin* nodep) { void V3Inst::instAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { InstVisitor visitor(nodep); } // Destruct before checking + { InstVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("inst", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Inst::dearrayAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { InstDeVisitor visitor(nodep); } // Destruct before checking + { InstDeVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("dearray", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3InstrCount.cpp b/src/V3InstrCount.cpp index b26628cbf..49e67e0d7 100644 --- a/src/V3InstrCount.cpp +++ b/src/V3InstrCount.cpp @@ -294,7 +294,7 @@ private: }; uint32_t V3InstrCount::count(AstNode* nodep, bool assertNoDups, std::ostream* osp) { - InstrCountVisitor visitor(nodep, assertNoDups, osp); + InstrCountVisitor visitor{nodep, assertNoDups, osp}; if (osp) InstrCountDumpVisitor dumper(nodep, osp); return visitor.instrCount(); } diff --git a/src/V3Life.cpp b/src/V3Life.cpp index c3dafa9f7..af09be5ea 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -461,12 +461,12 @@ private: virtual void visit(AstCFunc* nodep) override { if (nodep->entryPoint()) { // Usage model 1: Simulate all C code, doing lifetime analysis - LifeVisitor visitor(nodep, m_statep); + LifeVisitor visitor{nodep, m_statep}; } } virtual void visit(AstNodeProcedure* nodep) override { // Usage model 2: Cleanup basic blocks - LifeVisitor visitor(nodep, m_statep); + LifeVisitor visitor{nodep, m_statep}; } virtual void visit(AstVar*) override {} // Accelerate virtual void visit(AstNodeStmt*) override {} // Accelerate @@ -489,7 +489,7 @@ void V3Life::lifeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { LifeState state; - LifeTopVisitor visitor(nodep, &state); + LifeTopVisitor visitor{nodep, &state}; } // Destruct before checking V3Global::dumpCheckGlobalTree("life", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 86bfe48b3..f8306c38f 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -271,7 +271,7 @@ private: squashAssignposts(); // Replace any node4p varscopes with the new scope - LifePostElimVisitor visitor(nodep); + LifePostElimVisitor visitor{nodep}; } virtual void visit(AstVarRef* nodep) override { // Consumption/generation of a variable, @@ -348,6 +348,6 @@ public: void V3LifePost::lifepostAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); // Mark redundant AssignPost - { LifePostDlyVisitor visitor(nodep); } // Destruct before checking + { LifePostDlyVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("life_post", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index 0713c4d70..c6ee709b3 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -523,5 +523,5 @@ public: void V3LinkCells::link(AstNetlist* nodep, VInFilter* filterp, V3ParseSym* parseSymp) { UINFO(4, __FUNCTION__ << ": " << endl); - LinkCellsVisitor visitor(nodep, filterp, parseSymp); + LinkCellsVisitor visitor{nodep, filterp, parseSymp}; } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 33a576ebc..d8d13d9c5 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -165,7 +165,7 @@ public: void dump(const string& nameComment = "linkdot", bool force = false) { if (debug() >= 6 || force) { const string filename = v3Global.debugFilename(nameComment) + ".txt"; - const std::unique_ptr logp(V3File::new_ofstream(filename)); + const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); std::ostream& os = *logp; m_syms.dump(os); @@ -1766,7 +1766,7 @@ void LinkDotState::computeIfaceModSyms() { for (const auto& itr : m_ifaceModSyms) { AstIface* nodep = itr.first; VSymEnt* symp = itr.second; - LinkDotIfaceVisitor(nodep, symp, this); + LinkDotIfaceVisitor{nodep, symp, this}; } m_ifaceModSyms.clear(); } @@ -3042,13 +3042,13 @@ void V3LinkDot::linkDotGuts(AstNetlist* rootp, VLinkDotStep step) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot.tree")); } LinkDotState state(rootp, step); - LinkDotFindVisitor visitor(rootp, &state); + LinkDotFindVisitor visitor{rootp, &state}; if (LinkDotState::debug() >= 5 || v3Global.opt.dumpTree() >= 9) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot-find.tree")); } if (step == LDS_PRIMARY || step == LDS_PARAMED) { // Initial link stage, resolve parameters - LinkDotParamVisitor visitors(rootp, &state); + LinkDotParamVisitor visitors{rootp, &state}; if (LinkDotState::debug() >= 5 || v3Global.opt.dumpTree() >= 9) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot-param.tree")); } @@ -3056,7 +3056,7 @@ void V3LinkDot::linkDotGuts(AstNetlist* rootp, VLinkDotStep step) { } else if (step == LDS_SCOPED) { // Well after the initial link when we're ready to operate on the flat design, // process AstScope's. This needs to be separate pass after whole hierarchy graph created. - LinkDotScopeVisitor visitors(rootp, &state); + LinkDotScopeVisitor visitors{rootp, &state}; v3Global.assertScoped(true); if (LinkDotState::debug() >= 5 || v3Global.opt.dumpTree() >= 9) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot-scoped.tree")); @@ -3069,5 +3069,5 @@ void V3LinkDot::linkDotGuts(AstNetlist* rootp, VLinkDotStep step) { state.computeIfaceVarSyms(); state.computeScopeAliases(); state.dump(); - LinkDotResolveVisitor visitorb(rootp, &state); + LinkDotResolveVisitor visitorb{rootp, &state}; } diff --git a/src/V3LinkInc.cpp b/src/V3LinkInc.cpp index 00e9ef6ea..fc949abcd 100644 --- a/src/V3LinkInc.cpp +++ b/src/V3LinkInc.cpp @@ -246,6 +246,6 @@ public: void V3LinkInc::linkIncrements(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { LinkIncVisitor bvisitor(nodep); } // Destruct before checking + { LinkIncVisitor bvisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linkInc", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index c81bf09f8..5d4a35425 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -287,6 +287,6 @@ public: void V3LinkJump::linkJump(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { LinkJumpVisitor bvisitor(nodep); } // Destruct before checking + { LinkJumpVisitor bvisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("link", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3LinkLValue.cpp b/src/V3LinkLValue.cpp index ae87110db..9d9fadace 100644 --- a/src/V3LinkLValue.cpp +++ b/src/V3LinkLValue.cpp @@ -298,12 +298,12 @@ public: void V3LinkLValue::linkLValue(AstNetlist* nodep) { UINFO(4, __FUNCTION__ << ": " << endl); - { LinkLValueVisitor visitor(nodep, VAccess::NOCHANGE); } // Destruct before checking + { LinkLValueVisitor visitor{nodep, VAccess::NOCHANGE}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linklvalue", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } void V3LinkLValue::linkLValueSet(AstNode* nodep) { // Called by later link functions when it is known a node needs // to be converted to a lvalue. UINFO(9, __FUNCTION__ << ": " << endl); - LinkLValueVisitor visitor(nodep, VAccess::WRITE); + LinkLValueVisitor visitor{nodep, VAccess::WRITE}; } diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 310a5ff37..22cc38dc8 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -656,6 +656,6 @@ public: void V3LinkParse::linkParse(AstNetlist* rootp) { UINFO(4, __FUNCTION__ << ": " << endl); - { LinkParseVisitor visitor(rootp); } // Destruct before checking + { LinkParseVisitor visitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linkparse", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index e8713e179..6c0b2c02a 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -573,8 +573,8 @@ public: void V3LinkResolve::linkResolve(AstNetlist* rootp) { UINFO(4, __FUNCTION__ << ": " << endl); { - LinkResolveVisitor visitor(rootp); - LinkBotupVisitor visitorb(rootp); + LinkResolveVisitor visitor{rootp}; + LinkBotupVisitor visitorb{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linkresolve", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index 0563c9866..deb1f301e 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -201,6 +201,6 @@ public: void V3Localize::localizeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { LocalizeVisitor visitor(nodep); } // Destruct before checking + { LocalizeVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("localize", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 0cb527c42..32c7d6da0 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -179,17 +179,17 @@ private: } if (AstAnd* const andp = VN_CAST(rhsp, And)) { UASSERT_OBJ(andp->rhsp() == condp, rhsp, "Should not try to fold this"); - return new AstAnd(andp->fileline(), andp->lhsp()->cloneTree(false), resp); + return new AstAnd{andp->fileline(), andp->lhsp()->cloneTree(false), resp}; } } else if (AstAnd* const andp = VN_CAST(rhsp, And)) { if (andp->lhsp()->sameTree(m_mgCondp)) { return condTrue ? maskLsb(andp->rhsp()->unlinkFrBack()) - : new AstConst(rhsp->fileline(), AstConst::BitFalse()); + : new AstConst{rhsp->fileline(), AstConst::BitFalse()}; } else { UASSERT_OBJ(andp->rhsp()->sameTree(m_mgCondp), rhsp, "AstAnd doesn't hold condition expression"); return condTrue ? maskLsb(andp->lhsp()->unlinkFrBack()) - : new AstConst(rhsp->fileline(), AstConst::BitFalse()); + : new AstConst{rhsp->fileline(), AstConst::BitFalse()}; } } rhsp->v3fatalSrc("Don't know how to fold expression"); @@ -337,6 +337,6 @@ public: void V3MergeCond::mergeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { MergeCondVisitor visitor(nodep); } + { MergeCondVisitor visitor{nodep}; } V3Global::dumpCheckGlobalTree("merge_cond", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Name.cpp b/src/V3Name.cpp index ef90a8265..d448ad0da 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -142,6 +142,6 @@ public: void V3Name::nameAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { NameVisitor visitor(nodep); } // Destruct before checking + { NameVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("name", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 8e52d8761..6677c795c 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1499,7 +1499,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) { // Read the specified -f filename and process as arguments UINFO(1, "Reading Options File " << filename << endl); - const std::unique_ptr ifp(V3File::new_ifstream(filename)); + const std::unique_ptr ifp{V3File::new_ifstream(filename)}; if (ifp->fail()) { fl->v3error("Cannot open -f command file: " + filename); return; diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 011bed102..0ea3e82c0 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -1177,13 +1177,13 @@ private: virtual void visit(AstAlwaysPublic* nodep) override { iterateNewStmt(nodep); } virtual void visit(AstAssignAlias* nodep) override { iterateNewStmt(nodep); } virtual void visit(AstAssignW* nodep) override { - OrderClkAssVisitor visitor(nodep); + OrderClkAssVisitor visitor{nodep}; m_inClkAss = visitor.isClkAss(); iterateNewStmt(nodep); m_inClkAss = false; } virtual void visit(AstAssignPre* nodep) override { - OrderClkAssVisitor visitor(nodep); + OrderClkAssVisitor visitor{nodep}; m_inClkAss = visitor.isClkAss(); m_inPre = true; iterateNewStmt(nodep); @@ -1191,7 +1191,7 @@ private: m_inClkAss = false; } virtual void visit(AstAssignPost* nodep) override { - OrderClkAssVisitor visitor(nodep); + OrderClkAssVisitor visitor{nodep}; m_inClkAss = visitor.isClkAss(); m_inPost = true; iterateNewStmt(nodep); @@ -1545,7 +1545,7 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) { void OrderVisitor::processEdgeReport() { // Make report of all signal names and what clock edges they have const string filename = v3Global.debugFilename("order_edges.txt"); - const std::unique_ptr logp(V3File::new_ofstream(filename)); + const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); // Testing emitter: V3EmitV::verilogForTree(v3Global.rootp(), *logp); @@ -1777,7 +1777,7 @@ AstActive* OrderVisitor::processMoveOneLogic(const OrderLogicVertex* lvertexp, newFuncpr->addStmtsp(nodep); if (v3Global.opt.outputSplitCFuncs()) { // Add in the number of nodes we're adding - EmitCBaseCounterVisitor visitor(nodep); + EmitCBaseCounterVisitor visitor{nodep}; newStmtsr += visitor.count(); } } @@ -2005,7 +2005,7 @@ void OrderVisitor::process() { if (false && debug()) { const string dfilename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_INT_order"; - const std::unique_ptr logp(V3File::new_ofstream(dfilename)); + const std::unique_ptr logp{V3File::new_ofstream(dfilename)}; if (logp->fail()) v3fatal("Can't write " << dfilename); m_graph.dump(*logp); } @@ -2017,7 +2017,7 @@ void OrderVisitor::process() { void V3Order::orderAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - OrderClkMarkVisitor markVisitor(nodep); + OrderClkMarkVisitor markVisitor{nodep}; OrderVisitor visitor; visitor.main(nodep); } // Destruct before checking diff --git a/src/V3Os.cpp b/src/V3Os.cpp index 683aa8b99..9b6e6b428 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -236,8 +236,8 @@ void V3Os::createDir(const string& dirname) { } void V3Os::unlinkRegexp(const string& dir, const string& regexp) { - if (DIR* dirp = opendir(dir.c_str())) { - while (struct dirent* direntp = readdir(dirp)) { + if (DIR* const dirp = opendir(dir.c_str())) { + while (struct dirent* const direntp = readdir(dirp)) { if (VString::wildmatch(direntp->d_name, regexp.c_str())) { const string fullname = dir + "/" + string(direntp->d_name); #if defined(_WIN32) || defined(__MINGW32__) @@ -273,7 +273,7 @@ string V3Os::trueRandom(size_t size) { BCRYPT_USE_SYSTEM_PREFERRED_RNG); if (!BCRYPT_SUCCESS(hr)) v3fatal("Could not acquire random data."); #else - std::ifstream is("/dev/urandom", std::ios::in | std::ios::binary); + std::ifstream is{"/dev/urandom", std::ios::in | std::ios::binary}; // This read uses the size of the buffer. // Flawfinder: ignore if (VL_UNCOVERABLE(!is.read(data, size))) { diff --git a/src/V3Param.cpp b/src/V3Param.cpp index a09dca9e4..9976028bb 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -1223,6 +1223,6 @@ public: void V3Param::param(AstNetlist* rootp) { UINFO(2, __FUNCTION__ << ": " << endl); - { ParamVisitor visitor(rootp); } // Destruct before checking + { ParamVisitor visitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("param", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 1b9441c0c..f12a1bce3 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -624,8 +624,8 @@ public: static void dumpCpFilePrefixed(const V3Graph* graphp, const string& nameComment) { const string filename = v3Global.debugFilename(nameComment) + ".txt"; UINFO(1, "Writing " << filename << endl); - std::unique_ptr ofp(V3File::new_ofstream(filename)); - std::ostream* osp = &(*ofp); // &* needed to deref unique_ptr + std::unique_ptr ofp{V3File::new_ofstream(filename)}; + std::ostream* const osp = &(*ofp); // &* needed to deref unique_ptr if (osp->fail()) v3fatalStatic("Can't write " << filename); // Find start vertex with longest CP @@ -2077,7 +2077,7 @@ void ThreadSchedule::dumpDotFilePrefixedAlways(const string& nameComment) const void ThreadSchedule::dumpDotFile(const string& filename) const { // This generates a file used by graphviz, https://www.graphviz.org - const std::unique_ptr logp(V3File::new_ofstream(filename)); + const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); auto* depGraph = v3Global.rootp()->execGraphp()->depGraphp(); @@ -2765,8 +2765,8 @@ static const std::vector createThreadFunctions(const ThreadSchedule& funcp->argTypes("void* voidSelf, bool even_cycle"); // Setup vlSelf an vlSyms - funcp->addStmtsp(new AstCStmt(fl, EmitCBaseVisitor::voidSelfAssign(modp))); - funcp->addStmtsp(new AstCStmt(fl, EmitCBaseVisitor::symClassAssign())); + funcp->addStmtsp(new AstCStmt{fl, EmitCBaseVisitor::voidSelfAssign(modp)}); + funcp->addStmtsp(new AstCStmt{fl, EmitCBaseVisitor::symClassAssign()}); // Invoke each mtask scheduled to this thread from the thread function for (const ExecMTask* const mtaskp : thread) { diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 897f25445..948155f20 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -427,6 +427,6 @@ public: void V3Premit::premitAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { PremitVisitor visitor(nodep); } // Destruct before checking + { PremitVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("premit", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 1289b5a0d..6b6b1d8d4 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -246,8 +246,8 @@ public: void V3Randomize::randomizeNetlist(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - RandomizeMarkVisitor markVisitor(nodep); - RandomizeVisitor visitor(nodep); + RandomizeMarkVisitor markVisitor{nodep}; + RandomizeVisitor visitor{nodep}; } V3Global::dumpCheckGlobalTree("randomize", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index e95239473..646758819 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -267,6 +267,6 @@ public: void V3Reloop::reloopAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ReloopVisitor visitor(nodep); } // Destruct before checking + { ReloopVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("reloop", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index e90ed7a38..5cafafd3b 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -402,8 +402,8 @@ public: void V3Scope::scopeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - ScopeVisitor visitor(nodep); - ScopeCleanupVisitor cleanVisitor(nodep); + ScopeVisitor visitor{nodep}; + ScopeCleanupVisitor cleanVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("scope", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index 695d93082..f2a809797 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -236,6 +236,6 @@ public: void V3Slice::sliceAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { SliceVisitor visitor(nodep); } // Destruct before checking + { SliceVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("slice", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 4c8b1a60d..551dfd25c 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -932,7 +932,7 @@ protected: // Map each AstNodeIf to the set of colors (split always blocks) // it must participate in. Also find the whole set of colors. - IfColorVisitor ifColor(nodep); + IfColorVisitor ifColor{nodep}; if (ifColor.colors().size() > 1) { // Counting original always blocks rather than newly-split @@ -942,7 +942,7 @@ protected: // Visit through the original always block one more time, // and emit the split always blocks into m_replaceBlocks: - EmitSplitVisitor emitSplit(nodep, &ifColor, &(m_replaceBlocks[nodep])); + EmitSplitVisitor emitSplit{nodep, &ifColor, &(m_replaceBlocks[nodep])}; emitSplit.go(); } } @@ -964,11 +964,11 @@ private: void V3Split::splitReorderAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ReorderVisitor visitor(nodep); } // Destruct before checking + { ReorderVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("reorder", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Split::splitAlwaysAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { SplitVisitor visitor(nodep); } // Destruct before checking + { SplitVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("split", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index 5263a8a9a..ee9bf9236 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -144,11 +144,11 @@ private: newp->user1(true); // So we don't clone it again nodep->addNextHere(newp); { // Delete stuff we don't want in old - SplitAsCleanVisitor visitor(nodep, m_splitVscp, false); + SplitAsCleanVisitor visitor{nodep, m_splitVscp, false}; if (debug() >= 9) nodep->dumpTree(cout, "-out0: "); } { // Delete stuff we don't want in new - SplitAsCleanVisitor visitor(newp, m_splitVscp, true); + SplitAsCleanVisitor visitor{newp, m_splitVscp, true}; if (debug() >= 9) newp->dumpTree(cout, "-out1: "); } } @@ -159,7 +159,7 @@ private: AstVarScope* lastSplitVscp = nullptr; while (!nodep->user1()) { // Find any splittable variables - SplitAsFindVisitor visitor(nodep); + SplitAsFindVisitor visitor{nodep}; m_splitVscp = visitor.splitVscp(); if (m_splitVscp && m_splitVscp == lastSplitVscp) { // We did this last time! Something's stuck! @@ -194,6 +194,6 @@ public: void V3SplitAs::splitAsAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { SplitAsVisitor visitor(nodep); } // Destruct before checking + { SplitAsVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("splitas", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 5a3f8ab78..d47b198d6 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -1250,11 +1250,11 @@ void V3SplitVar::splitVariable(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); SplitVarRefsMap refs; { - SplitUnpackedVarVisitor visitor(nodep); + SplitUnpackedVarVisitor visitor{nodep}; refs = visitor.getPackedVarRefs(); } V3Global::dumpCheckGlobalTree("split_var", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 9); - { SplitPackedVarVisitor visitor(nodep, refs); } + { SplitPackedVarVisitor visitor{nodep, refs}; } V3Global::dumpCheckGlobalTree("split_var", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 9); } diff --git a/src/V3Stats.cpp b/src/V3Stats.cpp index ba11b2f4f..3084b233b 100644 --- a/src/V3Stats.cpp +++ b/src/V3Stats.cpp @@ -279,7 +279,7 @@ public: // Top Stats class void V3Stats::statsStageAll(AstNetlist* nodep, const string& stage, bool fast) { - StatsVisitor visitor(nodep, stage, fast); + StatsVisitor visitor{nodep, stage, fast}; } void V3Stats::statsFinalAll(AstNetlist* nodep) { diff --git a/src/V3StatsReport.cpp b/src/V3StatsReport.cpp index 24c148d3d..5833f8db6 100644 --- a/src/V3StatsReport.cpp +++ b/src/V3StatsReport.cpp @@ -222,7 +222,7 @@ void V3Stats::statsReport() { // Open stats file const string filename = v3Global.opt.hierTopDataDir() + "/" + v3Global.opt.prefix() + "__stats.txt"; - std::ofstream* ofp(V3File::new_ofstream(filename)); + std::ofstream* ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); StatsReport reporter(ofp); diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index a3c51797e..a9d422344 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -314,7 +314,7 @@ private: SubstVarEntry* entryp = getEntryp(varrefp); if (AstNode* substp = entryp->substWord(nodep, word)) { // Check that the RHS hasn't changed value since we recorded it. - SubstUseVisitor visitor(substp, entryp->getWordStep(word)); + SubstUseVisitor visitor{substp, entryp->getWordStep(word)}; if (visitor.ok()) { VL_DO_DANGLING(replaceSubstEtc(nodep, substp), nodep); } else { @@ -341,7 +341,7 @@ private: entryp->assignComplex(); } else if (AstNode* substp = entryp->substWhole(nodep)) { // Check that the RHS hasn't changed value since we recorded it. - SubstUseVisitor visitor(substp, entryp->getWholeStep()); + SubstUseVisitor visitor{substp, entryp->getWholeStep()}; if (visitor.ok()) { UINFO(8, " USEwhole " << nodep << endl); VL_DO_DANGLING(replaceSubstEtc(nodep, substp), nodep); @@ -380,6 +380,6 @@ public: void V3Subst::substituteAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { SubstVisitor visitor(nodep); } // Destruct before checking + { SubstVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("subst", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3SymTable.h b/src/V3SymTable.h index 6db11ae30..e7ff1905f 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -317,7 +317,7 @@ public: if (v3Global.opt.dumpTree()) { const string filename = v3Global.debugFilename(nameComment) + ".txt"; UINFO(2, "Dumping " << filename << endl); - const std::unique_ptr logp(V3File::new_ofstream(filename)); + const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); dump(*logp, ""); } diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index 6e3cc079d..eb5a53a64 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -355,7 +355,7 @@ public: void dumpGraphFilePrefixed(const string& nameComment) const { if (v3Global.opt.dumpTree()) { const string filename = v3Global.debugFilename(nameComment) + ".txt"; - const std::unique_ptr logp(V3File::new_ofstream(filename)); + const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); dumpGraph(*logp, nameComment); } diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 330873ced..f81c83021 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -97,9 +97,9 @@ public: v3Global.rootp()->typeTablep()->addTypesp(tableDTypep); // Create table initializer (with default value 0) AstConst* const defaultp = elemDType->isString() - ? new AstConst(m_fl, AstConst::String(), "") - : new AstConst(m_fl, AstConst::WidthedValue(), width, 0); - m_initp = new AstInitArray(m_fl, tableDTypep, defaultp); + ? new AstConst{m_fl, AstConst::String(), ""} + : new AstConst{m_fl, AstConst::WidthedValue(), width, 0}; + m_initp = new AstInitArray{m_fl, tableDTypep, defaultp}; } void addValue(unsigned index, const V3Number& value) { @@ -196,7 +196,7 @@ private: m_outVarps.clear(); // Collect stats - TableSimulateVisitor chkvis(this); + TableSimulateVisitor chkvis{this}; chkvis.mainTableCheck(nodep); m_assignDly = chkvis.isAssignDly(); // Also sets m_inWidthBits @@ -280,7 +280,7 @@ private: // There may be a simulation path by which the output doesn't change value. // We could bail on these cases, or we can have a "change it" boolean. // We've chosen the latter route, since recirc is common in large FSMs. - TableSimulateVisitor simvis(this); + TableSimulateVisitor simvis{this}; for (uint32_t i = 0; i <= VL_MASK_I(m_inWidthBits); ++i) { const uint32_t inValue = i; // Make a new simulation structure so we can set new input values @@ -354,11 +354,11 @@ private: AstVarScope* outputAssignedTableVscp) { FileLine* const fl = nodep->fileline(); for (TableOutputVar& tov : m_outVarps) { - AstNode* const alhsp = new AstVarRef(fl, tov.varScopep(), VAccess::WRITE); + AstNode* const alhsp = new AstVarRef{fl, tov.varScopep(), VAccess::WRITE}; AstNode* const arhsp = select(fl, tov.tabeVarScopep(), indexVscp); AstNode* outsetp = m_assignDly - ? static_cast(new AstAssignDly(fl, alhsp, arhsp)) - : static_cast(new AstAssign(fl, alhsp, arhsp)); + ? static_cast(new AstAssignDly{fl, alhsp, arhsp}) + : static_cast(new AstAssign{fl, alhsp, arhsp}); // If this output is unassigned on some code paths, wrap the assignment in an If if (tov.mayBeUnassigned()) { @@ -425,6 +425,6 @@ void TableSimulateVisitor::varRefCb(AstVarRef* nodep) { void V3Table::tableAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { TableVisitor visitor(nodep); } // Destruct before checking + { TableVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("table", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 13ab8a148..9b2226468 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -545,7 +545,7 @@ private: // Iteration requires a back, so put under temporary node { AstBegin* tempp = new AstBegin(beginp->fileline(), "[EditWrapper]", beginp); - TaskRelinkVisitor visitor(tempp); + TaskRelinkVisitor visitor{tempp}; tempp->stmtsp()->unlinkFrBackWithNext(); VL_DO_DANGLING(tempp->deleteTree(), tempp); } @@ -1230,7 +1230,7 @@ private: // Iteration requires a back, so put under temporary node { AstBegin* tempp = new AstBegin(cfuncp->fileline(), "[EditWrapper]", cfuncp); - TaskRelinkVisitor visitor(tempp); + TaskRelinkVisitor visitor{tempp}; tempp->stmtsp()->unlinkFrBackWithNext(); VL_DO_DANGLING(tempp->deleteTree(), tempp); } @@ -1728,8 +1728,8 @@ const char* V3Task::dpiTemporaryVarSuffix() { void V3Task::taskAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - TaskStateVisitor visitors(nodep); - TaskVisitor visitor(nodep, &visitors); + TaskStateVisitor visitors{nodep}; + TaskVisitor visitor{nodep, &visitors}; } // Destruct before checking V3Global::dumpCheckGlobalTree("task", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index a5901d1e8..168ae24d4 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -907,6 +907,6 @@ public: void V3Trace::traceAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { TraceVisitor visitor(nodep); } // Destruct before checking + { TraceVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("trace", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 07a62629d..3bbe20f31 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -361,6 +361,6 @@ public: void V3TraceDecl::traceDeclAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { TraceDeclVisitor visitor(nodep); } // Destruct before checking + { TraceDeclVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("tracedecl", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index dc85754bb..6be7c1621 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -1213,7 +1213,7 @@ class TristateVisitor final : public TristateBaseVisitor { // simple, it will flip ArraySel's and such, but if the // pin is an input the earlier reconnectSimple made it // a VarRef without any ArraySel, etc - TristatePinVisitor visitor(outexprp, m_tgraph, true); + TristatePinVisitor visitor{outexprp, m_tgraph, true}; } if (debug() >= 9) outpinp->dumpTree(cout, "-pin-opr: "); outAssignp = V3Inst::pinReconnectSimple(outpinp, m_cellp, @@ -1224,7 +1224,7 @@ class TristateVisitor final : public TristateBaseVisitor { } // Existing pin becomes an input, and we mark each resulting signal as tristate - TristatePinVisitor visitor(nodep->exprp(), m_tgraph, false); + TristatePinVisitor visitor{nodep->exprp(), m_tgraph, false}; AstNode* inAssignp = V3Inst::pinReconnectSimple( nodep, m_cellp, true); // Note may change nodep->exprp() if (debug() >= 9) nodep->dumpTree(cout, "-pin-in: "); @@ -1424,6 +1424,6 @@ public: void V3Tristate::tristateAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { TristateVisitor visitor(nodep); } // Destruct before checking + { TristateVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("tristate", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 4f8f4bcb4..ccf6ea283 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -461,5 +461,5 @@ public: void V3Undriven::undrivenAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - UndrivenVisitor visitor(nodep); + UndrivenVisitor visitor{nodep}; } diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index fb0d89866..5c86e25ed 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -487,6 +487,6 @@ public: void V3Unknown::unknownAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { UnknownVisitor visitor(nodep); } // Destruct before checking + { UnknownVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("unknown", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Waiver.cpp b/src/V3Waiver.cpp index 31b6b9c86..7e96d7ca3 100644 --- a/src/V3Waiver.cpp +++ b/src/V3Waiver.cpp @@ -30,7 +30,7 @@ void V3Waiver::addEntry(V3ErrorCode errorCode, const std::string& filename, } void V3Waiver::write(const std::string& filename) { - const std::unique_ptr ofp(V3File::new_ofstream(filename)); + const std::unique_ptr ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); *ofp << "// DESCR" diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 5f67404e4..cf2c264ae 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -5079,9 +5079,9 @@ private: case EXTEND_LHS: doSigned = nodep->isSigned(); break; default: nodep->v3fatalSrc("bad case"); } - AstNode* newp - = (doSigned ? static_cast(new AstExtendS(nodep->fileline(), nodep)) - : static_cast(new AstExtend(nodep->fileline(), nodep))); + AstNode* const newp + = (doSigned ? static_cast(new AstExtendS{nodep->fileline(), nodep}) + : static_cast(new AstExtend{nodep->fileline(), nodep})); linker.relink(newp); nodep = newp; } @@ -6158,8 +6158,8 @@ void V3Width::width(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { // We should do it in bottom-up module order, but it works in any order. - WidthClearVisitor cvisitor(nodep); - WidthVisitor visitor(false, false); + WidthClearVisitor cvisitor{nodep}; + WidthVisitor visitor{false, false}; (void)visitor.mainAcceptEdit(nodep); WidthRemoveVisitor rvisitor; (void)rvisitor.mainAcceptEdit(nodep); @@ -6172,7 +6172,7 @@ void V3Width::width(AstNetlist* nodep) { AstNode* V3Width::widthParamsEdit(AstNode* nodep) { UINFO(4, __FUNCTION__ << ": " << nodep << endl); // We should do it in bottom-up module order, but it works in any order. - WidthVisitor visitor(true, false); + WidthVisitor visitor{true, false}; nodep = visitor.mainAcceptEdit(nodep); // No WidthRemoveVisitor, as don't want to drop $signed etc inside gen blocks return nodep; @@ -6191,7 +6191,7 @@ AstNode* V3Width::widthGenerateParamsEdit( AstNode* nodep) { //!< [in] AST whose parameters widths are to be analysed. UINFO(4, __FUNCTION__ << ": " << nodep << endl); // We should do it in bottom-up module order, but it works in any order. - WidthVisitor visitor(true, true); + WidthVisitor visitor{true, true}; nodep = visitor.mainAcceptEdit(nodep); // No WidthRemoveVisitor, as don't want to drop $signed etc inside gen blocks return nodep; @@ -6199,6 +6199,6 @@ AstNode* V3Width::widthGenerateParamsEdit( void V3Width::widthCommit(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { WidthCommitVisitor visitor(nodep); } // Destruct before checking + { WidthCommitVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("widthcommit", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/VlcBucket.h b/src/VlcBucket.h index 3add0dd46..89e758c45 100644 --- a/src/VlcBucket.h +++ b/src/VlcBucket.h @@ -39,7 +39,7 @@ private: if (m_dataSize < point) m_dataSize = (point + 64) & ~63ULL; // Keep power of two m_dataSize *= 2; // UINFO(9, "Realloc "<(std::realloc(m_datap, allocSize())); + vluint64_t* const newp = static_cast(std::realloc(m_datap, allocSize())); if (VL_UNCOVERABLE(!newp)) { // cppcheck-suppress doubleFree // cppcheck 1.90 bug - realloc doesn't free on fail free(m_datap); // LCOV_EXCL_LINE diff --git a/src/VlcOptions.h b/src/VlcOptions.h index 22d98dd4a..6bebf0902 100644 --- a/src/VlcOptions.h +++ b/src/VlcOptions.h @@ -35,11 +35,11 @@ class VlcOptions final { // MEMBERS (general options) // clang-format off string m_annotateOut; // main switch: --annotate I - bool m_annotateAll=false; // main switch: --annotate-all - int m_annotateMin=10; // main switch: --annotate-min I + bool m_annotateAll = false; // main switch: --annotate-all + int m_annotateMin = 10; // main switch: --annotate-min I VlStringSet m_readFiles; // main switch: --read - bool m_rank=false; // main switch: --rank - bool m_unlink=false; // main switch: --unlink + bool m_rank = false; // main switch: --rank + bool m_unlink = false; // main switch: --unlink string m_writeFile; // main switch: --write string m_writeInfoFile; // main switch: --write-info // clang-format on diff --git a/src/VlcPoint.h b/src/VlcPoint.h index 26c8f5c65..c9ea193bb 100644 --- a/src/VlcPoint.h +++ b/src/VlcPoint.h @@ -127,7 +127,7 @@ public: m_points[pointnum].countInc(count); } else { pointnum = m_numPoints++; - VlcPoint point(name, pointnum); + VlcPoint point{name, pointnum}; point.countInc(count); m_points.push_back(point); m_nameMap.emplace(point.name(), point.pointNum()); diff --git a/src/VlcTest.h b/src/VlcTest.h index 7aa4cb77a..cf354d6aa 100644 --- a/src/VlcTest.h +++ b/src/VlcTest.h @@ -112,7 +112,7 @@ public: for (const auto& testp : m_tests) testp->dump(bucketsToo); } VlcTest* newTest(const string& name, vluint64_t testrun, double comp) { - VlcTest* testp = new VlcTest(name, testrun, comp); + VlcTest* const testp = new VlcTest{name, testrun, comp}; m_tests.push_back(testp); return testp; } diff --git a/src/VlcTop.cpp b/src/VlcTop.cpp index 606404666..219218232 100644 --- a/src/VlcTop.cpp +++ b/src/VlcTop.cpp @@ -27,14 +27,14 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) { UINFO(2, "readCoverage " << filename << endl); - std::ifstream is(filename.c_str()); + std::ifstream is{filename.c_str()}; if (!is) { if (!nonfatal) v3fatal("Can't read " << filename); return; } // Testrun and computrons argument unsupported as yet - VlcTest* testp = tests().newTest(filename, 0, 0); + VlcTest* const testp = tests().newTest(filename, 0, 0); while (!is.eof()) { const string line = V3Os::getline(is); @@ -63,7 +63,7 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) { void VlcTop::writeCoverage(const string& filename) { UINFO(2, "writeCoverage " << filename << endl); - std::ofstream os(filename.c_str()); + std::ofstream os{filename.c_str()}; if (!os) { v3fatal("Can't write " << filename); return; @@ -79,7 +79,7 @@ void VlcTop::writeCoverage(const string& filename) { void VlcTop::writeInfo(const string& filename) { UINFO(2, "writeInfo " << filename << endl); - std::ofstream os(filename.c_str()); + std::ofstream os{filename.c_str()}; if (!os) { v3fatal("Can't write " << filename); return; @@ -157,7 +157,7 @@ void VlcTop::rank() { VlcBuckets remaining; for (const auto& i : m_points) { - VlcPoint* pointp = &points().pointNumber(i.second); + VlcPoint* const pointp = &points().pointNumber(i.second); // If any tests hit this point, then we'll need to cover it. if (pointp->testsCovering()) remaining.addData(pointp->pointNum(), 1); } @@ -182,7 +182,7 @@ void VlcTop::rank() { } } } - if (VlcTest* testp = bestTestp) { + if (VlcTest* const testp = bestTestp) { testp->rank(nextrank++); testp->rankPoints(bestRemain); remaining.orData(bestTestp->buckets()); @@ -227,7 +227,7 @@ void VlcTop::annotateCalc() { } else if (*covp == '-') { range = true; } else if (std::isdigit(*covp)) { - const char* digitsp = covp; + const char* const digitsp = covp; while (std::isdigit(*covp)) ++covp; --covp; // Will inc in for loop if (!range) start = std::atoi(digitsp); @@ -279,13 +279,13 @@ void VlcTop::annotateOutputFiles(const string& dirname) { UINFO(1, "annotateOutputFile " << filename << " -> " << outfilename << endl); - std::ifstream is(filename.c_str()); + std::ifstream is{filename.c_str()}; if (!is) { v3error("Can't read " << filename); return; } - std::ofstream os(outfilename.c_str()); + std::ofstream os{outfilename.c_str()}; if (!os) { v3fatal("Can't write " << outfilename); return;