From 4fc9a906f652eaefe9bcd511fd05c073dc677341 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 4 Oct 2015 13:16:35 -0400 Subject: [PATCH] Internals: Fix cppcheck warnings; add VL_DANGLING. No functional change. --- include/verilatedos.h | 6 ++ src/V3Active.cpp | 16 ++--- src/V3ActiveTop.cpp | 2 +- src/V3Assert.cpp | 8 +-- src/V3AssertPre.cpp | 4 +- src/V3Ast.cpp | 6 +- src/V3Begin.cpp | 2 +- src/V3Case.cpp | 24 ++++--- src/V3ClkGater.cpp | 12 ++-- src/V3Clock.cpp | 12 ++-- src/V3Combine.cpp | 12 ++-- src/V3Const.cpp | 146 ++++++++++++++++++++--------------------- src/V3Coverage.cpp | 2 +- src/V3CoverageJoin.cpp | 2 +- src/V3Dead.cpp | 6 +- src/V3Delayed.cpp | 6 +- src/V3Expand.cpp | 32 ++++----- src/V3Gate.cpp | 30 ++++----- src/V3GenClk.cpp | 2 +- src/V3GraphAcyc.cpp | 26 ++++---- src/V3GraphAlg.cpp | 4 +- src/V3GraphDfa.cpp | 10 +-- src/V3Inline.cpp | 12 ++-- src/V3Inst.cpp | 4 +- src/V3Life.cpp | 6 +- src/V3LifePost.cpp | 4 +- src/V3LinkCells.cpp | 4 +- src/V3LinkDot.cpp | 42 ++++++------ src/V3LinkJump.cpp | 10 +-- src/V3LinkParse.cpp | 28 ++++---- src/V3LinkResolve.cpp | 16 ++--- src/V3Order.cpp | 6 +- src/V3Param.cpp | 11 ++-- src/V3ParseImp.cpp | 2 +- src/V3PreProc.cpp | 2 +- src/V3Scope.cpp | 2 +- src/V3Simulate.h | 4 +- src/V3Slice.cpp | 8 +-- src/V3StatsReport.cpp | 2 +- src/V3Subst.cpp | 8 +-- src/V3Table.cpp | 2 +- src/V3Task.cpp | 22 +++---- src/V3Trace.cpp | 2 +- src/V3Tristate.cpp | 12 ++-- src/V3Unknown.cpp | 26 ++++---- src/V3Unroll.cpp | 22 +++---- src/V3Width.cpp | 114 ++++++++++++++++---------------- src/V3WidthCommit.h | 8 +-- src/V3WidthSel.cpp | 42 ++++++------ src/astgen | 2 +- src/cppcheck_filtered | 24 +++---- src/verilog.y | 6 +- 52 files changed, 410 insertions(+), 413 deletions(-) diff --git a/include/verilatedos.h b/include/verilatedos.h index 936514cba..1e0d05b82 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -95,6 +95,12 @@ // This is not necessarily the same as #UL, depending on what the IData typedef is. #define VL_UL(c) ((IData)(c##UL)) ///< Add appropriate suffix to 32-bit constant +#ifdef VL_CPPCHECK +# define VL_DANGLING(v) +#else +# define VL_DANGLING(v) do { (v) = NULL; } while(0) ///< After e.g. delete, set variable to NULL to indicate must not use later +#endif + //========================================================================= // C++-2011 diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 2599eb696..f38aee9f0 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -83,7 +83,7 @@ private: } virtual void visit(AstSenTree* nodep, AstNUser*) { // Simplify sensitivity list - V3Const::constifyExpensiveEdit(nodep); nodep=NULL; + V3Const::constifyExpensiveEdit(nodep); VL_DANGLING(nodep); } // Empty visitors, speed things up virtual void visit(AstNodeStmt* nodep, AstNUser*) { } @@ -184,7 +184,7 @@ private: nodep->lhsp()->unlinkFrBack(), nodep->rhsp()->unlinkFrBack()); nodep->replaceWith(newp); - nodep->deleteTree(); nodep = NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } } virtual void visit(AstAssign* nodep, AstNUser*) { @@ -288,7 +288,7 @@ private: // Relink to CFUNC for the final UINFO(4," FINAL "<bodysp()) { // Empty, Kill it. - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); return; } ActiveDlyVisitor dlyvisitor (nodep, ActiveDlyVisitor::CT_INITIAL); @@ -304,7 +304,7 @@ private: nodep->unlinkFrBack(); m_scopeFinalp->addStmtsp(new AstComment(nodep->fileline(), nodep->typeName())); m_scopeFinalp->addStmtsp(nodep->bodysp()->unlinkFrBackWithNext()); - nodep->deleteTree(); nodep = NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } // METHODS @@ -316,7 +316,7 @@ private: && oldsensesp->sensesp()->castSenItem()->isNever()) { // Never executing. Kill it. if (oldsensesp->sensesp()->nextp()) nodep->v3fatalSrc("Never senitem should be alone, else the never should be eliminated."); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); return; } @@ -351,7 +351,7 @@ private: // Delete sensitivity list if (oldsensesp) { - oldsensesp->unlinkFrBackWithNext()->deleteTree(); oldsensesp=NULL; + oldsensesp->unlinkFrBackWithNext()->deleteTree(); VL_DANGLING(oldsensesp); } // Move node to new active @@ -377,7 +377,7 @@ private: if (!nodep->bodysp()) { // Empty always. Kill it. - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); return; } visitAlways(nodep, nodep->sensesp(), nodep->keyword()); @@ -402,7 +402,7 @@ private: m_itemCombo = true; // Delete the sensitivity // We'll add it as a generic COMBO SenItem in a moment. - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->varrefp()) { // V3LinkResolve should have cleaned most of these up if (!nodep->varrefp()->width1()) nodep->v3error("Unsupported: Non-single bit wide signal pos/negedge sensitivity: " diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index af89730e0..a947a3239 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -87,7 +87,7 @@ private: && sensesp->sensesp()->castSenItem()->isNever()) { // Never executing. Kill it. if (sensesp->sensesp()->nextp()) nodep->v3fatalSrc("Never senitem should be alone, else the never should be eliminated."); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); return; } // Copy combo tree to settlement tree with duplicated statements diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 29bf6a53c..f910cd65f 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -138,7 +138,7 @@ private: nodep->replaceWith(newp); } // Bye - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } void newVAssertion(AstVAssert* nodep, AstNode* propp) { @@ -160,7 +160,7 @@ private: // Install it nodep->replaceWith(newp); // Bye - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } virtual void visit(AstIf* nodep, AstNUser*) { @@ -285,12 +285,12 @@ private: nodep->iterateChildren(*this); if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name()); newPslAssertion(nodep, nodep->propp(), nodep->sentreep(), - nodep->stmtsp(), nodep->name()); nodep=NULL; + nodep->stmtsp(), nodep->name()); VL_DANGLING(nodep); ++m_statAsCover; } virtual void visit(AstVAssert* nodep, AstNUser*) { nodep->iterateChildren(*this); - newVAssertion(nodep, nodep->propp()); nodep=NULL; + newVAssertion(nodep, nodep->propp()); VL_DANGLING(nodep); ++m_statAsSV; } diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index ba9dacc7a..b6c1c85a5 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -83,7 +83,7 @@ private: } else { nodep->unlinkFrBack(); } - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } virtual void visit(AstPslCover* nodep, AstNUser*) { @@ -109,7 +109,7 @@ private: // Unlink and just keep a pointer to it, convert to sentree as needed m_senip = nodep->sensesp(); nodep->replaceWith(blockp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } virtual void visit(AstNodeModule* nodep, AstNUser*) { nodep->iterateChildren(*this); diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 65786faaa..8af35cdac 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -828,10 +828,10 @@ AstNode* AstNode::acceptSubtreeReturnEdits(AstNVisitor& v, AstNUser* vup) { // Calling on standalone tree; insert a shim node so we can keep track, then delete it on completion AstBegin* tempp = new AstBegin(nodep->fileline(),"[EditWrapper]",nodep); { - tempp->stmtsp()->accept(v, vup); nodep=NULL; // nodep to null as may be replaced + tempp->stmtsp()->accept(v, vup); VL_DANGLING(nodep); // nodep to null as may be replaced } nodep = tempp->stmtsp()->unlinkFrBackWithNext(); - tempp->deleteTree(); tempp=NULL; + tempp->deleteTree(); VL_DANGLING(tempp); } else { // Use back to determine who's pointing at us (IE assume new node grafts into same place as old one) AstNode** nextnodepp = NULL; @@ -842,7 +842,7 @@ AstNode* AstNode::acceptSubtreeReturnEdits(AstNVisitor& v, AstNUser* vup) { else if (this->m_backp->m_nextp == this) nextnodepp = &(this->m_backp->m_nextp); if (!nextnodepp) this->v3fatalSrc("Node's back doesn't point to forward to node itself"); { - nodep->accept(v, vup); nodep=NULL; // nodep to null as may be replaced + nodep->accept(v, vup); VL_DANGLING(nodep); // nodep to null as may be replaced } nodep = *nextnodepp; // Grab new node from point where old was connected } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index ba7f89fa2..d56467369 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -160,7 +160,7 @@ private: } else { nodep->unlinkFrBack(); } - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } virtual void visit(AstVar* nodep, AstNUser*) { if (m_unnamedScope != "") { diff --git a/src/V3Case.cpp b/src/V3Case.cpp index bc6c26cf1..393d2b623 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -246,7 +246,7 @@ private: if (m_valueItem[a] != m_valueItem[b]) { same=false; break; } } if (same) { - tree1p->deleteTree(); tree1p=NULL; + tree1p->deleteTree(); VL_DANGLING(tree1p); return tree0p; } @@ -295,8 +295,8 @@ private: if (ifrootp) nodep->replaceWith(ifrootp); else nodep->unlinkFrBack(); - nodep->deleteTree(); nodep=NULL; - cexprp->deleteTree(); cexprp=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); + cexprp->deleteTree(); VL_DANGLING(cexprp); if (debug()>=9) ifrootp->dumpTree(cout," _simp: "); } @@ -327,7 +327,7 @@ private: AstConst* iconstp = icondp->castConst(); if (iconstp && neverItem(nodep, iconstp)) { // X in casez can't ever be executed - icondp->deleteTree(); icondp=NULL; iconstp=NULL; + icondp->deleteTree(); VL_DANGLING(icondp); VL_DANGLING(iconstp); // For simplicity, make expression that is not equal, and let later // optimizations remove it condp = new AstConst(itemp->fileline(), AstConst::LogicFalse()); @@ -351,7 +351,7 @@ private: AstNode* and2p = new AstAnd(itemp->fileline(), new AstConst(itemp->fileline(), numval), new AstConst(itemp->fileline(), nummask)); - icondp->deleteTree(); icondp=NULL; iconstp=NULL; + icondp->deleteTree(); VL_DANGLING(icondp); VL_DANGLING(iconstp); condp = AstEq::newTyped(itemp->fileline(), and1p, and2p); } else { // Not a caseX mask, we can simply build CASEEQ(cexpr icond) @@ -369,7 +369,7 @@ private: itemp->condsp(ifexprp); } } - cexprp->deleteTree(); cexprp=NULL; + cexprp->deleteTree(); VL_DANGLING(cexprp); if (!hadDefault) { // If there was no default, add a empty one, this greatly simplifies below code // and constant propagation will just eliminate it for us later. @@ -408,10 +408,9 @@ private: } } { // Make the new lower IF and attach in the tree - AstNode* itemexprp = ifexprp; ifexprp=NULL; + AstNode* itemexprp = ifexprp; VL_DANGLING(ifexprp); if (depth == (CASE_ENCODER_GROUP_DEPTH)) { // End of group - can skip the condition - itemexprp->deleteTree(); itemexprp=NULL; - // cppcheck-suppress redundantAssignment + itemexprp->deleteTree(); VL_DANGLING(itemexprp); itemexprp = new AstConst(itemp->fileline(), AstConst::LogicTrue()); } AstIf* newp = new AstIf(itemp->fileline(), itemexprp, istmtsp, NULL); @@ -427,7 +426,7 @@ private: if (debug()>=9) grouprootp->dumpTree(cout," _new: "); if (grouprootp) nodep->replaceWith(grouprootp); else nodep->unlinkFrBack(); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } void replaceCaseParallel(AstCase* nodep, bool noOverlapsAllCovered) { @@ -460,11 +459,10 @@ private: // It's a simple priority encoder or complete statement // we can make a tree of statements to avoid extra comparisons ++m_statCaseFast; - replaceCaseFast(nodep); nodep=NULL; + replaceCaseFast(nodep); VL_DANGLING(nodep); } else { ++m_statCaseSlow; - // cppcheck-supporess uselessAssignmentPtrArg - replaceCaseComplicated(nodep); nodep=NULL; + replaceCaseComplicated(nodep); VL_DANGLING(nodep); } } //-------------------- diff --git a/src/V3ClkGater.cpp b/src/V3ClkGater.cpp index de7f72dd8..6fdd9468c 100644 --- a/src/V3ClkGater.cpp +++ b/src/V3ClkGater.cpp @@ -296,7 +296,7 @@ class GaterBodyVisitor : public GaterBaseVisitor { } if ((childstate & STATE_DELETE) && !(childstate & STATE_KEEP)) { - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); // Pass upwards we did delete m_state |= STATE_DELETE; } else { @@ -427,7 +427,7 @@ class GaterVisitor : public GaterBaseVisitor { for (V3GraphEdge* nextp,* edgep = m_pliVertexp->outBeginp(); edgep; edgep = nextp) { nextp = edgep->outNextp(); // We may edit the list if (GaterVarVertex* vVxp = dynamic_cast(edgep->top())) { - vVxp->unlinkDelete(&m_graph); vVxp=NULL; edgep=NULL; + vVxp->unlinkDelete(&m_graph); VL_DANGLING(vVxp); VL_DANGLING(edgep); } else { m_graph.dump(); v3fatalSrc("PLI vertex points to non-signal"); @@ -463,7 +463,7 @@ class GaterVisitor : public GaterBaseVisitor { V3GraphVertex* toVxp = edgep->top(); //UINFO(9," to "<user()<<" "<user() & VU_IF) && (toVxp->user() & VU_ELSE)) { - edgep->unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); if (!(toVxp->user() & VU_MADE)) { // Make an edge only once toVxp->user(toVxp->user() | VU_MADE); GaterEdge* inedgep = static_cast(vertexp->inBeginp()); @@ -487,7 +487,7 @@ class GaterVisitor : public GaterBaseVisitor { if (toVxp->user() && toVxp->user() < depth) { // A recursion "above" us marked it, // Remove this edge, it's redundant with the upper edge - edgep->unlinkDelete(); edgep=NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); } else { GaterEdge* cedgep = static_cast(edgep); if (cedgep->ifelseBoth()) { @@ -515,7 +515,7 @@ class GaterVisitor : public GaterBaseVisitor { if (GaterIfVertex* toVxp = dynamic_cast(edgep->top())) { if (!toVxp->outBeginp()) { if (!nextp || nextp->top() != edgep->top()) { // Else next would disappear; we'll do it next loop - toVxp->unlinkDelete(&m_graph); toVxp=NULL; edgep=NULL; + toVxp->unlinkDelete(&m_graph); VL_DANGLING(toVxp); VL_DANGLING(edgep); } } } @@ -529,7 +529,7 @@ class GaterVisitor : public GaterBaseVisitor { nextp = edgep->outNextp(); // We may edit the list if (GaterVarVertex* toVxp = dynamic_cast(edgep->top())) { if (!nextp || nextp->top() != edgep->top()) { // Else next would disappear; we'll do it next loop - toVxp->unlinkDelete(&m_graph); toVxp=NULL; edgep=NULL; + toVxp->unlinkDelete(&m_graph); VL_DANGLING(toVxp); VL_DANGLING(edgep); } } } diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index 36a3d1327..be8d44a07 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -268,7 +268,7 @@ private: stmtsp->unlinkFrBackWithNext(); cmtp->addNextHere(stmtsp); } - nodep->deleteTree(); nodep = NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstAlwaysPost* nodep, AstNUser*) { AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName()); @@ -277,7 +277,7 @@ private: stmtsp->unlinkFrBackWithNext(); cmtp->addNextHere(stmtsp); } - nodep->deleteTree(); nodep = NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstCoverToggle* nodep, AstNUser*) { //nodep->dumpTree(cout,"ct:"); @@ -297,7 +297,7 @@ private: newp->addIfsp(new AstAssign(nodep->fileline(), changep->cloneTree(false), origp->cloneTree(false))); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstInitial* nodep, AstNUser*) { AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName()); @@ -306,7 +306,7 @@ private: stmtsp->unlinkFrBackWithNext(); cmtp->addNextHere(stmtsp); } - nodep->deleteTree(); nodep = NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstCFunc* nodep, AstNUser*) { nodep->iterateChildren(*this); @@ -342,7 +342,7 @@ private: // Not at the top or empty block... // Only empty blocks should be leftover on the non-top. Killem. if (nodep->stmtsp()) nodep->v3fatalSrc("Non-empty lower active"); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else { UINFO(4," ACTIVE "<stmtsp()->unlinkFrBackWithNext(); @@ -374,7 +374,7 @@ private: // Move statements to function addToEvalLoop(stmtsp); } - nodep->unlinkFrBack()->deleteTree(); nodep = NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } } diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index ed412d38d..f7856b121 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -111,7 +111,7 @@ public: callp->unlinkFrBack(); } callp->user3(true); // Dead now - pushDeletep(callp); callp=NULL; + pushDeletep(callp); VL_DANGLING(callp); m_callMmap.erase(eqit); // Fix the table } } @@ -230,7 +230,7 @@ private: CombMarkVisitor visitor(oldfuncp); m_call.replaceFunc(oldfuncp, NULL); oldfuncp->unlinkFrBack(); - pushDeletep(oldfuncp); oldfuncp=NULL; + pushDeletep(oldfuncp); VL_DANGLING(oldfuncp); } } } @@ -262,7 +262,7 @@ private: CombMarkVisitor visitor(oldfuncp); m_call.replaceFunc(oldfuncp, newfuncp); oldfuncp->unlinkFrBack(); - pushDeletep(oldfuncp); oldfuncp=NULL; + pushDeletep(oldfuncp); VL_DANGLING(oldfuncp); } void replaceOnlyCallFunc(AstCCall* nodep) { if (AstCFunc* oldfuncp = nodep->backp()->castCFunc()) { @@ -274,7 +274,7 @@ private: UINFO(9," Function only has call "<funcp()); nodep=NULL; + replaceFuncWFunc(oldfuncp, nodep->funcp()); VL_DANGLING(nodep); } } } @@ -384,8 +384,8 @@ private: m_call.addCall(call2p); // If either new statement makes a func with only a single call, replace // the above callers to call it directly - replaceOnlyCallFunc(call1p); call1p=NULL; - replaceOnlyCallFunc(call2p); call2p=NULL; + replaceOnlyCallFunc(call1p); VL_DANGLING(call1p); + replaceOnlyCallFunc(call2p); VL_DANGLING(call2p); } // VISITORS diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 3b5125364..f434d49ca 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -214,7 +214,7 @@ private: if (!operandsSame(ap, bp)) return false; // Do it cp->unlinkFrBack(); - andp->unlinkFrBack()->deleteTree(); andp=NULL; notp=NULL; + andp->unlinkFrBack()->deleteTree(); VL_DANGLING(andp); VL_DANGLING(notp); // Replace whichever branch is now dangling if (nodep->rhsp()) nodep->lhsp(cp); else nodep->rhsp(cp); @@ -319,7 +319,7 @@ private: && nodep->lsbConst()==0 && (int)nodep->widthConst()==extendp->lhsp()->width() )) return false; - replaceWChild(nodep, extendp->lhsp()); nodep=NULL; + replaceWChild(nodep, extendp->lhsp()); VL_DANGLING(nodep); return true; } bool operandSelBiLower(AstSel* nodep) { @@ -338,7 +338,7 @@ private: bip->lhsp(new AstSel(nodep->fileline(), bilhsp, 0, nodep->widthConst())); bip->rhsp(new AstSel(nodep->fileline(), birhsp, 0, nodep->widthConst())); if (debug()>=9) bip->dumpTree(cout,"SEL(BI)-ou:"); - replaceWChild(nodep, bip); nodep=NULL; + replaceWChild(nodep, bip); VL_DANGLING(nodep); return true; } @@ -364,7 +364,7 @@ private: V3Number num (constp->fileline(), subsize); num.opAssign(constp->num()); nodep->lhsp(new AstConst(constp->fileline(), num)); - constp->deleteTree(); constp=NULL; + constp->deleteTree(); VL_DANGLING(constp); if (debug()>=9) nodep->dumpTree(cout,"BI(EXTEND)-ou:"); return true; } @@ -562,58 +562,58 @@ private: if (debug()>5) oldp->dumpTree(cout," const_old: "); if (debug()>5) newp->dumpTree(cout," _new: "); oldp->replaceWith(newp); - oldp->deleteTree(); oldp=NULL; + oldp->deleteTree(); VL_DANGLING(oldp); } void replaceNum (AstNode* nodep, uint32_t val) { V3Number num (nodep->fileline(), nodep->width(), val); - replaceNum(nodep, num); nodep=NULL; + replaceNum(nodep, num); VL_DANGLING(nodep); } void replaceNumSigned(AstNodeBiop* nodep, uint32_t val) { // We allow both sides to be constant, as one may have come from parameter propagation, etc. if (m_warn && !(nodep->lhsp()->castConst() && nodep->rhsp()->castConst())) { nodep->v3warn(UNSIGNED,"Comparison is constant due to unsigned arithmetic"); } - replaceNum(nodep, val); nodep=NULL; + replaceNum(nodep, val); VL_DANGLING(nodep); } void replaceNumLimited(AstNodeBiop* nodep, uint32_t val) { // Avoids gcc warning about same if (m_warn) nodep->v3warn(CMPCONST,"Comparison is constant due to limited range"); - replaceNum(nodep, val); nodep=NULL; + replaceNum(nodep, val); VL_DANGLING(nodep); } void replaceZero(AstNode* nodep) { - replaceNum(nodep, 0); nodep=NULL; + replaceNum(nodep, 0); VL_DANGLING(nodep); } void replaceZeroChkPure(AstNode* nodep, AstNode* checkp) { // For example, "0 * n" -> 0 if n has no side effects // Else strength reduce it to 0 & n. // If ever change the operation note AstAnd rule specially ignores this created pattern if (isTPure(checkp)) { - replaceNum(nodep, 0); nodep=NULL; + replaceNum(nodep, 0); VL_DANGLING(nodep); } else { AstNode* newp = new AstAnd(nodep->fileline(), new AstConst(nodep->fileline(), 0), checkp->unlinkFrBack()); newp->dtypeFrom(nodep); nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } } void replaceAllOnes (AstNode* nodep) { V3Number ones (nodep->fileline(), nodep->width(), 0); ones.setMask(nodep->width()); - replaceNum(nodep, ones); nodep=NULL; + replaceNum(nodep, ones); VL_DANGLING(nodep); } void replaceConst(AstNodeUniop* nodep) { V3Number num (nodep->fileline(), nodep->width()); nodep->numberOperate(num, nodep->lhsp()->castConst()->num()); UINFO(4,"UNICONST -> "<fileline(), nodep->width()); nodep->numberOperate(num, nodep->lhsp()->castConst()->num(), nodep->rhsp()->castConst()->num()); UINFO(4,"BICONST -> "<fileline(), nodep->width()); @@ -621,7 +621,7 @@ private: nodep->rhsp()->castConst()->num(), nodep->thsp()->castConst()->num()); UINFO(4,"TRICONST -> "<5) oldp->dumpTree(cout," const_old: "); if (debug()>5) newp->dumpTree(cout," _new: "); oldp->replaceWith(newp); - oldp->deleteTree(); oldp=NULL; + oldp->deleteTree(); VL_DANGLING(oldp); } //---------------------------------------- // Replacement functions. @@ -644,7 +644,7 @@ private: // This may adversly affect the operation of the node being replaced. childp->dtypeFrom(nodep); nodep->replaceWith(childp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } //! Replace a ternary node with its RHS after iterating @@ -778,9 +778,9 @@ private: UINFO(5, "merged two adjacent sel "<replaceWith(newselp); - lselp->deleteTree(); lselp = NULL; - rselp->deleteTree(); rselp = NULL; - nodep->deleteTree(); nodep = NULL; + lselp->deleteTree(); VL_DANGLING(lselp); + rselp->deleteTree(); VL_DANGLING(rselp); + nodep->deleteTree(); VL_DANGLING(nodep); } void replaceConcatMerge(AstConcat* nodep) { AstNodeBiop* lp = nodep->lhsp()->castNodeBiop(); @@ -797,8 +797,8 @@ private: lp->rhsp()->replaceWith(newrp); lp->dtypeChgWidthSigned(newlp->width(), newlp->width(), AstNumeric::fromBool(true)); UINFO(5, "merged "<< nodep <unlinkFrBack()->deleteTree(); rp = NULL; - nodep->replaceWith(lp->unlinkFrBack()); nodep->deleteTree(); nodep = NULL; + rp->unlinkFrBack()->deleteTree(); VL_DANGLING(rp); + nodep->replaceWith(lp->unlinkFrBack()); nodep->deleteTree(); VL_DANGLING(nodep); lp->lhsp()->accept(*this); lp->rhsp()->accept(*this); } else nodep->v3fatalSrc("tried to merge two Concat which are not adjacent"); @@ -811,7 +811,7 @@ private: ? (new AstExtendS(nodep->fileline(), arg0p))->castNode() : (new AstExtend (nodep->fileline(), arg0p))->castNode()); newp->dtypeFrom(nodep); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } void replacePowShift (AstNodeBiop* nodep) { // Pow or PowS UINFO(5,"POW(2,b)->SHIFTL(1,b) "<dtypeFrom(nodep); newp->lhsp()->dtypeFrom(nodep); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } void replaceMulShift (AstMul* nodep) { // Mul, but not MulS as not simple shift UINFO(5,"MUL(2^n,b)->SHIFTL(b,n) "<fileline(), opp, new AstConst(nodep->fileline(), amount)); newp->dtypeFrom(nodep); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } void replaceDivShift (AstDiv* nodep) { // Mul, but not MulS as not simple shift UINFO(5,"DIV(b,2^n)->SHIFTR(b,n) "<fileline(), opp, new AstConst(nodep->fileline(), amount)); newp->dtypeFrom(nodep); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } void replaceShiftOp (AstNodeBiop* nodep) { UINFO(5,"SHIFT(AND(a,b),CONST)->AND(SHIFT(a,CONST),SHIFT(b,CONST)) "<castConst()->toUInt(); int shift2 = shift2p->castConst()->toUInt(); int newshift = shift1+shift2; - shift1p->deleteTree(); shift1p=NULL; - shift2p->deleteTree(); shift2p=NULL; + shift1p->deleteTree(); VL_DANGLING(shift1p); + shift2p->deleteTree(); VL_DANGLING(shift2p); nodep->lhsp(ap); nodep->rhsp(new AstConst(nodep->fileline(), newshift)); nodep->accept(*this); // Further reduce, either node may have more reductions. @@ -880,8 +880,8 @@ private: int shift1 = shift1p->castConst()->toUInt(); if (lhsp->castShiftR()) shift1=-shift1; int shift2 = shift2p->castConst()->toUInt(); if (nodep->castShiftR()) shift2=-shift2; int newshift = shift1+shift2; - shift1p->deleteTree(); shift1p=NULL; - shift2p->deleteTree(); shift2p=NULL; + shift1p->deleteTree(); VL_DANGLING(shift1p); + shift2p->deleteTree(); VL_DANGLING(shift2p); AstNode* newp; V3Number mask1 (nodep->fileline(), nodep->width()); V3Number ones (nodep->fileline(), nodep->width()); @@ -909,11 +909,11 @@ private: newp, new AstConst (nodep->fileline(), mask)); newp->dtypeFrom(nodep); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); //newp->dumpTree(cout, " repShiftShift_new: "); newp->accept(*this); // Further reduce, either node may have more reductions. } - lhsp->deleteTree(); lhsp=NULL; + lhsp->deleteTree(); VL_DANGLING(lhsp); } bool replaceAssignMultiSel(AstNodeAssign* nodep) { @@ -986,7 +986,7 @@ private: nodep->v3error("Wire inputs its own output, creating circular logic (wire x=x)"); return false; // Don't delete the assign, or V3Gate will freak out } else { - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); return true; } } @@ -1082,8 +1082,8 @@ private: if (debug()>=9 && newp) newp->dumpTreeAndNext(cout," _new: "); nodep->addNextHere(newp); // Cleanup - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; - conp->deleteTree(); conp=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); + conp->deleteTree(); VL_DANGLING(conp); // Further reduce, either node may have more reductions. return true; } @@ -1096,8 +1096,8 @@ private: AstNode* streamp = nodep->rhsp()->castStreamR()->unlinkFrBack(); nodep->rhsp(srcp); // Cleanup - sizep->deleteTree(); sizep=NULL; - streamp->deleteTree(); streamp=NULL; + sizep->deleteTree(); VL_DANGLING(sizep); + streamp->deleteTree(); VL_DANGLING(streamp); // Further reduce, any of the nodes may have more reductions. return true; } @@ -1140,8 +1140,8 @@ private: nodep->lhsp(dstp); nodep->rhsp(srcp); // Cleanup - sizep->deleteTree(); sizep=NULL; - streamp->deleteTree(); streamp=NULL; + sizep->deleteTree(); VL_DANGLING(sizep); + streamp->deleteTree(); VL_DANGLING(streamp); // Further reduce, any of the nodes may have more reductions. return true; } @@ -1174,7 +1174,7 @@ private: fromp); newp->dtypeSetLogicSized(nodep->width(), nodep->width(), AstNumeric::UNSIGNED); // widthMin no longer applicable if different C-expanded width nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); if (debug()>=9) newp->dumpTree(cout," _new: "); } @@ -1188,13 +1188,13 @@ private: <prettyTypeName()<warnMore()<<"... Location of non-constant " <prettyTypeName()<<": "<v3fatalSrc("No number returned from simulation"); // Replace it - replaceNum(nodep,*outnump); nodep=NULL; + replaceNum(nodep,*outnump); VL_DANGLING(nodep); } } @@ -1274,7 +1274,7 @@ private: // If bp was a concat, then we have this exact same form again! // Recurse rather then calling node->iterate to prevent 2^n recursion! if (operandConcatMove(abConcp)) moveConcat(abConcp); - bcConcp->deleteTree(); bcConcp=NULL; + bcConcp->deleteTree(); VL_DANGLING(bcConcp); } else { AstConcat* abConcp = nodep->lhsp()->castConcat(); abConcp->unlinkFrBack(); AstNode* ap = abConcp->lhsp()->unlinkFrBack(); @@ -1285,7 +1285,7 @@ private: nodep->lhsp(ap); nodep->rhsp(bcConcp); if (operandConcatMove(bcConcp)) moveConcat(bcConcp); - abConcp->deleteTree(); abConcp=NULL; + abConcp->deleteTree(); VL_DANGLING(abConcp); } } @@ -1316,8 +1316,8 @@ private: if (lsb1p->castConst() && lsb2p->castConst()) { newlsbp = new AstConst(lsb1p->fileline(), lsb1p->castConst()->toUInt() + lsb2p->castConst()->toUInt()); - lsb1p->deleteTree(); lsb1p=NULL; - lsb2p->deleteTree(); lsb2p=NULL; + lsb1p->deleteTree(); VL_DANGLING(lsb1p); + lsb2p->deleteTree(); VL_DANGLING(lsb2p); } else { // Width is important, we need the width of the fromp's // expression, not the potentially smaller lsb1p's width @@ -1331,7 +1331,7 @@ private: newlsbp, widthp); nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } void replaceSelConcat(AstSel* nodep) { @@ -1371,7 +1371,7 @@ private: conRhsp->width()-nodep->lsbConst())); nodep->replaceWith(newp); } - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } void replaceSelReplicate(AstSel* nodep) { @@ -1385,7 +1385,7 @@ private: new AstConst(lsbp->fileline(), lsbp->toUInt() % fromp->width()), widthp); newp->dtypeFrom(nodep); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } void replaceSelIntoBiop(AstSel* nodep) { @@ -1403,7 +1403,7 @@ private: fromp->rhsp(new AstSel(nodep->fileline(), birhsp, lsbp, widthp)); fromp->dtypeFrom(nodep); - nodep->replaceWith(fromp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(fromp); nodep->deleteTree(); VL_DANGLING(nodep); } void replaceSelIntoUniop(AstSel* nodep) { // SEL(NOT(a),1,bit) => NOT(SEL(a,bit)) @@ -1417,7 +1417,7 @@ private: fromp->lhsp(new AstSel(nodep->fileline(), bilhsp, lsbp, widthp)); fromp->dtypeFrom(nodep); - nodep->replaceWith(fromp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(fromp); nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstAttrOf* nodep, AstNUser*) { @@ -1466,7 +1466,7 @@ private: if (operandConst(valuep)) { const V3Number& num = valuep->castConst()->num(); //UINFO(2,"constVisit "<<(void*)valuep<<" "<castInitArray()) { @@ -1476,7 +1476,7 @@ private: if (itemp->castConst()) { const V3Number& num = itemp->castConst()->num(); //UINFO(2,"constVisit "<<(void*)valuep<<" "<itemp()->valuep()->iterateAndNext(*this); if (AstConst* valuep = nodep->itemp()->valuep()->castConst()) { const V3Number& num = valuep->num(); - replaceNum(nodep, num); nodep=NULL; + replaceNum(nodep, num); VL_DANGLING(nodep); did=true; } } @@ -1522,13 +1522,13 @@ private: if (nodep->isClocked()) { // A constant can never get a pos/negexge if (onlySenItemInSenTree(nodep)) { nodep->replaceWith(new AstSenItem(nodep->fileline(), AstSenItem::Never())); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } else { - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } } else { // Otherwise it may compute a result that needs to settle out nodep->replaceWith(new AstSenItem(nodep->fileline(), AstSenItem::Combo())); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } } else if (m_doNConst && nodep->sensp()->castNot()) { // V3Gate may propagate NOTs into clocks... Just deal with it @@ -1544,7 +1544,7 @@ private: AstNodeVarRef* senvarp = lastSensp->unlinkFrBack()->castNodeVarRef(); if (!senvarp) sensp->v3fatalSrc("Non-varref sensitivity variable"); sensp->replaceWith(senvarp); - sensp->deleteTree(); sensp=NULL; + sensp->deleteTree(); VL_DANGLING(sensp); } else if (!m_doNConst // Deal with later when doNConst missing && (nodep->sensp()->castEnumItemRef() || nodep->sensp()->castConst())) { @@ -1559,15 +1559,15 @@ private: UINFO(4,"SENGATE(...,0)->NEVER"<replaceWith(new AstSenItem(nodep->fileline(), AstSenItem::Never())); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } else { - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } } else { UINFO(4,"SENGATE(SENITEM,0)->ALWAYS SENITEM"<sensesp()->unlinkFrBack(); nodep->replaceWith(senitemp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } } } @@ -1633,7 +1633,7 @@ private: // Found, push this item up to the top itemp->unlinkFrBack(); nodep->addSensesp(itemp); - gatep->unlinkFrBack()->deleteTree(); gatep=NULL; senp=NULL; + gatep->unlinkFrBack()->deleteTree(); VL_DANGLING(gatep); VL_DANGLING(senp); } } } @@ -1689,7 +1689,7 @@ private: && ritemp->edgeType()==AstEdgeType::ET_NEGEDGE) litemp->edgeType(AstEdgeType::ET_BOTHEDGE); // Remove redundant node - ritemp->unlinkFrBack()->deleteTree(); ritemp=NULL; cmpp=NULL; + ritemp->unlinkFrBack()->deleteTree(); VL_DANGLING(ritemp); VL_DANGLING(cmpp); // Try to collapse again nextp=litemp; } @@ -1732,7 +1732,7 @@ private: new AstAssign(nodep->fileline(), varrefp, exprp)); m_modp->addStmtp(newinitp); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); // Set the initial value right in the variable so we can constant propagate AstNode* initvaluep = exprp->cloneTree(false); varrefp->varp()->valuep(initvaluep); @@ -1757,12 +1757,12 @@ private: } else { nodep->unlinkFrBack(); } - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } else if (!afterComment(nodep->ifsp()) && !afterComment(nodep->elsesp())) { // Empty block, remove it // Note if we support more C++ then there might be side effects in the condition itself - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (!afterComment(nodep->ifsp())) { UINFO(4,"IF({x}) NULL {...} => IF(NOT{x}}: "<fileline(), condp, elsesp, ifsp); ifp->branchPred(nodep->branchPred().invert()); nodep->replaceWith(ifp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } else if (ifSameAssign(nodep)) { UINFO(4,"IF({a}) ASSIGN({b},{c}) else ASSIGN({b},{d}) => ASSIGN({b}, {a}?{c}:{d})"<rhsp(new AstCond(truep->fileline(), condp, truep, falsep)); nodep->replaceWith(ifp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } else if (0 // Disabled, as vpm assertions are faster without due to short-circuiting && operandIfIf(nodep)) { @@ -1809,7 +1809,7 @@ private: nodep->condp(new AstLogAnd(lowerIfp->fileline(), condp, lowerCondp)); lowerIfp->replaceWith(lowerIfsp); - lowerIfp->deleteTree(); lowerIfp=NULL; + lowerIfp->deleteTree(); VL_DANGLING(lowerIfp); } else if (operandBoolShift(nodep->condp())) { replaceBoolShift(nodep->condp()); @@ -1877,7 +1877,7 @@ private: && nodep->name().find("%") == string::npos && !nodep->hidden()) { // Just a simple constant string - the formatting is pointless - replaceConstString(nodep, nodep->name()); nodep=NULL; + replaceConstString(nodep, nodep->name()); VL_DANGLING(nodep); } } @@ -1898,7 +1898,7 @@ private: UINFO(4,"WHILE(0) => nop "<precondsp()) nodep->replaceWith(nodep->precondsp()); else nodep->unlinkFrBack(); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } else if (operandBoolShift(nodep->condp())) { replaceBoolShift(nodep->condp()); @@ -1918,7 +1918,7 @@ private: virtual void visit(AstSysIgnore* nodep, AstNUser*) { nodep->iterateChildren(*this); if (m_doNConst) { - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } } @@ -1948,7 +1948,7 @@ private: if (nodep->stmtsp()) underp = nodep->stmtsp()->unlinkFrBackWithNext(); if (underp) nodep->replaceWith(underp); else nodep->unlinkFrBack(); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } } diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 414336391..23e3e3700 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -343,7 +343,7 @@ private: // Skip all NEXT nodes under this block, and skip this if/case branch UINFO(4," OFF: "<unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else { if (m_checkBlock) nodep->iterateChildren(*this); } diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index 435ad416e..38a2da334 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -93,7 +93,7 @@ private: UINFO(8," new "<incp()->declp()<unlinkFrBack(); pushDeletep(removep); removep=NULL; + removep->unlinkFrBack(); pushDeletep(removep); VL_DANGLING(removep); // Remove node from comparison so don't hit it again hashed.erase(dupit); ++m_statToggleJoins; diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index e06ab77dc..e6b070dc8 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -229,7 +229,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 DeadModVisitor visitor(modp); - modp->unlinkFrBack()->deleteTree(); modp=NULL; + modp->unlinkFrBack()->deleteTree(); VL_DANGLING(modp); retry = true; } } @@ -252,9 +252,9 @@ private: for (AssignMap::iterator it = eqrange.first; it != eqrange.second; ++it) { AstNodeAssign* assp = it->second; UINFO(4," Dead assign "<unlinkFrBack()->deleteTree(); assp=NULL; + assp->unlinkFrBack()->deleteTree(); VL_DANGLING(assp); } - vscp->unlinkFrBack()->deleteTree(); vscp=NULL; + vscp->unlinkFrBack()->deleteTree(); VL_DANGLING(vscp); } } for (vector::iterator it = m_varEtcsp.begin(); it!=m_varEtcsp.end(); ++it) { diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index cd5cfd392..14c0742f4 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -374,9 +374,9 @@ private: if (newlhsp) { nodep->lhsp(newlhsp); } else { - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } - lhsp->deleteTree(); lhsp=NULL; + lhsp->deleteTree(); VL_DANGLING(lhsp); } else { nodep->iterateChildren(*this); @@ -420,7 +420,7 @@ private: } AstVarRef* newrefp = new AstVarRef(nodep->fileline(), dlyvscp, true); newrefp->user2(true); // No reason to do it again - nodep->replaceWith(newrefp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newrefp); nodep->deleteTree(); VL_DANGLING(nodep); } else if (!m_inDly && nodep->lvalue()) { //UINFO(9,"NBA "<user1(1); // Already processed, don't need to re-iterate nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } AstNode* newWordAssign (AstNodeAssign* placep, int word, AstNode* lhsp, AstNode* rhsp) { AstAssign* newp = new AstAssign (placep->fileline(), @@ -332,7 +332,7 @@ private: lhsp->dtypeFrom(nodep); // Just mark it, else nop } } - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } } bool expandWide (AstNodeAssign* nodep, AstExtend* rhsp) { @@ -438,7 +438,7 @@ private: if (midp) newp = new AstOr (nodep->fileline(), midp, newp); if (hip) newp = new AstOr (nodep->fileline(), hip, newp); newp->dtypeFrom(nodep); - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } else { // Long/Quad from Long/Quad UINFO(8," SEL->SHIFT "<fileline(), newp, nodep); } newp->dtypeFrom(nodep); - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } } @@ -541,8 +541,8 @@ private: rhsp, lsb))); } } - rhsp->deleteTree(); rhsp=NULL; - destp->deleteTree(); destp=NULL; + rhsp->deleteTree(); VL_DANGLING(rhsp); + destp->deleteTree(); VL_DANGLING(destp); } else { UINFO(8," ASSIGNSEL(const,narrow) "<isQuad() && !rhsp->isQuad()) rhsp = new AstCCast(nodep->fileline(), rhsp, nodep); @@ -667,7 +667,7 @@ private: nodep->width()), rhsp); newp->dtypeFrom(nodep); // Unsigned - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } } bool expandWide (AstNodeAssign* nodep, AstConcat* rhsp) { @@ -720,7 +720,7 @@ private: lhsp->deleteTree(); // Never used } newp->dtypeFrom(nodep); // Unsigned - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } } bool expandWide (AstNodeAssign* nodep, AstReplicate* rhsp) { @@ -761,7 +761,7 @@ private: newAstWordSelClone (nodep->rhsp(), w)); newp = (newp==NULL) ? eqp : (new AstOr (nodep->fileline(), newp, eqp)); } - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } void visitEqNeq(AstNodeBiop* nodep) { @@ -784,7 +784,7 @@ private: newp = new AstEq (nodep->fileline(), new AstConst (nodep->fileline(), 0), newp); } - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } } virtual void visit(AstEq* nodep, AstNUser*) { visitEqNeq (nodep); } @@ -803,7 +803,7 @@ private: } newp = new AstNeq (nodep->fileline(), new AstConst (nodep->fileline(), 0), newp); - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } else { UINFO(8," REDOR->EQ "<lhsp()->unlinkFrBack(); @@ -811,7 +811,7 @@ private: AstNode* newp = new AstNeq (nodep->fileline(), new AstConst (nodep->fileline(), zero), lhsp); - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } } virtual void visit(AstRedAnd* nodep, AstNUser*) { @@ -833,14 +833,14 @@ private: } newp = new AstEq (nodep->fileline(), new AstConst (nodep->fileline(), ~0), newp); - replaceWithDelete(nodep, newp); nodep=NULL; + replaceWithDelete(nodep, newp); VL_DANGLING(nodep); } else { UINFO(8," REDAND->EQ "<lhsp()->unlinkFrBack(); AstNode* newp = new AstEq (nodep->fileline(), new AstConst (nodep->fileline(), wordMask(lhsp)), lhsp); - replaceWithDelete(nodep,newp); nodep=NULL; + replaceWithDelete(nodep,newp); VL_DANGLING(nodep); } } virtual void visit(AstRedXor* nodep, AstNUser*) { @@ -856,7 +856,7 @@ private: } newp = new AstRedXor (nodep->fileline(), newp); UINFO(8," Wordize REDXORnew "<unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } m_stmtp = NULL; } diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 0f0e5ec30..b03cd3b80 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -617,7 +617,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { varvertexp->propagateAttrClocksFrom(vvertexp); } // Remove the edge - edgep->unlinkDelete(); edgep=NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); ++m_statRefs; edgep = vvertexp->outBeginp(); } @@ -625,7 +625,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { if (removedAllUsages) { // Remove input links while (V3GraphEdge* edgep = vvertexp->inBeginp()) { - edgep->unlinkDelete(); edgep=NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); } // Clone tree so we remember it for tracing, and keep the pointer // to the "ALWAYS" part of the tree as part of this statement @@ -678,25 +678,25 @@ void GateVisitor::replaceAssigns() { if (vscp->valuep() && !vscp->valuep()->castNodeMath()) { //if (debug()>9) vscp->dumpTree(cout, "-vscPre: "); while (AstNode* delp=vscp->valuep()->castComment()) { - delp->unlinkFrBack()->deleteTree(); delp=NULL; + delp->unlinkFrBack()->deleteTree(); VL_DANGLING(delp); } if (AstInitial* delp=vscp->valuep()->castInitial()) { AstNode* bodyp=delp->bodysp(); bodyp->unlinkFrBackWithNext(); delp->replaceWith(bodyp); - delp->deleteTree(); delp=NULL; + delp->deleteTree(); VL_DANGLING(delp); } if (AstAlways* delp=vscp->valuep()->castAlways()) { AstNode* bodyp=delp->bodysp(); bodyp->unlinkFrBackWithNext(); delp->replaceWith(bodyp); - delp->deleteTree(); delp=NULL; + delp->deleteTree(); VL_DANGLING(delp); } if (AstNodeAssign* delp=vscp->valuep()->castNodeAssign()) { AstNode* rhsp=delp->rhsp(); rhsp->unlinkFrBack(); delp->replaceWith(rhsp); - delp->deleteTree(); delp=NULL; + delp->deleteTree(); VL_DANGLING(delp); } //if (debug()>9) {vscp->dumpTree(cout, "-vscDone: "); cout<valuep()->castNodeMath() @@ -749,7 +749,7 @@ void GateVisitor::consumedMove() { // Eventually: Move the statement to a new active block with "tracing-on" sensitivity UINFO(8," Remove unconsumed "<unlinkFrBack(); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } } } @@ -817,7 +817,7 @@ private: // Make the substp an rvalue like nodep. This facilitate the hashing in dedupe. if (AstNodeVarRef* varrefp = substp->castNodeVarRef()) varrefp->lvalue(false); nodep->replaceWith(substp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } } virtual void visit(AstNode* nodep, AstNUser*) { @@ -1039,7 +1039,7 @@ private: // Remove inputs links while (V3GraphEdge* inedgep = vvertexp->inBeginp()) { - inedgep->unlinkDelete(); inedgep=NULL; + inedgep->unlinkDelete(); VL_DANGLING(inedgep); } // replaceAssigns() does the deleteTree on lvertexNodep in a later step AstNode* lvertexNodep = lvertexp->nodep(); @@ -1161,14 +1161,14 @@ private: if (AstSel* newselp = merge(preselp, curselp)) { UINFO(5, "assemble to new sel: "<replaceWith(newselp); preselp->deleteTree(); preselp = NULL; + preselp->replaceWith(newselp); preselp->deleteTree(); VL_DANGLING(preselp); // create new rhs for pre assignment AstNode* newrhsp = new AstConcat(m_assignp->rhsp()->fileline(), m_assignp->rhsp()->cloneTree(false), assignp->rhsp()->cloneTree(false)); AstNode* oldrhsp = m_assignp->rhsp(); - oldrhsp->replaceWith(newrhsp); oldrhsp->deleteTree(); oldrhsp = NULL; + oldrhsp->replaceWith(newrhsp); oldrhsp->deleteTree(); VL_DANGLING(oldrhsp); m_assignp->dtypeChgWidthSigned(m_assignp->width()+assignp->width(), m_assignp->width()+assignp->width(), AstNumeric::fromBool(true)); // don't need to delete, will be handled - //assignp->unlinkFrBack(); assignp->deleteTree(); assignp = NULL; + //assignp->unlinkFrBack(); assignp->deleteTree(); VL_DANGLING(assignp); // update the graph { @@ -1179,11 +1179,11 @@ private: ledgep = ledgep->inNextp(); GateEitherVertex* fromvp = dynamic_cast(oedgep->fromp()); new V3GraphEdge(m_graphp, fromvp, m_logicvp, 1); - oedgep->unlinkDelete(); oedgep = NULL; + oedgep->unlinkDelete(); VL_DANGLING(oedgep); } } // delete all outedges to lvertexp, only one - oldedgep->unlinkDelete(); oldedgep = NULL; + oldedgep->unlinkDelete(); VL_DANGLING(oldedgep); } ++m_numMergedAssigns; } else { @@ -1241,7 +1241,7 @@ private: AstNode* valuep = assp->rhsp(); valuep->unlinkFrBack(); assp->replaceWith(valuep); - assp->deleteTree(); assp=NULL; + assp->deleteTree(); VL_DANGLING(assp); } } // Speedups diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index cbee8f4c6..482aa2e4e 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -109,7 +109,7 @@ private: AstVarScope* newvscp = genInpClk(vscp); AstVarRef* newrefp = new AstVarRef(nodep->fileline(), newvscp, nodep->lvalue()); nodep->replaceWith(newrefp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } } } diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index 8f664b598..81fabd390 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -269,7 +269,7 @@ void GraphAcyc::deleteMarked () { nextp = vertexp->verticesNextp(); GraphAcycVertex* avertexp = (GraphAcycVertex*)vertexp; if (avertexp->isDelete()) { - avertexp->unlinkDelete(&m_breakGraph); avertexp=NULL; + avertexp->unlinkDelete(&m_breakGraph); VL_DANGLING(avertexp); } } } @@ -285,13 +285,13 @@ void GraphAcyc::simplifyNone (GraphAcycVertex* avertexp) { while (V3GraphEdge* edgep = avertexp->outBeginp()) { V3GraphVertex* otherVertexp = edgep->top(); //UINFO(9," out "<unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); workPush(otherVertexp); } while (V3GraphEdge* edgep = avertexp->inBeginp()) { V3GraphVertex* otherVertexp = edgep->fromp(); //UINFO(9," in "<unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); workPush(otherVertexp); } } @@ -322,8 +322,8 @@ void GraphAcyc::simplifyOne (GraphAcycVertex* avertexp) { // cppcheck-suppress leakReturnValNotUsed edgeFromEdge(templateEdgep, inVertexp, outVertexp); // Remove old edge - inEdgep->unlinkDelete(); inEdgep = NULL; - outEdgep->unlinkDelete(); outEdgep = NULL; templateEdgep=NULL; + inEdgep->unlinkDelete(); VL_DANGLING(inEdgep); + outEdgep->unlinkDelete(); VL_DANGLING(outEdgep); VL_DANGLING(templateEdgep); workPush(inVertexp); workPush(outVertexp); } @@ -357,10 +357,10 @@ void GraphAcyc::simplifyOut (GraphAcycVertex* avertexp) { // cppcheck-suppress leakReturnValNotUsed edgeFromEdge(inEdgep, inVertexp, outVertexp); // Remove old edge - inEdgep->unlinkDelete(); inEdgep = NULL; + inEdgep->unlinkDelete(); VL_DANGLING(inEdgep); workPush(inVertexp); } - outEdgep->unlinkDelete(); outEdgep = NULL; + outEdgep->unlinkDelete(); VL_DANGLING(outEdgep); workPush(outVertexp); } } @@ -383,18 +383,18 @@ void GraphAcyc::simplifyDup (GraphAcycVertex* avertexp) { // !cutable duplicates prev !cutable: we can ignore it, redundant // cutable duplicates prev !cutable: know it's not a relevant loop, ignore it UINFO(8," DelDupEdge "< "<top()<unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); } else if (!edgep->cutable()) { // !cutable duplicates prev cutable: delete the earlier cutable UINFO(8," DelDupPrev "< "<top()<unlinkDelete(); prevEdgep = NULL; + prevEdgep->unlinkDelete(); VL_DANGLING(prevEdgep); outVertexp->userp(edgep); } else { // cutable duplicates prev cutable: combine weights UINFO(8," DelDupComb "< "<top()<weight (prevEdgep->weight() + edgep->weight()); addOrigEdgep (prevEdgep, edgep); - edgep->unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); } workPush(outVertexp); workPush(avertexp); @@ -412,7 +412,7 @@ void GraphAcyc::cutBasic (GraphAcycVertex* avertexp) { nextp = edgep->outNextp(); if (edgep->cutable() && edgep->top()==avertexp) { cutOrigEdge (edgep, " Cut Basic"); - edgep->unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); workPush(avertexp); } } @@ -433,7 +433,7 @@ void GraphAcyc::cutBackward (GraphAcycVertex* avertexp) { nextp = edgep->outNextp(); if (edgep->cutable() && edgep->top()->user()) { cutOrigEdge (edgep, " Cut A->B->A"); - edgep->unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); workPush(avertexp); } } @@ -497,7 +497,7 @@ void GraphAcyc::placeTryEdge(V3GraphEdge* edgep) { // Adding this edge would cause a loop, kill it edgep->cutable(true); // So graph still looks pretty cutOrigEdge (edgep, " Cut loop"); - edgep->unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); // Backout the ranks we calculated while (GraphAcycVertex* vertexp = workBeginp()) { workPop(); diff --git a/src/V3GraphAlg.cpp b/src/V3GraphAlg.cpp index 141a7f953..8558cae51 100644 --- a/src/V3GraphAlg.cpp +++ b/src/V3GraphAlg.cpp @@ -109,10 +109,10 @@ private: } if (saveOld) { if (m_sumWeights) prevEdgep->weight(prevEdgep->weight() + edgep->weight()); - edgep->unlinkDelete(); edgep = NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); } else { if (m_sumWeights) edgep->weight(prevEdgep->weight() + edgep->weight()); - prevEdgep->unlinkDelete(); prevEdgep = NULL; + prevEdgep->unlinkDelete(); VL_DANGLING(prevEdgep); outVertexp->userp(edgep); } } diff --git a/src/V3GraphDfa.cpp b/src/V3GraphDfa.cpp index 23c967179..5920afd6a 100644 --- a/src/V3GraphDfa.cpp +++ b/src/V3GraphDfa.cpp @@ -331,7 +331,7 @@ private: for (V3GraphVertex* nextp,*vertexp = m_graphp->verticesBeginp(); vertexp; vertexp=nextp) { nextp = vertexp->verticesNextp(); if (nfaState(vertexp)) { - vertexp->unlinkDelete(m_graphp); vertexp=NULL; + vertexp->unlinkDelete(m_graphp); VL_DANGLING(vertexp); } } @@ -381,7 +381,7 @@ private: if (vvertexp->accepting()) { for (V3GraphEdge* nextp,*edgep = vertexp->outBeginp(); edgep; edgep=nextp) { nextp = edgep->outNextp(); - edgep->unlinkDelete(); edgep=NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); } } } @@ -417,7 +417,7 @@ private: for (V3GraphVertex* nextp,*vertexp = m_graphp->verticesBeginp(); vertexp; vertexp=nextp) { nextp = vertexp->verticesNextp(); if (!vertexp->user()) { - vertexp->unlinkDelete(m_graphp); vertexp=NULL; + vertexp->unlinkDelete(m_graphp); VL_DANGLING(vertexp); } } } @@ -458,7 +458,7 @@ private: } } // Transitions to this state removed by the unlink function - vertexp->unlinkDelete(m_graphp); vertexp=NULL; + vertexp->unlinkDelete(m_graphp); VL_DANGLING(vertexp); } } } @@ -535,7 +535,7 @@ private: DfaVertex* tovertexp = static_cast(edgep->top()); if (tovertexp->accepting()) { new DfaEdge(graphp(), vvertexp, m_tempNewerReject, vedgep); - edgep->unlinkDelete(); edgep=NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); } // NOT of all values goes to accept diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index c17ae69f2..7df044388 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -135,14 +135,14 @@ private: } else { m_modp->user1(1); } - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; // Remove so don't propagate to upper cell... + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); // Remove so don't propagate to upper cell... } else if (nodep->pragType() == AstPragmaType::NO_INLINE_MODULE) { if (!m_modp) { nodep->v3error("Inline pragma not under a module"); } else { cantInline("Pragma NO_INLINE_MODULE",false); } - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; // Remove so don't propagate to upper cell... + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); // Remove so don't propagate to upper cell... } else { nodep->iterateChildren(*this); } @@ -347,7 +347,7 @@ private: AstVarRef* exprvarrefp = nodep->varp()->user2p()->castNode()->castVarRef(); if (exprconstp) { nodep->replaceWith(exprconstp->cloneTree(true)); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); return; } else if (exprvarrefp) { @@ -521,9 +521,9 @@ private: if (stmtsp) stmtsp->unlinkFrBackWithNext(); if (stmtsp) m_modp->addStmtp(stmtsp); // Remove the cell - newmodp->deleteTree(); newmodp=NULL; // Clear any leftover ports, etc + newmodp->deleteTree(); VL_DANGLING(newmodp); // Clear any leftover ports, etc nodep->unlinkFrBack(); - pushDeletep(nodep); nodep = NULL; + pushDeletep(nodep); VL_DANGLING(nodep); if (debug()>=9) { m_modp->dumpTree(cout,"donemod:"); } } } @@ -560,7 +560,7 @@ void V3Inline::inlineAll(AstNetlist* nodep) { for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp=nextmodp) { nextmodp = modp->nextp()->castNodeModule(); if (modp->user1()) { // Was inlined - modp->unlinkFrBack()->deleteTree(); modp=NULL; + modp->unlinkFrBack()->deleteTree(); VL_DANGLING(modp); } } V3Global::dumpCheckGlobalTree("inline.tree", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 52d3069dc..9aefd5cda 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -118,7 +118,7 @@ private: } // We're done with the pin - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstUdpTable* nodep, AstNUser*) { @@ -188,7 +188,7 @@ private: // Done. Delete original m_cellRangep=NULL; - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } } virtual void visit(AstPin* nodep, AstNUser*) { diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 9f583ed3e..49ea5b24e 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -162,7 +162,7 @@ public: // above our current iteration point. if (debug()>4) oldassp->dumpTree(cout, " REMOVE/SAMEBLK "); entp->complexAssign(); - m_statep->pushUnlinkDeletep(oldassp); oldassp=NULL; + m_statep->pushUnlinkDeletep(oldassp); VL_DANGLING(oldassp); ++m_statep->m_statAssnDel; } } @@ -199,7 +199,7 @@ public: // We'll later constant propagate UINFO(4," replaceconst: "<replaceWith(constp->cloneTree(false)); - varrefp->deleteTree(); varrefp=NULL; + varrefp->deleteTree(); VL_DANGLING(varrefp); ++m_statep->m_statAssnCon; return; // **DONE, no longer a var reference** } @@ -313,7 +313,7 @@ private: if (nodep->lvalue()) { m_lifep->complexAssign(vscp); } else { - m_lifep->varUsageReplace(vscp, nodep); nodep=NULL; + m_lifep->varUsageReplace(vscp, nodep); VL_DANGLING(nodep); } } virtual void visit(AstNodeAssign* nodep, AstNUser*) { diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 6ba6cb353..ba420e844 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -68,7 +68,7 @@ private: UINFO(9, " Replace "<fileline(), newvscp, nodep->lvalue()); nodep->replaceWith(newrefp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } } virtual void visit(AstNodeModule* nodep, AstNUser*) { @@ -155,7 +155,7 @@ private: UINFO(4," DELETE "<varScopep()->user4p(lhsp->varScopep()); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); ++m_statAssnDel; } } diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index 6288909dc..1dbe0656a 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -292,7 +292,7 @@ private: if (pinStar) pinp->v3error("Duplicate .* in a cell"); pinStar = true; // Done with this fake pin - pinp->unlinkFrBack()->deleteTree(); pinp=NULL; + pinp->unlinkFrBack()->deleteTree(); VL_DANGLING(pinp); } } // Convert unnamed pins to pin number based assignments @@ -404,7 +404,7 @@ private: <warnMore()<<"... Location of original declaration"); } nodep->unlinkFrBack(); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } else if (!foundp) { m_mods.rootp()->insert(nodep->name(), new VSymEnt(&m_mods, nodep)); } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 9a5d9732a..935634749 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -814,7 +814,7 @@ class LinkDotFindVisitor : public AstNVisitor { newdtypep->unlinkFrBack(); findvarp->childDTypep(newdtypep); } - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else { nodep->v3error("Duplicate declaration of signal: "<prettyName()<warnMore()<<"... Location of original declaration"); @@ -1005,7 +1005,7 @@ private: nodep->name(), exprp); cellp->addParamsp(pinp); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } } virtual void visit(AstPort* nodep, AstNUser*) { @@ -1025,7 +1025,7 @@ private: symp->exported(false); } // Ports not needed any more - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstAssignW* nodep, AstNUser*) { // Deal with implicit definitions @@ -1050,7 +1050,7 @@ private: // Unsupported gates need implicit creation pinImplicitExprRecurse(nodep); // We're done with implicit gates - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstNode* nodep, AstNUser*) { // Default: Just iterate @@ -1168,7 +1168,7 @@ class LinkDotScopeVisitor : public AstNVisitor { // or maybe an alias of an alias m_statep->insertScopeAlias(LinkDotState::SAMN_IFTOP, lhsSymp, rhsSymp); // We have stored the link, we don't need these any more - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } // For speed, don't recurse things that can't have scope // Note we allow AstNodeStmt's as generates may be under them @@ -1235,7 +1235,7 @@ class LinkDotIfaceVisitor : public AstNVisitor { if (m_statep->forScopeCreation()) { // Done with AstModportFTaskRef. // Delete to prevent problems if we dead-delete pointed to ftask - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } } virtual void visit(AstModportVarRef* nodep, AstNUser*) { @@ -1258,7 +1258,7 @@ class LinkDotIfaceVisitor : public AstNVisitor { if (m_statep->forScopeCreation()) { // Done with AstModportVarRef. // Delete to prevent problems if we dead-delete pointed to variable - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } } virtual void visit(AstNode* nodep, AstNUser*) { @@ -1416,7 +1416,7 @@ private: virtual void visit(AstCellInline* nodep, AstNUser*) { checkNoDot(nodep); if (m_statep->forScopeCreation()) { - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } } virtual void visit(AstCell* nodep, AstNUser*) { @@ -1460,7 +1460,7 @@ private: if (!refp) { if (nodep->name() == "__paramNumber1" && m_cellp->modp()->castPrimitive()) { // Primitive parameter is really a delay we can just ignore - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); return; } nodep->v3error(ucfirst(whatp)<<" not found: "<prettyName()); @@ -1520,11 +1520,11 @@ private: } if (debug()>=9) newp->dumpTree("-dot-out: "); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } else { // Dot midpoint AstNode* newp = nodep->rhsp()->unlinkFrBack(); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } } if (start) { @@ -1551,7 +1551,7 @@ private: AstNode* varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack(); AstNode* newp = new AstMemberSel(nodep->fileline(), varEtcp, VFlagChildDType(), nodep->name()); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } else { // @@ -1624,7 +1624,7 @@ private: m_ds.m_dotPos = DP_SCOPE; UINFO(9," cell -> iface varref "<nodep()<fileline(), ifaceRefVarp, false); - nodep->replaceWith(newp); pushDeletep(nodep); nodep = NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } } else if (AstVar* varp = foundp->nodep()->castVar()) { @@ -1638,7 +1638,7 @@ private: m_ds.m_dotPos = DP_SCOPE; ok = true; AstNode* newp = new AstVarRef(nodep->fileline(), varp, false); - nodep->replaceWith(newp); pushDeletep(nodep); nodep = NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else if (allowVar) { AstNodeVarRef* newp; @@ -1652,7 +1652,7 @@ private: newp->packagep(foundp->packagep()); UINFO(9," new "<replaceWith(newp); pushDeletep(nodep); nodep = NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); m_ds.m_dotPos = DP_MEMBER; ok = true; } @@ -1682,13 +1682,13 @@ private: ok = true; AstVar* varp = makeIfaceModportVar(nodep->fileline(), cellp, ifacep, modportp); AstVarRef* refp = new AstVarRef(varp->fileline(), varp, false); - nodep->replaceWith(refp); pushDeletep(nodep); nodep = NULL; + nodep->replaceWith(refp); pushDeletep(nodep); VL_DANGLING(nodep); } } else if (AstEnumItem* valuep = foundp->nodep()->castEnumItem()) { if (allowVar) { AstNode* newp = new AstEnumItemRef(nodep->fileline(), valuep, foundp->packagep()); - nodep->replaceWith(newp); pushDeletep(nodep); nodep = NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); ok = true; m_ds.m_dotText = ""; } @@ -1717,7 +1717,7 @@ private: // Create if implicit, and also if error (so only complain once) AstVarRef* newp = new AstVarRef(nodep->fileline(), nodep->name(), false); nodep->replaceWith(newp); - pushDeletep(nodep); nodep = NULL; + pushDeletep(nodep); VL_DANGLING(nodep); createImplicitVar (m_curSymp, newp, m_modp, m_modSymp, err); } } @@ -1795,7 +1795,7 @@ private: UINFO(7," Resolved "<fileline(), vscp, nodep->lvalue()); nodep->replaceWith(newvscp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); UINFO(9," new "<pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext(); AstNode* newp = new AstMethodSel(nodep->fileline(), varEtcp, VFlagChildDType(), nodep->name(), argsp); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return; } else { checkNoDot(nodep); @@ -2016,7 +2016,7 @@ private: virtual void visit(AstPackageImport* nodep, AstNUser*) { // No longer needed checkNoDot(nodep); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstNode* nodep, AstNUser*) { // Default: Just iterate diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index a19cb6c6d..b1d58eeb8 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -159,7 +159,7 @@ private: initsp = initsp->addNext(newp); newp = initsp; nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstWhile* nodep, AstNUser*) { // Don't need to track AstRepeat/AstFor as they have already been converted @@ -192,7 +192,7 @@ private: AstJumpLabel* labelp = findAddLabel(m_ftaskp, false); nodep->addPrev(new AstJumpGo(nodep->fileline(), labelp)); } - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } virtual void visit(AstBreak* nodep, AstNUser*) { nodep->iterateChildren(*this); @@ -202,7 +202,7 @@ private: AstJumpLabel* labelp = findAddLabel(m_loopp, false); nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp)); } - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } virtual void visit(AstContinue* nodep, AstNUser*) { nodep->iterateChildren(*this); @@ -213,7 +213,7 @@ private: AstJumpLabel* labelp = findAddLabel(m_loopp, true); nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp)); } - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } virtual void visit(AstDisable* nodep, AstNUser*) { UINFO(8," DISABLE "<addNextHere(new AstJumpGo(nodep->fileline(), labelp)); } - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); //if (debug()>=9) { UINFO(0,"\n"); beginp->dumpTree(cout," labelo: "); } } virtual void visit(AstVarRef* nodep, AstNUser*) { diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index e21fb5370..a27a1b1ea 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -190,62 +190,62 @@ private: AstTypedef* typep = nodep->backp()->castTypedef(); if (!typep) nodep->v3fatalSrc("Attribute not attached to typedef"); typep->attrPublic(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_CLOCK) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->attrScClocked(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_CLOCK_ENABLE) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->attrClockEn(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_PUBLIC) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->sigUserRWPublic(true); m_varp->sigModPublic(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_PUBLIC_FLAT) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->sigUserRWPublic(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_PUBLIC_FLAT_RD) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->sigUserRdPublic(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_PUBLIC_FLAT_RW) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->sigUserRWPublic(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_ISOLATE_ASSIGNMENTS) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->attrIsolateAssign(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_SFORMAT) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->attrSFormat(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_SC_BV) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->attrScBv(true); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_CLOCKER) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->attrClocker(AstVarAttrClocker::CLOCKER_YES); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (nodep->attrType() == AstAttrType::VAR_NO_CLOCKER) { if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable"); m_varp->attrClocker(AstVarAttrClocker::CLOCKER_NO); - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } } @@ -288,7 +288,7 @@ private: if (backp->castTypedef()) { // A typedef doesn't need us to make yet another level of typedefing // For typedefs just remove the AstRefDType level of abstraction nodep->replaceWith(dtypep); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); return; } else { defp = new AstTypedef(nodep->fileline(), nodep->name(), NULL, VFlagChildDType(), dtypep); @@ -297,7 +297,7 @@ private: } } nodep->replaceWith(new AstRefDType(nodep->fileline(), defp->name())); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstTypedefFwd* nodep, AstNUser*) { diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 53a42e841..11dc9df35 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -82,7 +82,7 @@ private: nodep->iterateChildren(*this); // Initial assignments under function/tasks can just be simple assignments without the initial if (m_ftaskp) { - nodep->replaceWith(nodep->bodysp()->unlinkFrBackWithNext()); nodep=NULL; + nodep->replaceWith(nodep->bodysp()->unlinkFrBackWithNext()); VL_DANGLING(nodep); } } virtual void visit(AstVAssert* nodep, AstNUser*) { @@ -167,18 +167,18 @@ private: did=0; if (AstNodeSel* selp = nodep->sensp()->castNodeSel()) { AstNode* fromp = selp->fromp()->unlinkFrBack(); - selp->replaceWith(fromp); selp->deleteTree(); selp=NULL; + selp->replaceWith(fromp); selp->deleteTree(); VL_DANGLING(selp); did=1; } // NodeSel doesn't include AstSel.... if (AstSel* selp = nodep->sensp()->castSel()) { AstNode* fromp = selp->fromp()->unlinkFrBack(); - selp->replaceWith(fromp); selp->deleteTree(); selp=NULL; + selp->replaceWith(fromp); selp->deleteTree(); VL_DANGLING(selp); did=1; } if (AstNodePreSel* selp = nodep->sensp()->castNodePreSel()) { AstNode* fromp = selp->lhsp()->unlinkFrBack(); - selp->replaceWith(fromp); selp->deleteTree(); selp=NULL; + selp->replaceWith(fromp); selp->deleteTree(); VL_DANGLING(selp); did=1; } } @@ -233,17 +233,17 @@ private: if (nodep->pragType() == AstPragmaType::PUBLIC_MODULE) { if (!m_modp) nodep->v3fatalSrc("PUBLIC_MODULE not under a module\n"); m_modp->modPublic(true); - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } else if (nodep->pragType() == AstPragmaType::PUBLIC_TASK) { if (!m_ftaskp) nodep->v3fatalSrc("PUBLIC_TASK not under a task\n"); m_ftaskp->taskPublic(true); m_modp->modPublic(true); // Need to get to the task... - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } else if (nodep->pragType() == AstPragmaType::COVERAGE_BLOCK_OFF) { if (!v3Global.opt.coverageLine()) { // No need for block statements; may optimize better without - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } } else { @@ -372,7 +372,7 @@ private: } } } - nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL; + nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep); } } diff --git a/src/V3Order.cpp b/src/V3Order.cpp index d067a7c3b..aa79062fe 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -1265,7 +1265,7 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) { domainp->dumpTree(cout); cout<deleteTree(); newtreep=NULL; + newtreep->deleteTree(); VL_DANGLING(newtreep); } } } // next input edgep @@ -1476,7 +1476,7 @@ void OrderVisitor::processMoveDoneOne(OrderMoveVertex* vertexp) { UINFO(9," Clear to "<<(toVertexp->inEmpty()?"[EMP] ":" ") <unlinkDelete(); edgep=NULL; + edgep->unlinkDelete(); VL_DANGLING(edgep); if (toVertexp->inEmpty()) { // If destination node now has all inputs resolved; recurse to move that vertex // This is thus depth first (before width) which keeps the resulting executable's d-cache happy. @@ -1530,7 +1530,7 @@ void OrderVisitor::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* d nodep->unlinkFrBack(); if (domainp == m_deleteDomainp) { UINFO(4," Ordering deleting pre-settled "<addStmtsp(nodep); if (v3Global.opt.outputSplitCFuncs()) { diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 486541af7..35a035a37 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -265,7 +265,7 @@ private: } else { nodep->unlinkFrBack(); } - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstGenIf* nodep, AstNUser*) { UINFO(9," GENIF "<unlinkFrBack(); } - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); // Normal edit rules will now recurse the replacement } else { nodep->condp()->v3error("Generate If condition must evaluate to constant"); @@ -313,7 +313,7 @@ private: string beginName = nodep->name(); // Leave the original Begin, as need a container for the (possible) GENVAR // Note V3Unroll will replace some AstVarRef's to the loop variable with constants - V3Unroll::unrollGen(forp, beginName); forp=NULL; + V3Unroll::unrollGen(forp, beginName); VL_DANGLING(forp); // Blocks were constructed under the special begin, move them up // Note forp is null, so grab statements again if (AstNode* stmtsp = nodep->genforp()) { @@ -342,8 +342,7 @@ private: for (AstNode* ep = itemp->condsp(); ep; ) { AstNode* nextp = ep->nextp(); //May edit list ep->iterateAndNext(*this); - V3Const::constifyParamsEdit(ep); ep=NULL; // ep may change - // cppcheck-suppress redundantAssignment + V3Const::constifyParamsEdit(ep); VL_DANGLING(ep); // ep may change ep = nextp; } } @@ -375,7 +374,7 @@ private: nodep->replaceWith(keepp); } else nodep->unlinkFrBack(); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } // Default: Just iterate diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index 005baff3c..2ac90398e 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -146,7 +146,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i } if (ofp) { ofp->close(); - delete ofp; ofp = NULL; + delete ofp; VL_DANGLING(ofp); } } } diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index f885e3835..3ef9527e5 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -1074,7 +1074,7 @@ int V3PreProcImp::getStateToken() { out = defineSubst(refp); //NOP: out = m_preprocp->defSubstitute(out); } - m_defRefs.pop(); refp=NULL; + m_defRefs.pop(); VL_DANGLING(refp); if (m_defRefs.empty()) { statePop(); if (!m_off) unputDefrefString(out); diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 3588d3a19..efd76b8aa 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -334,7 +334,7 @@ private: nodep->iterateChildren(*this); } else { // A block that was just moved under a scope, Kill it. - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } } diff --git a/src/V3Simulate.h b/src/V3Simulate.h index ac4dc9253..7233eacb8 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -653,9 +653,7 @@ private: UINFO(5," FUNCREF "<taskp()->castNodeFTask(); if (!funcp) nodep->v3fatalSrc("Not linked"); - // cppcheck-suppress redundantAssignment - if (m_params) { V3Width::widthParamsEdit(funcp); } funcp=NULL; // Make sure we've sized the function - // cppcheck-suppress redundantAssignment + if (m_params) { V3Width::widthParamsEdit(funcp); } VL_DANGLING(funcp); // Make sure we've sized the function funcp = nodep->taskp()->castNodeFTask(); if (!funcp) nodep->v3fatalSrc("Not linked"); // Apply function call values to function V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index c69be8979..874b7a111 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -124,7 +124,7 @@ class SliceCloneVisitor : public AstNVisitor { clonep->iterateChildren(*this); nodep->addNextHere(clonep); } - nodep->unlinkFrBack()->deleteTree(); nodep = NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } // Not all Uniop nodes should be cloned down to a single bit @@ -164,7 +164,7 @@ class SliceCloneVisitor : public AstNVisitor { } } nodep->addNextHere(lhsp); - nodep->unlinkFrBack()->deleteTree(); nodep = NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstRedOr* nodep, AstNUser*) { cloneUniop(nodep); @@ -295,7 +295,7 @@ class SliceVisitor : public AstNVisitor { AstVarRef* clonep = nodep->cloneTree(false); clonep->user1p(nodep); AstNode* newp = insertImplicit(clonep, 1, dimensions); - nodep->replaceWith(newp); nodep = NULL; + nodep->replaceWith(newp); VL_DANGLING(nodep); newp->accept(*this); } } @@ -422,7 +422,7 @@ class SliceVisitor : public AstNVisitor { } //if (debug()>=9) newp->dumpTreeAndNext(cout, "-InitArrayOut: "); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return; // WIll iterate in a moment } // Hasn't been searched for implicit slices yet diff --git a/src/V3StatsReport.cpp b/src/V3StatsReport.cpp index 098680176..4b7377780 100644 --- a/src/V3StatsReport.cpp +++ b/src/V3StatsReport.cpp @@ -214,5 +214,5 @@ void V3Stats::statsReport() { StatsReport reporter (ofp); // Cleanup - ofp->close(); delete ofp; ofp = NULL; + ofp->close(); delete ofp; VL_DANGLING(ofp); } diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index 8aa380184..c2e9d2d88 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -163,7 +163,7 @@ public: } void deleteAssign (AstNodeAssign* nodep) { UINFO(5, "Delete "<unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } void deleteUnusedAssign() { // If there are unused assignments in this var, kill them @@ -310,7 +310,7 @@ private: } if (debug()>5) newp->dumpTree(cout," w_new: "); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); ++m_statSubsts; } virtual void visit(AstWordSel* nodep, AstNUser*) { @@ -329,7 +329,7 @@ private: // Check that the RHS hasn't changed value since we recorded it. SubstUseVisitor visitor (substp, entryp->getWordStep(word)); if (visitor.ok()) { - replaceSubstEtc(nodep, substp); nodep=NULL; + replaceSubstEtc(nodep, substp); VL_DANGLING(nodep); } else { entryp->consumeWord(word); } @@ -357,7 +357,7 @@ private: SubstUseVisitor visitor (substp, entryp->getWholeStep()); if (visitor.ok()) { UINFO(8," USEwhole "<consumeWhole(); diff --git a/src/V3Table.cpp b/src/V3Table.cpp index b2f121903..e064c1137 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -422,7 +422,7 @@ private: UINFO(4," ALWAYS "<iterateChildren(*this); nodep=NULL; // May delete nodep. + nodep->iterateChildren(*this); VL_DANGLING(nodep); // May delete nodep. m_assignwp = NULL; } virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) { @@ -456,7 +456,7 @@ private: { AstBegin* tempp = new AstBegin(beginp->fileline(),"[EditWrapper]",beginp); TaskRelinkVisitor visit (tempp); - tempp->stmtsp()->unlinkFrBackWithNext(); tempp->deleteTree(); tempp=NULL; + tempp->stmtsp()->unlinkFrBackWithNext(); tempp->deleteTree(); VL_DANGLING(tempp); } // if (debug()>=9) { beginp->dumpTreeAndNext(cout,"-iotask: "); } @@ -718,7 +718,7 @@ private: stmt += "(*__Vcb)("; args += ");\n"; AstCStmt* newp = new AstCStmt(nodep->fileline(), stmt); - newp->addBodysp(argnodesp); argnodesp=NULL; + newp->addBodysp(argnodesp); VL_DANGLING(argnodesp); newp->addBodysp(new AstText(nodep->fileline(), args, true)); dpip->addStmtsp(newp); } @@ -968,10 +968,10 @@ private: { AstBegin* tempp = new AstBegin(cfuncp->fileline(),"[EditWrapper]",cfuncp); TaskRelinkVisitor visit (tempp); - tempp->stmtsp()->unlinkFrBackWithNext(); tempp->deleteTree(); tempp=NULL; + tempp->stmtsp()->unlinkFrBackWithNext(); tempp->deleteTree(); VL_DANGLING(tempp); } // Delete rest of cloned task and return new func - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); if (debug()>=9) { cfuncp->dumpTree(cout,"-userFunc: "); } return cfuncp; } @@ -1069,7 +1069,7 @@ private: nodep->replaceWith(beginp); } // Cleanup - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); UINFO(4," FTask REF Done.\n"); } virtual void visit(AstNodeFTask* nodep, AstNUser*) { @@ -1106,7 +1106,7 @@ private: if (AstVar* portp = nodep->fvarp()->castVar()) { AstVarScope* vscp = m_statep->findVarScope(m_scopep, portp); UINFO(9," funcremovevsc "<unlinkFrBack()); vscp=NULL; + pushDeletep(vscp->unlinkFrBack()); VL_DANGLING(vscp); } } for (AstNode* nextp, *stmtp = nodep->stmtsp(); stmtp; stmtp=nextp) { @@ -1114,13 +1114,13 @@ private: if (AstVar* portp = stmtp->castVar()) { AstVarScope* vscp = m_statep->findVarScope(m_scopep, portp); UINFO(9," funcremovevsc "<unlinkFrBack()); vscp=NULL; + pushDeletep(vscp->unlinkFrBack()); VL_DANGLING(vscp); } } // Just push for deletion, as other references to func may // remain until visitor exits nodep->unlinkFrBack(); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } m_insMode = prevInsMode; m_insStmtp = prevInsStmtp; @@ -1215,7 +1215,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) pinp->v3error("No such argument '"<prettyName() <<"' in function call to "<taskp()->prettyTypeName()); // We'll just delete it; seems less error prone than making a false argument - pinp->unlinkFrBack()->deleteTree(); pinp=NULL; + pinp->unlinkFrBack()->deleteTree(); VL_DANGLING(pinp); } else { if (tconnects[it->second].second) { pinp->v3error("Duplicate argument '"<prettyName() @@ -1234,7 +1234,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) } else { pinp->v3error("Too many arguments in function call to "<taskp()->prettyTypeName()); // We'll just delete it; seems less error prone than making a false argument - pinp->unlinkFrBack()->deleteTree(); pinp=NULL; + pinp->unlinkFrBack()->deleteTree(); VL_DANGLING(pinp); } } else { tconnects[ppinnum].second = argp; diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 52c366783..eaa97f4c0 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -529,7 +529,7 @@ private: m_fullSubStmts += EmitCBaseCounterVisitor(nodep).count(); } else { // Duplicates don't need a TraceInc - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } return incAddp; } diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 18280dd84..9f605d5cd 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -612,7 +612,7 @@ class TristateVisitor : public TristateBaseVisitor { new AstConst(invarp->fileline(), pull)); orp = new AstOr(invarp->fileline(), orp, undrivenp); } else { - undrivenp->deleteTree(); undrivenp=NULL; + undrivenp->deleteTree(); VL_DANGLING(undrivenp); } if (envarp) { nodep->addStmtp(new AstAssignW(enp->fileline(), @@ -651,7 +651,7 @@ class TristateVisitor : public TristateBaseVisitor { AstNode* newp = new AstVarRef(nodep->fileline(), varp, true); UINFO(9," const->"<replaceWith(newp); - pushDeletep(nodep); nodep = NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } else if (m_tgraph.isTristate(nodep)) { m_tgraph.didProcess(nodep); @@ -662,7 +662,7 @@ class TristateVisitor : public TristateBaseVisitor { AstConst* newconstp = new AstConst(fl, num1); AstConst* enp = new AstConst(fl, numz0); nodep->replaceWith(newconstp); - pushDeletep(nodep); nodep = NULL; + pushDeletep(nodep); VL_DANGLING(nodep); newconstp->user1p(enp); // propagate up constant with non-Z bits as 1 } } @@ -818,7 +818,7 @@ class TristateVisitor : public TristateBaseVisitor { nodep->replaceWith(expr2p); UINFO(9," bufif datap="<=9) newp->dumpTree(cout,"-caseeq-new: "); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } else { checkUnhandled(nodep); } @@ -1006,7 +1006,7 @@ class TristateVisitor : public TristateBaseVisitor { nodep->v3error("Unsupported pullup/down (weak driver) construct."); } nodep->unlinkFrBack(); - pushDeletep(nodep); nodep = NULL; // Node must persist as user3p points to it + pushDeletep(nodep); VL_DANGLING(nodep); // Node must persist as user3p points to it } } diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index df10f565b..a40631941 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -109,7 +109,7 @@ private: prep=prep->backp(); } FileLine* fl = nodep->fileline(); - nodep=NULL; // Zap it so we don't use it by mistake - use prep + VL_DANGLING(nodep); // Zap it so we don't use it by mistake - use prep // Already exists; rather than IF(a,... IF(b... optimize to IF(a&&b, // Saves us teaching V3Const how to optimize, and it won't be needed again. @@ -154,12 +154,12 @@ private: } virtual void visit(AstAssignDly* nodep, AstNUser*) { m_assigndlyp = nodep; - nodep->iterateChildren(*this); nodep=NULL; // May delete nodep. + nodep->iterateChildren(*this); VL_DANGLING(nodep); // May delete nodep. m_assigndlyp = NULL; } virtual void visit(AstAssignW* nodep, AstNUser*) { m_assignwp = nodep; - nodep->iterateChildren(*this); nodep=NULL; // May delete nodep. + nodep->iterateChildren(*this); VL_DANGLING(nodep); // May delete nodep. m_assignwp = NULL; } virtual void visit(AstCaseItem* nodep, AstNUser*) { @@ -179,7 +179,7 @@ private: V3Const::constifyEdit(nodep->rhsp()); // rhsp may change if (nodep->lhsp()->castConst() && nodep->rhsp()->castConst()) { // Both sides are constant, node can be constant - V3Const::constifyEdit(nodep); nodep=NULL; + V3Const::constifyEdit(nodep); VL_DANGLING(nodep); return; } else { AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); @@ -190,15 +190,15 @@ private: || (rhsp->castConst() && rhsp->castConst()->num().isFourState()))) { V3Number num (nodep->fileline(), 1, (nodep->castEqCase()?0:1)); newp = new AstConst (nodep->fileline(), num); - lhsp->deleteTree(); lhsp=NULL; - rhsp->deleteTree(); rhsp=NULL; + lhsp->deleteTree(); VL_DANGLING(lhsp); + rhsp->deleteTree(); VL_DANGLING(rhsp); } else { if (nodep->castEqCase()) newp = new AstEq (nodep->fileline(), lhsp, rhsp); else newp = new AstNeq (nodep->fileline(), lhsp, rhsp); } nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); // Iterate tree now that we may have gotten rid of Xs newp->iterateChildren(*this); } @@ -209,7 +209,7 @@ private: V3Const::constifyEdit(nodep->rhsp()); // rhsp may change if (nodep->lhsp()->castConst() && nodep->rhsp()->castConst()) { // Both sides are constant, node can be constant - V3Const::constifyEdit(nodep); nodep=NULL; + V3Const::constifyEdit(nodep); VL_DANGLING(nodep); return; } else { AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); @@ -231,10 +231,10 @@ private: if (nodep->castEqWild()) newp = new AstEq (nodep->fileline(), and1p, and2p); else newp = new AstNeq (nodep->fileline(), and1p, and2p); - rhsp->deleteTree(); rhsp=NULL; + rhsp->deleteTree(); VL_DANGLING(rhsp); } nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); // Iterate tree now that we may have gotten rid of the compare newp->iterateChildren(*this); } @@ -259,7 +259,7 @@ private: V3Number zero (nodep->fileline(), 1, 0); AstConst* newp = new AstConst (nodep->fileline(), zero); nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } virtual void visit(AstConst* nodep, AstNUser*) { if (m_constXCvt @@ -283,7 +283,7 @@ private: } AstConst* newp = new AstConst(nodep->fileline(), numnew); nodep->replaceWith(newp); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); UINFO(4," -> "<=9) newref1p->dumpTree(cout," _new: "); if (debug()>=9) newvarp->dumpTree(cout," _new: "); if (debug()>=9) newinitp->dumpTree(cout," _new: "); - nodep->deleteTree(); nodep=NULL; + nodep->deleteTree(); VL_DANGLING(nodep); } } } diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index 306394338..915c74799 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -232,7 +232,7 @@ private: forUnroller(nodep, initp, precondsp, incp, bodysp, constInitp->num(), cmpInstrp, constStopp->num(), cmpVarLhs, - incInstrp, constIncp->num()); nodep = NULL; + incInstrp, constIncp->num()); VL_DANGLING(nodep); // Cleanup return true; } @@ -301,7 +301,7 @@ private: m_varModeReplace = true; tempp->stmtsp()->iterateAndNext(*this); m_varModeReplace = false; - oneloopp = tempp->stmtsp()->unlinkFrBackWithNext(); tempp->deleteTree(); tempp=NULL; + oneloopp = tempp->stmtsp()->unlinkFrBackWithNext(); tempp->deleteTree(); VL_DANGLING(tempp); } if (m_generate) { string index = AstNode::encodeNumber(m_varValuep->toSInt()); @@ -330,10 +330,10 @@ private: // Replace the FOR() if (newbodysp) nodep->replaceWith(newbodysp); else nodep->unlinkFrBack(); - if (bodysp) { pushDeletep(bodysp); bodysp=NULL; } - if (precondsp) { pushDeletep(precondsp); precondsp=NULL; } - if (initp) { pushDeletep(initp); initp=NULL; } - if (incp && !incp->backp()) { pushDeletep(incp); incp=NULL; } + if (bodysp) { pushDeletep(bodysp); VL_DANGLING(bodysp); } + if (precondsp) { pushDeletep(precondsp); VL_DANGLING(precondsp); } + if (initp) { pushDeletep(initp); VL_DANGLING(initp); } + if (incp && !incp->backp()) { pushDeletep(incp); VL_DANGLING(incp); } if (debug()>=9) newbodysp->dumpTree(cout,"- _new: "); } @@ -347,7 +347,7 @@ private: // Grab initial value AstNode* initp = NULL; // Should be statement before the while. if (nodep->backp()->nextp() == nodep) initp=nodep->backp(); - if (initp) { V3Const::constifyEdit(initp); initp=NULL; } + if (initp) { V3Const::constifyEdit(initp); VL_DANGLING(initp); } if (nodep->backp()->nextp() == nodep) initp=nodep->backp(); // Grab assignment AstNode* incp = NULL; // Should be last statement @@ -355,14 +355,14 @@ private: if (nodep->incsp()) incp = nodep->incsp(); else { for (incp = nodep->bodysp(); incp && incp->nextp(); incp = incp->nextp()) {} - if (incp) { V3Const::constifyEdit(incp); incp=NULL; } + if (incp) { V3Const::constifyEdit(incp); VL_DANGLING(incp); } for (incp = nodep->bodysp(); incp && incp->nextp(); incp = incp->nextp()) {} // Again, as may have changed } // And check it if (forUnrollCheck(nodep, initp, nodep->precondsp(), nodep->condp(), incp, nodep->bodysp())) { - pushDeletep(nodep); nodep=NULL; // Did replacement + pushDeletep(nodep); VL_DANGLING(nodep); // Did replacement } } } @@ -384,11 +384,11 @@ private: // we'd need to initialize the variable to the initial // condition, but they'll become while's which can be // deleted by V3Const. - nodep->unlinkFrBack()->deleteTree(); nodep=NULL; + nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); } else if (forUnrollCheck(nodep, nodep->initsp(), NULL, nodep->condp(), nodep->incsp(), nodep->bodysp())) { - pushDeletep(nodep); nodep=NULL; // Did replacement + pushDeletep(nodep); VL_DANGLING(nodep); // Did replacement } else { nodep->v3error("For loop doesn't have genvar index, or is malformed"); } diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 909b27291..6e71180df 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -367,14 +367,14 @@ private: if (AstReplicate* repp=nodep->lhsp()->castReplicate()) { if (repp->width()==0) { // Keep rhs nodep->replaceWith(nodep->rhsp()->unlinkFrBack()); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return; } } if (AstReplicate* repp=nodep->rhsp()->castReplicate()) { if (repp->width()==0) { // Keep lhs nodep->replaceWith(nodep->lhsp()->unlinkFrBack()); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return; } } @@ -383,7 +383,7 @@ private: AstNode* newp = new AstConcatN (nodep->fileline(),nodep->lhsp()->unlinkFrBack(), nodep->rhsp()->unlinkFrBack()); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return; } } @@ -427,7 +427,7 @@ private: AstNode* newp = new AstReplicateN(nodep->fileline(),nodep->lhsp()->unlinkFrBack(), nodep->rhsp()->unlinkFrBack()); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return; } else { nodep->dtypeSetLogicSized((nodep->lhsp()->width() * times), @@ -765,7 +765,7 @@ private: if (nodep->lhsp()->isDouble() || nodep->rhsp()->isDouble()) { spliceCvtD(nodep->lhsp()); spliceCvtD(nodep->rhsp()); - replaceWithDVersion(nodep); nodep=NULL; + replaceWithDVersion(nodep); VL_DANGLING(nodep); return; } @@ -795,7 +795,7 @@ private: newp->dtypeFrom(nodep); UINFO(9,"powOld "<replaceWith(newp); nodep=NULL; + nodep->replaceWith(newp); VL_DANGLING(nodep); } } } @@ -844,7 +844,7 @@ private: pair dim = nodep->fromp()->dtypep()->dimensions(true); int val = (nodep->attrType()==AstAttrType::DIM_UNPK_DIMENSIONS ? dim.second : (dim.first+dim.second)); - nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::Signed32(), val)); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::Signed32(), val)); nodep->deleteTree(); VL_DANGLING(nodep); break; } case AstAttrType::DIM_BITS: @@ -860,7 +860,7 @@ private: if (!nodep->dimp() || nodep->dimp()->castConst() || msbdim<1) { int dim = !nodep->dimp() ? 1 : nodep->dimp()->castConst()->toSInt(); AstConst* newp = dimensionValue(nodep->fromp()->dtypep(), nodep->attrType(), dim); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } else { // Need a runtime lookup table. Yuk. if (!nodep->fromp() || !nodep->fromp()->dtypep()) nodep->v3fatalSrc("Unsized expression"); @@ -869,7 +869,7 @@ private: AstVarRef* varrefp = new AstVarRef(nodep->fileline(), varp, false); varrefp->packagep(v3Global.rootp()->dollarUnitPkgAddp()); AstNode* newp = new AstArraySel(nodep->fileline(), varrefp, dimp); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } break; } @@ -961,7 +961,7 @@ private: constp->unlinkFrBack(); AstNode* newp = new AstCastSize(nodep->fileline(), nodep->lhsp()->unlinkFrBack(), constp); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); newp->accept(*this,vup); } else { nodep->v3error("Unsupported: Cast to "<dtp()->prettyTypeName()); @@ -1004,7 +1004,7 @@ private: //newp = newp; // Can just remove cast } nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); //if (debug()) newp->dumpTree(cout," CastOut: "); } virtual void visit(AstCastSize* nodep, AstNUser* vup) { @@ -1049,7 +1049,7 @@ private: // CastSize not needed once sizes determined AstNode* underp = nodep->lhsp()->unlinkFrBack(); nodep->replaceWith(underp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } //if (debug()) nodep->dumpTree(cout," CastSizeOut: "); } @@ -1093,7 +1093,7 @@ private: // we want the init numbers to retain their width/minwidth until parameters are replaced. // This prevents width warnings at the location the parameter is substituted in if (nodep->valuep()->isDouble()) { - nodep->dtypeSetDouble(); bdtypep=NULL; + nodep->dtypeSetDouble(); VL_DANGLING(bdtypep); } else { int width=0; AstBasicDType* valueBdtypep = nodep->valuep()->dtypep()->basicp(); @@ -1128,11 +1128,11 @@ private: //UINFO below will print variable nodep } else { // Or, if nothing assigned, they're integral - nodep->dtypeSetSigned32(); bdtypep=NULL; + nodep->dtypeSetSigned32(); VL_DANGLING(bdtypep); } } else if (bdtypep && bdtypep->implicit()) { // Implicits get converted to size 1 - nodep->dtypeSetLogicSized(1,1,bdtypep->numeric()); bdtypep=NULL; + nodep->dtypeSetLogicSized(1,1,bdtypep->numeric()); VL_DANGLING(bdtypep); } if (nodep->valuep() && !didchk) { //if (debug()) nodep->dumpTree(cout," final: "); @@ -1236,7 +1236,7 @@ private: if (enump->castEnumDType()) break; } if (!enump) nodep->v3fatalSrc("EnumItemRef can't deref back to an Enum"); - enump->iterate(*this,vup); enump=NULL; // parent's connection to enump may be relinked + enump->iterate(*this,vup); VL_DANGLING(enump); // parent's connection to enump may be relinked } nodep->dtypeFrom(nodep->itemp()); } @@ -1257,7 +1257,7 @@ private: nodep->exprp()->iterateAndNext(*this,WidthVP(CONTEXT,PRELIM).p()); for (AstNode* nextip, *itemp = nodep->itemsp(); itemp; itemp=nextip) { nextip = itemp->nextp(); // Prelim may cause the node to get replaced - itemp->iterate(*this,WidthVP(CONTEXT,PRELIM).p()); itemp=NULL; + itemp->iterate(*this,WidthVP(CONTEXT,PRELIM).p()); VL_DANGLING(itemp); } // Take width as maximum across all items int width = nodep->exprp()->width(); @@ -1298,7 +1298,7 @@ private: } if (!newp) newp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); if (debug()>=9) newp->dumpTree(cout,"-inside-out: "); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } virtual void visit(AstInsideRange* nodep, AstNUser* vup) { // Just do each side; AstInside will rip these nodes out later @@ -1373,7 +1373,7 @@ private: // Convert this into a method call, and let that visitor figure out what to do next AstNode* newp = new AstMethodSel(nodep->fileline(), nodep->fromp()->unlinkFrBack(), nodep->name(), NULL); nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); newp->accept(*this,vup); return; } @@ -1394,13 +1394,13 @@ private: UINFO(9," MEMBERSEL -> "< "<dtypep()<replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); // Should be able to treat it as a normal-ish nodesel - maybe. The lhsp() will be strange until this stage; create the number here? } } if (!memberp) { // Very bogus, but avoids core dump nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::LogicFalse())); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } } @@ -1443,7 +1443,7 @@ private: if (!newp) nodep->v3fatalSrc("Enum method (perhaps enum item) not const"); newp->fileline(nodep->fileline()); // Use method's filename/line number to be clearer; may have warning disables nodep->replaceWith(newp); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } else if (nodep->name() == "name" || nodep->name() == "next" @@ -1481,7 +1481,7 @@ private: AstVarRef* varrefp = new AstVarRef(nodep->fileline(), varp, false); varrefp->packagep(v3Global.rootp()->dollarUnitPkgAddp()); AstNode* newp = new AstArraySel(nodep->fileline(), varrefp, nodep->fromp()->unlinkFrBack()); - nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL; + nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep); } else { nodep->v3error("Unknown built-in enum method '"<fromp()->prettyTypeName()<<"'"); } @@ -1605,7 +1605,7 @@ private: if (valuep->castConst()) { // Forming a AstConcat will cause problems with unsized (uncommitted sized) constants if (AstNode* newp = WidthCommitVisitor::newIfConstCommitSize(valuep->castConst())) { - pushDeletep(valuep); valuep=NULL; + pushDeletep(valuep); VL_DANGLING(valuep); valuep = newp; } } @@ -1618,11 +1618,11 @@ private: nodep->dtypep()->numeric()); } } - if (newpatp) { pushDeletep(newpatp); newpatp=NULL; } + if (newpatp) { pushDeletep(newpatp); VL_DANGLING(newpatp); } } if (newp) nodep->replaceWith(newp); else nodep->v3error("Assignment pattern with no members"); - pushDeletep(nodep); nodep = NULL; // Deletes defaultp also, if present + pushDeletep(nodep); VL_DANGLING(nodep); // Deletes defaultp also, if present } else if (vdtypep->castNodeArrayDType()) { AstNodeArrayDType* arrayp = vdtypep->castNodeArrayDType(); @@ -1659,7 +1659,7 @@ private: if (valuep->castConst()) { // Forming a AstConcat will cause problems with unsized (uncommitted sized) constants if (AstNode* newp = WidthCommitVisitor::newIfConstCommitSize(valuep->castConst())) { - pushDeletep(valuep); valuep=NULL; + pushDeletep(valuep); VL_DANGLING(valuep); valuep = newp; } } @@ -1682,13 +1682,13 @@ private: } } } - if (newpatp) { pushDeletep(newpatp); newpatp=NULL; } + if (newpatp) { pushDeletep(newpatp); VL_DANGLING(newpatp); } } if (!patmap.empty()) nodep->v3error("Assignment pattern with too many elements"); if (newp) nodep->replaceWith(newp); else nodep->v3error("Assignment pattern with no members"); //if (debug()>=9) newp->dumpTree("-apat-out: "); - pushDeletep(nodep); nodep = NULL; // Deletes defaultp also, if present + pushDeletep(nodep); VL_DANGLING(nodep); // Deletes defaultp also, if present } else if (vdtypep->castBasicDType() && vdtypep->castBasicDType()->isRanged()) { @@ -1725,7 +1725,7 @@ private: if (valuep->castConst()) { // Forming a AstConcat will cause problems with unsized (uncommitted sized) constants if (AstNode* newp = WidthCommitVisitor::newIfConstCommitSize(valuep->castConst())) { - pushDeletep(valuep); valuep=NULL; + pushDeletep(valuep); VL_DANGLING(valuep); valuep = newp; } } @@ -1740,13 +1740,13 @@ private: } } } - if (newpatp) { pushDeletep(newpatp); newpatp=NULL; } + if (newpatp) { pushDeletep(newpatp); VL_DANGLING(newpatp); } } if (!patmap.empty()) nodep->v3error("Assignment pattern with too many elements"); if (newp) nodep->replaceWith(newp); else nodep->v3error("Assignment pattern with no members"); //if (debug()>=9) newp->dumpTree("-apat-out: "); - pushDeletep(nodep); nodep = NULL; // Deletes defaultp also, if present + pushDeletep(nodep); VL_DANGLING(nodep); // Deletes defaultp also, if present } else { nodep->v3error("Unsupported: Assignment pattern applies against non struct/union: "<prettyTypeName()); } @@ -1801,7 +1801,7 @@ private: if (!nodep->castGenCase()) itemp->bodysp()->iterateAndNext(*this); for (AstNode* nextcp, *condp = itemp->condsp(); condp; condp=nextcp) { nextcp = condp->nextp(); // Prelim may cause the node to get replaced - condp->iterate(*this,WidthVP(CONTEXT,PRELIM).p()); condp=NULL; + condp->iterate(*this,WidthVP(CONTEXT,PRELIM).p()); VL_DANGLING(condp); } } @@ -2145,7 +2145,7 @@ private: nodep->exprp()->iterateAndNext(*this,vup); nodep->replaceWith(nodep->exprp()->unlinkFrBack()); } - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } } virtual void visit(AstNodeFTask* nodep, AstNUser* vup) { @@ -2227,7 +2227,7 @@ private: string format; if (pinp->castConst()) format = pinp->castConst()->num().toString(); else pinp->v3error("Format to $display-like function must have constant format string"); - pushDeletep(argp); argp=NULL; + pushDeletep(argp); VL_DANGLING(argp); AstSFormatF* newp = new AstSFormatF(nodep->fileline(), format, false, argsp); if (!newp->scopeNamep() && newp->formatScopeTracking()) { newp->scopeNamep(new AstScopeName(newp->fileline())); @@ -2248,11 +2248,11 @@ private: pinp = newp; } // AstPattern requires assignments to pass datatype on PRELIM - pinp->accept(*this,WidthVP(portp->dtypep(),PRELIM).p()); pinp=NULL; + pinp->accept(*this,WidthVP(portp->dtypep(),PRELIM).p()); VL_DANGLING(pinp); } else if (accept_mode==1) { // Change data types based on above accept completion if (portp->isDouble()) { - spliceCvtD(pinp); pinp=NULL; + spliceCvtD(pinp); VL_DANGLING(pinp); } } else if (accept_mode==2) { // Do PRELIM again, because above accept may have exited early due to node replacement @@ -2417,20 +2417,20 @@ private: nodep->rhsp()->iterateAndNext(*this,WidthVP(CONTEXT,PRELIM).p()); if (nodep->lhsp()->isDouble() || nodep->rhsp()->isDouble()) { if (!realok) nodep->v3error("Real not allowed as operand to in ?== operator"); - if (AstNodeBiop* newp=replaceWithDVersion(nodep)) { nodep=NULL; + if (AstNodeBiop* newp=replaceWithDVersion(nodep)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead iterateCheckReal(nodep,"LHS",nodep->lhsp(),FINAL); iterateCheckReal(nodep,"RHS",nodep->rhsp(),FINAL); } } else if (nodep->lhsp()->isString() || nodep->rhsp()->isString()) { - if (AstNodeBiop* newp=replaceWithNVersion(nodep)) { nodep=NULL; + if (AstNodeBiop* newp=replaceWithNVersion(nodep)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead iterateCheckString(nodep,"LHS",nodep->lhsp(),FINAL); iterateCheckString(nodep,"RHS",nodep->rhsp(),FINAL); } } else { bool signedFl = nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned(); - if (AstNodeBiop* newp=replaceWithUOrSVersion(nodep, signedFl)) { nodep=NULL; + if (AstNodeBiop* newp=replaceWithUOrSVersion(nodep, signedFl)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead } int width = max(nodep->lhsp()->width(), nodep->rhsp()->width()); @@ -2484,7 +2484,7 @@ private: } if (real_ok && nodep->lhsp()->isDouble()) { spliceCvtD(nodep->lhsp()); - if (AstNodeUniop* newp=replaceWithDVersion(nodep)) { nodep=NULL; + if (AstNodeUniop* newp=replaceWithDVersion(nodep)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead iterateCheckReal(nodep,"LHS",nodep->lhsp(),BOTH); nodep->dtypeSetDouble(); @@ -2533,7 +2533,7 @@ private: // RHS is self-determined. RHS is always treated as unsigned, has no effect on result. iterate_shift_prelim(nodep,vup); nodep->dtypeChgSigned(nodep->lhsp()->isSigned()); - AstNodeBiop* newp = iterate_shift_final(nodep,vup); nodep=NULL; + AstNodeBiop* newp = iterate_shift_final(nodep,vup); VL_DANGLING(nodep); if (newp) {} // Ununused } void iterate_shift_prelim(AstNodeBiop* nodep, AstNUser* vup) { @@ -2555,7 +2555,7 @@ private: nodep->dtypeFrom(expDTypep); // ShiftRS converts to ShiftR, but not vice-versa if (nodep->castShiftRS()) { - if (AstNodeBiop* newp=replaceWithUOrSVersion(nodep, nodep->isSigned())) { nodep=NULL; + if (AstNodeBiop* newp=replaceWithUOrSVersion(nodep, nodep->isSigned())) { VL_DANGLING(nodep); nodep = newp; // Process new node instead } } @@ -2570,7 +2570,7 @@ private: V3Number num (shiftp->fileline(), 32, 0); num.opAssign(shiftp->num()); AstNode* shiftp = nodep->rhsp(); nodep->rhsp()->replaceWith(new AstConst(shiftp->fileline(), num)); - shiftp->deleteTree(); shiftp=NULL; + shiftp->deleteTree(); VL_DANGLING(shiftp); } else { nodep->rhsp()->v3error("Unsupported: Shifting of by over 32-bit number isn't supported." <<" (This isn't a shift of 32 bits, but a shift of 2^32, or 4 billion!)\n"); @@ -2635,7 +2635,7 @@ private: if (nodep->lhsp()->isDouble() || nodep->rhsp()->isDouble()) { spliceCvtD(nodep->lhsp()); spliceCvtD(nodep->rhsp()); - if (AstNodeBiop* newp=replaceWithDVersion(nodep)) { nodep=NULL; + if (AstNodeBiop* newp=replaceWithDVersion(nodep)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead } nodep->dtypeSetDouble(); @@ -2654,7 +2654,7 @@ private: AstNodeDType* expDTypep = vup->c()->dtypeOverridep(nodep->dtypep()); AstNodeDType* subDTypep = expDTypep; nodep->dtypeFrom(expDTypep); - if (AstNodeBiop* newp=replaceWithUOrSVersion(nodep, expDTypep->isSigned())) { nodep=NULL; + if (AstNodeBiop* newp=replaceWithUOrSVersion(nodep, expDTypep->isSigned())) { VL_DANGLING(nodep); nodep = newp; // Process new node instead } // Some warning suppressions @@ -2728,7 +2728,7 @@ private: num.isSigned(expDTypep->isSigned()); AstNode* newp = new AstConst(nodep->fileline(), num); constp->replaceWith(newp); - pushDeletep(constp); constp=NULL; nodep=NULL; + pushDeletep(constp); VL_DANGLING(constp); VL_DANGLING(nodep); nodep=newp; } else if (expWidthwidth()) { // Trunc - Extract @@ -2780,7 +2780,7 @@ private: num.isSigned(expSigned); AstNode* newp = new AstConst(nodep->fileline(), num); constp->replaceWith(newp); - constp->deleteTree(); constp=NULL; nodep=NULL; + constp->deleteTree(); VL_DANGLING(constp); VL_DANGLING(nodep); nodep=newp; } else { AstNRelinker linker; @@ -2805,7 +2805,7 @@ private: if (debug()>4) constp->dumpTree(cout," fixAutoExtend_old: "); if (debug()>4) newp->dumpTree(cout," _new: "); constp->replaceWith(newp); - constp->deleteTree(); constp=NULL; + constp->deleteTree(); VL_DANGLING(constp); // Tell caller the new constp, and that we changed it. nodepr = newp; return true; @@ -2895,7 +2895,7 @@ private: nodep->v3error("Logical Operator "<prettyTypeName() <<" expects a non-complex data type on the "<replaceWith(new AstConst(nodep->fileline(), AstConst::LogicFalse())); - pushDeletep(underp); underp=NULL; + pushDeletep(underp); VL_DANGLING(underp); } else { bool bad = widthBad(underp,nodep->findLogicBoolDType()); if (bad) { @@ -2909,7 +2909,7 @@ private: ?" or "+cvtToStr(underp->widthMin()):"") <<" bits."); } - fixWidthReduce(underp); underp=NULL;//Changed + fixWidthReduce(underp); VL_DANGLING(underp);//Changed } } } @@ -3034,7 +3034,7 @@ private: } else if (pinp && !pinp->modVarp()->isInput()) { // V3Inst::pinReconnectSimple must deal UINFO(5,"pinInSizeMismatch: "<replaceWith(newp); newp->dtypeFrom(nodep); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return newp; } AstNodeBiop* replaceWithDVersion(AstNodeBiop* nodep) { @@ -3173,7 +3173,7 @@ private: UINFO(6," ReplaceWithDVersion: "<replaceWith(newp); // No width change; the default created type (bool or double) is correct - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return newp; } AstNodeBiop* replaceWithNVersion(AstNodeBiop* nodep) { @@ -3201,7 +3201,7 @@ private: UINFO(6," ReplaceWithNVersion: "<replaceWith(newp); // No width change; the default created type (bool or string) is correct - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return newp; } AstNodeUniop* replaceWithDVersion(AstNodeUniop* nodep) { @@ -3222,7 +3222,7 @@ private: UINFO(6," ReplaceWithDVersion: "<replaceWith(newp); newp->dtypeFrom(nodep); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); return newp; } @@ -3470,7 +3470,7 @@ private: if (!nodep->castConst()) { nodep->v3error(message); nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::Unsized32(), 1)); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } } diff --git a/src/V3WidthCommit.h b/src/V3WidthCommit.h index 1b49c1b3c..b7c73e83b 100644 --- a/src/V3WidthCommit.h +++ b/src/V3WidthCommit.h @@ -37,10 +37,10 @@ class WidthRemoveVisitor : public AstNVisitor { private: // VISITORS virtual void visit(AstSigned* nodep, AstNUser*) { - replaceWithSignedVersion(nodep, nodep->lhsp()->unlinkFrBack()); nodep=NULL; + replaceWithSignedVersion(nodep, nodep->lhsp()->unlinkFrBack()); VL_DANGLING(nodep); } virtual void visit(AstUnsigned* nodep, AstNUser*) { - replaceWithSignedVersion(nodep, nodep->lhsp()->unlinkFrBack()); nodep=NULL; + replaceWithSignedVersion(nodep, nodep->lhsp()->unlinkFrBack()); VL_DANGLING(nodep); } virtual void visit(AstNode* nodep, AstNUser*) { nodep->iterateChildren(*this); @@ -49,7 +49,7 @@ private: UINFO(6," Replace "<replaceWith(newp); newp->dtypeFrom(nodep); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } public: // CONSTRUCTORS @@ -119,7 +119,7 @@ private: AstNode* oldp = nodep; nodep = newp; //if (debug()>4) oldp->dumpTree(cout," fixConstSize_old: "); //if (debug()>4) newp->dumpTree(cout," _new: "); - pushDeletep(oldp); oldp=NULL; + pushDeletep(oldp); VL_DANGLING(oldp); } editDType(nodep); } diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 1173671a4..e0a263aae 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -65,7 +65,7 @@ private: if (!nodep->castConst()) { nodep->v3error(message); nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::Unsized32(), 1)); - pushDeletep(nodep); nodep=NULL; + pushDeletep(nodep); VL_DANGLING(nodep); } } @@ -217,7 +217,7 @@ private: fromp, subp); newp->dtypeFrom(adtypep->subDTypep()); // Need to strip off array reference if (debug()>=9) newp->dumpTree(cout,"--SELBTn: "); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else if (AstPackArrayDType* adtypep = ddtypep->castPackArrayDType()) { // SELBIT(array, index) -> SEL(array, index*width-of-subindex, width-of-subindex) @@ -239,7 +239,7 @@ private: newp->declElWidth(elwidth); newp->dtypeFrom(adtypep->subDTypep()); // Need to strip off array reference if (debug()>=9) newp->dumpTree(cout,"--SELBTn: "); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else if (ddtypep->castBasicDType()) { // SELBIT(range, index) -> SEL(array, index, 1) @@ -251,7 +251,7 @@ private: newp->declRange(fromRange); UINFO(6," new "<=9) newp->dumpTree(cout,"--SELBTn: "); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else if (ddtypep->castNodeClassDType()) { // It's packed, so a bit from the packed struct // SELBIT(range, index) -> SEL(array, index, 1) @@ -263,15 +263,15 @@ private: newp->declRange(fromRange); UINFO(6," new "<=9) newp->dumpTree(cout,"--SELBTn: "); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else { // NULL=bad extract, or unknown node type nodep->v3error("Illegal bit or array select; type already selected, or bad dimension: type is" <prettyName()); // How to recover? We'll strip a dimension. - nodep->replaceWith(fromp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(fromp); pushDeletep(nodep); VL_DANGLING(nodep); } - if (!rhsp->backp()) pushDeletep(rhsp); rhsp=NULL; + if (!rhsp->backp()) { pushDeletep(rhsp); VL_DANGLING(rhsp); } } virtual void visit(AstSelExtract* nodep, AstNUser*) { // Select of a range specified part of an array, i.e. "array[2:3]" @@ -297,13 +297,13 @@ private: // Slice extraction if (fromRange.elements() == (msb-lsb+1) && fromRange.lo() == lsb) { // Extracting whole of original array - nodep->replaceWith(fromp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(fromp); pushDeletep(nodep); VL_DANGLING(nodep); } else { // TODO when unpacked arrays fully supported probably need new data type here AstArraySel* newp = new AstArraySel (nodep->fileline(), fromp, lsbp); newp->start(lsb); newp->length((msb - lsb) + 1); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } } else if (AstPackArrayDType* adtypep = ddtypep->castPackArrayDType()) { @@ -321,7 +321,7 @@ private: newp->dtypeFrom(sliceDType(adtypep, msb, lsb)); //if (debug()>=9) newp->dumpTree(cout,"--EXTBTn: "); if (newp->widthMin()!=(int)newp->widthConst()) nodep->v3fatalSrc("Width mismatch"); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else if (ddtypep->castBasicDType()) { if (fromRange.littleEndian()) { @@ -341,7 +341,7 @@ private: newp->declRange(fromRange); UINFO(6," new "<=9) newp->dumpTree(cout,"--SELEXnew: "); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else if (ddtypep->castNodeClassDType()) { // Classes aren't little endian @@ -358,19 +358,19 @@ private: newp->declRange(fromRange); UINFO(6," new "<=9) newp->dumpTree(cout,"--SELEXnew: "); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else { // NULL=bad extract, or unknown node type nodep->v3error("Illegal range select; type already selected, or bad dimension: type is " <prettyName()); UINFO(1," Related ddtype: "<replaceWith(fromp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(fromp); pushDeletep(nodep); VL_DANGLING(nodep); } // delete whataver we didn't use in reconstruction - if (!fromp->backp()) pushDeletep(fromp); fromp=NULL; - if (!msbp->backp()) pushDeletep(msbp); msbp=NULL; - if (!lsbp->backp()) pushDeletep(lsbp); lsbp=NULL; + if (!fromp->backp()) { pushDeletep(fromp); VL_DANGLING(fromp); } + if (!msbp->backp()) { pushDeletep(msbp); VL_DANGLING(msbp); } + if (!lsbp->backp()) { pushDeletep(lsbp); VL_DANGLING(lsbp); } } void replaceSelPlusMinus(AstNodePreSel* nodep) { @@ -430,18 +430,18 @@ private: newp->declElWidth(elwidth); UINFO(6," new "<=9) newp->dumpTree(cout,"--SELNEW: "); - nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } else { // NULL=bad extract, or unknown node type nodep->v3error("Illegal +: or -: select; type already selected, or bad dimension: type is " <prettyTypeName()); // How to recover? We'll strip a dimension. - nodep->replaceWith(fromp); pushDeletep(nodep); nodep=NULL; + nodep->replaceWith(fromp); pushDeletep(nodep); VL_DANGLING(nodep); } // delete whataver we didn't use in reconstruction - if (!fromp->backp()) pushDeletep(fromp); fromp=NULL; - if (!rhsp->backp()) pushDeletep(rhsp); rhsp=NULL; - if (!widthp->backp()) pushDeletep(widthp); widthp=NULL; + if (!fromp->backp()) { pushDeletep(fromp); VL_DANGLING(fromp); } + if (!rhsp->backp()) { pushDeletep(rhsp); VL_DANGLING(rhsp); } + if (!widthp->backp()) { pushDeletep(widthp); VL_DANGLING(widthp); } } virtual void visit(AstSelPlus* nodep, AstNUser*) { replaceSelPlusMinus(nodep); diff --git a/src/astgen b/src/astgen index f79582cb8..20b00f36b 100755 --- a/src/astgen +++ b/src/astgen @@ -527,7 +527,7 @@ sub treeop_exec_func { $out .= "AstNode* newp = " . _exec_new_recurse($aref).";\n"; $out .= "nodep->replaceWith(newp);"; - $out .= "nodep->deleteTree(); nodep=NULL;"; + $out .= "nodep->deleteTree(); VL_DANGLING(nodep);"; #print "FF $out\n" if $Debug; } elsif ($func eq "NEVER") { $out .= "nodep->v3fatalSrc(\"Executing transform that was NEVERed\");"; diff --git a/src/cppcheck_filtered b/src/cppcheck_filtered index 29a86bf83..05d0f9f4a 100755 --- a/src/cppcheck_filtered +++ b/src/cppcheck_filtered @@ -112,24 +112,20 @@ sub _suppress { while (defined(my $line = $fh->getline())) { ++$l; if ($l+1 == $linenum) { - if ($line =~ /cppcheck-suppress\s+(\S+)/) { - my $supid = $1; - if ($supid eq $id) { - return 1; - } else { - warn "%Warning: $filename: $l: Found suppress for id='$supid', not expected id='$id'\n"; + if ($line =~ /cppcheck-suppress((\s+\S+)+)/) { + my $supids = $1; + foreach my $supid (split /\s+/, $supids) { + if ($supid eq $id) { + return 1; + } } + warn "%Warning: $filename: $l: Found suppress for ids='$supids', not expected id='$id'\n"; } } if ($l == $linenum) { - if ($id eq "uselessAssignmentPtrArg" - && $line =~ /(delete|Delete|Edit).*p *= *NULL;/) { - # delete(nodep); nodep=NULL; # This is ok, it's how we prevent later using nodep - return 1; - } - if (($id eq "uselessAssignment" - || $id eq "uselessAssignmentPtrArg") - && $line =~ /;.*p *= *NULL;/) { + if (0 && # We now use VL_DANGLING instead of this rule + $id eq "uselessAssignmentPtrArg" + && $line =~ /(delete|Delete|Edit).*p *= *(NULL|nullptr);/) { # delete(nodep); nodep=NULL; # This is ok, it's how we prevent later using nodep return 1; } diff --git a/src/verilog.y b/src/verilog.y index 0cea2b9ca..8f8feaf60 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -150,7 +150,7 @@ public: // It's no longer implicit but a real logic type AstBasicDType* newp = new AstBasicDType(dtypep->fileline(), AstBasicDTypeKwd::LOGIC, dtypep->numeric(), dtypep->width(), dtypep->widthMin()); - dtypep->deleteTree(); dtypep=NULL; + dtypep->deleteTree(); VL_DANGLING(dtypep); dtypep = newp; } dtypep->rangep(finalp); @@ -1816,7 +1816,7 @@ loop_generate_construct: // ==IEEE: loop_generate_construct // for loop won't get an extra layer of hierarchy tacked on blkp->addGenforp(new AstGenFor($1,initp,$5,$7,lowerNoBegp)); $$ = blkp; - lowerBegp->deleteTree(); lowerBegp=NULL; + lowerBegp->deleteTree(); VL_DANGLING(lowerBegp); } ; @@ -3736,7 +3736,7 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, string name, AstRange } AstVarType type = GRAMMARP->m_varIO; if (dtypep->castIfaceRefDType()) { - if (arrayp) { fileline->v3error("Unsupported: Arrayed interfaces"); arrayp=NULL; } + if (arrayp) { fileline->v3error("Unsupported: Arrayed interfaces"); VL_DANGLING(arrayp); } } if (!dtypep) { // Created implicitly dtypep = new AstBasicDType(fileline, LOGIC_IMPLICIT);