Internals: Add VL_DO_DANGLING in some missing places. No functional change intended.

This commit is contained in:
Wilson Snyder
2026-09-23 18:27:40 -04:00
parent 7fd68b58ca
commit 3d386f8fa5
24 changed files with 58 additions and 57 deletions
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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);
}
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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;
}
}
+3 -3
View File
@@ -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
+2 -2
View File
@@ -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}; }
+2 -2
View File
@@ -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);
+4 -3
View File
@@ -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();
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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();
+3 -3
View File
@@ -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;
}
+6 -6
View File
@@ -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;
}
+7 -6
View File
@@ -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,
+2 -1
View File
@@ -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();
}
+1 -1
View File
@@ -112,7 +112,7 @@ struct LogicByScope final : public std::vector<std::pair<AstScope*, AstActive*>>
}
}
if (activep->backp()) activep->unlinkFrBack();
activep->deleteTree();
VL_DO_DANGLING(activep->deleteTree(), activep);
}
clear();
};
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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) {
+2 -3
View File
@@ -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
+1 -2
View File
@@ -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);
+7 -7
View File
@@ -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)) {
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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
+6 -6
View File
@@ -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{}, "<scope-unavailable>"});
pushDeletep(nodep);
VL_DO_DANGLING(pushDeletep(nodep), nodep);
});
V3Const::constifyParamsEdit(nodep->fmtp()); // fmtp may change
string text = VString::dequotePercent(nodep->fmtp()->text());