From 203993b018f2990ab4025f44a283eb213afd07fc Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 21 Oct 2022 19:03:40 -0400 Subject: [PATCH] Internals: Fix constructor style. --- src/V3Active.cpp | 7 ++--- src/V3Assert.cpp | 72 ++++++++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 7ca4e1742..06a1d7f51 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -129,7 +129,7 @@ public: // Start a new if/else tracking graph // See NODE STATE comment in ActiveLatchCheckVisitor AstNode::user1ClearTree(); - m_curVertexp = new LatchDetectGraphVertex(this, "ROOT"); + m_curVertexp = new LatchDetectGraphVertex{this, "ROOT"}; } // Clear out userp field of referenced outputs on destruction // (occurs at the end of each combinational always block) @@ -165,7 +165,7 @@ public: } else { outVertexp = castVertexp(nodep->varp()->user1p()); } - new V3GraphEdge(this, m_curVertexp, outVertexp, 1); + new V3GraphEdge{this, m_curVertexp, outVertexp, 1}; } // Run latchCheckInternal on each variable assigned by the always block to see if all control // paths make an assignment. Detected latches are flagged in the variables AstVar @@ -271,7 +271,7 @@ public: // No such AstActive yet, creat it, and add to map. AstSenTree* const newsenp = sensesp->cloneTree(false); - AstActive* const activep = new AstActive(fl, "sequent", newsenp); + AstActive* const activep = new AstActive{fl, "sequent", newsenp}; activep->sensesStorep(activep->sensesp()); addActive(activep); m_activeMap.emplace(*newsenp, activep); @@ -556,7 +556,6 @@ private: if (const auto* const dtypep = nodep->sensp()->dtypep()) { if (const auto* const basicp = dtypep->basicp()) { - if (basicp->isEvent()) nodep->edgeType(VEdgeType::ET_EVENT); } } diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index a499aaf7b..bc49f8834 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -59,7 +59,7 @@ private: nodep->displayType(VDisplayType::DT_WRITE); nodep->fmtp()->text(assertDisplayMessage(nodep, prefix, nodep->fmtp()->text())); // cppcheck-suppress nullPointer - AstNode* const timenewp = new AstTime(nodep->fileline(), m_modp->timeunit()); + AstNode* const timenewp = new AstTime{nodep->fileline(), m_modp->timeunit()}; if (AstNode* const timesp = nodep->fmtp()->exprsp()) { timesp->unlinkFrBackWithNext(); timenewp->addNext(timesp); @@ -80,7 +80,7 @@ private: nodep->findUInt64DType()}; v3Global.rootp()->dollarUnitPkgAddp()->addStmtsp(m_monitorNumVarp); } - const auto varrefp = new AstVarRef(nodep->fileline(), m_monitorNumVarp, access); + const auto varrefp = new AstVarRef{nodep->fileline(), m_monitorNumVarp, access}; varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp()); return varrefp; } @@ -90,7 +90,7 @@ private: nodep->findBitDType()}; v3Global.rootp()->dollarUnitPkgAddp()->addStmtsp(m_monitorOffVarp); } - const auto varrefp = new AstVarRef(nodep->fileline(), m_monitorOffVarp, access); + const auto varrefp = new AstVarRef{nodep->fileline(), m_monitorOffVarp, access}; varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp()); return varrefp; } @@ -98,16 +98,16 @@ private: // Add a internal if to check assertions are on. // Don't make this a AND term, as it's unlikely to need to test this. FileLine* const fl = nodep->fileline(); - AstNode* const newp = new AstIf( + AstNode* const newp = new AstIf{ fl, - (force ? new AstConst(fl, AstConst::BitTrue()) + (force ? new AstConst{fl, AstConst::BitTrue{}} : // If assertions are off, have constant propagation rip them out later // This allows syntax errors and such to be detected normally. (v3Global.opt.assertOn() ? static_cast( - new AstCMath(fl, "vlSymsp->_vm_contextp__->assertOn()", 1)) - : static_cast(new AstConst(fl, AstConst::BitFalse())))), - nodep); + new AstCMath{fl, "vlSymsp->_vm_contextp__->assertOn()", 1}) + : static_cast(new AstConst{fl, AstConst::BitFalse{}}))), + nodep}; newp->user1(true); // Don't assert/cover this if return newp; } @@ -115,11 +115,11 @@ private: AstNode* newFireAssertUnchecked(AstNode* nodep, const string& message) { // Like newFireAssert() but omits the asserts-on check AstDisplay* const dispp - = new AstDisplay(nodep->fileline(), VDisplayType::DT_ERROR, message, nullptr, nullptr); + = new AstDisplay{nodep->fileline(), VDisplayType::DT_ERROR, message, nullptr, nullptr}; dispp->fmtp()->timeunit(m_modp->timeunit()); AstNode* const bodysp = dispp; replaceDisplay(dispp, "%%Error"); // Convert to standard DISPLAY format - bodysp->addNext(new AstStop(nodep->fileline(), true)); + bodysp->addNext(new AstStop{nodep->fileline(), true}); return bodysp; } @@ -163,7 +163,7 @@ private: } if (bodysp && passsp) bodysp = bodysp->addNext(passsp); - ifp = new AstIf(nodep->fileline(), propp, bodysp); + ifp = new AstIf{nodep->fileline(), propp, bodysp}; bodysp = ifp; } else if (VN_IS(nodep, Assert) || VN_IS(nodep, AssertIntrinsic)) { if (nodep->immediate()) { @@ -175,7 +175,7 @@ private: if (passsp) passsp = newIfAssertOn(passsp, force); if (failsp) failsp = newIfAssertOn(failsp, force); if (!failsp) failsp = newFireAssertUnchecked(nodep, "'assert' failed."); - ifp = new AstIf(nodep->fileline(), propp, passsp, failsp); + ifp = new AstIf{nodep->fileline(), propp, passsp, failsp}; // It's more LIKELY that we'll take the nullptr if clause // than the sim-killing else clause: ifp->branchPred(VBranchPred::BP_LIKELY); @@ -186,7 +186,7 @@ private: AstNode* newp; if (sentreep) { - newp = new AstAlways(nodep->fileline(), VAlwaysKwd::ALWAYS, sentreep, bodysp); + newp = new AstAlways{nodep->fileline(), VAlwaysKwd::ALWAYS, sentreep, bodysp}; } else { newp = bodysp; } @@ -227,7 +227,7 @@ private: // Build a bitmask of the true predicates AstNode* const predp = ifp->condp()->cloneTree(false); if (propp) { - propp = new AstConcat(nodep->fileline(), predp, propp); + propp = new AstConcat{nodep->fileline(), predp, propp}; } else { propp = predp; } @@ -242,17 +242,17 @@ private: const bool allow_none = nodep->unique0Pragma(); // Empty case means no property - if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse()); + if (!propp) propp = new AstConst{nodep->fileline(), AstConst::BitFalse{}}; // Note: if this ends with an 'else', then we don't need to validate that one of the // predicates evaluates to true. AstNode* const ohot = ((allow_none || hasDefaultElse) - ? static_cast(new AstOneHot0(nodep->fileline(), propp)) - : static_cast(new AstOneHot(nodep->fileline(), propp))); + ? static_cast(new AstOneHot0{nodep->fileline(), propp}) + : static_cast(new AstOneHot{nodep->fileline(), propp})); AstIf* const checkifp - = new AstIf(nodep->fileline(), new AstLogNot(nodep->fileline(), ohot), - newFireAssert(nodep, "'unique if' statement violated"), newifp); + = new AstIf{nodep->fileline(), new AstLogNot{nodep->fileline(), ohot}, + newFireAssert(nodep, "'unique if' statement violated"), newifp}; checkifp->branchPred(VBranchPred::BP_UNLIKELY); nodep->replaceWith(checkifp); pushDeletep(nodep); @@ -274,9 +274,9 @@ private: // Need to add a default if there isn't one already ++m_statAsFull; if (!has_default) { - nodep->addItemsp(new AstCaseItem( + nodep->addItemsp(new AstCaseItem{ nodep->fileline(), nullptr /*DEFAULT*/, - newFireAssert(nodep, "synthesis full_case, but non-match found"))); + newFireAssert(nodep, "synthesis full_case, but non-match found")}); } } if (nodep->parallelPragma() || nodep->uniquePragma() || nodep->unique0Pragma()) { @@ -305,24 +305,24 @@ private: icondp->cloneTree(false)); } if (propp) { - propp = new AstConcat(icondp->fileline(), onep, propp); + propp = new AstConcat{icondp->fileline(), onep, propp}; } else { propp = onep; } } } // Empty case means no property - if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse()); + if (!propp) propp = new AstConst{nodep->fileline(), AstConst::BitFalse{}}; const bool allow_none = has_default || nodep->unique0Pragma(); AstNode* const ohot = (allow_none - ? static_cast(new AstOneHot0(nodep->fileline(), propp)) - : static_cast(new AstOneHot(nodep->fileline(), propp))); - AstIf* const ifp = new AstIf( - nodep->fileline(), new AstLogNot(nodep->fileline(), ohot), + ? static_cast(new AstOneHot0{nodep->fileline(), propp}) + : static_cast(new AstOneHot{nodep->fileline(), propp})); + AstIf* const ifp = new AstIf{ + nodep->fileline(), new AstLogNot{nodep->fileline(), ohot}, newFireAssert(nodep, - "synthesis parallel_case, but multiple matches found")); + "synthesis parallel_case, but multiple matches found")}; ifp->branchPred(VBranchPred::BP_UNLIKELY); nodep->addNotParallelp(ifp); } @@ -346,19 +346,19 @@ private: AstSenTree* const sentreep = nodep->sentreep(); sentreep->unlinkFrBack(); AstAlways* const alwaysp - = new AstAlways(nodep->fileline(), VAlwaysKwd::ALWAYS, sentreep, nullptr); + = new AstAlways{nodep->fileline(), VAlwaysKwd::ALWAYS, sentreep, nullptr}; m_modp->addStmtsp(alwaysp); for (uint32_t i = 0; i < ticks; ++i) { - AstVar* const outvarp = new AstVar( + AstVar* const outvarp = new AstVar{ nodep->fileline(), VVarType::MODULETEMP, - "_Vpast_" + cvtToStr(m_modPastNum++) + "_" + cvtToStr(i), inp->dtypep()); + "_Vpast_" + cvtToStr(m_modPastNum++) + "_" + cvtToStr(i), inp->dtypep()}; m_modp->addStmtsp(outvarp); - AstNode* const assp = new AstAssignDly( - nodep->fileline(), new AstVarRef(nodep->fileline(), outvarp, VAccess::WRITE), inp); + AstNode* const assp = new AstAssignDly{ + nodep->fileline(), new AstVarRef{nodep->fileline(), outvarp, VAccess::WRITE}, inp}; alwaysp->addStmtsp(assp); // if (debug() >= 9) assp->dumpTree(cout, "-ass: "); invarp = outvarp; - inp = new AstVarRef(nodep->fileline(), invarp, VAccess::READ); + inp = new AstVarRef{nodep->fileline(), invarp, VAccess::READ}; } nodep->replaceWith(inp); } @@ -452,8 +452,8 @@ private: } void visit(AstMonitorOff* nodep) override { const auto newp - = new AstAssign(nodep->fileline(), newMonitorOffVarRefp(nodep, VAccess::WRITE), - new AstConst(nodep->fileline(), AstConst::BitTrue{}, nodep->off())); + = new AstAssign{nodep->fileline(), newMonitorOffVarRefp(nodep, VAccess::WRITE), + new AstConst{nodep->fileline(), AstConst::BitTrue{}, nodep->off()}}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); }