diff --git a/src/V3AssertNfa.cpp b/src/V3AssertNfa.cpp index 5d99415e5..fbc9c02da 100644 --- a/src/V3AssertNfa.cpp +++ b/src/V3AssertNfa.cpp @@ -1839,7 +1839,7 @@ class SvaNfaLowering final { }; UASSERT_OBJ(size > 0, idxExprp, "Ring size must be positive"); if (size == 1) { - idxExprp->deleteTree(); + VL_DO_DANGLING(idxExprp->deleteTree(), idxExprp); return u32Const(0); } // idx == size - 1 ? 0 : idx + 1 diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index 2b40ca537..544f60201 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -1549,7 +1549,7 @@ private: "Unsupported: $sampled inside disabled condition of a sequence"); m_disablep = new AstConst{m_disablep->fileline(), AstConst::BitFalse{}}; // always a copy is used, so remove it now - pushDeletep(m_disablep); + pushDeletep(m_disablep); // m_disablep used later } FileLine* const flp = nodep->fileline(); // Add counter which counts times the condition turned true @@ -1587,7 +1587,7 @@ private: = new AstIf{flp, new AstEq{flp, new AstVarRef{flp, initialCntp, VAccess::READ}, readCntRefp->cloneTree(false)}}; // Delete it, because it is always copied before insetion to the AST - pushDeletep(m_disableSeqIfp); + pushDeletep(m_disableSeqIfp); // m_disableSeqIfp used later } iterateChildren(nodep); } diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index 39777fe6c..10a9f2874 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -97,7 +97,7 @@ class ClockVisitor final : public VNVisitor { VL_DO_DANGLING(nodep->deleteTree(), nodep); } void visit(AstSenTree* nodep) override { - pushDeletep(nodep->unlinkFrBack()); // No longer needed + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); // No longer needed } //========== Move sampled assignments diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 32b44e9a8..2da9de2e2 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -1053,7 +1053,7 @@ class CoverageVisitor final : public VNVisitor { unrolledp = new T_Oper{fl, selp, unrolledp}; } iterate(unrolledp); - pushDeletep(unrolledp); + VL_DO_DANGLING(pushDeletep(unrolledp), unrolledp); } else { iterateChildren(nodep); lineTrack(nodep); diff --git a/src/V3Covergroup.cpp b/src/V3Covergroup.cpp index 95f51c0c2..aebfd1bd4 100644 --- a/src/V3Covergroup.cpp +++ b/src/V3Covergroup.cpp @@ -3011,7 +3011,7 @@ class FunctionalCoverageVisitor final : public VNVisitor { bindp->add(" = &"); bindp->add(rhsp->unlinkFrBack()); assignp->replaceWith(bindp->makeStmt()); - pushDeletep(assignp); + VL_DO_DANGLING(pushDeletep(assignp), assignp); ++rewrittenBindings; } } diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 29f459343..a268e3ccb 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -820,7 +820,7 @@ class DelayedVisitor final : public VNVisitor { m_prevVscp = vscp; // Delete original NBA - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } // Scheme::FlagUnique @@ -870,7 +870,7 @@ class DelayedVisitor final : public VNVisitor { ifp->addThensp(new AstAssign{flp, capturedLhsp, capturedRhsp}); // Delete original NBA - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } // Scheme::ValueQueuePartial/Scheme::ValueQueueWhole @@ -1020,7 +1020,7 @@ class DelayedVisitor final : public VNVisitor { nodep->addHereThisAsNext(callp->makeStmt()); // Delete original NBA - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } // Record where a variable is assigned diff --git a/src/V3Force.cpp b/src/V3Force.cpp index 034109773..0a70aefee 100644 --- a/src/V3Force.cpp +++ b/src/V3Force.cpp @@ -1605,12 +1605,12 @@ static void assignAllImpl(AstNetlist* nodep, ForceState::ForceHelperVarsByVar& h assignp->replaceWith(new AstAssignForce{assignp->fileline(), assignp->lhsp()->unlinkFrBack(), assignp->rhsp()->unlinkFrBack()}); - assignp->deleteTree(); + VL_DO_DANGLING(assignp->deleteTree(), assignp); } for (AstDeassign* const deassignp : deassignps) { deassignp->replaceWith( new AstRelease{deassignp->fileline(), deassignp->lhsp()->cloneTreePure(true)}); - deassignp->deleteTree(); + VL_DO_DANGLING(deassignp->deleteTree(), deassignp); } ForceState state{true, helperVars, permanentlyProtected, forceRdUpdateBuilt}; { ForceDiscoveryVisitor{nodep, state}; } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 36f5901f4..878b19fe8 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -639,7 +639,7 @@ private: } if (prevp) { pinVarp->replaceWith(prevp); - pushDeletep(pinVarp); + VL_DO_DANGLING(pushDeletep(pinVarp), pinVarp); } nodep->replaceWith(prevPinp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -713,7 +713,7 @@ private: } if (prevp) { pinVarp->replaceWith(prevp); - pushDeletep(pinVarp); + VL_DO_DANGLING(pushDeletep(pinVarp), pinVarp); } // else pinVarp already unlinked when another instance did this step nodep->replaceWith(prevPinp); VL_DO_DANGLING(pushDeletep(nodep), nodep); diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index bd298d118..a71b9a5bc 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2076,7 +2076,7 @@ class LinkDotFindVisitor final : public VNVisitor { AstNodeDType* const oldDtp = nodep->childDTypep(); oldDtp->replaceWith(newDtp->cloneTree(false)); - oldDtp->deleteTree(); + VL_DO_DANGLING(oldDtp->deleteTree(), oldDtp); } } } @@ -2781,7 +2781,7 @@ private: } } iterateChildren(nodep); - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } void visit(AstAliasScope* nodep) override { // ScopeVisitor:: // Defer AliasScope processing - must process outer scopes before inner ones @@ -6364,7 +6364,8 @@ class LinkDotResolveVisitor final : public VNVisitor { nodep->v3warn(E_UNSUPPORTED, "Node of type " << nodep->targetRefp()->prettyTypeName() << " referenced by disable"); - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); + return; } if (nodep->targetp()) { nodep->targetRefp()->unlinkFrBack()->deleteTree(); diff --git a/src/V3LinkWith.cpp b/src/V3LinkWith.cpp index f93d8d589..cd5a7ebca 100644 --- a/src/V3LinkWith.cpp +++ b/src/V3LinkWith.cpp @@ -116,7 +116,7 @@ class LinkWithVisitor final : public VNVisitor { AstNodeExpr* const newp = new AstLambdaArgRef{prevFromp->fileline(), prevFromp->name(), false}; prevFromp->replaceWith(newp); - pushDeletep(prevFromp); + VL_DO_DANGLING(pushDeletep(prevFromp), prevFromp); } iterateChildren(nodep); } diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index 47cc6d940..d0a3f48f3 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -104,7 +104,7 @@ class LocalizeVisitor final : public VNVisitor { // Yank the VarScope from it's parent and schedule them for deletion. Leave the Var // for now, as not all VarScopes referencing this Var might be localized. - pushDeletep(nodep->unlinkFrBack()); + pushDeletep(nodep->unlinkFrBack()); // TODO nodep used past here // In each referencing function, create a replacement local variable AstVar* const oldVarp = nodep->varp(); diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 2c3929eea..c4eaf5dc9 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -1209,7 +1209,7 @@ class ParamProcessor final { if (constp && !constp->num().isString()) { constp->replaceWith( new AstConst{constp->fileline(), AstConst::String{}, constp->num().toString()}); - constp->deleteTree(); + VL_DO_DANGLING(constp->deleteTree(), constp); } } @@ -2113,7 +2113,7 @@ class ParamProcessor final { // It is a temporary copy of the original class node, stored in order to create // another instances. It is needed only during class instantiation. UINFO(8, " Created clone " << nodeCopyp); - m_deleter.pushDeletep(nodeCopyp); + m_deleter.pushDeletep(nodeCopyp); // nodeCopyp used past here srcModp->user3p(nodeCopyp); storeOriginalParams(nodeCopyp); } @@ -2155,7 +2155,7 @@ class ParamProcessor final { genericInterfaceVarSetup(paramsp, pinsp); // Delete the parameters from the cell; they're not relevant any longer. - if (paramsp) paramsp->unlinkFrBackWithNext()->deleteTree(); + if (paramsp) VL_DO_DANGLING(paramsp->unlinkFrBackWithNext()->deleteTree(), paramsp); return newModp; } diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index 62baeea15..905c1ed43 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -102,7 +102,7 @@ AstNodeExpr* V3ParseImp::makePropertyCase(FileLine* flp, AstNodeExpr* exprp, Ast if (!itemsp) { flp->v3error("Property case statement with no items"); - exprp->deleteTree(); + VL_DO_DANGLING(exprp->deleteTree(), exprp); return new AstConst{flp, AstConst::BitTrue{}}; } @@ -113,7 +113,7 @@ AstNodeExpr* V3ParseImp::makePropertyCase(FileLine* flp, AstNodeExpr* exprp, Ast if (itemp->isDefault()) { if (defaultPropp) { itemp->v3error("Multiple default statements in property case statement"); - defaultPropp->deleteTree(); + VL_DO_DANGLING(defaultPropp->deleteTree(), defaultPropp); exprp->deleteTree(); return new AstConst{flp, AstConst::BitTrue{}}; } @@ -140,11 +140,11 @@ AstNodeExpr* V3ParseImp::makePropertyCase(FileLine* flp, AstNodeExpr* exprp, Ast resultp = resultp ? new AstSAnd{flp, resultp, branchp, /*propertyControl=*/true} : branchp; matchedp = matchedp ? new AstLogOr{itemp->fileline(), matchedp, itemMatchp} : itemMatchp; } - itemsp->deleteTree(); + VL_DO_DANGLING(itemsp->deleteTree(), itemsp); if (defaultPropp) { if (!matchedp) { - exprp->deleteTree(); + VL_DO_DANGLING(exprp->deleteTree(), exprp); return defaultPropp; } AstNodeExpr* const noMatchp @@ -152,8 +152,8 @@ AstNodeExpr* V3ParseImp::makePropertyCase(FileLine* flp, AstNodeExpr* exprp, Ast AstNodeExpr* const branchp = new AstImplication{defaultFlp, noMatchp, defaultPropp, true}; resultp = new AstSAnd{flp, resultp, branchp, /*propertyControl=*/true}; } - matchedp->deleteTree(); - exprp->deleteTree(); + VL_DO_DANGLING(matchedp->deleteTree(), matchedp); + VL_DO_DANGLING(exprp->deleteTree(), exprp); return resultp; } diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index d12a3a93c..0580a937b 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -866,7 +866,8 @@ class ConstraintExprVisitor final : public VNVisitor { , m_firstExpressionInsideIndexPointerp{pointerToFirstExprp} {} ~NestedAccessPath() { if (m_nestedNameFormatp) { - m_nestedNameFormatTopp->deleteTree(); + VL_DO_CLEAR(m_nestedNameFormatTopp->deleteTree(), + m_nestedNameFormatTopp = nullptr); m_nestedNameFormatp = nullptr; } } @@ -2621,7 +2622,7 @@ class ConstraintExprVisitor final : public VNVisitor { if (!genVarp) { // This shall be substituted with an assert when it will be supported nodep->v3warn(CONSTRAINTIGN, "Unsupported: Unique constraint in randomize() with {}"); - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); return; } if (m_classp) { @@ -3494,7 +3495,7 @@ class CaptureVisitor final : public VNVisitor { = new AstVarRef{nodep->fileline(), newVarp, VAccess::READ}; notXVarRefp->classOrPackagep(nodep->classOrPackagep()); nodep->replaceWith(notXVarRefp); - nodep->deleteTree(); + VL_DO_DANGLING(nodep->deleteTree(), nodep); nodep = notXVarRefp; } m_ignore.emplace(nodep); @@ -4884,7 +4885,7 @@ class RandomizeVisitor final : public VNVisitor { } if (appendStmtp) newStmtp->addNext(appendStmtp); m_stmtp->replaceWith(newStmtp); - pushDeletep(m_stmtp); + VL_DO_CLEAR(pushDeletep(m_stmtp), m_stmtp = nullptr); } else { UASSERT_OBJ(receiverp, ftaskRefp, "Should have receiver"); UASSERT_OBJ(!appendStmtp, ftaskRefp, "Append path requires arg-form rand_mode"); @@ -4995,7 +4996,7 @@ class RandomizeVisitor final : public VNVisitor { = AstNode::addNext(setStmtsp, new AstAssign{fl, setp, new AstConst{fl, 1}}); exprp = getFromp(exprp); } - argp->unlinkFrBack()->deleteTree(); + VL_DO_DANGLING(argp->unlinkFrBack()->deleteTree(), argp); } if (hasNullArg) { // Re-point to the per-class __Vrandomize_null wrapper AstClass* targetClassp = nullptr; @@ -6104,7 +6105,7 @@ class RandomizeVisitor final : public VNVisitor { "Per-instance rand_mode var missing without static fallback"); UASSERT_OBJ(VN_IS(nodep->backp(), StmtExpr), nodep, "Should be a statement"); m_stmtp->replaceWith(classLevelStaticLoopp); - pushDeletep(m_stmtp); + VL_DO_CLEAR(pushDeletep(m_stmtp), m_stmtp = nullptr); return; } AstNodeExpr* const lhsp = makeModeAssignLhs(nodep->fileline(), randModeTarget.classp, diff --git a/src/V3Sched.cpp b/src/V3Sched.cpp index 834b33c6f..39a6109e6 100644 --- a/src/V3Sched.cpp +++ b/src/V3Sched.cpp @@ -581,7 +581,8 @@ void createIcoRegion(AstNetlist* netlistp, AstCFunc* const initFuncp, util::callVoidFunc(icoFuncp)); // Release temporary input change detect SenTrees - for (AstSenTree* const senTreep : icoChangeSenTreeps) senTreep->deleteTree(); + for (AstSenTree* const senTreep : icoChangeSenTreeps) + VL_DO_DANGLING(senTreep->deleteTree(), senTreep); icoChangeSenTreeps.clear(); } diff --git a/src/V3Sched.h b/src/V3Sched.h index 456947615..41d8b13db 100644 --- a/src/V3Sched.h +++ b/src/V3Sched.h @@ -112,7 +112,7 @@ struct LogicByScope final : public std::vector> } } if (activep->backp()) activep->unlinkFrBack(); - activep->deleteTree(); + VL_DO_DANGLING(activep->deleteTree(), activep); } clear(); }; diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 48fa53cfe..d270ce815 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -760,7 +760,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { varp->attrSplitVar(!cannotSplitPackedVarReason(varp)); m_forPackedSplit.m_refs[m_modp].add(varp); } else { - pushDeletep(varp->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(varp->unlinkFrBack()), varp); } ++numSplit; } diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 631d4a6db..8779b24e2 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -596,7 +596,7 @@ class TaskVisitor final : public VNVisitor { m_scopep->addVarsp(newvscp); AstVarRef* const repp = new AstVarRef{pinp->fileline(), newvscp, VAccess::WRITE}; pinp->replaceWith(repp); - pushDeletep(pinp); + VL_DO_DANGLING(pushDeletep(pinp), pinp); pinp = repp; } if (inlineTask) { diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 8b931fb58..d977e532d 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -355,7 +355,7 @@ class TraceVisitor final : public VNVisitor { } while (emptyScope); } // Can't purge until we finish this pass - pushDeletep(declp->unlinkFrBack()); + pushDeletep(declp->unlinkFrBack()); // declp used below vvertexp->rerouteEdges(&m_graph); vvertexp->unlinkDelete(&m_graph); } @@ -1137,8 +1137,7 @@ class TraceVisitor final : public VNVisitor { // TraceInc for (const auto& i : traces) { AstNode* const valuep = i.second->nodep()->valuep(); - valuep->unlinkFrBack(); - valuep->deleteTree(); + VL_DO_DANGLING(valuep->unlinkFrBack()->deleteTree(), valuep); } // Create the trace cleanup function clearing the activity flags diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 76b6e2129..f89599c26 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -1974,8 +1974,7 @@ class TristateVisitor final : public TristateBaseVisitor { } newp = new AstAdd{nodep->fileline(), nodep, newp}; } else { - // TODO: looks dubious that we still iterate this below... - pushDeletep(nodep); + pushDeletep(nodep); // TODO: looks dubious that we still iterate this below... } UINFOTREE(9, newp, "", "countout"); relinkHandle.relink(newp); diff --git a/src/V3Udp.cpp b/src/V3Udp.cpp index 2ee5908bb..f5d5e77f9 100644 --- a/src/V3Udp.cpp +++ b/src/V3Udp.cpp @@ -139,8 +139,8 @@ class UdpVisitor final : public VNVisitor { } else if (valName == "x" || valName == "X") { // No x inputs supported yet, so this whole table line // can never match. Drop the whole thing. - if (edgetrigp) pushDeletep(edgetrigp); - if (logandp) pushDeletep(logandp); + if (edgetrigp) VL_DO_DANGLING(pushDeletep(edgetrigp), edgetrigp); + if (logandp) VL_DO_DANGLING(pushDeletep(logandp), logandp); return; } } @@ -157,8 +157,8 @@ class UdpVisitor final : public VNVisitor { string const oValName = nodep->udpIsCombo() ? oNodep->name() : oNodep->nextp()->name(); if (oValName == "-") { - if (edgetrigp) pushDeletep(edgetrigp); - if (logandp) pushDeletep(logandp); + if (edgetrigp) VL_DO_DANGLING(pushDeletep(edgetrigp), edgetrigp); + if (logandp) VL_DO_DANGLING(pushDeletep(logandp), logandp); return; } @@ -173,8 +173,8 @@ class UdpVisitor final : public VNVisitor { } else if (oNodep->name() == "x" || oNodep->name() == "X") { // No x inputs supported yet, so this whole table line // can never match. Drop the whole thing. - if (edgetrigp) pushDeletep(edgetrigp); - if (logandp) pushDeletep(logandp); + if (edgetrigp) VL_DO_DANGLING(pushDeletep(edgetrigp), edgetrigp); + if (logandp) VL_DO_DANGLING(pushDeletep(logandp), logandp); return; } } @@ -189,7 +189,7 @@ class UdpVisitor final : public VNVisitor { oNodep->v3error("Illegal value for combinational UDP line output"); } m_alwaysBlockp->addStmtsp(ifp); - if (edgetrigp) pushDeletep(edgetrigp); + if (edgetrigp) VL_DO_DANGLING(pushDeletep(edgetrigp), edgetrigp); return; } if (!isSequentOutputSig(oValName)) { diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 6f989a889..99d6d7288 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -126,7 +126,7 @@ class UnknownVisitor final : public VNVisitor { addVar(varp); AstNode* const prepCopyp = prep->clonep(); prepCopyp->replaceWith(new AstVarRef{fl, varp, VAccess::WRITE}); - pushDeletep(prepCopyp); + VL_DO_DANGLING(pushDeletep(prepCopyp), prepCopyp); } AstIf* const newp = new AstIf{fl, condp, origStmtp, elseStmtp}; replaceHandle.relink(newp); diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index 62cf42fa9..5af72ed8c 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -186,7 +186,7 @@ class UnrollOneVisitor final : VNVisitor { if (AstLoopTest* const testp = VN_CAST(nodep, LoopTest)) { foundLoopTest = true; // Will not actually need it, nor any subsequent - pushDeletep(testp); + pushDeletep(testp); // TODO testp used past here // Loop continues - add rest of statements if (testp->condp()->isNeqZero()) continue; // Won't need any of the trailing statements diff --git a/src/V3Width.cpp b/src/V3Width.cpp index c66872e30..74b8e1150 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1782,7 +1782,7 @@ class WidthVisitor final : public VNVisitor { } } if (!newp) { - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); return; } nodep->replaceWith(new AstAlways{newp}); @@ -2316,7 +2316,7 @@ class WidthVisitor final : public VNVisitor { // Delete a subtree after removing any saved references that point into it. static void deleteTreeCaptured(AstNode* nodep) { V3LinkDotIfaceCapture::purgeDeletedSubtree(nodep); - nodep->deleteTree(); + VL_DO_DANGLING(nodep->deleteTree(), nodep); } void visit(AstAttrOf* nodep) override { VL_RESTORER(m_attrp); @@ -2477,7 +2477,7 @@ class WidthVisitor final : public VNVisitor { AstNodeDType* const declDtp = [&]() { if (m_ftaskp->fvarp()) return m_ftaskp->fvarp()->dtypep(); AstNodeDType* const voidp = new AstVoidDType{m_ftaskp->fileline()}; - pushDeletep(voidp); + pushDeletep(voidp); // Note voidp used past here return voidp; }(); if (!similarDTypeRecurse(protoDtp, declDtp)) { @@ -5854,9 +5854,9 @@ class WidthVisitor final : public VNVisitor { AstPatMember* patp = nullptr; if (it == patmap.end()) { // Default or default_type assignment patp = defaultPatp_patternUOrStruct(nodep, memp, vdtypep, defaultp, dtypemap); - pushDeletep(patp); + pushDeletep(patp); // patp used below patp = defaultPatp_forDType(patp, memp->virtRefDTypep(), dtypemap); - pushDeletep(patp); + pushDeletep(patp); // patp used below } else { patp = it->second; // Member assignment } @@ -6868,7 +6868,7 @@ class WidthVisitor final : public VNVisitor { nodep->foreach([this](AstScopeName* nodep) { // nodep->replaceWith( new AstConst{nodep->fileline(), AstConst::String{}, ""}); - pushDeletep(nodep); + VL_DO_DANGLING(pushDeletep(nodep), nodep); }); V3Const::constifyParamsEdit(nodep->fmtp()); // fmtp may change string text = VString::dequotePercent(nodep->fmtp()->text());