diff --git a/include/verilated_profiler.cpp b/include/verilated_profiler.cpp index 85d76352b..7ea499c1b 100644 --- a/include/verilated_profiler.cpp +++ b/include/verilated_profiler.cpp @@ -173,7 +173,7 @@ void VlExecutionProfiler::dump(const char* filenamep, uint64_t tickEnd) // Copy /proc/cpuinfo into this output so verilator_gantt can be run on // a different machine { - const std::unique_ptr ifp{new std::ifstream("/proc/cpuinfo")}; + const std::unique_ptr ifp{new std::ifstream{"/proc/cpuinfo"}}; if (!ifp->fail()) { std::string line; while (std::getline(*ifp, line)) { fprintf(fp, "VLPROFPROC %s\n", line.c_str()); } diff --git a/src/V3Config.cpp b/src/V3Config.cpp index 9570c7245..1cefb40cf 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -291,7 +291,7 @@ public: } void addLineAttribute(int lineno, VPragmaType attr) { m_lineAttrs[lineno].set(attr); } void addIgnore(V3ErrorCode code, int lineno, bool on) { - m_ignLines.insert(V3ConfigIgnoresLine(code, lineno, on)); + m_ignLines.insert(V3ConfigIgnoresLine{code, lineno, on}); m_lastIgnore.it = m_ignLines.begin(); } void addWaiver(V3ErrorCode code, const string& match) { diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 07f985362..1cfccf607 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -144,9 +144,9 @@ private: for (AstNode* stmtp = newfuncp->argsp(); stmtp; stmtp = stmtp->nextp()) { if (AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && !portp->isFuncReturn()) { - AstVarRef* const newp = new AstVarRef( + AstVarRef* const newp = new AstVarRef{ portp->fileline(), portp, - portp->isWritable() ? VAccess::WRITE : VAccess::READ); + portp->isWritable() ? VAccess::WRITE : VAccess::READ}; argsp = AstNode::addNext(argsp, newp); } } @@ -161,14 +161,14 @@ private: AstNode* const returnp = new AstCReturn{funcp->fileline(), callp}; if (moreOfSame) { - AstIf* const ifp = new AstIf( + AstIf* const ifp = new AstIf{ funcp->fileline(), - new AstEq( - funcp->fileline(), new AstCExpr(funcp->fileline(), "this", 64), - new AstCExpr(funcp->fileline(), + new AstEq{ + funcp->fileline(), new AstCExpr{funcp->fileline(), "this", 64}, + new AstCExpr{funcp->fileline(), string("&(") + funcp->scopep()->nameVlSym() + ")", - 64)), - returnp); + 64}}, + returnp}; newfuncp->addStmtsp(ifp); } else { newfuncp->addStmtsp(returnp); diff --git a/src/V3EmitCBase.cpp b/src/V3EmitCBase.cpp index c481f5bba..1a426e1bb 100644 --- a/src/V3EmitCBase.cpp +++ b/src/V3EmitCBase.cpp @@ -58,7 +58,7 @@ string EmitCBaseVisitor::funcNameProtect(const AstCFunc* nodep, const AstNodeMod } AstCFile* EmitCBaseVisitor::newCFile(const string& filename, bool slow, bool source, bool add) { - AstCFile* const cfilep = new AstCFile(v3Global.rootp()->fileline(), filename); + AstCFile* const cfilep = new AstCFile{v3Global.rootp()->fileline(), filename}; cfilep->slow(slow); cfilep->source(source); if (add) v3Global.rootp()->addFilesp(cfilep); diff --git a/src/V3EmitCConstPool.cpp b/src/V3EmitCConstPool.cpp index 672d2cabb..00c3d9459 100644 --- a/src/V3EmitCConstPool.cpp +++ b/src/V3EmitCConstPool.cpp @@ -45,7 +45,7 @@ class EmitCConstPool final : public EmitCConstInit { const string fileName = v3Global.opt.makeDir() + "/" + topClassName() + "__ConstPool_" + cvtToStr(m_outFileCount) + ".cpp"; newCFile(fileName, /* slow: */ true, /* source: */ true); - V3OutCFile* const ofp = new V3OutCFile(fileName); + V3OutCFile* const ofp = new V3OutCFile{fileName}; ofp->putsHeader(); ofp->puts("// DESCRIPTION: Verilator output: Constant pool\n"); ofp->puts("//\n"); diff --git a/src/V3EmitCHeaders.cpp b/src/V3EmitCHeaders.cpp index d9197cd0c..a20c622ab 100644 --- a/src/V3EmitCHeaders.cpp +++ b/src/V3EmitCHeaders.cpp @@ -301,7 +301,7 @@ class EmitCHeader final : public EmitCConstInit { // Open output file const string filename = v3Global.opt.makeDir() + "/" + prefixNameProtect(modp) + ".h"; newCFile(filename, /* slow: */ false, /* source: */ false); - m_ofp = v3Global.opt.systemC() ? new V3OutScFile(filename) : new V3OutCFile(filename); + m_ofp = v3Global.opt.systemC() ? new V3OutScFile{filename} : new V3OutCFile{filename}; ofp()->putsHeader(); puts("// DESCRIPTION: Verilator output: Design internal header\n"); @@ -333,7 +333,7 @@ class EmitCHeader final : public EmitCConstInit { ~EmitCHeader() override = default; public: - static void main(const AstNodeModule* modp) { EmitCHeader emitCHeader(modp); } + static void main(const AstNodeModule* modp) { EmitCHeader emitCHeader{modp}; } }; //###################################################################### diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index 05749c259..cf6fa6ccd 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -167,7 +167,7 @@ class EmitCImp final : EmitCFunc { const string filename = VL_DEV_NULL; m_cfilesr.push_back( newCFile(filename, /* slow: */ m_slow, /* source: */ true, /* add */ false)); - m_ofp = new V3OutCFile(filename); + m_ofp = new V3OutCFile{filename}; } else { string filename = v3Global.opt.makeDir() + "/" + prefixNameProtect(m_fileModp); if (!subFileName.empty()) { @@ -178,7 +178,7 @@ class EmitCImp final : EmitCFunc { filename += ".cpp"; m_cfilesr.push_back( newCFile(filename, /* slow: */ m_slow, /* source: */ true, /* add */ false)); - m_ofp = v3Global.opt.systemC() ? new V3OutScFile(filename) : new V3OutCFile(filename); + m_ofp = v3Global.opt.systemC() ? new V3OutScFile{filename} : new V3OutCFile{filename}; } ofp()->putsHeader(); @@ -593,9 +593,9 @@ class EmitCTrace final : EmitCFunc { m_cfilesr.push_back(cfilep); if (optSystemC()) { - m_ofp = new V3OutScFile(filename); + m_ofp = new V3OutScFile{filename}; } else { - m_ofp = new V3OutCFile(filename); + m_ofp = new V3OutCFile{filename}; } m_ofp->putsHeader(); m_ofp->puts("// DESCR" @@ -937,10 +937,10 @@ void V3EmitC::emitcFiles() { filep = VN_AS(filep->nextp(), NodeFile)) { AstCFile* const cfilep = VN_CAST(filep, CFile); if (cfilep && cfilep->tblockp()) { - V3OutCFile of(cfilep->name()); + V3OutCFile of{cfilep->name()}; of.puts("// DESCR" "IPTION: Verilator generated C++\n"); - const EmitCFunc visitor(cfilep->tblockp(), &of, true); + const EmitCFunc visitor{cfilep->tblockp(), &of, true}; } } } diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 517d2618c..32cceae3a 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -59,7 +59,7 @@ class EmitCModel final : public EmitCFunc { const string filename = v3Global.opt.makeDir() + "/" + topClassName() + ".h"; newCFile(filename, /* slow: */ false, /* source: */ false); - m_ofp = v3Global.opt.systemC() ? new V3OutScFile(filename) : new V3OutCFile(filename); + m_ofp = v3Global.opt.systemC() ? new V3OutScFile{filename} : new V3OutCFile{filename}; ofp()->putsHeader(); puts("// DESCRIPTION: Verilator output: Primary model header\n"); @@ -598,7 +598,7 @@ class EmitCModel final : public EmitCFunc { const string filename = v3Global.opt.makeDir() + "/" + topClassName() + ".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}; ofp()->putsHeader(); puts("// DESCRIPTION: Verilator output: " diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 756b29096..f19410b84 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -378,9 +378,9 @@ void EmitCSyms::emitSymHdr() { newCFile(filename, true /*slow*/, false /*source*/); if (v3Global.opt.systemC()) { - m_ofp = new V3OutScFile(filename); + m_ofp = new V3OutScFile{filename}; } else { - m_ofp = new V3OutCFile(filename); + m_ofp = new V3OutCFile{filename}; } ofp()->putsHeader(); @@ -569,9 +569,9 @@ void EmitCSyms::checkSplit(bool usesVfinal) { closeSplit(); if (v3Global.opt.systemC()) { - m_ofp = new V3OutScFile(filename); + m_ofp = new V3OutScFile{filename}; } else { - m_ofp = new V3OutCFile(filename); + m_ofp = new V3OutCFile{filename}; } m_ofpBase->puts(symClassName() + "_" + cvtToStr(m_funcNum) + "("); @@ -650,9 +650,9 @@ void EmitCSyms::emitSymImp() { cfilep->support(true); if (v3Global.opt.systemC()) { - m_ofp = new V3OutScFile(filename); + m_ofp = new V3OutScFile{filename}; } else { - m_ofp = new V3OutCFile(filename); + m_ofp = new V3OutCFile{filename}; } m_ofpBase = m_ofp; diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index f51f0fe34..7c1bf0094 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -39,7 +39,7 @@ public: void emitClassMake() { // Generate the makefile - V3OutMkFile of(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_classes.mk"); + V3OutMkFile of{v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_classes.mk"}; of.putsHeader(); of.puts("# DESCR" "IPTION: Verilator output: Make include file with class lists\n"); @@ -135,7 +135,7 @@ public: void emitOverallMake() { // Generate the makefile - V3OutMkFile of(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".mk"); + V3OutMkFile of{v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".mk"}; of.putsHeader(); of.puts("# DESCR" "IPTION: Verilator output: " @@ -398,7 +398,7 @@ public: explicit EmitMkHierVerilation(const V3HierBlockPlan* planp) : m_planp{planp} , m_makefile{v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_hier.mk"} { - V3OutMkFile of(m_makefile); + V3OutMkFile of{m_makefile}; emit(of); } }; diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 02f658334..bf56a4b11 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -880,7 +880,7 @@ void V3EmitV::emitvFiles() { filep = VN_AS(filep->nextp(), NodeFile)) { AstVFile* const vfilep = VN_CAST(filep, VFile); if (vfilep && vfilep->tblockp()) { - V3OutVFile of(vfilep->name()); + V3OutVFile of{vfilep->name()}; of.puts("// DESCR" "IPTION: Verilator generated Verilog\n"); { EmitVFileVisitor{vfilep->tblockp(), &of, true, false}; } diff --git a/src/V3File.cpp b/src/V3File.cpp index a8e23182a..eef75c73a 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -125,7 +125,7 @@ public: if (m_filenameSet.find(filename) == m_filenameSet.end()) { // cppcheck-suppress stlFindInsert // cppcheck 1.90 bug m_filenameSet.insert(filename); - DependFile df(filename, false); + DependFile df{filename, false}; df.loadStats(); // Get size now, in case changes during the run m_filenameList.insert(df); } @@ -134,7 +134,7 @@ public: if (m_filenameSet.find(filename) == m_filenameSet.end()) { // cppcheck-suppress stlFindInsert // cppcheck 1.90 bug m_filenameSet.insert(filename); - m_filenameList.insert(DependFile(filename, true)); + m_filenameList.insert(DependFile{filename, true}); } } void writeDepend(const string& filename); @@ -603,7 +603,7 @@ protected: // VInFilter // Just dispatch to the implementation -VInFilter::VInFilter(const string& command) { m_impp = new VInFilterImp(command); } +VInFilter::VInFilter(const string& command) { m_impp = new VInFilterImp{command}; } VInFilter::~VInFilter() { if (m_impp) VL_DO_CLEAR(delete m_impp, m_impp = nullptr); } @@ -1002,7 +1002,7 @@ public: // missing a protect() out = "PS" + old; } else { - VHashSha256 digest(v3Global.opt.protectKeyDefaulted()); + VHashSha256 digest{v3Global.opt.protectKeyDefaulted()}; digest.insert(old); // Add "PS" prefix (Protect Symbols) as cannot start symbol with number out = "PS" + digest.digestSymbol(); @@ -1044,7 +1044,7 @@ public: return out; } void writeMapFile(const string& filename) const { - V3OutXmlFile of(filename); + V3OutXmlFile of{filename}; of.putsHeader(); of.puts("\n"); diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index 3704d4631..8a83b110e 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -279,7 +279,7 @@ FileLine* FileLine::copyOrSameFileLine() { if (lastNewp && *lastNewp == *this) { // Compares lineno, filename, etc return lastNewp; } - FileLine* const newp = new FileLine(this); + FileLine* const newp = new FileLine{this}; lastNewp = newp; return newp; } @@ -340,7 +340,7 @@ bool FileLine::warnOff(const string& msg, bool flag) { warnOff(V3ErrorCode::UNUSEDSIGNAL, flag); return true; } - const V3ErrorCode code(cmsg); + const V3ErrorCode code{cmsg}; if (code < V3ErrorCode::EC_FIRST_WARN) { return false; } else { diff --git a/src/V3Graph.cpp b/src/V3Graph.cpp index 4218394fa..ca3a4ed91 100644 --- a/src/V3Graph.cpp +++ b/src/V3Graph.cpp @@ -80,9 +80,9 @@ void V3GraphVertex::rerouteEdges(V3Graph* graphp) { // Make new edges for each from/to pair for (V3GraphEdge* iedgep = inBeginp(); iedgep; iedgep = iedgep->inNextp()) { for (V3GraphEdge* oedgep = outBeginp(); oedgep; oedgep = oedgep->outNextp()) { - new V3GraphEdge(graphp, iedgep->fromp(), oedgep->top(), + new V3GraphEdge{graphp, iedgep->fromp(), oedgep->top(), std::min(iedgep->weight(), oedgep->weight()), - iedgep->cutable() && oedgep->cutable()); + iedgep->cutable() && oedgep->cutable()}; } } // Remove old edges diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index e2be3e019..5a6b4bff2 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -126,8 +126,8 @@ private: } V3GraphEdge* edgeFromEdge(V3GraphEdge* oldedgep, V3GraphVertex* fromp, V3GraphVertex* top) { // Make new breakGraph edge, with old edge as a template - GraphAcycEdge* const newEdgep = new GraphAcycEdge(&m_breakGraph, fromp, top, - oldedgep->weight(), oldedgep->cutable()); + GraphAcycEdge* const newEdgep = new GraphAcycEdge{&m_breakGraph, fromp, top, + oldedgep->weight(), oldedgep->cutable()}; newEdgep->userp(oldedgep->userp()); // Keep pointer to OrigEdgeList return newEdgep; } @@ -203,7 +203,7 @@ void GraphAcyc::buildGraph(V3Graph* origGraphp) { for (V3GraphVertex* overtexp = origGraphp->verticesBeginp(); overtexp; overtexp = overtexp->verticesNextp()) { if (overtexp->color()) { - GraphAcycVertex* const avertexp = new GraphAcycVertex(&m_breakGraph, overtexp); + GraphAcycVertex* const avertexp = new GraphAcycVertex{&m_breakGraph, overtexp}; overtexp->userp(avertexp); // Stash so can look up later } } @@ -228,8 +228,8 @@ void GraphAcyc::buildGraphIterate(V3GraphVertex* overtexp, GraphAcycVertex* aver = static_cast(toVertexp->userp()); // Replicate the old edge into the new graph // There may be multiple edges between same pairs of vertices - V3GraphEdge* breakEdgep = new GraphAcycEdge(&m_breakGraph, avertexp, toAVertexp, - edgep->weight(), edgep->cutable()); + V3GraphEdge* breakEdgep = new GraphAcycEdge{&m_breakGraph, avertexp, toAVertexp, + edgep->weight(), edgep->cutable()}; addOrigEdgep(breakEdgep, edgep); // So can find original edge } } diff --git a/src/V3GraphAlg.cpp b/src/V3GraphAlg.cpp index b74de1351..c8af95e3f 100644 --- a/src/V3GraphAlg.cpp +++ b/src/V3GraphAlg.cpp @@ -106,7 +106,7 @@ public: explicit GraphAlgRemoveTransitiveEdges(V3Graph* graphp) : GraphAlg<>(graphp, nullptr) {} void go() { - GraphPathChecker checker(m_graphp); + GraphPathChecker checker{m_graphp}; for (V3GraphVertex* vxp = m_graphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { V3GraphEdge* deletep = nullptr; for (V3GraphEdge* edgep = vxp->outBeginp(); edgep; edgep = edgep->outNextp()) { @@ -125,7 +125,7 @@ private: VL_UNCOPYABLE(GraphAlgRemoveTransitiveEdges); }; -void V3Graph::removeTransitiveEdges() { GraphAlgRemoveTransitiveEdges(this).go(); } +void V3Graph::removeTransitiveEdges() { GraphAlgRemoveTransitiveEdges{this}.go(); } //###################################################################### //###################################################################### @@ -166,7 +166,7 @@ public: ~GraphAlgWeakly() = default; }; -void V3Graph::weaklyConnected(V3EdgeFuncP edgeFuncp) { GraphAlgWeakly(this, edgeFuncp); } +void V3Graph::weaklyConnected(V3EdgeFuncP edgeFuncp) { GraphAlgWeakly{this, edgeFuncp}; } //###################################################################### //###################################################################### @@ -257,7 +257,7 @@ public: ~GraphAlgStrongly() = default; }; -void V3Graph::stronglyConnected(V3EdgeFuncP edgeFuncp) { GraphAlgStrongly(this, edgeFuncp); } +void V3Graph::stronglyConnected(V3EdgeFuncP edgeFuncp) { GraphAlgStrongly{this, edgeFuncp}; } //###################################################################### //###################################################################### @@ -310,9 +310,9 @@ public: ~GraphAlgRank() = default; }; -void V3Graph::rank() { GraphAlgRank(this, &V3GraphEdge::followAlwaysTrue); } +void V3Graph::rank() { GraphAlgRank{this, &V3GraphEdge::followAlwaysTrue}; } -void V3Graph::rank(V3EdgeFuncP edgeFuncp) { GraphAlgRank(this, edgeFuncp); } +void V3Graph::rank(V3EdgeFuncP edgeFuncp) { GraphAlgRank{this, edgeFuncp}; } //###################################################################### //###################################################################### diff --git a/src/V3GraphTest.cpp b/src/V3GraphTest.cpp index 3fdb8dfe7..540a5d85a 100644 --- a/src/V3GraphTest.cpp +++ b/src/V3GraphTest.cpp @@ -83,24 +83,24 @@ public: V3Graph* gp = &m_graph; // Verify we break edges at a good point // A simple alg would make 3 breaks, below only requires b->i to break - V3GraphTestVertex* i = new V3GraphTestVarVertex(gp, "*INPUTS*"); - V3GraphTestVertex* a = new V3GraphTestVarVertex(gp, "a"); - V3GraphTestVertex* b = new V3GraphTestVarVertex(gp, "b"); - V3GraphTestVertex* g1 = new V3GraphTestVarVertex(gp, "g1"); - V3GraphTestVertex* g2 = new V3GraphTestVarVertex(gp, "g2"); - V3GraphTestVertex* g3 = new V3GraphTestVarVertex(gp, "g3"); - V3GraphTestVertex* q = new V3GraphTestVarVertex(gp, "q"); - new V3GraphEdge(gp, i, a, 2, true); - new V3GraphEdge(gp, a, b, 2, true); - new V3GraphEdge(gp, b, g1, 2, true); - new V3GraphEdge(gp, b, g2, 2, true); - new V3GraphEdge(gp, b, g3, 2, true); - new V3GraphEdge(gp, g1, a, 2, true); - new V3GraphEdge(gp, g3, g2, 2, true); - new V3GraphEdge(gp, g2, g3, 2, true); - new V3GraphEdge(gp, g1, q, 2, true); - new V3GraphEdge(gp, g2, q, 2, true); - new V3GraphEdge(gp, g3, q, 2, true); + V3GraphTestVertex* i = new V3GraphTestVarVertex{gp, "*INPUTS*"}; + V3GraphTestVertex* a = new V3GraphTestVarVertex{gp, "a"}; + V3GraphTestVertex* b = new V3GraphTestVarVertex{gp, "b"}; + V3GraphTestVertex* g1 = new V3GraphTestVarVertex{gp, "g1"}; + V3GraphTestVertex* g2 = new V3GraphTestVarVertex{gp, "g2"}; + V3GraphTestVertex* g3 = new V3GraphTestVarVertex{gp, "g3"}; + V3GraphTestVertex* q = new V3GraphTestVarVertex{gp, "q"}; + new V3GraphEdge{gp, i, a, 2, true}; + new V3GraphEdge{gp, a, b, 2, true}; + new V3GraphEdge{gp, b, g1, 2, true}; + new V3GraphEdge{gp, b, g2, 2, true}; + new V3GraphEdge{gp, b, g3, 2, true}; + new V3GraphEdge{gp, g1, a, 2, true}; + new V3GraphEdge{gp, g3, g2, 2, true}; + new V3GraphEdge{gp, g2, g3, 2, true}; + new V3GraphEdge{gp, g1, q, 2, true}; + new V3GraphEdge{gp, g2, q, 2, true}; + new V3GraphEdge{gp, g3, q, 2, true}; gp->stronglyConnected(&V3GraphEdge::followAlwaysTrue); dumpSelf(); @@ -121,20 +121,20 @@ public: V3Graph* gp = &m_graph; // Verify we break edges at a good point // A simple alg would make 3 breaks, below only requires b->i to break - V3GraphTestVertex* i = new V3GraphTestVarVertex(gp, "*INPUTS*"); - V3GraphTestVertex* a = new V3GraphTestVarVertex(gp, "a"); - V3GraphTestVertex* b = new V3GraphTestVarVertex(gp, "b"); - V3GraphTestVertex* g1 = new V3GraphTestVarVertex(gp, "g1"); - V3GraphTestVertex* g2 = new V3GraphTestVarVertex(gp, "g2"); - V3GraphTestVertex* g3 = new V3GraphTestVarVertex(gp, "g3"); - new V3GraphEdge(gp, i, a, 2, true); - new V3GraphEdge(gp, a, b, 2, true); - new V3GraphEdge(gp, b, g1, 2, true); - new V3GraphEdge(gp, b, g2, 2, true); - new V3GraphEdge(gp, b, g3, 2, true); - new V3GraphEdge(gp, g1, a, 2, true); - new V3GraphEdge(gp, g2, a, 2, true); - new V3GraphEdge(gp, g3, a, 2, true); + V3GraphTestVertex* i = new V3GraphTestVarVertex{gp, "*INPUTS*"}; + V3GraphTestVertex* a = new V3GraphTestVarVertex{gp, "a"}; + V3GraphTestVertex* b = new V3GraphTestVarVertex{gp, "b"}; + V3GraphTestVertex* g1 = new V3GraphTestVarVertex{gp, "g1"}; + V3GraphTestVertex* g2 = new V3GraphTestVarVertex{gp, "g2"}; + V3GraphTestVertex* g3 = new V3GraphTestVarVertex{gp, "g3"}; + new V3GraphEdge{gp, i, a, 2, true}; + new V3GraphEdge{gp, a, b, 2, true}; + new V3GraphEdge{gp, b, g1, 2, true}; + new V3GraphEdge{gp, b, g2, 2, true}; + new V3GraphEdge{gp, b, g3, 2, true}; + new V3GraphEdge{gp, g1, a, 2, true}; + new V3GraphEdge{gp, g2, a, 2, true}; + new V3GraphEdge{gp, g3, a, 2, true}; gp->acyclic(&V3GraphEdge::followAlwaysTrue); gp->order(); @@ -148,20 +148,20 @@ public: void runTest() override { V3Graph* gp = &m_graph; - V3GraphTestVertex* clk = new V3GraphTestVarVertex(gp, "$clk"); + V3GraphTestVertex* clk = new V3GraphTestVarVertex{gp, "$clk"}; - V3GraphTestVertex* a = new V3GraphTestVarVertex(gp, "$a"); - V3GraphTestVertex* a_dly = new V3GraphTestVarVertex(gp, "$a_dly"); - V3GraphTestVertex* a_dlyblk = new V3GraphTestVarVertex(gp, "$a_dlyblk"); - V3GraphTestVertex* b = new V3GraphTestVarVertex(gp, "$b"); - V3GraphTestVertex* b_dly = new V3GraphTestVarVertex(gp, "$b_dly"); - V3GraphTestVertex* b_dlyblk = new V3GraphTestVarVertex(gp, "$b_dlyblk"); - V3GraphTestVertex* c = new V3GraphTestVarVertex(gp, "$c"); - V3GraphTestVertex* i = new V3GraphTestVarVertex(gp, "$i"); + V3GraphTestVertex* a = new V3GraphTestVarVertex{gp, "$a"}; + V3GraphTestVertex* a_dly = new V3GraphTestVarVertex{gp, "$a_dly"}; + V3GraphTestVertex* a_dlyblk = new V3GraphTestVarVertex{gp, "$a_dlyblk"}; + V3GraphTestVertex* b = new V3GraphTestVarVertex{gp, "$b"}; + V3GraphTestVertex* b_dly = new V3GraphTestVarVertex{gp, "$b_dly"}; + V3GraphTestVertex* b_dlyblk = new V3GraphTestVarVertex{gp, "$b_dlyblk"}; + V3GraphTestVertex* c = new V3GraphTestVarVertex{gp, "$c"}; + V3GraphTestVertex* i = new V3GraphTestVarVertex{gp, "$i"}; - V3GraphTestVertex* ap = new V3GraphTestVarVertex(gp, "$a_pre"); - V3GraphTestVertex* bp = new V3GraphTestVarVertex(gp, "$b_pre"); - V3GraphTestVertex* cp = new V3GraphTestVarVertex(gp, "$c_pre"); + V3GraphTestVertex* ap = new V3GraphTestVarVertex{gp, "$a_pre"}; + V3GraphTestVertex* bp = new V3GraphTestVarVertex{gp, "$b_pre"}; + V3GraphTestVertex* cp = new V3GraphTestVarVertex{gp, "$c_pre"}; V3GraphTestVertex* n; @@ -176,68 +176,68 @@ public: // Desired order between different _DLY blocks so we can elim temporaries // implemented by cutable "pre" signal dependencies - n = new V3GraphTestVertex(gp, "*INPUTS*"); + n = new V3GraphTestVertex{gp, "*INPUTS*"}; { - new V3GraphEdge(gp, n, clk, 2); - new V3GraphEdge(gp, n, i, 2); + new V3GraphEdge{gp, n, clk, 2}; + new V3GraphEdge{gp, n, i, 2}; } - V3GraphTestVertex* posedge = n = new V3GraphTestVertex(gp, "*posedge clk*"); - { new V3GraphEdge(gp, clk, n, 2); } + V3GraphTestVertex* posedge = n = new V3GraphTestVertex{gp, "*posedge clk*"}; + { new V3GraphEdge{gp, clk, n, 2}; } // AssignPre's VarRefs on LHS: generate special BLK // normal: VarRefs on LHS: generate normal // underSBlock: VarRefs on RHS: consume 'pre' (required to save cutable tests) - n = new V3GraphTestVertex(gp, "a_dlyacyclic(&V3GraphEdge::followAlwaysTrue); @@ -294,9 +294,9 @@ void V3Graph::selfTest() { // Execute all of the tests UINFO(2, __FUNCTION__ << ": " << endl); // clang-format off - { V3GraphTestStrong test; test.run(); } - { V3GraphTestAcyc test; test.run(); } - { V3GraphTestVars test; test.run(); } - { V3GraphTestImport test; test.run(); } + { V3GraphTestStrong{}.run(); } + { V3GraphTestAcyc{}.run(); } + { V3GraphTestVars{}.run(); } + { V3GraphTestImport{}.run(); } // clang-format on } diff --git a/src/V3Hash.h b/src/V3Hash.h index 0fda1b6c9..b9ab8bd98 100644 --- a/src/V3Hash.h +++ b/src/V3Hash.h @@ -59,7 +59,7 @@ public: // '+' combines hashes template V3Hash operator+(T that) const { - return V3Hash(combine(m_value, V3Hash(that).m_value)); + return V3Hash(combine(m_value, V3Hash{that}.m_value)); } // '+=' combines in place diff --git a/src/V3Hasher.cpp b/src/V3Hasher.cpp index 2916d70cf..2b72c0bc5 100644 --- a/src/V3Hasher.cpp +++ b/src/V3Hasher.cpp @@ -42,11 +42,11 @@ private: std::function&& f) { // See comments in visit(AstCFunc) about this breaking recursion if (m_cacheInUser4 && nodep->user4()) { - return V3Hash(nodep->user4()); + return V3Hash{nodep->user4()}; } else { VL_RESTORER(m_hash); // Reset accumulator - m_hash = V3Hash(nodep->type()); // Node type + m_hash = V3Hash{nodep->type()}; // Node type f(); // Node specific hash if (hashDType && nodep != nodep->dtypep()) iterateNull(nodep->dtypep()); // Node dtype if (hashChildren) iterateChildrenConst(nodep); // Children @@ -401,7 +401,7 @@ private: m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // // We might be in a recursive function, if so on *second* call // here we need to break what would be an infinite loop. - nodep->user4(V3Hash(1).value()); // Set this "first" call + nodep->user4(V3Hash{1}.value()); // Set this "first" call // So that a second call will then exit hashNodeAndIterate // Having a constant in the hash just means the recursion will // end, it shouldn't change the CFunc having a unique hash itself. @@ -518,13 +518,13 @@ public: V3Hash V3Hasher::operator()(AstNode* nodep) const { if (!nodep->user4()) HasherVisitor{nodep}; - return V3Hash(nodep->user4()); + return V3Hash{nodep->user4()}; } V3Hash V3Hasher::rehash(AstNode* nodep) const { nodep->user4(0); { HasherVisitor{nodep}; } - return V3Hash(nodep->user4()); + return V3Hash{nodep->user4()}; } V3Hash V3Hasher::uncachedHash(const AstNode* nodep) { diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index 5f4754925..a1a2342aa 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -311,7 +311,7 @@ public: void V3HierBlockPlan::add(const AstNodeModule* modp, const std::vector& gparams) { const iterator it = m_blocks.find(modp); if (it == m_blocks.end()) { - V3HierBlock* hblockp = new V3HierBlock(modp, gparams); + V3HierBlock* hblockp = new V3HierBlock{modp, gparams}; UINFO(3, "Add " << modp->prettyNameQ() << " with " << gparams.size() << " parameters" << std::endl); m_blocks.emplace(modp, hblockp); diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 8d0eb3b6d..26abb43c6 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -292,8 +292,8 @@ private: UASSERT_OBJ(exprconstp || exprvarrefp, nodep, "Unknown interconnect type; pinReconnectSimple should have cleared up"); if (exprconstp) { - m_modp->addStmtsp(new AstAssignW(flp, new AstVarRef(flp, nodep, VAccess::WRITE), - exprconstp->cloneTree(false))); + m_modp->addStmtsp(new AstAssignW{flp, new AstVarRef{flp, nodep, VAccess::WRITE}, + exprconstp->cloneTree(false)}); } else if (nodep->user3()) { // Public variable at the lower module end - we need to make sure we propagate // the logic changes up and down; if we aliased, we might @@ -301,8 +301,8 @@ private: UINFO(9, "public pin assign: " << exprvarrefp << endl); UASSERT_OBJ(!nodep->isNonOutput(), nodep, "Outputs only - inputs use AssignAlias"); m_modp->addStmtsp( - new AstAssignW(flp, new AstVarRef(flp, exprvarrefp->varp(), VAccess::WRITE), - new AstVarRef(flp, nodep, VAccess::READ))); + new AstAssignW{flp, new AstVarRef{flp, exprvarrefp->varp(), VAccess::WRITE}, + new AstVarRef{flp, nodep, VAccess::READ}}); } else if (nodep->isSigPublic() && VN_IS(nodep->dtypep(), UnpackArrayDType)) { // Public variable at this end and it is an unpacked array. We need to assign // instead of aliased, because otherwise it will pass V3Slice and invalid @@ -313,8 +313,8 @@ private: new AstVarRef{flp, exprvarrefp->varp(), VAccess::READ}}); } else if (nodep->isIfaceRef()) { m_modp->addStmtsp( - new AstAssignVarScope(flp, new AstVarRef(flp, nodep, VAccess::WRITE), - new AstVarRef(flp, exprvarrefp->varp(), VAccess::READ))); + new AstAssignVarScope{flp, new AstVarRef{flp, nodep, VAccess::WRITE}, + new AstVarRef{flp, exprvarrefp->varp(), VAccess::READ}}); FileLine* const flbp = exprvarrefp->varp()->fileline(); flp->modifyStateInherit(flbp); flbp->modifyStateInherit(flp); @@ -322,8 +322,8 @@ private: // Do to inlining child's variable now within the same // module, so a AstVarRef not AstVarXRef below m_modp->addStmtsp( - new AstAssignAlias(flp, new AstVarRef(flp, nodep, VAccess::WRITE), - new AstVarRef(flp, exprvarrefp->varp(), VAccess::READ))); + new AstAssignAlias{flp, new AstVarRef{flp, nodep, VAccess::WRITE}, + new AstVarRef{flp, exprvarrefp->varp(), VAccess::READ}}); FileLine* const flbp = exprvarrefp->varp()->fileline(); flp->modifyStateInherit(flbp); flbp->modifyStateInherit(flp); @@ -519,8 +519,8 @@ private: }); // Create data for dotted variable resolution AstCellInline* const inlinep - = new AstCellInline(nodep->fileline(), nodep->name(), nodep->modp()->origName(), - nodep->modp()->timeunit()); + = new AstCellInline{nodep->fileline(), nodep->name(), nodep->modp()->origName(), + nodep->modp()->timeunit()}; m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells // Create assignments to the pins for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { @@ -659,7 +659,7 @@ private: if ((cellp = VN_CAST(fromVarp->user1p(), Cell)) || (cellp = irdtp->cellp())) { varp->user1p(cellp); const string alias = m_scope + "__DOT__" + pinp->name(); - cellp->addIntfRefsp(new AstIntfRef(pinp->fileline(), alias)); + cellp->addIntfRefsp(new AstIntfRef{pinp->fileline(), alias}); } } @@ -688,7 +688,7 @@ private: string alias; if (!m_scope.empty()) alias = m_scope + "__DOT__"; alias += varlp->name(); - cellp->addIntfRefsp(new AstIntfRef(varlp->fileline(), alias)); + cellp->addIntfRefsp(new AstIntfRef{varlp->fileline(), alias}); } //-------------------- void visit(AstNodeExpr*) override {} // Accelerate diff --git a/src/V3Life.cpp b/src/V3Life.cpp index d1a3ff617..407880934 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -350,8 +350,8 @@ private: // Condition is part of PREVIOUS block iterateAndNextNull(nodep->condp()); LifeBlock* const prevLifep = m_lifep; - LifeBlock* const ifLifep = new LifeBlock(prevLifep, m_statep); - LifeBlock* const elseLifep = new LifeBlock(prevLifep, m_statep); + LifeBlock* const ifLifep = new LifeBlock{prevLifep, m_statep}; + LifeBlock* const elseLifep = new LifeBlock{prevLifep, m_statep}; { m_lifep = ifLifep; iterateAndNextNull(nodep->thensp()); @@ -380,8 +380,8 @@ private: // it as a IF statement, and just don't allow elimination of // variables across the body. LifeBlock* const prevLifep = m_lifep; - LifeBlock* const condLifep = new LifeBlock(prevLifep, m_statep); - LifeBlock* const bodyLifep = new LifeBlock(prevLifep, m_statep); + LifeBlock* const condLifep = new LifeBlock{prevLifep, m_statep}; + LifeBlock* const bodyLifep = new LifeBlock{prevLifep, m_statep}; { m_lifep = condLifep; iterateAndNextNull(nodep->precondsp()); @@ -405,7 +405,7 @@ private: // It's worse though as an IF(..., JUMPGO) may change the control flow. // Just don't optimize blocks with labels; they're rare - so far. LifeBlock* const prevLifep = m_lifep; - LifeBlock* const bodyLifep = new LifeBlock(prevLifep, m_statep); + LifeBlock* const bodyLifep = new LifeBlock{prevLifep, m_statep}; { VL_RESTORER(m_noopt); m_lifep = bodyLifep; @@ -461,7 +461,7 @@ public: : m_statep{statep} { UINFO(4, " LifeVisitor on " << nodep << endl); { - m_lifep = new LifeBlock(nullptr, m_statep); + m_lifep = new LifeBlock{nullptr, m_statep}; iterate(nodep); if (m_lifep) VL_DO_CLEAR(delete m_lifep, m_lifep = nullptr); } diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 6ad15bad7..780026a4f 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -263,7 +263,7 @@ private: if (v3Global.opt.mtasks()) { UASSERT_OBJ(m_mtasksGraphp, nodep, "Should have initted m_mtasksGraphp by now"); - m_checker.reset(new GraphPathChecker(m_mtasksGraphp)); + m_checker.reset(new GraphPathChecker{m_mtasksGraphp}); } else { UASSERT_OBJ(!m_mtasksGraphp, nodep, "Did not expect any m_mtasksGraphp in serial mode"); diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index 417cd08dc..171349790 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -147,7 +147,7 @@ void V3LinkLevel::wrapTop(AstNetlist* rootp) { return; } - AstNodeModule* const newmodp = new AstModule(oldmodp->fileline(), "$root"); + AstNodeModule* const newmodp = new AstModule{oldmodp->fileline(), "$root"}; newmodp->name(AstNode::encodeName(newmodp->name())); // so origName is nice // Make the new module first in the list oldmodp->unlinkFrBackWithNext(); @@ -167,10 +167,10 @@ void V3LinkLevel::wrapTop(AstNetlist* rootp) { for (AstNodeModule* modp = rootp->modulesp(); modp; modp = VN_AS(modp->nextp(), NodeModule)) { if (VN_IS(modp, Package)) { AstCell* const cellp - = new AstCell(modp->fileline(), modp->fileline(), + = new AstCell{modp->fileline(), modp->fileline(), // Could add __03a__03a="::" to prevent conflict // with module names/"v" - modp->name(), modp->name(), nullptr, nullptr, nullptr); + modp->name(), modp->name(), nullptr, nullptr, nullptr}; cellp->modp(modp); newmodp->addStmtsp(cellp); } @@ -240,10 +240,14 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { if (VN_IS(oldmodp, Package)) continue; // Add instance UINFO(5, "LOOP " << oldmodp << endl); - AstCell* const cellp = new AstCell( - newmodp->fileline(), newmodp->fileline(), + AstCell* const cellp = new AstCell{ + newmodp->fileline(), + newmodp->fileline(), (!v3Global.opt.l2Name().empty() ? v3Global.opt.l2Name() : oldmodp->name()), - oldmodp->name(), nullptr, nullptr, nullptr); + oldmodp->name(), + nullptr, + nullptr, + nullptr}; cellp->modp(oldmodp); newmodp->addStmtsp(cellp); @@ -279,10 +283,10 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { varp->trace(false); } - AstPin* const pinp = new AstPin( + AstPin* const pinp = new AstPin{ oldvarp->fileline(), 0, varp->name(), - new AstVarRef(varp->fileline(), varp, - oldvarp->isWritable() ? VAccess::WRITE : VAccess::READ)); + new AstVarRef{varp->fileline(), varp, + oldvarp->isWritable() ? VAccess::WRITE : VAccess::READ}}; // Skip length and width comp; we know it's a direct assignment pinp->modVarp(oldvarp); cellp->addPinsp(pinp); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 9b6729e72..06d1bc27e 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -152,21 +152,21 @@ private: AstNode* const basefromp = AstArraySel::baseFromp(nodep, false); if (AstNodeVarRef* const varrefp = VN_CAST(basefromp, NodeVarRef)) { // Maybe varxref - so need to clone - nodep->attrp(new AstAttrOf(nodep->fileline(), VAttrType::VAR_BASE, - varrefp->cloneTree(false))); + nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE, + varrefp->cloneTree(false)}); } else if (AstUnlinkedRef* const uvxrp = VN_CAST(basefromp, UnlinkedRef)) { // Maybe unlinked - so need to clone - nodep->attrp(new AstAttrOf(nodep->fileline(), VAttrType::VAR_BASE, - uvxrp->cloneTree(false))); + nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE, + uvxrp->cloneTree(false)}); } else if (auto* const fromp = VN_CAST(basefromp, LambdaArgRef)) { - nodep->attrp(new AstAttrOf(nodep->fileline(), VAttrType::VAR_BASE, - fromp->cloneTree(false))); + nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE, + fromp->cloneTree(false)}); } else if (AstMemberSel* const fromp = VN_CAST(basefromp, MemberSel)) { - nodep->attrp(new AstAttrOf(nodep->fileline(), VAttrType::MEMBER_BASE, - fromp->cloneTree(false))); + nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::MEMBER_BASE, + fromp->cloneTree(false)}); } else if (AstEnumItemRef* const fromp = VN_CAST(basefromp, EnumItemRef)) { - nodep->attrp(new AstAttrOf(nodep->fileline(), VAttrType::ENUM_BASE, - fromp->cloneTree(false))); + nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::ENUM_BASE, + fromp->cloneTree(false)}); } else if (VN_IS(basefromp, Replicate)) { // From {...}[...] syntax in IEEE 2017 if (basefromp) UINFO(1, " Related node: " << basefromp << endl); @@ -412,9 +412,9 @@ private: varoutp = varp; // Tie off m_modp->addStmtsp( - new AstAssignW(varp->fileline(), - new AstVarRef(varp->fileline(), varp, VAccess::WRITE), - new AstConst(varp->fileline(), AstConst::BitFalse()))); + new AstAssignW{varp->fileline(), + new AstVarRef{varp->fileline(), varp, VAccess::WRITE}, + new AstConst{varp->fileline(), AstConst::BitFalse{}}}); } else { varp->v3error("Only inputs and outputs are allowed in udp modules"); } diff --git a/src/V3Options.cpp b/src/V3Options.cpp index e438d646e..f8dd03135 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -133,7 +133,7 @@ VTimescale::VTimescale(const string& value, bool& badr) badr = true; const string spaceless = VString::removeWhitespace(value); for (int i = TS_100S; i < _ENUM_END; ++i) { - const VTimescale ts(i); + const VTimescale ts{i}; if (spaceless == ts.ascii()) { badr = false; m_e = ts.m_e; @@ -258,7 +258,7 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr } bool unitbad; - const VTimescale unit(unitStr, unitbad /*ref*/); + const VTimescale unit{unitStr, unitbad /*ref*/}; if (unitbad && !(unitStr.empty() && allowEmpty)) { fl->v3error("`timescale timeunit syntax error: '" << unitStr << "'"); return; @@ -863,7 +863,7 @@ string V3Options::protectKeyDefaulted() { if (m_protectKey.empty()) { // Create a key with a human-readable symbol-like name. // This conversion drops ~2 bits of entropy out of 256, shouldn't matter. - VHashSha256 digest(V3Os::trueRandom(32)); + VHashSha256 digest{V3Os::trueRandom(32)}; m_protectKey = "VL-KEY-" + digest.digestSymbol(); } return m_protectKey; @@ -1198,7 +1198,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-hierarchical", OnOff, &m_hierarchical); DECL_OPTION("-hierarchical-block", CbVal, [this](const char* valp) { - const V3HierarchicalBlockOption opt(valp); + const V3HierarchicalBlockOption opt{valp}; m_hierBlocks.emplace(opt.mangledName(), opt); }); DECL_OPTION("-hierarchical-child", Set, &m_hierChild); @@ -1502,7 +1502,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char V3Error::pretendError(V3ErrorCode::UNUSEDSIGNAL, true); }); DECL_OPTION("-Werror-", CbPartialMatch, [this, fl](const char* optp) { - const V3ErrorCode code(optp); + const V3ErrorCode code{optp}; if (code == V3ErrorCode::EC_ERROR) { if (!isFuture(optp)) fl->v3fatal("Unknown warning specified: -Werror-" << optp); } else { diff --git a/src/V3Order.cpp b/src/V3Order.cpp index bd3a3ee6e..1e3f50987 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -498,7 +498,7 @@ public: if (iter != s_dsMap.end()) { return iter->second; } else { - OrderMoveDomScope* domScopep = new OrderMoveDomScope(domainp, scopep); + OrderMoveDomScope* domScopep = new OrderMoveDomScope{domainp, scopep}; s_dsMap.emplace(key, domScopep); return domScopep; } @@ -736,7 +736,7 @@ public: // METHODS OrderMoveVertex* makeVertexp(OrderLogicVertex* lvertexp, const OrderEitherVertex*, const AstSenTree* domainp) override { - OrderMoveVertex* const resultp = new OrderMoveVertex(m_pomGraphp, lvertexp); + OrderMoveVertex* const resultp = new OrderMoveVertex{m_pomGraphp, lvertexp}; AstScope* const scopep = lvertexp ? lvertexp->scopep() : nullptr; resultp->domScopep(OrderMoveDomScope::findCreate(domainp, scopep)); resultp->m_pomWaitingE.pushBack(*m_pomWaitingp, resultp); @@ -1358,7 +1358,7 @@ void OrderProcess::processMTasks() { const AbstractLogicMTask* const mtaskp = static_cast(mtaskVxp); // Create a body for this mtask - AstMTaskBody* const bodyp = new AstMTaskBody(rootFlp); + AstMTaskBody* const bodyp = new AstMTaskBody{rootFlp}; MTaskState& state = mtaskStates[mtaskp->id()]; state.m_mtaskBodyp = bodyp; @@ -1388,7 +1388,7 @@ void OrderProcess::processMTasks() { // - The ExecMTask graph and the AstMTaskBody's produced here // persist until code generation time. V3Graph* const depGraphp = execGraphp->depGraphp(); - state.m_execMTaskp = new ExecMTask(depGraphp, bodyp, mtaskp->id()); + state.m_execMTaskp = new ExecMTask{depGraphp, bodyp, mtaskp->id()}; // Cross-link each ExecMTask and MTaskBody // Q: Why even have two objects? // A: One is an AstNode, the other is a GraphVertex, @@ -1399,7 +1399,7 @@ void OrderProcess::processMTasks() { const AbstractLogicMTask* const fromp = static_cast(fromVxp); const MTaskState& fromState = mtaskStates[fromp->id()]; - new V3GraphEdge(depGraphp, fromState.m_execMTaskp, state.m_execMTaskp, 1); + new V3GraphEdge{depGraphp, fromState.m_execMTaskp, state.m_execMTaskp, 1}; } execGraphp->addMTaskBodiesp(bodyp); } diff --git a/src/V3Param.cpp b/src/V3Param.cpp index b1153931b..86434f450 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -211,7 +211,7 @@ public: } else { varNum.opAssign(pinValuep->num()); } - V3Number isEq(pinValuep, 1); + V3Number isEq{pinValuep, 1}; isEq.opEq(varNum, hierOptParamp->num()); return isEq.isNeqZero(); } @@ -344,7 +344,7 @@ class ParamProcessor final { const string key = paramValueKey(nodep); V3Hash hash = V3Hasher::uncachedHash(nodep); // Force hash collisions -- for testing only - if (VL_UNLIKELY(v3Global.opt.debugCollision())) hash = V3Hash(); + if (VL_UNLIKELY(v3Global.opt.debugCollision())) hash = V3Hash{}; int num; const auto it = m_valueMap.find(hash); if (it != m_valueMap.end() && it->second.second == key) { @@ -656,8 +656,8 @@ class ParamProcessor final { if (debug()) pinp->dumpTree(cout, "-nodes: "); pinp->v3error("Can't convert defparam value to constant: Param " << pinp->prettyNameQ() << " of " << nodep->prettyNameQ()); - pinp->exprp()->replaceWith(new AstConst( - pinp->fileline(), AstConst::WidthedValue(), modvarp->width(), 0)); + pinp->exprp()->replaceWith(new AstConst{ + pinp->fileline(), AstConst::WidthedValue{}, modvarp->width(), 0}); } else if (origp && exprp->sameTree(origp)) { // Setting parameter to its default value. Just ignore it. // This prevents making additional modules, and makes coverage more @@ -1220,7 +1220,7 @@ class ParamVisitor final : public VNVisitor { if (!itemp->isDefault()) { for (AstNode* ep = itemp->condsp(); ep; ep = ep->nextp()) { if (const AstConst* const ccondp = VN_CAST(ep, Const)) { - V3Number match(nodep, 1); + V3Number match{nodep, 1}; match.opEq(ccondp->num(), exprp->num()); if (!keepp && match.isNeqZero()) keepp = itemp->stmtsp(); } else { diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 4bc4f0d76..2236eb934 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -344,7 +344,7 @@ void V3PreProcImp::define(FileLine* fl, const string& name, const string& value, } undef(name); } - m_defines.emplace(name, VDefine(fl, value, params, cmdline)); + m_defines.emplace(name, VDefine{fl, value, params, cmdline}); } } @@ -1050,7 +1050,7 @@ int V3PreProcImp::getStateToken() { bool enable = defExists(m_lastSym); UINFO(4, "Ifdef " << m_lastSym << (enable ? " ON" : " OFF") << endl); if (state() == ps_DEFNAME_IFNDEF) enable = !enable; - m_ifdefStack.push(VPreIfEntry(enable, false)); + m_ifdefStack.push(VPreIfEntry{enable, false}); if (!enable) parsingOff(); statePop(); goto next_tok; @@ -1065,7 +1065,7 @@ int V3PreProcImp::getStateToken() { // Handle `if portion const bool enable = !lastIf.everOn() && defExists(m_lastSym); UINFO(4, "Elsif " << m_lastSym << (enable ? " ON" : " OFF") << endl); - m_ifdefStack.push(VPreIfEntry(enable, lastIf.everOn())); + m_ifdefStack.push(VPreIfEntry{enable, lastIf.everOn()}); if (!enable) parsingOff(); } statePop(); @@ -1380,7 +1380,7 @@ int V3PreProcImp::getStateToken() { m_ifdefStack.pop(); const bool enable = !lastIf.everOn(); UINFO(4, "Else " << (enable ? " ON" : " OFF") << endl); - m_ifdefStack.push(VPreIfEntry(enable, lastIf.everOn())); + m_ifdefStack.push(VPreIfEntry{enable, lastIf.everOn()}); if (!lastIf.on()) parsingOn(); if (!enable) parsingOff(); } @@ -1428,7 +1428,7 @@ int V3PreProcImp::getStateToken() { if (params == "0" || params == "") { // Found, as simple substitution string out; if (!m_off) { - VDefineRef tempref(name, ""); + VDefineRef tempref{name, ""}; out = defineSubst(&tempref); } // Similar code in parenthesized define (Search for END_OF_DEFARG) @@ -1467,7 +1467,7 @@ int V3PreProcImp::getStateToken() { // The CURRENT macro needs the paren saved, it's not a // property of the child macro if (!m_defRefs.empty()) m_defRefs.top().parenLevel(m_lexp->m_parenLevel); - m_defRefs.push(VDefineRef(name, params)); + m_defRefs.push(VDefineRef{name, params}); statePush(ps_DEFPAREN); m_lexp->pushStateDefArg(0); goto next_tok; diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index ce60b19de..ffc8127e7 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -107,10 +107,10 @@ private: UINFO(4, " MOD AT " << scopename << " " << nodep << endl); AstNode::user1ClearTree(); - m_scopep = new AstScope( + m_scopep = new AstScope{ (m_aboveCellp ? static_cast(m_aboveCellp) : static_cast(nodep)) ->fileline(), - nodep, scopename, m_aboveScopep, m_aboveCellp); + nodep, scopename, m_aboveScopep, m_aboveCellp}; if (VN_IS(nodep, Package)) m_packageScopes.emplace(nodep, m_scopep); // Now for each child cell, iterate the module this cell points to @@ -173,7 +173,7 @@ private: const AstNode* const abovep = (m_aboveCellp ? static_cast(m_aboveCellp) : static_cast(nodep)); m_scopep - = new AstScope(abovep->fileline(), m_modp, scopename, m_aboveScopep, m_aboveCellp); + = new AstScope{abovep->fileline(), m_modp, scopename, m_aboveScopep, m_aboveCellp}; m_packageScopes.emplace(nodep, m_scopep); // Create scope for the current usage of this cell @@ -304,11 +304,11 @@ private: // To keep correct visual order, must add before other Text's AstText* afterp = nodep->scopeAttrp(); if (afterp) afterp->unlinkFrBackWithNext(); - nodep->addScopeAttrp(new AstText(nodep->fileline(), prefix)); + nodep->addScopeAttrp(new AstText{nodep->fileline(), prefix}); if (afterp) nodep->addScopeAttrp(afterp); afterp = nodep->scopeEntrp(); if (afterp) afterp->unlinkFrBackWithNext(); - nodep->addScopeEntrp(new AstText(nodep->fileline(), prefix)); + nodep->addScopeEntrp(new AstText{nodep->fileline(), prefix}); if (afterp) nodep->addScopeEntrp(afterp); iterateChildren(nodep); } diff --git a/src/V3Stats.h b/src/V3Stats.h index 1a51619c6..6676797a1 100644 --- a/src/V3Stats.h +++ b/src/V3Stats.h @@ -103,16 +103,16 @@ class V3Stats final { public: static void addStat(const V3Statistic&); static void addStat(const string& stage, const string& name, double count) { - addStat(V3Statistic(stage, name, count)); + addStat(V3Statistic{stage, name, count}); } static void addStat(const string& name, double count) { - addStat(V3Statistic("*", name, count)); + addStat(V3Statistic{"*", name, count}); } static void addStatSum(const string& name, double count) { - addStat(V3Statistic("*", name, count, true)); + addStat(V3Statistic{"*", name, count, true}); } static void addStatPerf(const string& name, double count) { - addStat(V3Statistic("*", name, count, true, true)); + addStat(V3Statistic{"*", name, count, true, true}); } /// Called each stage static void statsStage(const string& name); diff --git a/src/V3String.cpp b/src/V3String.cpp index 58369df21..232673006 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -386,7 +386,7 @@ string VHashSha256::digestSymbol() { void VHashSha256::selfTestOne(const string& data, const string& data2, const string& exp, const string& exp64) { - VHashSha256 digest(data); + VHashSha256 digest{data}; if (data2 != "") digest.insert(data2); if (VL_UNCOVERABLE(digest.digestHex() != exp)) { std::cerr << "%Error: When hashing '" << data + data2 << "'\n" // LCOV_EXCL_LINE @@ -476,7 +476,7 @@ string VName::hashedName() { m_hashed = m_name; return m_hashed; } else { - VHashSha256 hash(m_name); + VHashSha256 hash{m_name}; const string suffix = "__Vhsh" + hash.digestSymbol(); if (s_minLength < s_maxLength) { s_dehashMap[suffix] = m_name.substr(s_minLength); diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index e0b96f4ae..73fbaaabc 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -198,9 +198,9 @@ private: AstNode* clonep = nodep->cloneTree(true); UASSERT_OBJ(clonep, nodep, "Failed to clone tree"); if (loopValue) { - m_varValuep = new AstConst(nodep->fileline(), *loopValue); + m_varValuep = new AstConst{nodep->fileline(), *loopValue}; // Iteration requires a back, so put under temporary node - AstBegin* tempp = new AstBegin(nodep->fileline(), "[EditWrapper]", clonep); + AstBegin* tempp = new AstBegin{nodep->fileline(), "[EditWrapper]", clonep}; m_varModeReplace = true; iterateAndNextNull(tempp->stmtsp()); m_varModeReplace = false; @@ -310,12 +310,12 @@ private: // Replace iterator values with constant. AstNode* oneloopp = stmtsp->cloneTree(true); - m_varValuep = new AstConst(nodep->fileline(), loopValue); + m_varValuep = new AstConst{nodep->fileline(), loopValue}; // Iteration requires a back, so put under temporary node if (oneloopp) { AstBegin* const tempp - = new AstBegin(oneloopp->fileline(), "[EditWrapper]", oneloopp); + = new AstBegin{oneloopp->fileline(), "[EditWrapper]", oneloopp}; m_varModeReplace = true; iterateAndNextNull(tempp->stmtsp()); m_varModeReplace = false; @@ -325,7 +325,7 @@ private: if (m_generate) { const string index = AstNode::encodeNumber(m_varValuep->toSInt()); const string nname = m_beginName + "__BRA__" + index + "__KET__"; - oneloopp = new AstBegin(oneloopp->fileline(), nname, oneloopp, true); + oneloopp = new AstBegin{oneloopp->fileline(), nname, oneloopp, true}; } VL_DO_CLEAR(pushDeletep(m_varValuep), m_varValuep = nullptr); if (newbodysp) { diff --git a/src/VlcSource.h b/src/VlcSource.h index af711f0af..fc40ae241 100644 --- a/src/VlcSource.h +++ b/src/VlcSource.h @@ -89,7 +89,7 @@ public: ColumnMap& cmap = lit->second; ColumnMap::iterator cit = cmap.find(column); if (cit == cmap.end()) { - cit = cmap.insert(std::make_pair(column, VlcSourceCount(lineno, column))).first; + cit = cmap.insert(std::make_pair(column, VlcSourceCount{lineno, column})).first; } VlcSourceCount& sc = cit->second; sc.incCount(count, ok); @@ -124,7 +124,7 @@ public: if (iter != m_sources.end()) { return iter->second; } else { - iter = m_sources.insert(std::make_pair(name, VlcSource(name))).first; + iter = m_sources.insert(std::make_pair(name, VlcSource{name})).first; return iter->second; } }