From a68da7e2205ab77af18479ac1d9be2f665e4b0f9 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 10 Nov 2024 10:51:48 -0500 Subject: [PATCH] Internals: Style cleanup. Ignore whitespace if diff. No functional change. --- src/V3Assert.cpp | 22 +++---- src/V3Begin.cpp | 93 +++++++++++++++--------------- src/V3Class.cpp | 32 +++++------ src/V3Clean.cpp | 6 +- src/V3Const.cpp | 28 ++++----- src/V3Depth.cpp | 38 ++++++------ src/V3DepthBlock.cpp | 16 ++---- src/V3Descope.cpp | 12 ++-- src/V3EmitCSyms.cpp | 12 ++-- src/V3EmitV.cpp | 12 ++-- src/V3LinkCells.cpp | 10 ++-- src/V3LinkJump.cpp | 30 ++++------ src/V3LinkParse.cpp | 130 ++++++++++++++++++------------------------ src/V3LinkResolve.cpp | 14 ++--- src/V3Reloop.cpp | 8 +-- src/V3Scope.cpp | 52 ++++++++--------- src/V3Table.cpp | 8 +-- src/V3Task.cpp | 40 ++++++------- src/V3Trace.cpp | 6 +- src/V3Undriven.cpp | 48 ++++++---------- src/V3Unknown.cpp | 38 +++++------- src/V3Width.cpp | 32 ++++------- 22 files changed, 285 insertions(+), 402 deletions(-) diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index b90e1e106..8c72aabef 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -510,10 +510,8 @@ class AssertVisitor final : public VNVisitor { // Don't sample sensitivities void visit(AstSenItem* nodep) override { VL_RESTORER(m_inSampled); - { - m_inSampled = false; - iterateChildren(nodep); - } + m_inSampled = false; + iterateChildren(nodep); } //========== Statements @@ -691,12 +689,10 @@ class AssertVisitor final : public VNVisitor { VL_RESTORER(m_modp); VL_RESTORER(m_modPastNum); VL_RESTORER(m_modStrobeNum); - { - m_modp = nodep; - m_modPastNum = 0; - m_modStrobeNum = 0; - iterateChildren(nodep); - } + m_modp = nodep; + m_modPastNum = 0; + m_modStrobeNum = 0; + iterateChildren(nodep); } void visit(AstNodeProcedure* nodep) override { VL_RESTORER(m_procedurep); @@ -707,10 +703,8 @@ class AssertVisitor final : public VNVisitor { // This code is needed rather than a visitor in V3Begin, // because V3Assert is called before V3Begin VL_RESTORER(m_beginp); - { - m_beginp = nodep; - iterateChildren(nodep); - } + m_beginp = nodep; + iterateChildren(nodep); } void visit(AstNode* nodep) override { iterateChildren(nodep); } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index d6e881f40..f20ba4f6d 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -54,8 +54,10 @@ public: //###################################################################### class BeginVisitor final : public VNVisitor { - // STATE + // STATE - across all visitors BeginState* const m_statep; // Current global state + + // STATE - for current visit position (use VL_RESTORER) AstNodeModule* m_modp = nullptr; // Current module AstNodeFTask* m_ftaskp = nullptr; // Current function/task AstNode* m_liftedp = nullptr; // Local nodes we are lifting into m_ftaskp @@ -145,10 +147,8 @@ class BeginVisitor final : public VNVisitor { } void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); - { - m_modp = nodep; - iterateChildren(nodep); - } + m_modp = nodep; + iterateChildren(nodep); } void visit(AstNodeFTask* nodep) override { UINFO(8, " " << nodep << endl); @@ -164,29 +164,28 @@ class BeginVisitor final : public VNVisitor { // inside the function. // Process children VL_RESTORER(m_displayScope); + VL_RESTORER(m_ftaskp); + VL_RESTORER(m_liftedp); VL_RESTORER(m_namedScope); VL_RESTORER(m_unnamedScope); - { - m_displayScope = dot(m_displayScope, nodep->name()); - m_namedScope = ""; - m_unnamedScope = ""; - m_ftaskp = nodep; - m_liftedp = nullptr; - iterateChildren(nodep); - nodep->foreach([&](AstInitialStatic* const initp) { - initp->unlinkFrBack(); - m_ftaskp->addHereThisAsNext(initp); - }); - if (m_liftedp) { - // Place lifted nodes at beginning of stmtsp, so Var nodes appear before referenced - if (AstNode* const stmtsp = nodep->stmtsp()) { - stmtsp->unlinkFrBackWithNext(); - m_liftedp->addNext(stmtsp); - } - nodep->addStmtsp(m_liftedp); - m_liftedp = nullptr; + m_displayScope = dot(m_displayScope, nodep->name()); + m_namedScope = ""; + m_unnamedScope = ""; + m_ftaskp = nodep; + m_liftedp = nullptr; + iterateChildren(nodep); + nodep->foreach([&](AstInitialStatic* const initp) { + initp->unlinkFrBack(); + m_ftaskp->addHereThisAsNext(initp); + }); + if (m_liftedp) { + // Place lifted nodes at beginning of stmtsp, so Var nodes appear before referenced + if (AstNode* const stmtsp = nodep->stmtsp()) { + stmtsp->unlinkFrBackWithNext(); + m_liftedp->addNext(stmtsp); } - m_ftaskp = nullptr; + nodep->addStmtsp(m_liftedp); + m_liftedp = nullptr; } } void visit(AstBegin* nodep) override { @@ -196,30 +195,28 @@ class BeginVisitor final : public VNVisitor { VL_RESTORER(m_namedScope); VL_RESTORER(m_unnamedScope); { - { - VL_RESTORER(m_keepBegins); - m_keepBegins = false; - dotNames(nodep, "__BEGIN__"); - } - UASSERT_OBJ(!nodep->genforp(), nodep, "GENFORs should have been expanded earlier"); - - // Cleanup - if (m_keepBegins) { - nodep->name(""); - return; - } - AstNode* addsp = nullptr; - if (AstNode* const stmtsp = nodep->stmtsp()) { - stmtsp->unlinkFrBackWithNext(); - addsp = AstNode::addNext(addsp, stmtsp); - } - if (addsp) { - nodep->replaceWith(addsp); - } else { - nodep->unlinkFrBack(); - } - VL_DO_DANGLING(pushDeletep(nodep), nodep); + VL_RESTORER(m_keepBegins); + m_keepBegins = false; + dotNames(nodep, "__BEGIN__"); } + UASSERT_OBJ(!nodep->genforp(), nodep, "GENFORs should have been expanded earlier"); + + // Cleanup + if (m_keepBegins) { + nodep->name(""); + return; + } + AstNode* addsp = nullptr; + if (AstNode* const stmtsp = nodep->stmtsp()) { + stmtsp->unlinkFrBackWithNext(); + addsp = AstNode::addNext(addsp, stmtsp); + } + if (addsp) { + nodep->replaceWith(addsp); + } else { + nodep->unlinkFrBack(); + } + VL_DO_DANGLING(pushDeletep(nodep), nodep); } void visit(AstVar* nodep) override { // If static variable, move it outside a function. diff --git a/src/V3Class.cpp b/src/V3Class.cpp index 5d187a5c0..9e82be6ea 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -129,24 +129,20 @@ class ClassVisitor final : public VNVisitor { VL_RESTORER(m_classScopep); VL_RESTORER(m_packageScopep); VL_RESTORER(m_modp); - { - m_modp = nodep; - m_classPackagep = packagep; - m_classScopep = classScopep; - m_packageScopep = scopep; - m_prefix = nodep->name() + "__02e"; // . - iterateChildren(nodep); - } + m_modp = nodep; + m_classPackagep = packagep; + m_classScopep = classScopep; + m_packageScopep = scopep; + m_prefix = nodep->name() + "__02e"; // . + iterateChildren(nodep); } void visit(AstNodeModule* nodep) override { // Visit for NodeModules that are not AstClass (AstClass is-a AstNodeModule) VL_RESTORER(m_prefix); VL_RESTORER(m_modp); - { - m_modp = nodep; - m_prefix = nodep->name() + "__03a__03a"; // :: - iterateChildren(nodep); - } + m_modp = nodep; + m_prefix = nodep->name() + "__03a__03a"; // :: + iterateChildren(nodep); } void visit(AstVar* nodep) override { @@ -174,12 +170,10 @@ class ClassVisitor final : public VNVisitor { void visit(AstNodeFTask* nodep) override { VL_RESTORER(m_ftaskp); - { - m_ftaskp = nodep; - iterateChildren(nodep); - if (m_packageScopep && nodep->isStatic()) { - m_toScopeMoves.emplace_back(nodep, m_packageScopep); - } + m_ftaskp = nodep; + iterateChildren(nodep); + if (m_packageScopep && nodep->isStatic()) { + m_toScopeMoves.emplace_back(nodep, m_packageScopep); } } void visit(AstCFunc* nodep) override { diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 9acb79559..90035dc6c 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -173,10 +173,8 @@ class CleanVisitor final : public VNVisitor { // VISITORS void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); - { - m_modp = nodep; - iterateChildren(nodep); - } + m_modp = nodep; + iterateChildren(nodep); } void visit(AstNodeUniop* nodep) override { iterateChildren(nodep); diff --git a/src/V3Const.cpp b/src/V3Const.cpp index dbe81ed4a..ec8107bc6 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -2333,20 +2333,16 @@ class ConstVisitor final : public VNVisitor { } void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); - { - m_modp = nodep; - m_concswapNames.reset(); - iterateChildren(nodep); - } + m_modp = nodep; + m_concswapNames.reset(); + iterateChildren(nodep); } void visit(AstCFunc* nodep) override { // No ASSIGNW removals under funcs, we've long eliminated INITIALs // (We should perhaps rename the assignw's to just assigns) VL_RESTORER(m_wremove); - { - m_wremove = false; - iterateChildren(nodep); - } + m_wremove = false; + iterateChildren(nodep); } void visit(AstCLocalScope* nodep) override { iterateChildren(nodep); @@ -2359,11 +2355,9 @@ class ConstVisitor final : public VNVisitor { // No ASSIGNW removals under scope, we've long eliminated INITIALs VL_RESTORER(m_wremove); VL_RESTORER(m_scopep); - { - m_wremove = false; - m_scopep = nodep; - iterateChildren(nodep); - } + m_wremove = false; + m_scopep = nodep; + iterateChildren(nodep); } void swapSides(AstNodeBiCom* nodep) { @@ -2695,10 +2689,8 @@ class ConstVisitor final : public VNVisitor { void visit(AstAttrOf* nodep) override { VL_RESTORER(m_attrp); - { - m_attrp = nodep; - iterateChildren(nodep); - } + m_attrp = nodep; + iterateChildren(nodep); } void visit(AstArraySel* nodep) override { diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index 25a294268..49e386cc5 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -71,35 +71,29 @@ class DepthVisitor final : public VNVisitor { void visit(AstCFunc* nodep) override { VL_RESTORER(m_cfuncp); VL_RESTORER(m_mtaskbodyp); - { - m_cfuncp = nodep; - m_mtaskbodyp = nullptr; - m_depth = 0; - m_maxdepth = 0; - m_tempNames.reset(); - iterateChildren(nodep); - } + m_cfuncp = nodep; + m_mtaskbodyp = nullptr; + m_depth = 0; + m_maxdepth = 0; + m_tempNames.reset(); + iterateChildren(nodep); } void visit(AstMTaskBody* nodep) override { VL_RESTORER(m_cfuncp); VL_RESTORER(m_mtaskbodyp); - { - m_cfuncp = nullptr; - m_mtaskbodyp = nodep; - m_depth = 0; - m_maxdepth = 0; - // We don't reset the names, as must share across tasks - iterateChildren(nodep); - } + m_cfuncp = nullptr; + m_mtaskbodyp = nodep; + m_depth = 0; + m_maxdepth = 0; + // We don't reset the names, as must share across tasks + iterateChildren(nodep); } void visitStmt(AstNodeStmt* nodep) { VL_RESTORER(m_stmtp); - { - m_stmtp = nodep; - m_depth = 0; - m_maxdepth = 0; - iterateChildren(nodep); - } + m_stmtp = nodep; + m_depth = 0; + m_maxdepth = 0; + iterateChildren(nodep); } void visit(AstNodeStmt* nodep) override { visitStmt(nodep); } // Operators diff --git a/src/V3DepthBlock.cpp b/src/V3DepthBlock.cpp index 54fa3f2b6..296709bb0 100644 --- a/src/V3DepthBlock.cpp +++ b/src/V3DepthBlock.cpp @@ -70,21 +70,17 @@ class DepthBlockVisitor final : public VNVisitor { void visit(AstNodeModule* nodep) override { UINFO(4, " MOD " << nodep << endl); VL_RESTORER(m_modp); - { - m_modp = nodep; - m_deepNum = 0; - iterateChildren(nodep); - } + m_modp = nodep; + m_deepNum = 0; + iterateChildren(nodep); } void visit(AstCFunc* nodep) override { // We recurse into this. VL_RESTORER(m_depth); VL_RESTORER(m_cfuncp); - { - m_depth = 0; - m_cfuncp = nodep; - iterateChildren(nodep); - } + m_depth = 0; + m_cfuncp = nodep; + iterateChildren(nodep); } void visit(AstStmtExpr* nodep) override {} // Stop recursion after introducing new function void visit(AstJumpBlock*) override {} // Stop recursion as can't break up across a jump diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 42c718c9b..b6ff4c07e 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -208,13 +208,11 @@ class DescopeVisitor final : public VNVisitor { // VISITORS void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); - { - m_modp = nodep; - m_modFuncs.clear(); - m_modSingleton = modIsSingleton(m_modp); - iterateChildren(nodep); - makePublicFuncWrappers(); - } + m_modp = nodep; + m_modFuncs.clear(); + m_modSingleton = modIsSingleton(m_modp); + iterateChildren(nodep); + makePublicFuncWrappers(); } void visit(AstScope* nodep) override { m_scopep = nodep; diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 4198eecc5..e2e020f7f 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -300,10 +300,8 @@ class EmitCSyms final : EmitCBaseVisitorConst { void visit(AstNodeModule* nodep) override { nameCheck(nodep); VL_RESTORER(m_modp); - { - m_modp = nodep; - iterateChildrenConst(nodep); - } + m_modp = nodep; + iterateChildrenConst(nodep); } void visit(AstCellInlineScope* nodep) override { if (v3Global.opt.vpi()) { @@ -372,10 +370,8 @@ class EmitCSyms final : EmitCBaseVisitorConst { nameCheck(nodep); if (nodep->dpiImportPrototype() || nodep->dpiExportDispatcher()) m_dpis.push_back(nodep); VL_RESTORER(m_cfuncp); - { - m_cfuncp = nodep; - iterateChildrenConst(nodep); - } + m_cfuncp = nodep; + iterateChildrenConst(nodep); } //--------------------------------------- diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index c3c9c7d8b..861787ae8 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -393,13 +393,11 @@ class EmitVBaseVisitorConst VL_NOT_FINAL : public EmitCBaseVisitorConst { } void visit(AstTextBlock* nodep) override { visit(static_cast(nodep)); - { - VL_RESTORER(m_suppressSemi); - m_suppressVarSemi = nodep->commas(); - for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) { - iterateConst(childp); - if (nodep->commas() && childp->nextp()) puts(", "); - } + VL_RESTORER(m_suppressSemi); + m_suppressVarSemi = nodep->commas(); + for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) { + iterateConst(childp); + if (nodep->commas() && childp->nextp()) puts(", "); } } void visit(AstScopeName* nodep) override {} diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index 5667f8856..5263080b6 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -286,12 +286,10 @@ class LinkCellsVisitor final : public VNVisitor { AstNode* const cellsp = nodep->cellsp()->unlinkFrBackWithNext(); // Module may have already linked, so need to pick up these new cells VL_RESTORER(m_modp); - { - m_modp = modp; - // Important that this adds to end, as next iterate assumes does all cells - modp->addStmtsp(cellsp); - iterateAndNextNull(cellsp); - } + m_modp = modp; + // Important that this adds to end, as next iterate assumes does all cells + modp->addStmtsp(cellsp); + iterateAndNextNull(cellsp); } VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index 7919b9ecb..693d9da11 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -163,11 +163,9 @@ class LinkJumpVisitor final : public VNVisitor { if (nodep->dead()) return; VL_RESTORER(m_modp); VL_RESTORER(m_modRepeatNum); - { - m_modp = nodep; - m_modRepeatNum = 0; - iterateChildren(nodep); - } + m_modp = nodep; + m_modRepeatNum = 0; + iterateChildren(nodep); } void visit(AstNodeFTask* nodep) override { m_ftaskp = nodep; @@ -236,15 +234,13 @@ class LinkJumpVisitor final : public VNVisitor { m_unrollFull = VOptionBool::OPT_DEFAULT_FALSE; VL_RESTORER(m_loopp); VL_RESTORER(m_loopInc); - { - m_loopp = nodep; - m_loopInc = false; - iterateAndNextNull(nodep->precondsp()); - iterateAndNextNull(nodep->condp()); - iterateAndNextNull(nodep->stmtsp()); - m_loopInc = true; - iterateAndNextNull(nodep->incsp()); - } + m_loopp = nodep; + m_loopInc = false; + iterateAndNextNull(nodep->precondsp()); + iterateAndNextNull(nodep->condp()); + iterateAndNextNull(nodep->stmtsp()); + m_loopInc = true; + iterateAndNextNull(nodep->incsp()); } void visit(AstDoWhile* nodep) override { // It is converted to AstWhile in this visit method @@ -272,10 +268,8 @@ class LinkJumpVisitor final : public VNVisitor { } void visit(AstNodeForeach* nodep) override { VL_RESTORER(m_loopp); - { - m_loopp = nodep; - iterateAndNextNull(nodep->stmtsp()); - } + m_loopp = nodep; + iterateAndNextNull(nodep->stmtsp()); } void visit(AstReturn* nodep) override { iterateChildren(nodep); diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 123716fb2..69a5d2c2e 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -101,11 +101,9 @@ class LinkParseVisitor final : public VNVisitor { void visitIterateNodeDType(AstNodeDType* nodep) { if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); - { - VL_RESTORER(m_dtypep); - m_dtypep = nodep; - iterateChildren(nodep); - } + VL_RESTORER(m_dtypep); + m_dtypep = nodep; + iterateChildren(nodep); } } @@ -186,58 +184,54 @@ class LinkParseVisitor final : public VNVisitor { cleanFileline(nodep); VL_RESTORER(m_ftaskp); VL_RESTORER(m_lifetime); - { - m_ftaskp = nodep; - if (!nodep->lifetime().isNone()) { - m_lifetime = nodep->lifetime(); - } else { - if (nodep->classMethod()) { - // Class methods are automatic by default - m_lifetime = VLifetime::AUTOMATIC; - } else if (nodep->dpiImport() || VN_IS(nodep, Property)) { - // DPI-imported functions and properties don't have lifetime specifiers - m_lifetime = VLifetime::NONE; - } - for (AstNode* itemp = nodep->stmtsp(); itemp; itemp = itemp->nextp()) { - AstVar* const varp = VN_CAST(itemp, Var); - if (varp && varp->valuep() && varp->lifetime().isNone() - && m_lifetime.isStatic() && !varp->isIO()) { - if (VN_IS(m_modp, Module)) { - nodep->v3warn(IMPLICITSTATIC, - "Function/task's lifetime implicitly set to static\n" - << nodep->warnMore() - << "... Suggest use 'function automatic' or " - "'function static'\n" - << nodep->warnContextPrimary() << '\n' - << varp->warnOther() - << "... Location of implicit static variable\n" - << varp->warnContextSecondary() << '\n' - << "... Suggest use 'function automatic' or " - "'function static'"); - } else { - varp->v3warn(IMPLICITSTATIC, - "Variable's lifetime implicitly set to static\n" - << nodep->warnMore() - << "... Suggest use 'static' before " - "variable declaration'"); - } + m_ftaskp = nodep; + if (!nodep->lifetime().isNone()) { + m_lifetime = nodep->lifetime(); + } else { + if (nodep->classMethod()) { + // Class methods are automatic by default + m_lifetime = VLifetime::AUTOMATIC; + } else if (nodep->dpiImport() || VN_IS(nodep, Property)) { + // DPI-imported functions and properties don't have lifetime specifiers + m_lifetime = VLifetime::NONE; + } + for (AstNode* itemp = nodep->stmtsp(); itemp; itemp = itemp->nextp()) { + AstVar* const varp = VN_CAST(itemp, Var); + if (varp && varp->valuep() && varp->lifetime().isNone() + && m_lifetime.isStatic() && !varp->isIO()) { + if (VN_IS(m_modp, Module)) { + nodep->v3warn(IMPLICITSTATIC, + "Function/task's lifetime implicitly set to static\n" + << nodep->warnMore() + << "... Suggest use 'function automatic' or " + "'function static'\n" + << nodep->warnContextPrimary() << '\n' + << varp->warnOther() + << "... Location of implicit static variable\n" + << varp->warnContextSecondary() << '\n' + << "... Suggest use 'function automatic' or " + "'function static'"); + } else { + varp->v3warn(IMPLICITSTATIC, + "Variable's lifetime implicitly set to static\n" + << nodep->warnMore() + << "... Suggest use 'static' before " + "variable declaration'"); } } - nodep->lifetime(m_lifetime); } - iterateChildren(nodep); + nodep->lifetime(m_lifetime); } + iterateChildren(nodep); } } void visit(AstNodeFTaskRef* nodep) override { if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); UINFO(5, " " << nodep << endl); - { - VL_RESTORER(m_valueModp); - m_valueModp = nullptr; - iterateChildren(nodep); - } + VL_RESTORER(m_valueModp); + m_valueModp = nullptr; + iterateChildren(nodep); } } void visit(AstNodeDType* nodep) override { visitIterateNodeDType(nodep); } @@ -580,19 +574,15 @@ class LinkParseVisitor final : public VNVisitor { void visit(AstRepeat* nodep) override { cleanFileline(nodep); VL_RESTORER(m_insideLoop); - { - m_insideLoop = true; - checkIndent(nodep, nodep->stmtsp()); - iterateChildren(nodep); - } + m_insideLoop = true; + checkIndent(nodep, nodep->stmtsp()); + iterateChildren(nodep); } void visit(AstDoWhile* nodep) override { cleanFileline(nodep); VL_RESTORER(m_insideLoop); - { - m_insideLoop = true; - iterateChildren(nodep); - } + m_insideLoop = true; + iterateChildren(nodep); } void visit(AstWait* nodep) override { cleanFileline(nodep); @@ -608,11 +598,9 @@ class LinkParseVisitor final : public VNVisitor { void visit(AstWhile* nodep) override { cleanFileline(nodep); VL_RESTORER(m_insideLoop); - { - m_insideLoop = true; - checkIndent(nodep, nodep->stmtsp()); - iterateChildren(nodep); - } + m_insideLoop = true; + checkIndent(nodep, nodep->stmtsp()); + iterateChildren(nodep); } void visit(AstNodeModule* nodep) override { V3Config::applyModule(nodep); @@ -651,11 +639,9 @@ class LinkParseVisitor final : public VNVisitor { void visitIterateNoValueMod(AstNode* nodep) { // Iterate a node which shouldn't have any local variables moved to an Initial cleanFileline(nodep); - { - VL_RESTORER(m_valueModp); - m_valueModp = nullptr; - iterateChildren(nodep); - } + VL_RESTORER(m_valueModp); + m_valueModp = nullptr; + iterateChildren(nodep); } void visit(AstNodeProcedure* nodep) override { visitIterateNoValueMod(nodep); } void visit(AstAlways* nodep) override { @@ -721,13 +707,11 @@ class LinkParseVisitor final : public VNVisitor { void visit(AstGenCase* nodep) override { ++m_genblkNum; cleanFileline(nodep); - { - VL_RESTORER(m_genblkAbove); - VL_RESTORER(m_genblkNum); - m_genblkAbove = m_genblkNum; - m_genblkNum = 0; - iterateChildren(nodep); - } + VL_RESTORER(m_genblkAbove); + VL_RESTORER(m_genblkNum); + m_genblkAbove = m_genblkNum; + m_genblkNum = 0; + iterateChildren(nodep); } void visit(AstGenIf* nodep) override { cleanFileline(nodep); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 426d7b1ca..58af8051c 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -63,18 +63,14 @@ class LinkResolveVisitor final : public VNVisitor { if (nodep->dead()) return; VL_RESTORER(m_modp); VL_RESTORER(m_senitemCvtNum); - { - m_modp = nodep; - m_senitemCvtNum = 0; - iterateChildren(nodep); - } + m_modp = nodep; + m_senitemCvtNum = 0; + iterateChildren(nodep); } void visit(AstClass* nodep) override { VL_RESTORER(m_classp); - { - m_classp = nodep; - iterateChildren(nodep); - } + m_classp = nodep; + iterateChildren(nodep); } void visit(AstInitialAutomatic* nodep) override { iterateChildren(nodep); diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 15c4afbc7..4d61ba20b 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -145,11 +145,9 @@ class ReloopVisitor final : public VNVisitor { // VISITORS void visit(AstCFunc* nodep) override { VL_RESTORER(m_cfuncp); - { - m_cfuncp = nodep; - iterateChildren(nodep); - mergeEnd(); // Finish last pending merge, if any - } + m_cfuncp = nodep; + iterateChildren(nodep); + mergeEnd(); // Finish last pending merge, if any } void visit(AstNodeAssign* nodep) override { if (!m_cfuncp) return; diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 81621ca3e..bc71b549a 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -149,32 +149,30 @@ class ScopeVisitor final : public VNVisitor { VL_RESTORER(m_aboveCellp); VL_RESTORER(m_aboveScopep); VL_RESTORER(m_modp); - { - m_aboveScopep = m_scopep; - m_modp = nodep; + m_aboveScopep = m_scopep; + m_modp = nodep; - string scopename; - if (!m_aboveScopep) { - scopename = "TOP"; - } else { - scopename = m_aboveScopep->name() + "." + nodep->name(); - } - - UINFO(4, " CLASS AT " << scopename << " " << nodep << endl); - AstNode::user1ClearTree(); - - const AstNode* const abovep = (m_aboveCellp ? static_cast(m_aboveCellp) - : static_cast(nodep)); - m_scopep - = new AstScope{abovep->fileline(), m_modp, scopename, m_aboveScopep, m_aboveCellp}; - m_packageScopes.emplace(nodep, m_scopep); - - // Create scope for the current usage of this cell - AstNode::user1ClearTree(); - nodep->addMembersp(m_scopep); - - iterateChildren(nodep); + string scopename; + if (!m_aboveScopep) { + scopename = "TOP"; + } else { + scopename = m_aboveScopep->name() + "." + nodep->name(); } + + UINFO(4, " CLASS AT " << scopename << " " << nodep << endl); + AstNode::user1ClearTree(); + + const AstNode* const abovep + = (m_aboveCellp ? static_cast(m_aboveCellp) : static_cast(nodep)); + m_scopep + = new AstScope{abovep->fileline(), m_modp, scopename, m_aboveScopep, m_aboveCellp}; + m_packageScopes.emplace(nodep, m_scopep); + + // Create scope for the current usage of this cell + AstNode::user1ClearTree(); + nodep->addMembersp(m_scopep); + + iterateChildren(nodep); } void visit(AstCellInline* nodep) override { // if (v3Global.opt.vpi()) { @@ -334,10 +332,8 @@ class ScopeCleanupVisitor final : public VNVisitor { void visit(AstScope* nodep) override { // Want to ignore blocks under it VL_RESTORER(m_scopep); - { - m_scopep = nodep; - iterateChildren(nodep); - } + m_scopep = nodep; + iterateChildren(nodep); } virtual void movedDeleteOrIterate(AstNode* nodep) { diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 0c356dd38..a6ac5be24 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -383,11 +383,9 @@ private: void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); VL_RESTORER(m_modTables); - { - m_modp = nodep; - m_modTables = 0; - iterateChildren(nodep); - } + m_modp = nodep; + m_modTables = 0; + iterateChildren(nodep); } void visit(AstScope* nodep) override { UINFO(4, " SCOPE " << nodep << endl); diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 460647692..b2603a1cd 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -217,20 +217,18 @@ private: } void visit(AstNodeFTask* nodep) override { UINFO(9, " TASK " << nodep << endl); - { - VL_RESTORER(m_curVxp); - m_curVxp = getFTaskVertex(nodep); - if (nodep->dpiImport()) m_curVxp->noInline(true); - if (nodep->classMethod()) m_curVxp->noInline(true); // Until V3Task supports it - if (nodep->recursive()) m_curVxp->noInline(true); - if (nodep->isConstructor()) { - m_curVxp->noInline(true); - m_ctorp = nodep; - UASSERT_OBJ(m_classp, nodep, "Ctor not under class"); - m_funcToClassMap[nodep] = m_classp; - } - iterateChildren(nodep); + VL_RESTORER(m_curVxp); + m_curVxp = getFTaskVertex(nodep); + if (nodep->dpiImport()) m_curVxp->noInline(true); + if (nodep->classMethod()) m_curVxp->noInline(true); // Until V3Task supports it + if (nodep->recursive()) m_curVxp->noInline(true); + if (nodep->isConstructor()) { + m_curVxp->noInline(true); + m_ctorp = nodep; + UASSERT_OBJ(m_classp, nodep, "Ctor not under class"); + m_funcToClassMap[nodep] = m_classp; } + iterateChildren(nodep); } void visit(AstPragma* nodep) override { if (nodep->pragType() == VPragmaType::NO_INLINE_TASK) { @@ -1393,10 +1391,8 @@ class TaskVisitor final : public VNVisitor { // scope then the caller, so we need to restore state. VL_RESTORER(m_scopep); VL_RESTORER(m_insStmtp); - { - m_scopep = m_statep->getScope(nodep); - iterate(nodep); - } + m_scopep = m_statep->getScope(nodep); + iterate(nodep); } void insertBeforeStmt(AstNode* nodep, AstNode* newp) { if (debug() >= 9) nodep->dumpTree("- newstmt: "); @@ -1409,12 +1405,10 @@ class TaskVisitor final : public VNVisitor { void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); VL_RESTORER(m_modNCalls); - { - m_modp = nodep; - m_insStmtp = nullptr; - m_modNCalls = 0; - iterateChildren(nodep); - } + m_modp = nodep; + m_insStmtp = nullptr; + m_modNCalls = 0; + iterateChildren(nodep); } void visit(AstWith* nodep) override { if (nodep->user1SetOnce()) { diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 6022bc377..c136a90ce 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -883,10 +883,8 @@ class TraceVisitor final : public VNVisitor { } } VL_RESTORER(m_cfuncp); - { - m_cfuncp = nodep; - iterateChildren(nodep); - } + m_cfuncp = nodep; + iterateChildren(nodep); } void visit(AstTraceDecl* nodep) override { UINFO(8, " TRACE " << nodep << endl); diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index f89d1937a..0c518ebcd 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -460,46 +460,36 @@ class UndrivenVisitor final : public VNVisitorConst { // Don't know what black boxed calls do, assume in+out void visit(AstSysIgnore* nodep) override { VL_RESTORER(m_inBBox); - { - m_inBBox = true; - iterateChildrenConst(nodep); - } + m_inBBox = true; + iterateChildrenConst(nodep); } void visit(AstAssign* nodep) override { VL_RESTORER(m_inProcAssign); - { - m_inProcAssign = true; - iterateChildrenConst(nodep); - } + m_inProcAssign = true; + iterateChildrenConst(nodep); } void visit(AstAssignDly* nodep) override { VL_RESTORER(m_inProcAssign); - { - m_inProcAssign = true; - iterateChildrenConst(nodep); - } + m_inProcAssign = true; + iterateChildrenConst(nodep); } void visit(AstAssignW* nodep) override { VL_RESTORER(m_inContAssign); - { - m_inContAssign = true; - iterateChildrenConst(nodep); - } + m_inContAssign = true; + iterateChildrenConst(nodep); } void visit(AstAlways* nodep) override { VL_RESTORER(m_alwaysCombp); - { - AstNode::user2ClearTree(); - if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) { - UINFO(9, " " << nodep << endl); - m_alwaysCombp = nodep; - } else { - m_alwaysCombp = nullptr; - } - iterateChildrenConst(nodep); - if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9, " Done " << nodep << endl); + AstNode::user2ClearTree(); + if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) { + UINFO(9, " " << nodep << endl); + m_alwaysCombp = nodep; + } else { + m_alwaysCombp = nullptr; } + iterateChildrenConst(nodep); + if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9, " Done " << nodep << endl); } void visit(AstNodeFTaskRef* nodep) override { VL_RESTORER(m_inFTaskRef); @@ -509,10 +499,8 @@ class UndrivenVisitor final : public VNVisitorConst { void visit(AstNodeFTask* nodep) override { VL_RESTORER(m_taskp); - { - m_taskp = nodep; - iterateChildrenConst(nodep); - } + m_taskp = nodep; + iterateChildrenConst(nodep); } void visit(AstPin* nodep) override { VL_RESTORER(m_inInoutPin); diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 96d427b22..b68241674 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -179,43 +179,33 @@ class UnknownVisitor final : public VNVisitor { void visit(AstAssignDly* nodep) override { VL_RESTORER(m_assigndlyp); VL_RESTORER(m_timingControlp); - { - m_assigndlyp = nodep; - m_timingControlp = nodep->timingControlp(); - VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep. - } + m_assigndlyp = nodep; + m_timingControlp = nodep->timingControlp(); + VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep. } void visit(AstAssignW* nodep) override { VL_RESTORER(m_assignwp); VL_RESTORER(m_timingControlp); - { - m_assignwp = nodep; - m_timingControlp = nodep->timingControlp(); - VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep. - } + m_assignwp = nodep; + m_timingControlp = nodep->timingControlp(); + VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep. } void visit(AstNodeAssign* nodep) override { VL_RESTORER(m_timingControlp); - { - m_timingControlp = nodep->timingControlp(); - iterateChildren(nodep); - } + m_timingControlp = nodep->timingControlp(); + iterateChildren(nodep); } void visit(AstCaseItem* nodep) override { VL_RESTORER(m_constXCvt); - { - m_constXCvt = false; // Avoid losing the X's in casex - iterateAndNextNull(nodep->condsp()); - m_constXCvt = true; - iterateAndNextNull(nodep->stmtsp()); - } + m_constXCvt = false; // Avoid losing the X's in casex + iterateAndNextNull(nodep->condsp()); + m_constXCvt = true; + iterateAndNextNull(nodep->stmtsp()); } void visit(AstNodeDType* nodep) override { VL_RESTORER(m_constXCvt); - { - m_constXCvt = false; // Avoid losing the X's in casex - iterateChildren(nodep); - } + m_constXCvt = false; // Avoid losing the X's in casex + iterateChildren(nodep); } void visit(AstVar* nodep) override { VL_RESTORER(m_allowXUnique); diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 87760c0bb..d302ac4c7 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -7963,36 +7963,28 @@ class WidthVisitor final : public VNVisitor { } void userIterate(AstNode* nodep, WidthVP* vup) { if (!nodep) return; - { - VL_RESTORER(m_vup); - m_vup = vup; - iterate(nodep); - } + VL_RESTORER(m_vup); + m_vup = vup; + iterate(nodep); } void userIterateAndNext(AstNode* nodep, WidthVP* vup) { if (!nodep) return; if (nodep->didWidth()) return; // Avoid iterating list we have already iterated - { - VL_RESTORER(m_vup); - m_vup = vup; - iterateAndNextNull(nodep); - } + VL_RESTORER(m_vup); + m_vup = vup; + iterateAndNextNull(nodep); } void userIterateChildren(AstNode* nodep, WidthVP* vup) { if (!nodep) return; - { - VL_RESTORER(m_vup); - m_vup = vup; - iterateChildren(nodep); - } + VL_RESTORER(m_vup); + m_vup = vup; + iterateChildren(nodep); } void userIterateChildrenBackwardsConst(AstNode* nodep, WidthVP* vup) { if (!nodep) return; - { - VL_RESTORER(m_vup); - m_vup = vup; - iterateChildrenBackwardsConst(nodep); - } + VL_RESTORER(m_vup); + m_vup = vup; + iterateChildrenBackwardsConst(nodep); } public: