From 8daae7336d77e73dfd9f99bb41b1ec028d649040 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Tue, 21 Oct 2025 10:42:03 +0100 Subject: [PATCH] Internals: Remove redundant AstNode::addNextStmt --- src/V3Ast.h | 3 --- src/V3AstNodeStmt.h | 2 -- src/V3AstNodes.cpp | 14 -------------- src/V3Unknown.cpp | 5 +++-- 4 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index ae039639d..00a4d95b3 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -825,9 +825,6 @@ public: void swapWith(AstNode* bp); void relink(VNRelinker* linkerp); // Generally use linker->relink() instead void cloneRelinkNode() { cloneRelink(); } - // Iterate and insert - assumes tree format - virtual void addNextStmt(AstNode* newp, - AstNode* belowp); // When calling, "this" is second argument // METHODS - Iterate on a tree AstNode* cloneTree(bool cloneNextLink, diff --git a/src/V3AstNodeStmt.h b/src/V3AstNodeStmt.h index db2fab8b3..3142f0bad 100644 --- a/src/V3AstNodeStmt.h +++ b/src/V3AstNodeStmt.h @@ -38,8 +38,6 @@ protected: public: ASTGEN_MEMBERS_AstNodeStmt; // METHODS - void addNextStmt(AstNode* newp, - AstNode* belowp) override; // Stop statement searchback here void dump(std::ostream& str = std::cout) const override; void dumpJson(std::ostream& str = std::cout) const override; }; diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index fe69fe405..e9240b18e 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -1528,20 +1528,6 @@ AstVarScope* AstConstPool::findConst(AstConst* initp, bool mergeDType) { return varScopep; } -//====================================================================== -// Special walking tree inserters - -void AstNode::addNextStmt(AstNode* newp, AstNode*) { - UASSERT_OBJ(backp(), newp, "Can't find current statement to addNextStmt"); - // Look up; virtual call will find where to put it - this->backp()->addNextStmt(newp, this); -} - -void AstNodeStmt::addNextStmt(AstNode* newp, AstNode*) { - // Insert newp after current node - this->addNextHere(newp); -} - //====================================================================== // Per-type Debugging diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 5a8c6a172..9120ff339 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -114,7 +114,8 @@ class UnknownVisitor final : public VNVisitor { AstVar* const varp = new AstVar{fl, VVarType::MODULETEMP, m_lvboundNames.get(prep), prep->dtypep()}; m_modp->addStmtsp(varp); - AstNode* const abovep = prep->backp(); // Grab above point before we replace 'prep' + AstNode* stmtp = prep->backp(); // Grab above point before we replace 'prep' + while (!VN_IS(stmtp, NodeStmt)) stmtp = stmtp->backp(); prep->replaceWith(new AstVarRef{fl, varp, VAccess::WRITE}); if (m_timingControlp) m_timingControlp->unlinkFrBack(); @@ -128,7 +129,7 @@ class UnknownVisitor final : public VNVisitor { newp->branchPred(VBranchPred::BP_LIKELY); newp->isBoundsCheck(true); UINFOTREE(9, newp, "", "_new"); - abovep->addNextStmt(newp, abovep); + stmtp->addNextHere(newp); prep->user2p(newp); // Save so we may LogAnd it next time } }