Internals: Style cleanup. Ignore whitespace if diff. No functional change.

This commit is contained in:
Wilson Snyder
2024-11-10 10:59:18 -05:00
parent 77ef2cd487
commit a68da7e220
22 changed files with 285 additions and 402 deletions
+8 -14
View File
@@ -510,10 +510,8 @@ class AssertVisitor final : public VNVisitor {
// Don't sample sensitivities // Don't sample sensitivities
void visit(AstSenItem* nodep) override { void visit(AstSenItem* nodep) override {
VL_RESTORER(m_inSampled); VL_RESTORER(m_inSampled);
{ m_inSampled = false;
m_inSampled = false; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
//========== Statements //========== Statements
@@ -691,12 +689,10 @@ class AssertVisitor final : public VNVisitor {
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
VL_RESTORER(m_modPastNum); VL_RESTORER(m_modPastNum);
VL_RESTORER(m_modStrobeNum); VL_RESTORER(m_modStrobeNum);
{ m_modp = nodep;
m_modp = nodep; m_modPastNum = 0;
m_modPastNum = 0; m_modStrobeNum = 0;
m_modStrobeNum = 0; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNodeProcedure* nodep) override { void visit(AstNodeProcedure* nodep) override {
VL_RESTORER(m_procedurep); VL_RESTORER(m_procedurep);
@@ -707,10 +703,8 @@ class AssertVisitor final : public VNVisitor {
// This code is needed rather than a visitor in V3Begin, // This code is needed rather than a visitor in V3Begin,
// because V3Assert is called before V3Begin // because V3Assert is called before V3Begin
VL_RESTORER(m_beginp); VL_RESTORER(m_beginp);
{ m_beginp = nodep;
m_beginp = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNode* nodep) override { iterateChildren(nodep); } void visit(AstNode* nodep) override { iterateChildren(nodep); }
+45 -48
View File
@@ -54,8 +54,10 @@ public:
//###################################################################### //######################################################################
class BeginVisitor final : public VNVisitor { class BeginVisitor final : public VNVisitor {
// STATE // STATE - across all visitors
BeginState* const m_statep; // Current global state BeginState* const m_statep; // Current global state
// STATE - for current visit position (use VL_RESTORER)
AstNodeModule* m_modp = nullptr; // Current module AstNodeModule* m_modp = nullptr; // Current module
AstNodeFTask* m_ftaskp = nullptr; // Current function/task AstNodeFTask* m_ftaskp = nullptr; // Current function/task
AstNode* m_liftedp = nullptr; // Local nodes we are lifting into m_ftaskp 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 { void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = nodep;
m_modp = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNodeFTask* nodep) override { void visit(AstNodeFTask* nodep) override {
UINFO(8, " " << nodep << endl); UINFO(8, " " << nodep << endl);
@@ -164,29 +164,28 @@ class BeginVisitor final : public VNVisitor {
// inside the function. // inside the function.
// Process children // Process children
VL_RESTORER(m_displayScope); VL_RESTORER(m_displayScope);
VL_RESTORER(m_ftaskp);
VL_RESTORER(m_liftedp);
VL_RESTORER(m_namedScope); VL_RESTORER(m_namedScope);
VL_RESTORER(m_unnamedScope); VL_RESTORER(m_unnamedScope);
{ m_displayScope = dot(m_displayScope, nodep->name());
m_displayScope = dot(m_displayScope, nodep->name()); m_namedScope = "";
m_namedScope = ""; m_unnamedScope = "";
m_unnamedScope = ""; m_ftaskp = nodep;
m_ftaskp = nodep; m_liftedp = nullptr;
m_liftedp = nullptr; iterateChildren(nodep);
iterateChildren(nodep); nodep->foreach([&](AstInitialStatic* const initp) {
nodep->foreach([&](AstInitialStatic* const initp) { initp->unlinkFrBack();
initp->unlinkFrBack(); m_ftaskp->addHereThisAsNext(initp);
m_ftaskp->addHereThisAsNext(initp); });
}); if (m_liftedp) {
if (m_liftedp) { // Place lifted nodes at beginning of stmtsp, so Var nodes appear before referenced
// Place lifted nodes at beginning of stmtsp, so Var nodes appear before referenced if (AstNode* const stmtsp = nodep->stmtsp()) {
if (AstNode* const stmtsp = nodep->stmtsp()) { stmtsp->unlinkFrBackWithNext();
stmtsp->unlinkFrBackWithNext(); m_liftedp->addNext(stmtsp);
m_liftedp->addNext(stmtsp);
}
nodep->addStmtsp(m_liftedp);
m_liftedp = nullptr;
} }
m_ftaskp = nullptr; nodep->addStmtsp(m_liftedp);
m_liftedp = nullptr;
} }
} }
void visit(AstBegin* nodep) override { void visit(AstBegin* nodep) override {
@@ -196,30 +195,28 @@ class BeginVisitor final : public VNVisitor {
VL_RESTORER(m_namedScope); VL_RESTORER(m_namedScope);
VL_RESTORER(m_unnamedScope); VL_RESTORER(m_unnamedScope);
{ {
{ VL_RESTORER(m_keepBegins);
VL_RESTORER(m_keepBegins); m_keepBegins = false;
m_keepBegins = false; dotNames(nodep, "__BEGIN__");
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);
} }
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 { void visit(AstVar* nodep) override {
// If static variable, move it outside a function. // If static variable, move it outside a function.
+13 -19
View File
@@ -129,24 +129,20 @@ class ClassVisitor final : public VNVisitor {
VL_RESTORER(m_classScopep); VL_RESTORER(m_classScopep);
VL_RESTORER(m_packageScopep); VL_RESTORER(m_packageScopep);
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = nodep;
m_modp = nodep; m_classPackagep = packagep;
m_classPackagep = packagep; m_classScopep = classScopep;
m_classScopep = classScopep; m_packageScopep = scopep;
m_packageScopep = scopep; m_prefix = nodep->name() + "__02e"; // .
m_prefix = nodep->name() + "__02e"; // . iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
// Visit for NodeModules that are not AstClass (AstClass is-a AstNodeModule) // Visit for NodeModules that are not AstClass (AstClass is-a AstNodeModule)
VL_RESTORER(m_prefix); VL_RESTORER(m_prefix);
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = nodep;
m_modp = nodep; m_prefix = nodep->name() + "__03a__03a"; // ::
m_prefix = nodep->name() + "__03a__03a"; // :: iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstVar* nodep) override { void visit(AstVar* nodep) override {
@@ -174,12 +170,10 @@ class ClassVisitor final : public VNVisitor {
void visit(AstNodeFTask* nodep) override { void visit(AstNodeFTask* nodep) override {
VL_RESTORER(m_ftaskp); VL_RESTORER(m_ftaskp);
{ m_ftaskp = nodep;
m_ftaskp = nodep; iterateChildren(nodep);
iterateChildren(nodep); if (m_packageScopep && nodep->isStatic()) {
if (m_packageScopep && nodep->isStatic()) { m_toScopeMoves.emplace_back(nodep, m_packageScopep);
m_toScopeMoves.emplace_back(nodep, m_packageScopep);
}
} }
} }
void visit(AstCFunc* nodep) override { void visit(AstCFunc* nodep) override {
+2 -4
View File
@@ -173,10 +173,8 @@ class CleanVisitor final : public VNVisitor {
// VISITORS // VISITORS
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = nodep;
m_modp = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNodeUniop* nodep) override { void visit(AstNodeUniop* nodep) override {
iterateChildren(nodep); iterateChildren(nodep);
+10 -18
View File
@@ -2333,20 +2333,16 @@ class ConstVisitor final : public VNVisitor {
} }
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = nodep;
m_modp = nodep; m_concswapNames.reset();
m_concswapNames.reset(); iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstCFunc* nodep) override { void visit(AstCFunc* nodep) override {
// No ASSIGNW removals under funcs, we've long eliminated INITIALs // No ASSIGNW removals under funcs, we've long eliminated INITIALs
// (We should perhaps rename the assignw's to just assigns) // (We should perhaps rename the assignw's to just assigns)
VL_RESTORER(m_wremove); VL_RESTORER(m_wremove);
{ m_wremove = false;
m_wremove = false; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstCLocalScope* nodep) override { void visit(AstCLocalScope* nodep) override {
iterateChildren(nodep); iterateChildren(nodep);
@@ -2359,11 +2355,9 @@ class ConstVisitor final : public VNVisitor {
// No ASSIGNW removals under scope, we've long eliminated INITIALs // No ASSIGNW removals under scope, we've long eliminated INITIALs
VL_RESTORER(m_wremove); VL_RESTORER(m_wremove);
VL_RESTORER(m_scopep); VL_RESTORER(m_scopep);
{ m_wremove = false;
m_wremove = false; m_scopep = nodep;
m_scopep = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void swapSides(AstNodeBiCom* nodep) { void swapSides(AstNodeBiCom* nodep) {
@@ -2695,10 +2689,8 @@ class ConstVisitor final : public VNVisitor {
void visit(AstAttrOf* nodep) override { void visit(AstAttrOf* nodep) override {
VL_RESTORER(m_attrp); VL_RESTORER(m_attrp);
{ m_attrp = nodep;
m_attrp = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstArraySel* nodep) override { void visit(AstArraySel* nodep) override {
+16 -22
View File
@@ -71,35 +71,29 @@ class DepthVisitor final : public VNVisitor {
void visit(AstCFunc* nodep) override { void visit(AstCFunc* nodep) override {
VL_RESTORER(m_cfuncp); VL_RESTORER(m_cfuncp);
VL_RESTORER(m_mtaskbodyp); VL_RESTORER(m_mtaskbodyp);
{ m_cfuncp = nodep;
m_cfuncp = nodep; m_mtaskbodyp = nullptr;
m_mtaskbodyp = nullptr; m_depth = 0;
m_depth = 0; m_maxdepth = 0;
m_maxdepth = 0; m_tempNames.reset();
m_tempNames.reset(); iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstMTaskBody* nodep) override { void visit(AstMTaskBody* nodep) override {
VL_RESTORER(m_cfuncp); VL_RESTORER(m_cfuncp);
VL_RESTORER(m_mtaskbodyp); VL_RESTORER(m_mtaskbodyp);
{ m_cfuncp = nullptr;
m_cfuncp = nullptr; m_mtaskbodyp = nodep;
m_mtaskbodyp = nodep; m_depth = 0;
m_depth = 0; m_maxdepth = 0;
m_maxdepth = 0; // We don't reset the names, as must share across tasks
// We don't reset the names, as must share across tasks iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visitStmt(AstNodeStmt* nodep) { void visitStmt(AstNodeStmt* nodep) {
VL_RESTORER(m_stmtp); VL_RESTORER(m_stmtp);
{ m_stmtp = nodep;
m_stmtp = nodep; m_depth = 0;
m_depth = 0; m_maxdepth = 0;
m_maxdepth = 0; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNodeStmt* nodep) override { visitStmt(nodep); } void visit(AstNodeStmt* nodep) override { visitStmt(nodep); }
// Operators // Operators
+6 -10
View File
@@ -70,21 +70,17 @@ class DepthBlockVisitor final : public VNVisitor {
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
UINFO(4, " MOD " << nodep << endl); UINFO(4, " MOD " << nodep << endl);
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = nodep;
m_modp = nodep; m_deepNum = 0;
m_deepNum = 0; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstCFunc* nodep) override { void visit(AstCFunc* nodep) override {
// We recurse into this. // We recurse into this.
VL_RESTORER(m_depth); VL_RESTORER(m_depth);
VL_RESTORER(m_cfuncp); VL_RESTORER(m_cfuncp);
{ m_depth = 0;
m_depth = 0; m_cfuncp = nodep;
m_cfuncp = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstStmtExpr* nodep) override {} // Stop recursion after introducing new function 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 void visit(AstJumpBlock*) override {} // Stop recursion as can't break up across a jump
+5 -7
View File
@@ -208,13 +208,11 @@ class DescopeVisitor final : public VNVisitor {
// VISITORS // VISITORS
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = nodep;
m_modp = nodep; m_modFuncs.clear();
m_modFuncs.clear(); m_modSingleton = modIsSingleton(m_modp);
m_modSingleton = modIsSingleton(m_modp); iterateChildren(nodep);
iterateChildren(nodep); makePublicFuncWrappers();
makePublicFuncWrappers();
}
} }
void visit(AstScope* nodep) override { void visit(AstScope* nodep) override {
m_scopep = nodep; m_scopep = nodep;
+4 -8
View File
@@ -300,10 +300,8 @@ class EmitCSyms final : EmitCBaseVisitorConst {
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
nameCheck(nodep); nameCheck(nodep);
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = nodep;
m_modp = nodep; iterateChildrenConst(nodep);
iterateChildrenConst(nodep);
}
} }
void visit(AstCellInlineScope* nodep) override { void visit(AstCellInlineScope* nodep) override {
if (v3Global.opt.vpi()) { if (v3Global.opt.vpi()) {
@@ -372,10 +370,8 @@ class EmitCSyms final : EmitCBaseVisitorConst {
nameCheck(nodep); nameCheck(nodep);
if (nodep->dpiImportPrototype() || nodep->dpiExportDispatcher()) m_dpis.push_back(nodep); if (nodep->dpiImportPrototype() || nodep->dpiExportDispatcher()) m_dpis.push_back(nodep);
VL_RESTORER(m_cfuncp); VL_RESTORER(m_cfuncp);
{ m_cfuncp = nodep;
m_cfuncp = nodep; iterateChildrenConst(nodep);
iterateChildrenConst(nodep);
}
} }
//--------------------------------------- //---------------------------------------
+5 -7
View File
@@ -393,13 +393,11 @@ class EmitVBaseVisitorConst VL_NOT_FINAL : public EmitCBaseVisitorConst {
} }
void visit(AstTextBlock* nodep) override { void visit(AstTextBlock* nodep) override {
visit(static_cast<AstNodeSimpleText*>(nodep)); visit(static_cast<AstNodeSimpleText*>(nodep));
{ VL_RESTORER(m_suppressSemi);
VL_RESTORER(m_suppressSemi); m_suppressVarSemi = nodep->commas();
m_suppressVarSemi = nodep->commas(); for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) {
for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) { iterateConst(childp);
iterateConst(childp); if (nodep->commas() && childp->nextp()) puts(", ");
if (nodep->commas() && childp->nextp()) puts(", ");
}
} }
} }
void visit(AstScopeName* nodep) override {} void visit(AstScopeName* nodep) override {}
+4 -6
View File
@@ -286,12 +286,10 @@ class LinkCellsVisitor final : public VNVisitor {
AstNode* const cellsp = nodep->cellsp()->unlinkFrBackWithNext(); AstNode* const cellsp = nodep->cellsp()->unlinkFrBackWithNext();
// Module may have already linked, so need to pick up these new cells // Module may have already linked, so need to pick up these new cells
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_modp = modp;
m_modp = modp; // Important that this adds to end, as next iterate assumes does all cells
// Important that this adds to end, as next iterate assumes does all cells modp->addStmtsp(cellsp);
modp->addStmtsp(cellsp); iterateAndNextNull(cellsp);
iterateAndNextNull(cellsp);
}
} }
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
} }
+12 -18
View File
@@ -163,11 +163,9 @@ class LinkJumpVisitor final : public VNVisitor {
if (nodep->dead()) return; if (nodep->dead()) return;
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
VL_RESTORER(m_modRepeatNum); VL_RESTORER(m_modRepeatNum);
{ m_modp = nodep;
m_modp = nodep; m_modRepeatNum = 0;
m_modRepeatNum = 0; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNodeFTask* nodep) override { void visit(AstNodeFTask* nodep) override {
m_ftaskp = nodep; m_ftaskp = nodep;
@@ -236,15 +234,13 @@ class LinkJumpVisitor final : public VNVisitor {
m_unrollFull = VOptionBool::OPT_DEFAULT_FALSE; m_unrollFull = VOptionBool::OPT_DEFAULT_FALSE;
VL_RESTORER(m_loopp); VL_RESTORER(m_loopp);
VL_RESTORER(m_loopInc); VL_RESTORER(m_loopInc);
{ m_loopp = nodep;
m_loopp = nodep; m_loopInc = false;
m_loopInc = false; iterateAndNextNull(nodep->precondsp());
iterateAndNextNull(nodep->precondsp()); iterateAndNextNull(nodep->condp());
iterateAndNextNull(nodep->condp()); iterateAndNextNull(nodep->stmtsp());
iterateAndNextNull(nodep->stmtsp()); m_loopInc = true;
m_loopInc = true; iterateAndNextNull(nodep->incsp());
iterateAndNextNull(nodep->incsp());
}
} }
void visit(AstDoWhile* nodep) override { void visit(AstDoWhile* nodep) override {
// It is converted to AstWhile in this visit method // It is converted to AstWhile in this visit method
@@ -272,10 +268,8 @@ class LinkJumpVisitor final : public VNVisitor {
} }
void visit(AstNodeForeach* nodep) override { void visit(AstNodeForeach* nodep) override {
VL_RESTORER(m_loopp); VL_RESTORER(m_loopp);
{ m_loopp = nodep;
m_loopp = nodep; iterateAndNextNull(nodep->stmtsp());
iterateAndNextNull(nodep->stmtsp());
}
} }
void visit(AstReturn* nodep) override { void visit(AstReturn* nodep) override {
iterateChildren(nodep); iterateChildren(nodep);
+57 -73
View File
@@ -101,11 +101,9 @@ class LinkParseVisitor final : public VNVisitor {
void visitIterateNodeDType(AstNodeDType* nodep) { void visitIterateNodeDType(AstNodeDType* nodep) {
if (!nodep->user1SetOnce()) { // Process only once. if (!nodep->user1SetOnce()) { // Process only once.
cleanFileline(nodep); cleanFileline(nodep);
{ VL_RESTORER(m_dtypep);
VL_RESTORER(m_dtypep); m_dtypep = nodep;
m_dtypep = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
} }
@@ -186,58 +184,54 @@ class LinkParseVisitor final : public VNVisitor {
cleanFileline(nodep); cleanFileline(nodep);
VL_RESTORER(m_ftaskp); VL_RESTORER(m_ftaskp);
VL_RESTORER(m_lifetime); VL_RESTORER(m_lifetime);
{ m_ftaskp = nodep;
m_ftaskp = nodep; if (!nodep->lifetime().isNone()) {
if (!nodep->lifetime().isNone()) { m_lifetime = nodep->lifetime();
m_lifetime = nodep->lifetime(); } else {
} else { if (nodep->classMethod()) {
if (nodep->classMethod()) { // Class methods are automatic by default
// Class methods are automatic by default m_lifetime = VLifetime::AUTOMATIC;
m_lifetime = VLifetime::AUTOMATIC; } else if (nodep->dpiImport() || VN_IS(nodep, Property)) {
} else if (nodep->dpiImport() || VN_IS(nodep, Property)) { // DPI-imported functions and properties don't have lifetime specifiers
// DPI-imported functions and properties don't have lifetime specifiers m_lifetime = VLifetime::NONE;
m_lifetime = VLifetime::NONE; }
} for (AstNode* itemp = nodep->stmtsp(); itemp; itemp = itemp->nextp()) {
for (AstNode* itemp = nodep->stmtsp(); itemp; itemp = itemp->nextp()) { AstVar* const varp = VN_CAST(itemp, Var);
AstVar* const varp = VN_CAST(itemp, Var); if (varp && varp->valuep() && varp->lifetime().isNone()
if (varp && varp->valuep() && varp->lifetime().isNone() && m_lifetime.isStatic() && !varp->isIO()) {
&& m_lifetime.isStatic() && !varp->isIO()) { if (VN_IS(m_modp, Module)) {
if (VN_IS(m_modp, Module)) { nodep->v3warn(IMPLICITSTATIC,
nodep->v3warn(IMPLICITSTATIC, "Function/task's lifetime implicitly set to static\n"
"Function/task's lifetime implicitly set to static\n" << nodep->warnMore()
<< nodep->warnMore() << "... Suggest use 'function automatic' or "
<< "... Suggest use 'function automatic' or " "'function static'\n"
"'function static'\n" << nodep->warnContextPrimary() << '\n'
<< nodep->warnContextPrimary() << '\n' << varp->warnOther()
<< varp->warnOther() << "... Location of implicit static variable\n"
<< "... Location of implicit static variable\n" << varp->warnContextSecondary() << '\n'
<< varp->warnContextSecondary() << '\n' << "... Suggest use 'function automatic' or "
<< "... Suggest use 'function automatic' or " "'function static'");
"'function static'"); } else {
} else { varp->v3warn(IMPLICITSTATIC,
varp->v3warn(IMPLICITSTATIC, "Variable's lifetime implicitly set to static\n"
"Variable's lifetime implicitly set to static\n" << nodep->warnMore()
<< nodep->warnMore() << "... Suggest use 'static' before "
<< "... Suggest use 'static' before " "variable declaration'");
"variable declaration'");
}
} }
} }
nodep->lifetime(m_lifetime);
} }
iterateChildren(nodep); nodep->lifetime(m_lifetime);
} }
iterateChildren(nodep);
} }
} }
void visit(AstNodeFTaskRef* nodep) override { void visit(AstNodeFTaskRef* nodep) override {
if (!nodep->user1SetOnce()) { // Process only once. if (!nodep->user1SetOnce()) { // Process only once.
cleanFileline(nodep); cleanFileline(nodep);
UINFO(5, " " << nodep << endl); UINFO(5, " " << nodep << endl);
{ VL_RESTORER(m_valueModp);
VL_RESTORER(m_valueModp); m_valueModp = nullptr;
m_valueModp = nullptr; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
} }
void visit(AstNodeDType* nodep) override { visitIterateNodeDType(nodep); } void visit(AstNodeDType* nodep) override { visitIterateNodeDType(nodep); }
@@ -580,19 +574,15 @@ class LinkParseVisitor final : public VNVisitor {
void visit(AstRepeat* nodep) override { void visit(AstRepeat* nodep) override {
cleanFileline(nodep); cleanFileline(nodep);
VL_RESTORER(m_insideLoop); VL_RESTORER(m_insideLoop);
{ m_insideLoop = true;
m_insideLoop = true; checkIndent(nodep, nodep->stmtsp());
checkIndent(nodep, nodep->stmtsp()); iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstDoWhile* nodep) override { void visit(AstDoWhile* nodep) override {
cleanFileline(nodep); cleanFileline(nodep);
VL_RESTORER(m_insideLoop); VL_RESTORER(m_insideLoop);
{ m_insideLoop = true;
m_insideLoop = true; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstWait* nodep) override { void visit(AstWait* nodep) override {
cleanFileline(nodep); cleanFileline(nodep);
@@ -608,11 +598,9 @@ class LinkParseVisitor final : public VNVisitor {
void visit(AstWhile* nodep) override { void visit(AstWhile* nodep) override {
cleanFileline(nodep); cleanFileline(nodep);
VL_RESTORER(m_insideLoop); VL_RESTORER(m_insideLoop);
{ m_insideLoop = true;
m_insideLoop = true; checkIndent(nodep, nodep->stmtsp());
checkIndent(nodep, nodep->stmtsp()); iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
V3Config::applyModule(nodep); V3Config::applyModule(nodep);
@@ -651,11 +639,9 @@ class LinkParseVisitor final : public VNVisitor {
void visitIterateNoValueMod(AstNode* nodep) { void visitIterateNoValueMod(AstNode* nodep) {
// Iterate a node which shouldn't have any local variables moved to an Initial // Iterate a node which shouldn't have any local variables moved to an Initial
cleanFileline(nodep); cleanFileline(nodep);
{ VL_RESTORER(m_valueModp);
VL_RESTORER(m_valueModp); m_valueModp = nullptr;
m_valueModp = nullptr; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstNodeProcedure* nodep) override { visitIterateNoValueMod(nodep); } void visit(AstNodeProcedure* nodep) override { visitIterateNoValueMod(nodep); }
void visit(AstAlways* nodep) override { void visit(AstAlways* nodep) override {
@@ -721,13 +707,11 @@ class LinkParseVisitor final : public VNVisitor {
void visit(AstGenCase* nodep) override { void visit(AstGenCase* nodep) override {
++m_genblkNum; ++m_genblkNum;
cleanFileline(nodep); cleanFileline(nodep);
{ VL_RESTORER(m_genblkAbove);
VL_RESTORER(m_genblkAbove); VL_RESTORER(m_genblkNum);
VL_RESTORER(m_genblkNum); m_genblkAbove = m_genblkNum;
m_genblkAbove = m_genblkNum; m_genblkNum = 0;
m_genblkNum = 0; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstGenIf* nodep) override { void visit(AstGenIf* nodep) override {
cleanFileline(nodep); cleanFileline(nodep);
+5 -9
View File
@@ -63,18 +63,14 @@ class LinkResolveVisitor final : public VNVisitor {
if (nodep->dead()) return; if (nodep->dead()) return;
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
VL_RESTORER(m_senitemCvtNum); VL_RESTORER(m_senitemCvtNum);
{ m_modp = nodep;
m_modp = nodep; m_senitemCvtNum = 0;
m_senitemCvtNum = 0; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstClass* nodep) override { void visit(AstClass* nodep) override {
VL_RESTORER(m_classp); VL_RESTORER(m_classp);
{ m_classp = nodep;
m_classp = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstInitialAutomatic* nodep) override { void visit(AstInitialAutomatic* nodep) override {
iterateChildren(nodep); iterateChildren(nodep);
+3 -5
View File
@@ -145,11 +145,9 @@ class ReloopVisitor final : public VNVisitor {
// VISITORS // VISITORS
void visit(AstCFunc* nodep) override { void visit(AstCFunc* nodep) override {
VL_RESTORER(m_cfuncp); VL_RESTORER(m_cfuncp);
{ m_cfuncp = nodep;
m_cfuncp = nodep; iterateChildren(nodep);
iterateChildren(nodep); mergeEnd(); // Finish last pending merge, if any
mergeEnd(); // Finish last pending merge, if any
}
} }
void visit(AstNodeAssign* nodep) override { void visit(AstNodeAssign* nodep) override {
if (!m_cfuncp) return; if (!m_cfuncp) return;
+24 -28
View File
@@ -149,32 +149,30 @@ class ScopeVisitor final : public VNVisitor {
VL_RESTORER(m_aboveCellp); VL_RESTORER(m_aboveCellp);
VL_RESTORER(m_aboveScopep); VL_RESTORER(m_aboveScopep);
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
{ m_aboveScopep = m_scopep;
m_aboveScopep = m_scopep; m_modp = nodep;
m_modp = nodep;
string scopename; string scopename;
if (!m_aboveScopep) { if (!m_aboveScopep) {
scopename = "TOP"; scopename = "TOP";
} else { } else {
scopename = m_aboveScopep->name() + "." + nodep->name(); scopename = m_aboveScopep->name() + "." + nodep->name();
}
UINFO(4, " CLASS AT " << scopename << " " << nodep << endl);
AstNode::user1ClearTree();
const AstNode* const abovep = (m_aboveCellp ? static_cast<AstNode*>(m_aboveCellp)
: static_cast<AstNode*>(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);
} }
UINFO(4, " CLASS AT " << scopename << " " << nodep << endl);
AstNode::user1ClearTree();
const AstNode* const abovep
= (m_aboveCellp ? static_cast<AstNode*>(m_aboveCellp) : static_cast<AstNode*>(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 { // void visit(AstCellInline* nodep) override { //
if (v3Global.opt.vpi()) { if (v3Global.opt.vpi()) {
@@ -334,10 +332,8 @@ class ScopeCleanupVisitor final : public VNVisitor {
void visit(AstScope* nodep) override { void visit(AstScope* nodep) override {
// Want to ignore blocks under it // Want to ignore blocks under it
VL_RESTORER(m_scopep); VL_RESTORER(m_scopep);
{ m_scopep = nodep;
m_scopep = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
virtual void movedDeleteOrIterate(AstNode* nodep) { virtual void movedDeleteOrIterate(AstNode* nodep) {
+3 -5
View File
@@ -383,11 +383,9 @@ private:
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
VL_RESTORER(m_modTables); VL_RESTORER(m_modTables);
{ m_modp = nodep;
m_modp = nodep; m_modTables = 0;
m_modTables = 0; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstScope* nodep) override { void visit(AstScope* nodep) override {
UINFO(4, " SCOPE " << nodep << endl); UINFO(4, " SCOPE " << nodep << endl);
+17 -23
View File
@@ -217,20 +217,18 @@ private:
} }
void visit(AstNodeFTask* nodep) override { void visit(AstNodeFTask* nodep) override {
UINFO(9, " TASK " << nodep << endl); UINFO(9, " TASK " << nodep << endl);
{ VL_RESTORER(m_curVxp);
VL_RESTORER(m_curVxp); m_curVxp = getFTaskVertex(nodep);
m_curVxp = getFTaskVertex(nodep); if (nodep->dpiImport()) m_curVxp->noInline(true);
if (nodep->dpiImport()) m_curVxp->noInline(true); if (nodep->classMethod()) m_curVxp->noInline(true); // Until V3Task supports it
if (nodep->classMethod()) m_curVxp->noInline(true); // Until V3Task supports it if (nodep->recursive()) m_curVxp->noInline(true);
if (nodep->recursive()) m_curVxp->noInline(true); if (nodep->isConstructor()) {
if (nodep->isConstructor()) { m_curVxp->noInline(true);
m_curVxp->noInline(true); m_ctorp = nodep;
m_ctorp = nodep; UASSERT_OBJ(m_classp, nodep, "Ctor not under class");
UASSERT_OBJ(m_classp, nodep, "Ctor not under class"); m_funcToClassMap[nodep] = m_classp;
m_funcToClassMap[nodep] = m_classp;
}
iterateChildren(nodep);
} }
iterateChildren(nodep);
} }
void visit(AstPragma* nodep) override { void visit(AstPragma* nodep) override {
if (nodep->pragType() == VPragmaType::NO_INLINE_TASK) { 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. // scope then the caller, so we need to restore state.
VL_RESTORER(m_scopep); VL_RESTORER(m_scopep);
VL_RESTORER(m_insStmtp); VL_RESTORER(m_insStmtp);
{ m_scopep = m_statep->getScope(nodep);
m_scopep = m_statep->getScope(nodep); iterate(nodep);
iterate(nodep);
}
} }
void insertBeforeStmt(AstNode* nodep, AstNode* newp) { void insertBeforeStmt(AstNode* nodep, AstNode* newp) {
if (debug() >= 9) nodep->dumpTree("- newstmt: "); if (debug() >= 9) nodep->dumpTree("- newstmt: ");
@@ -1409,12 +1405,10 @@ class TaskVisitor final : public VNVisitor {
void visit(AstNodeModule* nodep) override { void visit(AstNodeModule* nodep) override {
VL_RESTORER(m_modp); VL_RESTORER(m_modp);
VL_RESTORER(m_modNCalls); VL_RESTORER(m_modNCalls);
{ m_modp = nodep;
m_modp = nodep; m_insStmtp = nullptr;
m_insStmtp = nullptr; m_modNCalls = 0;
m_modNCalls = 0; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstWith* nodep) override { void visit(AstWith* nodep) override {
if (nodep->user1SetOnce()) { if (nodep->user1SetOnce()) {
+2 -4
View File
@@ -883,10 +883,8 @@ class TraceVisitor final : public VNVisitor {
} }
} }
VL_RESTORER(m_cfuncp); VL_RESTORER(m_cfuncp);
{ m_cfuncp = nodep;
m_cfuncp = nodep; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstTraceDecl* nodep) override { void visit(AstTraceDecl* nodep) override {
UINFO(8, " TRACE " << nodep << endl); UINFO(8, " TRACE " << nodep << endl);
+18 -30
View File
@@ -460,46 +460,36 @@ class UndrivenVisitor final : public VNVisitorConst {
// Don't know what black boxed calls do, assume in+out // Don't know what black boxed calls do, assume in+out
void visit(AstSysIgnore* nodep) override { void visit(AstSysIgnore* nodep) override {
VL_RESTORER(m_inBBox); VL_RESTORER(m_inBBox);
{ m_inBBox = true;
m_inBBox = true; iterateChildrenConst(nodep);
iterateChildrenConst(nodep);
}
} }
void visit(AstAssign* nodep) override { void visit(AstAssign* nodep) override {
VL_RESTORER(m_inProcAssign); VL_RESTORER(m_inProcAssign);
{ m_inProcAssign = true;
m_inProcAssign = true; iterateChildrenConst(nodep);
iterateChildrenConst(nodep);
}
} }
void visit(AstAssignDly* nodep) override { void visit(AstAssignDly* nodep) override {
VL_RESTORER(m_inProcAssign); VL_RESTORER(m_inProcAssign);
{ m_inProcAssign = true;
m_inProcAssign = true; iterateChildrenConst(nodep);
iterateChildrenConst(nodep);
}
} }
void visit(AstAssignW* nodep) override { void visit(AstAssignW* nodep) override {
VL_RESTORER(m_inContAssign); VL_RESTORER(m_inContAssign);
{ m_inContAssign = true;
m_inContAssign = true; iterateChildrenConst(nodep);
iterateChildrenConst(nodep);
}
} }
void visit(AstAlways* nodep) override { void visit(AstAlways* nodep) override {
VL_RESTORER(m_alwaysCombp); VL_RESTORER(m_alwaysCombp);
{ AstNode::user2ClearTree();
AstNode::user2ClearTree(); if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) {
if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) { UINFO(9, " " << nodep << endl);
UINFO(9, " " << nodep << endl); m_alwaysCombp = nodep;
m_alwaysCombp = nodep; } else {
} else { m_alwaysCombp = nullptr;
m_alwaysCombp = nullptr;
}
iterateChildrenConst(nodep);
if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9, " Done " << nodep << endl);
} }
iterateChildrenConst(nodep);
if (nodep->keyword() == VAlwaysKwd::ALWAYS_COMB) UINFO(9, " Done " << nodep << endl);
} }
void visit(AstNodeFTaskRef* nodep) override { void visit(AstNodeFTaskRef* nodep) override {
VL_RESTORER(m_inFTaskRef); VL_RESTORER(m_inFTaskRef);
@@ -509,10 +499,8 @@ class UndrivenVisitor final : public VNVisitorConst {
void visit(AstNodeFTask* nodep) override { void visit(AstNodeFTask* nodep) override {
VL_RESTORER(m_taskp); VL_RESTORER(m_taskp);
{ m_taskp = nodep;
m_taskp = nodep; iterateChildrenConst(nodep);
iterateChildrenConst(nodep);
}
} }
void visit(AstPin* nodep) override { void visit(AstPin* nodep) override {
VL_RESTORER(m_inInoutPin); VL_RESTORER(m_inInoutPin);
+14 -24
View File
@@ -179,43 +179,33 @@ class UnknownVisitor final : public VNVisitor {
void visit(AstAssignDly* nodep) override { void visit(AstAssignDly* nodep) override {
VL_RESTORER(m_assigndlyp); VL_RESTORER(m_assigndlyp);
VL_RESTORER(m_timingControlp); VL_RESTORER(m_timingControlp);
{ m_assigndlyp = nodep;
m_assigndlyp = nodep; m_timingControlp = nodep->timingControlp();
m_timingControlp = nodep->timingControlp(); VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep.
VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep.
}
} }
void visit(AstAssignW* nodep) override { void visit(AstAssignW* nodep) override {
VL_RESTORER(m_assignwp); VL_RESTORER(m_assignwp);
VL_RESTORER(m_timingControlp); VL_RESTORER(m_timingControlp);
{ m_assignwp = nodep;
m_assignwp = nodep; m_timingControlp = nodep->timingControlp();
m_timingControlp = nodep->timingControlp(); VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep.
VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep.
}
} }
void visit(AstNodeAssign* nodep) override { void visit(AstNodeAssign* nodep) override {
VL_RESTORER(m_timingControlp); VL_RESTORER(m_timingControlp);
{ m_timingControlp = nodep->timingControlp();
m_timingControlp = nodep->timingControlp(); iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstCaseItem* nodep) override { void visit(AstCaseItem* nodep) override {
VL_RESTORER(m_constXCvt); VL_RESTORER(m_constXCvt);
{ m_constXCvt = false; // Avoid losing the X's in casex
m_constXCvt = false; // Avoid losing the X's in casex iterateAndNextNull(nodep->condsp());
iterateAndNextNull(nodep->condsp()); m_constXCvt = true;
m_constXCvt = true; iterateAndNextNull(nodep->stmtsp());
iterateAndNextNull(nodep->stmtsp());
}
} }
void visit(AstNodeDType* nodep) override { void visit(AstNodeDType* nodep) override {
VL_RESTORER(m_constXCvt); VL_RESTORER(m_constXCvt);
{ m_constXCvt = false; // Avoid losing the X's in casex
m_constXCvt = false; // Avoid losing the X's in casex iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void visit(AstVar* nodep) override { void visit(AstVar* nodep) override {
VL_RESTORER(m_allowXUnique); VL_RESTORER(m_allowXUnique);
+12 -20
View File
@@ -7963,36 +7963,28 @@ class WidthVisitor final : public VNVisitor {
} }
void userIterate(AstNode* nodep, WidthVP* vup) { void userIterate(AstNode* nodep, WidthVP* vup) {
if (!nodep) return; if (!nodep) return;
{ VL_RESTORER(m_vup);
VL_RESTORER(m_vup); m_vup = vup;
m_vup = vup; iterate(nodep);
iterate(nodep);
}
} }
void userIterateAndNext(AstNode* nodep, WidthVP* vup) { void userIterateAndNext(AstNode* nodep, WidthVP* vup) {
if (!nodep) return; if (!nodep) return;
if (nodep->didWidth()) return; // Avoid iterating list we have already iterated if (nodep->didWidth()) return; // Avoid iterating list we have already iterated
{ VL_RESTORER(m_vup);
VL_RESTORER(m_vup); m_vup = vup;
m_vup = vup; iterateAndNextNull(nodep);
iterateAndNextNull(nodep);
}
} }
void userIterateChildren(AstNode* nodep, WidthVP* vup) { void userIterateChildren(AstNode* nodep, WidthVP* vup) {
if (!nodep) return; if (!nodep) return;
{ VL_RESTORER(m_vup);
VL_RESTORER(m_vup); m_vup = vup;
m_vup = vup; iterateChildren(nodep);
iterateChildren(nodep);
}
} }
void userIterateChildrenBackwardsConst(AstNode* nodep, WidthVP* vup) { void userIterateChildrenBackwardsConst(AstNode* nodep, WidthVP* vup) {
if (!nodep) return; if (!nodep) return;
{ VL_RESTORER(m_vup);
VL_RESTORER(m_vup); m_vup = vup;
m_vup = vup; iterateChildrenBackwardsConst(nodep);
iterateChildrenBackwardsConst(nodep);
}
} }
public: public: