From 6c9cbaef620c37ecab11621b8c549fb8514ff37d Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 3 Jul 2025 18:59:32 -0400 Subject: [PATCH] Internals: Clean up some constructors. No functional change intended. --- include/verilated_random.h | 10 +++++----- src/V3Ast.h | 2 +- src/V3AstNodeDType.h | 28 ++++++++++++++-------------- src/V3AstNodeExpr.h | 14 +++++++------- src/V3AstNodeOther.h | 12 ++++++------ src/V3AstNodes.cpp | 2 +- src/V3CUse.cpp | 2 +- src/V3Coverage.cpp | 2 +- src/V3EmitCFunc.h | 4 ++-- src/V3ExecGraph.cpp | 2 +- src/V3LinkDot.cpp | 2 +- src/V3MergeCond.cpp | 4 ++-- src/V3OptionParser.h | 2 +- src/V3Randomize.cpp | 8 ++++---- src/V3SymTable.h | 34 +++++++++++++++++----------------- src/V3Undriven.cpp | 2 +- src/V3UniqueNames.h | 2 +- 17 files changed, 66 insertions(+), 66 deletions(-) diff --git a/include/verilated_random.h b/include/verilated_random.h index f144b179d..1fdf61629 100644 --- a/include/verilated_random.h +++ b/include/verilated_random.h @@ -45,11 +45,11 @@ public: ArrayInfo(const std::string& name, void* datap, int index, const std::vector& indices, const std::vector& idxWidths) - : m_name(name) - , m_datap(datap) - , m_index(index) - , m_indices(indices) - , m_idxWidths(idxWidths) {} + : m_name{name} + , m_datap{datap} + , m_index{index} + , m_indices{indices} + , m_idxWidths{idxWidths} {} }; using ArrayInfoMap = std::map>; diff --git a/src/V3Ast.h b/src/V3Ast.h index 20715688e..dd350519f 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1415,7 +1415,7 @@ public: // cppcheck-suppress noExplicitConstructor constexpr VStrength(en strengthLevel) - : m_e(strengthLevel) {} + : m_e{strengthLevel} {} explicit VStrength(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning constexpr operator en() const { return m_e; } diff --git a/src/V3AstNodeDType.h b/src/V3AstNodeDType.h index 635095644..1a43f4ef0 100644 --- a/src/V3AstNodeDType.h +++ b/src/V3AstNodeDType.h @@ -245,12 +245,12 @@ protected: numeric(VSigning::fromBool(numericUnpack.isSigned())); } AstNodeUOrStructDType(const AstNodeUOrStructDType& other) - : AstNodeDType(other) - , m_name(other.m_name) - , m_uniqueNum(uniqueNumInc()) - , m_packed(other.m_packed) - , m_isFourstate(other.m_isFourstate) - , m_constrainedRand(false) {} + : AstNodeDType{other} + , m_name{other.m_name} + , m_uniqueNum{uniqueNumInc()} + , m_packed{other.m_packed} + , m_isFourstate{other.m_isFourstate} + , m_constrainedRand{false} {} public: ASTGEN_MEMBERS_AstNodeUOrStructDType; @@ -684,8 +684,8 @@ public: } AstDefImplicitDType(const AstDefImplicitDType& other) : AstNodeDType(other) - , m_name(other.m_name) - , m_uniqueNum(uniqueNumInc()) {} + , m_name{other.m_name} + , m_uniqueNum{uniqueNumInc()} {} ASTGEN_MEMBERS_AstDefImplicitDType; int uniqueNum() const { return m_uniqueNum; } bool sameNode(const AstNode* samep) const override { @@ -800,9 +800,9 @@ public: widthFromSub(subDTypep()); } AstEnumDType(const AstEnumDType& other) - : AstNodeDType(other) - , m_name(other.m_name) - , m_uniqueNum(uniqueNumInc()) {} + : AstNodeDType{other} + , m_name{other.m_name} + , m_uniqueNum{uniqueNumInc()} {} ASTGEN_MEMBERS_AstEnumDType; const char* broken() const override; @@ -925,7 +925,7 @@ public: AstNode* valuep) : ASTGEN_SUPER_MemberDType(fl) , m_name{name} - , m_constrainedRand(false) { + , m_constrainedRand{false} { childDTypep(dtp); // Only for parser this->valuep(valuep); dtypep(nullptr); // V3Width will resolve @@ -934,7 +934,7 @@ public: AstMemberDType(FileLine* fl, const string& name, AstNodeDType* dtp) : ASTGEN_SUPER_MemberDType(fl) , m_name{name} - , m_constrainedRand(false) { + , m_constrainedRand{false} { UASSERT(dtp, "AstMember created with no dtype"); refDTypep(dtp); dtypep(this); @@ -1434,7 +1434,7 @@ public: // isSoft implies packed AstUnionDType(FileLine* fl, bool isSoft, VSigning numericUnpack) : ASTGEN_SUPER_UnionDType(fl, numericUnpack) - , m_isSoft(isSoft) { + , m_isSoft{isSoft} { packed(packed() | m_isSoft); } ASTGEN_MEMBERS_AstUnionDType; diff --git a/src/V3AstNodeExpr.h b/src/V3AstNodeExpr.h index 970b6e54a..8be95ea1f 100644 --- a/src/V3AstNodeExpr.h +++ b/src/V3AstNodeExpr.h @@ -820,14 +820,14 @@ public: : ASTGEN_SUPER_ConsDynArray(fl) {} explicit AstConsDynArray(FileLine* fl, bool lhsIsValue, AstNode* lhsp) : ASTGEN_SUPER_ConsDynArray(fl) - , m_lhsIsValue(lhsIsValue) { + , m_lhsIsValue{lhsIsValue} { this->lhsp(lhsp); } explicit AstConsDynArray(FileLine* fl, bool lhsIsValue, AstNode* lhsp, bool rhsIsValue, AstNode* rhsp) : ASTGEN_SUPER_ConsDynArray(fl) - , m_lhsIsValue(lhsIsValue) - , m_rhsIsValue(rhsIsValue) { + , m_lhsIsValue{lhsIsValue} + , m_rhsIsValue{rhsIsValue} { this->lhsp(lhsp); this->rhsp(rhsp); } @@ -902,14 +902,14 @@ public: : ASTGEN_SUPER_ConsQueue(fl) {} explicit AstConsQueue(FileLine* fl, bool lhsIsValue, AstNode* lhsp) : ASTGEN_SUPER_ConsQueue(fl) - , m_lhsIsValue(lhsIsValue) { + , m_lhsIsValue{lhsIsValue} { this->lhsp(lhsp); } explicit AstConsQueue(FileLine* fl, bool lhsIsValue, AstNode* lhsp, bool rhsIsValue, AstNode* rhsp) : ASTGEN_SUPER_ConsQueue(fl) - , m_lhsIsValue(lhsIsValue) - , m_rhsIsValue(rhsIsValue) { + , m_lhsIsValue{lhsIsValue} + , m_rhsIsValue{rhsIsValue} { this->lhsp(lhsp); this->rhsp(rhsp); } @@ -1605,7 +1605,7 @@ public: AstLambdaArgRef(FileLine* fl, const string& name, bool index) : ASTGEN_SUPER_LambdaArgRef(fl) , m_name{name} - , m_index(index) {} + , m_index{index} {} bool sameNode(const AstNode* /*samep*/) const override { return true; } string emitVerilog() override { return name(); } string emitC() override { V3ERROR_NA_RETURN(""); } diff --git a/src/V3AstNodeOther.h b/src/V3AstNodeOther.h index 2a4304ccf..6502a8838 100644 --- a/src/V3AstNodeOther.h +++ b/src/V3AstNodeOther.h @@ -510,7 +510,7 @@ public: AstNodeReadWriteMem(VNType t, FileLine* fl, bool hex, AstNodeExpr* filenamep, AstNodeExpr* memp, AstNodeExpr* lsbp, AstNodeExpr* msbp) : AstNodeStmt{t, fl} - , m_isHex(hex) { + , m_isHex{hex} { this->filenamep(filenamep); this->memp(memp); this->lsbp(lsbp); @@ -1114,7 +1114,7 @@ class AstConstraint final : public AstNode { public: AstConstraint(FileLine* fl, const string& name, AstNode* itemsp) : ASTGEN_SUPER_Constraint(fl) - , m_name(name) { + , m_name{name} { addItemsp(itemsp); } ASTGEN_MEMBERS_AstConstraint; @@ -1579,7 +1579,7 @@ public: AstPragma(FileLine* fl, VPragmaType pragType, const VTimescale& timescale) : ASTGEN_SUPER_Pragma(fl) , m_pragType{pragType} - , m_timescale(timescale) {} + , m_timescale{timescale} {} ASTGEN_MEMBERS_AstPragma; VPragmaType pragType() const { return m_pragType; } // *=type of the pragma bool isPredictOptimizable() const override { return false; } @@ -2880,7 +2880,7 @@ class AstCReset final : public AstNodeStmt { public: AstCReset(FileLine* fl, AstVarRef* varrefp, bool constructing) : ASTGEN_SUPER_CReset(fl) - , m_constructing(constructing) { + , m_constructing{constructing} { this->varrefp(varrefp); } ASTGEN_MEMBERS_AstCReset; @@ -3518,7 +3518,7 @@ class AstStop final : public AstNodeStmt { public: AstStop(FileLine* fl, bool isFatal) : ASTGEN_SUPER_Stop(fl) - , m_isFatal(isFatal) {} + , m_isFatal{isFatal} {} ASTGEN_MEMBERS_AstStop; void dump(std::ostream& str) const override; void dumpJson(std::ostream& str) const override; @@ -4094,7 +4094,7 @@ public: explicit AstTextBlock(FileLine* fl, const string& textp = "", bool tracking = false, bool commas = false) : ASTGEN_SUPER_TextBlock(fl, textp, tracking) - , m_commas(commas) {} + , m_commas{commas} {} ASTGEN_MEMBERS_AstTextBlock; bool commas() const { return m_commas; } void commas(bool flag) { m_commas = flag; } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 7903046c6..5c073487b 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -788,7 +788,7 @@ string AstVar::dpiTmpVarType(const string& varName) const { public: explicit converter(const string& name) - : m_name(name) {} + : m_name{name} {} }; return converter{varName}.convert(this); } diff --git a/src/V3CUse.cpp b/src/V3CUse.cpp index 46505673f..e51507c39 100644 --- a/src/V3CUse.cpp +++ b/src/V3CUse.cpp @@ -92,7 +92,7 @@ class CUseVisitor final : public VNVisitorConst { public: // CONSTRUCTORS explicit CUseVisitor(AstNodeModule* modp) - : m_modp(modp) { + : m_modp{modp} { iterateConst(modp); for (auto& used : m_didUse) { diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index a5ef8f363..3ec67eb85 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -83,7 +83,7 @@ class CoverageVisitor final : public VNVisitor { CoverTerm(AstNodeExpr* exprp, bool objective, const string& emitV) : m_exprp{exprp} , m_objective{objective} - , m_emitV(emitV) {} + , m_emitV{emitV} {} }; using CoverExpr = std::deque; using CoverExprs = std::list; diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index a5bc9f002..491e6c5a2 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -93,7 +93,7 @@ class EmitCLazyDecls final : public VNVisitorConst { public: explicit EmitCLazyDecls(EmitCBaseVisitorConst& emitter) - : m_emitter(emitter) {} + : m_emitter{emitter} {} void emit(AstNode* nodep) { m_needsBlankLine = false; iterateChildrenConst(nodep); @@ -1513,7 +1513,7 @@ public: } // LCOV_EXCL_STOP EmitCFunc() - : m_lazyDecls(*this) {} + : m_lazyDecls{*this} {} EmitCFunc(AstNode* nodep, V3OutCFile* ofp, AstCFile* cfilep, bool trackText = false) : EmitCFunc{} { setOutputFile(ofp, cfilep); diff --git a/src/V3ExecGraph.cpp b/src/V3ExecGraph.cpp index b470041d1..69735a309 100644 --- a/src/V3ExecGraph.cpp +++ b/src/V3ExecGraph.cpp @@ -88,7 +88,7 @@ public: static std::unordered_map mtaskState; explicit ThreadSchedule(uint32_t nThreads) - : m_id(s_nextId++) + : m_id{s_nextId++} , threads{nThreads} {} ThreadSchedule(ThreadSchedule&&) = default; ThreadSchedule& operator=(ThreadSchedule&&) = default; diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 64eaf05fe..e43da39fb 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -211,7 +211,7 @@ public: LinkDotState(AstNetlist* rootp, VLinkDotStep step) : m_syms{rootp} , m_mods{rootp} - , m_step(step) { + , m_step{step} { UINFO(4, __FUNCTION__ << ": "); s_errorThisp = this; V3Error::errorExitCb(preErrorDumpHandler); // If get error, dump self diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 52aa77532..4860affd6 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -276,7 +276,7 @@ class CodeMotionAnalysisVisitor final : public VNVisitorConst { // CONSTRUCTOR CodeMotionAnalysisVisitor(AstNode* nodep, StmtPropertiesAllocator& stmtProperties) - : m_stmtProperties(stmtProperties) { + : m_stmtProperties{stmtProperties} { iterateAndNextConstNull(nodep); } @@ -399,7 +399,7 @@ class CodeMotionOptimizeVisitor final : public VNVisitor { // CONSTRUCTOR CodeMotionOptimizeVisitor(AstNode* nodep, const StmtPropertiesAllocator& stmtProperties) - : m_stmtProperties(stmtProperties) { + : m_stmtProperties{stmtProperties} { // We assert the given node is at the head of the list otherwise we might move a node // before the given node. This is easy to fix in the above iteration with a check on a // boundary node we should not move past, if we ever need to do so. diff --git a/src/V3OptionParser.h b/src/V3OptionParser.h index b7bcc60b9..ac70c07c4 100644 --- a/src/V3OptionParser.h +++ b/src/V3OptionParser.h @@ -153,7 +153,7 @@ public: // CONSTRUCTORS explicit AppendHelper(V3OptionParser& parser) - : m_parser(parser) {} + : m_parser{parser} {} }; #define V3OPTION_PARSER_DECL_TAGS \ diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 97b38e744..de73e9523 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -1206,9 +1206,9 @@ class CaptureVisitor final : public VNVisitor { public: explicit CaptureVisitor(AstNode* const nodep, AstNodeModule* callerp, AstClass* const targetp) - : m_argsp(nullptr) - , m_callerp(callerp) - , m_targetp(targetp) { + : m_argsp{nullptr} + , m_callerp{callerp} + , m_targetp{targetp} { iterateAndNextNull(nodep); } @@ -2355,7 +2355,7 @@ class RandomizeVisitor final : public VNVisitor { public: // CONSTRUCTORS explicit RandomizeVisitor(AstNetlist* nodep) - : m_inlineUniqueNames("__Vrandwith") { + : m_inlineUniqueNames{"__Vrandwith"} { createRandomizeClassVars(nodep); iterate(nodep); nodep->foreach([&](AstConstraint* constrp) { diff --git a/src/V3SymTable.h b/src/V3SymTable.h index 09d2460ce..c2bf5028f 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -46,12 +46,12 @@ class VSymEnt final { using IdNameMap = std::multimap; IdNameMap m_idNameMap; // Hash of variables by name AstNode* m_nodep; // Node that entry belongs to - VSymEnt* m_fallbackp; // Table "above" this one in name scope, for fallback resolution - VSymEnt* m_parentp; // Table that created this table, dot notation needed to resolve into it - AstNodeModule* m_classOrPackagep; // Package node is in (for V3LinkDot, unused here) + VSymEnt* m_fallbackp = nullptr; // Table "above" this in name scope, for fallback resolution + VSymEnt* m_parentp = nullptr; // Table that created this + AstNodeModule* m_classOrPackagep = nullptr; // Package node is in (for V3LinkDot, unused here) string m_symPrefix; // String to prefix symbols with (for V3LinkDot, unused here) - bool m_exported; // Allow importing - bool m_imported; // Was imported + bool m_exported = true; // Allow importing + bool m_imported = false; // Was imported #ifdef VL_DEBUG VL_DEFINE_DEBUG_FUNCTIONS; #else @@ -68,6 +68,11 @@ public: << std::setw(0) << std::right; os << " se" << cvtToHex(this) << std::setw(0); os << " fallb=se" << cvtToHex(m_fallbackp); + if (m_imported || m_exported) { + os << " "; + if (m_imported) os << "[I]"; + if (m_exported) os << "[E]"; + } if (m_symPrefix != "") os << " symPrefix=" << m_symPrefix; if (nodep()) os << " n=" << nodep(); os << '\n'; @@ -332,25 +337,20 @@ protected: //###################################################################### inline VSymEnt::VSymEnt(VSymGraph* graphp, AstNode* nodep) - : m_nodep(nodep) { + : m_nodep{nodep} { // No argument to set fallbackp, as generally it's wrong to set it in the new call, // Instead it needs to be set on a "findOrNew()" return, as it may have been new'ed // by an earlier search insertion. - m_fallbackp = nullptr; - m_parentp = nullptr; - m_classOrPackagep = nullptr; - m_exported = true; - m_imported = false; graphp->pushNewEnt(this); } inline VSymEnt::VSymEnt(VSymGraph* graphp, const VSymEnt* symp) - : m_nodep(symp->m_nodep) { - m_fallbackp = symp->m_fallbackp; - m_parentp = symp->m_parentp; - m_classOrPackagep = symp->m_classOrPackagep; - m_exported = symp->m_exported; - m_imported = symp->m_imported; + : m_nodep{symp->m_nodep} + , m_fallbackp{symp->m_fallbackp} + , m_parentp{symp->m_parentp} + , m_classOrPackagep{symp->m_classOrPackagep} + , m_exported{symp->m_exported} + , m_imported{symp->m_imported} { graphp->pushNewEnt(this); } diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index ca8492353..800b367c3 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -56,7 +56,7 @@ class UndrivenVarEntry final { public: // CONSTRUCTORS explicit UndrivenVarEntry(AstVar* varp) - : m_varp(varp) { // Construction for when a var is used + : m_varp{varp} { // Construction for when a var is used UINFO(9, "create " << varp); m_wholeFlags.resize(FLAGS_PER_BIT); for (int i = 0; i < FLAGS_PER_BIT; i++) m_wholeFlags[i] = false; diff --git a/src/V3UniqueNames.h b/src/V3UniqueNames.h index a61627834..66f3f6d7a 100644 --- a/src/V3UniqueNames.h +++ b/src/V3UniqueNames.h @@ -38,7 +38,7 @@ public: V3UniqueNames() = default; explicit V3UniqueNames(const std::string& prefix, bool addSuffix = true) : m_prefix{prefix} - , m_addSuffix(addSuffix) { + , m_addSuffix{addSuffix} { if (!m_prefix.empty()) { UASSERT(VString::startsWith(m_prefix, "__V"), "Prefix must start with '__V'"); UASSERT(!VString::endsWith(m_prefix, "_"), "Prefix must not end with '_'");