From 24a0d2a0c9a26655a1dee646993ece02a09b230a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 1 Jan 2022 11:46:49 -0500 Subject: [PATCH] Internals: Favor member assignment initialization. No functional change intended. --- src/V3Ast.cpp | 22 +--------------------- src/V3Ast.h | 42 ++++++++++++++++++++++-------------------- src/V3Cdc.cpp | 2 +- src/V3Changed.cpp | 15 +++++++-------- src/V3EmitCFunc.h | 12 ++++-------- src/V3EmitV.cpp | 3 +-- src/V3EmitXml.cpp | 2 +- src/V3File.h | 2 +- src/V3Gate.cpp | 17 ++++++++--------- src/V3Global.h | 14 +++++++------- src/V3GraphAcyc.cpp | 4 ++-- src/V3GraphAlg.cpp | 2 +- src/V3GraphStream.h | 4 ++-- src/V3InstrCount.cpp | 4 ++-- src/V3Life.cpp | 17 ++++++++--------- src/V3LinkCells.cpp | 8 ++++---- src/V3LinkDot.cpp | 11 +++++------ src/V3ParseImp.h | 18 ++++++------------ src/V3ParseSym.h | 2 +- src/V3Partition.cpp | 6 +++--- src/V3Partition.h | 2 +- src/V3PreLex.h | 4 ++-- src/V3Scoreboard.h | 2 +- src/V3Simulate.h | 4 ++-- src/V3Undriven.cpp | 6 +++--- 25 files changed, 96 insertions(+), 129 deletions(-) diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 5c322cbbf..4f1ad9232 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -61,33 +61,13 @@ std::ostream& operator<<(std::ostream& os, AstType rhs); AstNode::AstNode(AstType t, FileLine* fl) : m_type{t} , m_fileline{fl} { - editCountInc(); - m_nextp = nullptr; - m_backp = nullptr; m_headtailp = this; // When made, we're a list of only a single element - m_op1p = nullptr; - m_op2p = nullptr; - m_op3p = nullptr; - m_op4p = nullptr; - m_iterpp = nullptr; - m_dtypep = nullptr; - m_clonep = nullptr; - m_cloneCnt = 0; // Attributes m_flags.didWidth = false; m_flags.doingWidth = false; m_flags.protect = true; m_flags.unused = 0; // Initializing this avoids a read-modify-write on construction - m_user1u = VNUser(0); - m_user1Cnt = 0; - m_user2u = VNUser(0); - m_user2Cnt = 0; - m_user3u = VNUser(0); - m_user3Cnt = 0; - m_user4u = VNUser(0); - m_user4Cnt = 0; - m_user5u = VNUser(0); - m_user5Cnt = 0; + editCountInc(); } AstNode* AstNode::abovep() const { diff --git a/src/V3Ast.h b/src/V3Ast.h index 867605e5d..751bad25c 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1356,13 +1356,14 @@ public: class AstNode VL_NOT_FINAL { // v ASTNODE_PREFETCH depends on below ordering of members - AstNode* m_nextp; // Next peer in the parent's list - AstNode* m_backp; // Node that points to this one (via next/op1/op2/...) - AstNode* m_op1p; // Generic pointer 1 - AstNode* m_op2p; // Generic pointer 2 - AstNode* m_op3p; // Generic pointer 3 - AstNode* m_op4p; // Generic pointer 4 - AstNode** m_iterpp; // Pointer to node iterating on, change it if we replace this node. + AstNode* m_nextp = nullptr; // Next peer in the parent's list + AstNode* m_backp = nullptr; // Node that points to this one (via next/op1/op2/...) + AstNode* m_op1p = nullptr; // Generic pointer 1 + AstNode* m_op2p = nullptr; // Generic pointer 2 + AstNode* m_op3p = nullptr; // Generic pointer 3 + AstNode* m_op4p = nullptr; // Generic pointer 4 + AstNode** m_iterpp + = nullptr; // Pointer to node iterating on, change it if we replace this node. const AstType m_type; // Node sub-type identifier // ^ ASTNODE_PREFETCH depends on above ordering of members @@ -1384,7 +1385,7 @@ class AstNode VL_NOT_FINAL { // field masking resulting in unnecessary read-modify-write ops. uint8_t m_brokenState = 0; - int m_cloneCnt; // Sequence number for when last clone was made + int m_cloneCnt = 0; // Sequence number for when last clone was made #if defined(__x86_64__) && defined(__gnu_linux__) // Only assert this on known platforms, as it only affects performance, not correctness @@ -1393,7 +1394,7 @@ class AstNode VL_NOT_FINAL { "packing requires padding"); #endif - AstNodeDType* m_dtypep; // Data type of output or assignment (etc) + AstNodeDType* m_dtypep = nullptr; // Data type of output or assignment (etc) AstNode* m_headtailp; // When at begin/end of list, the opposite end of the list FileLine* m_fileline; // Where it was declared vluint64_t m_editCount; // When it was last edited @@ -1401,20 +1402,21 @@ class AstNode VL_NOT_FINAL { // Global edit counter, last value for printing * near node #s static vluint64_t s_editCntLast; - AstNode* m_clonep; // Pointer to clone of/ source of this module (for *LAST* cloneTree() ONLY) + AstNode* m_clonep + = nullptr; // Pointer to clone of/ source of this module (for *LAST* cloneTree() ONLY) static int s_cloneCntGbl; // Count of which userp is set // This member ordering both allows 64 bit alignment and puts associated data together - VNUser m_user1u; // Contains any information the user iteration routine wants - uint32_t m_user1Cnt; // Mark of when userp was set - uint32_t m_user2Cnt; // Mark of when userp was set - VNUser m_user2u; // Contains any information the user iteration routine wants - VNUser m_user3u; // Contains any information the user iteration routine wants - uint32_t m_user3Cnt; // Mark of when userp was set - uint32_t m_user4Cnt; // Mark of when userp was set - VNUser m_user4u; // Contains any information the user iteration routine wants - VNUser m_user5u; // Contains any information the user iteration routine wants - uint32_t m_user5Cnt; // Mark of when userp was set + VNUser m_user1u = VNUser{0}; // Contains any information the user iteration routine wants + uint32_t m_user1Cnt = 0; // Mark of when userp was set + uint32_t m_user2Cnt = 0; // Mark of when userp was set + VNUser m_user2u = VNUser{0}; // Contains any information the user iteration routine wants + VNUser m_user3u = VNUser{0}; // Contains any information the user iteration routine wants + uint32_t m_user3Cnt = 0; // Mark of when userp was set + uint32_t m_user4Cnt = 0; // Mark of when userp was set + VNUser m_user4u = VNUser{0}; // Contains any information the user iteration routine wants + VNUser m_user5u = VNUser{0}; // Contains any information the user iteration routine wants + uint32_t m_user5Cnt = 0; // Mark of when userp was set // METHODS void op1p(AstNode* nodep) { diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 013fad115..6ab8d3023 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -140,7 +140,7 @@ private: // NODE STATE // Entire netlist: // {statement}Node::user3 -> bool, indicating not hazard - std::ofstream* m_ofp; // Output file + std::ofstream* const m_ofp = nullptr; // Output file string m_prefix; virtual void visit(AstNode* nodep) override { diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index 8f77b2019..9bef98940 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -118,13 +118,13 @@ public: class ChangedInsertVisitor final : public AstNVisitor { private: // STATE - ChangedState* m_statep; // Shared state across visitors - AstVarScope* m_vscp; // Original (non-change) variable we're change-detecting - AstVarScope* m_newvscp; // New (change detect) variable we're change-detecting - AstNode* m_varEqnp; // Original var's equation to get var value - AstNode* m_newLvEqnp; // New var's equation to read value - AstNode* m_newRvEqnp; // New var's equation to set value - uint32_t m_detects; // # detects created + ChangedState* m_statep = nullptr; // Shared state across visitors + AstVarScope* m_vscp = nullptr; // Original (non-change) variable we're change-detecting + AstVarScope* m_newvscp = nullptr; // New (change detect) variable we're change-detecting + AstNode* m_varEqnp = nullptr; // Original var's equation to get var value + AstNode* m_newLvEqnp = nullptr; // New var's equation to read value + AstNode* m_newRvEqnp = nullptr; // New var's equation to set value + uint32_t m_detects = 0; // # detects created // CONSTANTS enum MiscConsts { @@ -211,7 +211,6 @@ public: "DPI export trigger should not need change detect"); m_statep = statep; m_vscp = vscp; - m_detects = 0; { AstVar* const varp = m_vscp->varp(); const string newvarname{"__Vchglast__" + m_vscp->scopep()->nameDotless() + "__" diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index 10e116ec7..a207d4e22 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -115,9 +115,9 @@ public: class EmitCFunc VL_NOT_FINAL : public EmitCConstInit { private: - AstVarRef* m_wideTempRefp; // Variable that _WW macros should be setting - int m_labelNum; // Next label number - int m_splitSize; // # of cfunc nodes placed into output file + AstVarRef* m_wideTempRefp = nullptr; // Variable that _WW macros should be setting + int m_labelNum = 0; // Next label number + int m_splitSize = 0; // # of cfunc nodes placed into output file bool m_inUC = false; // Inside an AstUCStmt or AstUCMath std::vector m_blkChangeDetVec; // All encountered changes in block bool m_emitConstInit = false; // Emitting constant initializer @@ -1225,11 +1225,7 @@ public: } EmitCFunc() - : m_lazyDecls(*this) { - m_wideTempRefp = nullptr; - m_labelNum = 0; - m_splitSize = 0; - } + : m_lazyDecls(*this) {} EmitCFunc(AstNode* nodep, V3OutCFile* ofp, bool trackText = false) : EmitCFunc{} { m_ofp = ofp; diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 4203e606a..5c87cf36f 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -754,7 +754,7 @@ class EmitVPrefixedFormatter final : public V3OutFormatter { std::ostream& m_os; const string m_prefix; // What to print at beginning of each line const int m_flWidth; // Padding of fileline - int m_column; // Rough location; need just zero or non-zero + int m_column = 0; // Rough location; need just zero or non-zero FileLine* m_prefixFl; // METHODS virtual void putcOutput(char chr) override { @@ -783,7 +783,6 @@ public: , m_os(os) // Need () or GCC 4.8 false warning , m_prefix{prefix} , m_flWidth{flWidth} { - m_column = 0; m_prefixFl = v3Global.rootp()->fileline(); // NETLIST's fileline instead of nullptr to // avoid nullptr checks } diff --git a/src/V3EmitXml.cpp b/src/V3EmitXml.cpp index 34e89531a..d8fcdb9f3 100644 --- a/src/V3EmitXml.cpp +++ b/src/V3EmitXml.cpp @@ -34,7 +34,7 @@ class EmitXmlFileVisitor final : public AstNVisitor { // AstNode::user1 -> uint64_t, number to connect crossrefs // MEMBERS - V3OutFile* m_ofp; + V3OutFile* const m_ofp; uint64_t m_id = 0; // METHODS diff --git a/src/V3File.h b/src/V3File.h index 36b28a3a0..c13f01fef 100644 --- a/src/V3File.h +++ b/src/V3File.h @@ -182,7 +182,7 @@ public: class V3OutFile VL_NOT_FINAL : public V3OutFormatter { // MEMBERS - FILE* m_fp; + FILE* m_fp = nullptr; public: V3OutFile(const string& filename, V3OutFormatter::Language lang); diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 4791da3ee..14e41aea7 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -826,10 +826,10 @@ class GateElimVisitor final : public GateBaseVisitor { private: // NODE STATE // STATE - const AstVarScope* m_elimVarScp; // Variable being eliminated - AstNode* m_replaceTreep; // What to replace the variable with - bool m_didReplace; // Did we do any replacements - GateDedupeVarVisitor* m_varVisp; // Callback to keep hash up to date + const AstVarScope* const m_elimVarScp; // Variable being eliminated + AstNode* const m_replaceTreep; // What to replace the variable with + bool m_didReplace = false; // Did we do any replacements + GateDedupeVarVisitor* const m_varVisp; // Callback to keep hash up to date // METHODS void hashReplace(AstNode* oldp, AstNode* newp); @@ -867,14 +867,13 @@ public: // CONSTRUCTORS virtual ~GateElimVisitor() override = default; GateElimVisitor(AstNode* nodep, AstVarScope* varscp, AstNode* replaceTreep, - GateDedupeVarVisitor* varVisp) { + GateDedupeVarVisitor* varVisp) + : m_elimVarScp{varscp} + , m_replaceTreep{replaceTreep} + , m_varVisp{varVisp} { UINFO(9, " elimvisitor " << nodep << endl); UINFO(9, " elim varscp " << varscp << endl); UINFO(9, " elim repce " << replaceTreep << endl); - m_didReplace = false; - m_elimVarScp = varscp; - m_replaceTreep = replaceTreep; - m_varVisp = varVisp; iterate(nodep); } bool didReplace() const { return m_didReplace; } diff --git a/src/V3Global.h b/src/V3Global.h index bd752add0..45bb73ed2 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -89,9 +89,12 @@ inline bool operator==(VWidthMinUsage::en lhs, const VWidthMinUsage& rhs) { class V3Global final { // Globals - AstNetlist* m_rootp; // Root of entire netlist - V3HierBlockPlan* m_hierPlanp; // Hierarchical verilation plan, nullptr unless hier_block - VWidthMinUsage m_widthMinUsage; // What AstNode::widthMin() is used for + AstNetlist* m_rootp = nullptr; // Root of entire netlist, + // created by makeInitNetlist(} so static constructors run first + V3HierBlockPlan* m_hierPlanp = nullptr; // Hierarchical verilation plan, + // nullptr unless hier_block, set via hierPlanp(V3HierBlockPlan*} + VWidthMinUsage m_widthMinUsage + = VWidthMinUsage::LINT_WIDTH; // What AstNode::widthMin() is used for int m_debugFileNumber = 0; // Number to append to debug files created bool m_assertDTypesResolved = false; // Tree should have dtypep()'s @@ -112,10 +115,7 @@ public: V3Options opt; // All options; let user see them directly // CONSTRUCTORS - V3Global() - : m_rootp{nullptr} // created by makeInitNetlist(} so static constructors run first - , m_hierPlanp{nullptr} // Set via hierPlanp(V3HierBlockPlan*} when use hier_block - , m_widthMinUsage{VWidthMinUsage::LINT_WIDTH} {} + V3Global() {} AstNetlist* makeNetlist(); void boot() { UASSERT(!m_rootp, "call once"); diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index 0399db04c..a62fd3d9d 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -31,7 +31,7 @@ class GraphAcycVertex final : public V3GraphVertex { // user() is used for various sub-algorithm pieces - V3GraphVertex* m_origVertexp; // Pointer to first vertex this represents + V3GraphVertex* const m_origVertexp; // Pointer to first vertex this represents protected: friend class GraphAcyc; V3ListEnt m_work; // List of vertices with optimization work left @@ -98,7 +98,7 @@ private: // GraphEdge::user() OrigEdgeList* Old graph edges // GraphVertex::user bool Detection of loops in simplifyDupIterate // MEMBERS - V3Graph* m_origGraphp; // Original graph + V3Graph* const m_origGraphp; // Original graph V3Graph m_breakGraph; // Graph with only breakable edges represented V3List m_work; // List of vertices with optimization work left std::vector m_origEdgeDelp; // List of deletions to do when done diff --git a/src/V3GraphAlg.cpp b/src/V3GraphAlg.cpp index 5ce9ee4ee..9d4aa776f 100644 --- a/src/V3GraphAlg.cpp +++ b/src/V3GraphAlg.cpp @@ -369,7 +369,7 @@ void V3Graph::reportLoops(V3EdgeFuncP edgeFuncp, V3GraphVertex* vertexp) { class GraphAlgSubtrees final : GraphAlg<> { private: - V3Graph* m_loopGraphp; + V3Graph* const m_loopGraphp; //! Iterate through all connected nodes of a graph with a loop or loops. V3GraphVertex* vertexIterateAll(V3GraphVertex* vertexp) { diff --git a/src/V3GraphStream.h b/src/V3GraphStream.h index e7dd84bb2..1c92b3fce 100644 --- a/src/V3GraphStream.h +++ b/src/V3GraphStream.h @@ -43,7 +43,7 @@ private: class VxHolder final { public: // MEMBERS - const V3GraphVertex* m_vxp; // [mtask] Vertex + const V3GraphVertex* const m_vxp; // [mtask] Vertex const uint32_t m_pos; // Sort position uint32_t m_numBlockingEdges; // Number of blocking edges // CONSTRUCTORS @@ -57,7 +57,7 @@ private: // newly unblocked bool unblock() { UASSERT_OBJ(m_numBlockingEdges > 0, vertexp(), "Underflow of blocking edges"); - m_numBlockingEdges--; + --m_numBlockingEdges; return (m_numBlockingEdges == 0); } }; diff --git a/src/V3InstrCount.cpp b/src/V3InstrCount.cpp index 4ff6070b7..33a710dc7 100644 --- a/src/V3InstrCount.cpp +++ b/src/V3InstrCount.cpp @@ -42,7 +42,7 @@ private: bool m_tracingCall = false; // Iterating into a CCall to a CFunc bool m_inCFunc = false; // Inside AstCFunc const bool m_assertNoDups; // Check for duplicates - const std::ostream* m_osp; // Dump file + const std::ostream* const m_osp; // Dump file // TYPES // Little class to cleanly call startVisitBase/endVisitBase @@ -264,7 +264,7 @@ private: // AstNode::user4() -> int. Path cost, 0 means don't dump // MEMBERS - std::ostream* m_osp; // Dump file + std::ostream* const m_osp; // Dump file unsigned m_depth = 0; // Current tree depth for printing indent public: diff --git a/src/V3Life.cpp b/src/V3Life.cpp index cda69a57a..89d233ea5 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -125,16 +125,15 @@ class LifeBlock final { // For each basic block, we'll make a new map of what variables that if/else is changing using LifeMap = std::unordered_map; LifeMap m_map; // Current active lifetime map for current scope - LifeBlock* m_aboveLifep; // Upper life, or nullptr - LifeState* m_statep; // Current global state + LifeBlock* const m_aboveLifep; // Upper life, or nullptr + LifeState* const m_statep; // Current global state VL_DEBUG_FUNC; // Declare debug() public: - LifeBlock(LifeBlock* aboveLifep, LifeState* statep) { - m_aboveLifep = aboveLifep; // Null if top - m_statep = statep; - } + LifeBlock(LifeBlock* aboveLifep, LifeState* statep) + : m_aboveLifep{aboveLifep} // Null if top + , m_statep{statep} {} ~LifeBlock() = default; // METHODS void checkRemoveAssign(const LifeMap::iterator& it) { @@ -271,7 +270,7 @@ public: class LifeVisitor final : public AstNVisitor { private: // STATE - LifeState* m_statep; // Current state + LifeState* const m_statep; // Current state bool m_sideEffect = false; // Side effects discovered in assign RHS bool m_noopt = false; // Disable optimization of variables in this block bool m_tracingCall = false; // Iterating into a CCall to a CFunc @@ -433,9 +432,9 @@ private: public: // CONSTRUCTORS - LifeVisitor(AstNode* nodep, LifeState* statep) { + LifeVisitor(AstNode* nodep, LifeState* statep) + : m_statep{statep} { UINFO(4, " LifeVisitor on " << nodep << endl); - m_statep = statep; { m_lifep = new LifeBlock(nullptr, m_statep); iterate(nodep); diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index b6c8f1507..32322db7a 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -105,7 +105,7 @@ private: const AstUser2InUse m_inuser2; // STATE - VInFilter* m_filterp; // Parser filter + VInFilter* const m_filterp; // Parser filter V3ParseSym* m_parseSymp; // Parser symbol table // Below state needs to be preserved between each module call. @@ -498,9 +498,9 @@ private: public: // CONSTRUCTORS LinkCellsVisitor(AstNetlist* nodep, VInFilter* filterp, V3ParseSym* parseSymp) - : m_mods{nodep} { - m_filterp = filterp; - m_parseSymp = parseSymp; + : m_filterp{filterp} + , m_parseSymp{parseSymp} + , m_mods{nodep} { if (v3Global.opt.hierChild()) { const V3HierBlockOptSet& hierBlocks = v3Global.opt.hierBlocks(); UASSERT(!v3Global.opt.topModule().empty(), diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 1bf0e73c6..6a210105e 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -147,7 +147,7 @@ private: // MEMBERS VSymGraph m_syms; // Symbol table - VSymEnt* m_dunitEntp; // $unit entry + VSymEnt* m_dunitEntp = nullptr; // $unit entry std::multimap m_nameScopeSymMap; // Map of scope referenced by non-pretty textual name std::set> @@ -204,7 +204,6 @@ public: m_forPrimary = (step == LDS_PRIMARY); m_forPrearray = (step == LDS_PARAMED || step == LDS_PRIMARY); m_forScopeCreation = (step == LDS_SCOPED); - m_dunitEntp = nullptr; s_errorThisp = this; V3Error::errorExitCb(preErrorDumpHandler); // If get error, dump self } @@ -1744,7 +1743,7 @@ public: // Iterate an interface to resolve modports class LinkDotIfaceVisitor final : public AstNVisitor { // STATE - LinkDotState* m_statep; // State to pass between visitors, including symbol table + LinkDotState* const m_statep; // State to pass between visitors, including symbol table VSymEnt* m_curSymp; // Symbol Entry for current table, where to lookup/insert // METHODS @@ -1815,10 +1814,10 @@ class LinkDotIfaceVisitor final : public AstNVisitor { public: // CONSTRUCTORS - LinkDotIfaceVisitor(AstIface* nodep, VSymEnt* curSymp, LinkDotState* statep) { + LinkDotIfaceVisitor(AstIface* nodep, VSymEnt* curSymp, LinkDotState* statep) + : m_statep{statep} + , m_curSymp{curSymp} { UINFO(4, __FUNCTION__ << ": " << endl); - m_curSymp = curSymp; - m_statep = statep; iterate(nodep); } virtual ~LinkDotIfaceVisitor() override = default; diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index fa52132d3..73ea1ea6e 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -137,18 +137,18 @@ class V3ParseImp final { VInFilter* const m_filterp; // Reading filter V3ParseSym* m_symp; // Symbol table - V3Lexer* m_lexerp; // Current FlexLexer + V3Lexer* m_lexerp = nullptr; // Current FlexLexer static V3ParseImp* s_parsep; // Current THIS, bison() isn't class based - FileLine* m_lexFileline; // Filename/linenumber currently active for lexing + FileLine* m_lexFileline = nullptr; // Filename/linenumber currently active for lexing FileLine* m_bisonLastFileline; // Filename/linenumber of last token - bool m_inLibrary; // Currently reading a library vs. regular file - int m_lexKwdDepth; // Inside a `begin_keywords + bool m_inLibrary = false; // Currently reading a library vs. regular file + int m_lexKwdDepth = 0; // Inside a `begin_keywords int m_lexKwdLast; // Last LEX state in `begin_keywords VOptionBool m_unconnectedDrive; // Last unconnected drive - int m_lexPrevToken; // previous parsed token (for lexer) + int m_lexPrevToken = 0; // previous parsed token (for lexer) std::deque m_tokensAhead; // Tokens we parsed ahead of parser std::deque m_stringps; // Created strings for later cleanup @@ -156,7 +156,7 @@ class V3ParseImp final { std::deque m_lexLintState; // Current lint state for save/restore std::deque m_ppBuffers; // Preprocessor->lex buffer of characters to process - AstNode* m_tagNodep; // Points to the node to set to m_tag or nullptr to not set. + AstNode* m_tagNodep = nullptr; // Points to the node to set to m_tag or nullptr to not set. VTimescale m_timeLastUnit; // Last `timescale's unit public: @@ -293,13 +293,7 @@ public: : m_rootp{rootp} , m_filterp{filterp} , m_symp{parserSymp} { - m_lexFileline = nullptr; - m_lexerp = nullptr; - m_inLibrary = false; - m_lexKwdDepth = 0; m_lexKwdLast = stateVerilogRecent(); - m_lexPrevToken = 0; - m_tagNodep = nullptr; m_timeLastUnit = v3Global.opt.timeDefaultUnit(); } ~V3ParseImp(); diff --git a/src/V3ParseSym.h b/src/V3ParseSym.h index b727ecc05..6ff760def 100644 --- a/src/V3ParseSym.h +++ b/src/V3ParseSym.h @@ -39,7 +39,7 @@ private: static int s_anonNum; // Number of next anonymous object (parser use only) VSymGraph m_syms; // Graph of symbol tree VSymEnt* m_symTableNextId = nullptr; // Symbol table for next lexer lookup (parser use only) - VSymEnt* m_symCurrentp; // Active symbol table for additions/lookups + VSymEnt* m_symCurrentp = nullptr; // Active symbol table for additions/lookups std::vector m_sympStack; // Stack of upper nodes with pending symbol tables public: diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 789e58387..be57f6222 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -876,7 +876,7 @@ public: class PartParallelismEst final { // MEMBERS - const V3Graph* m_graphp; // Mtask-containing graph + const V3Graph* const m_graphp; // Mtask-containing graph // Total cost of evaluating the whole graph. // The ratio of m_totalGraphCost to longestCpCost gives us an estimate @@ -1108,7 +1108,7 @@ private: }; // MEMBERS - V3Graph* m_mtasksp; // Mtask graph + V3Graph* const m_mtasksp; // Mtask graph uint32_t m_scoreLimit; // Sloppy score allowed when picking merges uint32_t m_scoreLimitBeforeRescore = 0xffffffff; // Next score rescore at unsigned m_mergesSinceRescore = 0; // Merges since last rescore @@ -1827,7 +1827,7 @@ private: using Olv2MTaskMap = std::unordered_map; // MEMBERS - V3Graph* m_mtasksp; // Mtask graph + V3Graph* const m_mtasksp; // Mtask graph Olv2MTaskMap m_olv2mtask; // Map OrderLogicVertex to LogicMTask who wraps it unsigned m_mergesDone = 0; // Number of MTasks merged. For stats only. public: diff --git a/src/V3Partition.h b/src/V3Partition.h index d1049f546..7eaec699e 100644 --- a/src/V3Partition.h +++ b/src/V3Partition.h @@ -36,7 +36,7 @@ using Vx2MTaskMap = std::unordered_map; class V3Partition final { // MEMBERS - V3Graph* m_fineDepsGraphp; // Fine-grained dependency graph + V3Graph* const m_fineDepsGraphp; // Fine-grained dependency graph public: // CONSTRUCTORS explicit V3Partition(V3Graph* fineDepsGraphp) diff --git a/src/V3PreLex.h b/src/V3PreLex.h index fc2b9ec45..804b29e86 100644 --- a/src/V3PreLex.h +++ b/src/V3PreLex.h @@ -129,7 +129,7 @@ void yy_delete_buffer(YY_BUFFER_STATE b); class VPreStream final { public: FileLine* m_curFilelinep; // Current processing point (see also m_tokFilelinep) - V3PreLex* m_lexp; // Lexer, for resource tracking + V3PreLex* const m_lexp; // Lexer, for resource tracking std::deque m_buffers; // Buffer of characters to process int m_ignNewlines = 0; // Ignore multiline newlines bool m_eof = false; // "EOF" buffer @@ -155,7 +155,7 @@ enum class Enctype : uint8_t { UUENCODE, BASE64, QUOTE_PRINTABLE, RAW, ERR }; class V3PreLex final { public: // Used only by V3PreLex.cpp and V3PreProc.cpp - V3PreProcImp* m_preimpp; // Preprocessor lexor belongs to + V3PreProcImp* const m_preimpp; // Preprocessor lexor belongs to std::stack m_streampStack; // Stack of processing files int m_streamDepth = 0; // Depth of stream processing YY_BUFFER_STATE m_bufferState; // Flex state diff --git a/src/V3Scoreboard.h b/src/V3Scoreboard.h index e174d67aa..e7f45bb78 100644 --- a/src/V3Scoreboard.h +++ b/src/V3Scoreboard.h @@ -70,7 +70,7 @@ public: // MEMBERS typename KeySet::iterator m_keyIt; typename Val2Keys::iterator m_valIt; - SortByValueMap* m_sbvmp; + SortByValueMap* const m_sbvmp; bool m_end = true; // At the end() // CONSTRUCTORS diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 64ea12b49..ede20b512 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -52,8 +52,8 @@ class SimStackNode final { public: // MEMBERS - AstFuncRef* m_funcp; - V3TaskConnects* m_tconnects; + AstFuncRef* const m_funcp; + V3TaskConnects* const m_tconnects; // CONSTRUCTORS SimStackNode(AstFuncRef* funcp, V3TaskConnects* tconnects) : m_funcp{funcp} diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 689d03de5..be909a9e8 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -39,7 +39,7 @@ class UndrivenVarEntry final { // MEMBERS - AstVar* m_varp; // Variable this tracks + AstVar* const m_varp; // Variable this tracks std::vector m_wholeFlags; // Used/Driven on whole vector std::vector m_bitFlags; // Used/Driven on each subbit @@ -49,9 +49,9 @@ class UndrivenVarEntry final { public: // CONSTRUCTORS - explicit UndrivenVarEntry(AstVar* varp) { // Construction for when a var is used + explicit UndrivenVarEntry(AstVar* varp) + : m_varp(varp) { // Construction for when a var is used UINFO(9, "create " << varp << endl); - m_varp = varp; m_wholeFlags.resize(FLAGS_PER_BIT); for (int i = 0; i < FLAGS_PER_BIT; i++) m_wholeFlags[i] = false; m_bitFlags.resize(varp->width() * FLAGS_PER_BIT);