diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index f6e8fa34d..366b229c1 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -100,16 +100,12 @@ private: IndexValueMap m_indexValues VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for keys ItemList m_items VL_GUARDED_BY(m_mutex); ///< List of all items - VerilatedCovImpItem* m_insertp VL_GUARDED_BY(m_mutex); ///< Item about to insert - const char* m_insertFilenamep VL_GUARDED_BY(m_mutex); ///< Filename about to insert - int m_insertLineno VL_GUARDED_BY(m_mutex); ///< Line number about to insert + VerilatedCovImpItem* m_insertp VL_GUARDED_BY(m_mutex) = nullptr; ///< Item about to insert + const char* m_insertFilenamep VL_GUARDED_BY(m_mutex) = nullptr; ///< Filename about to insert + int m_insertLineno VL_GUARDED_BY(m_mutex) = 0; ///< Line number about to insert // CONSTRUCTORS - VerilatedCovImp() { - m_insertp = nullptr; - m_insertFilenamep = nullptr; - m_insertLineno = 0; - } + VerilatedCovImp() {} VL_UNCOPYABLE(VerilatedCovImp); public: diff --git a/include/verilated_save.h b/include/verilated_save.h index 909a12949..767d99589 100644 --- a/include/verilated_save.h +++ b/include/verilated_save.h @@ -34,7 +34,7 @@ protected: // For speed, keep m_cp as the first member of this structure vluint8_t* m_cp; ///< Current pointer into m_bufp buffer vluint8_t* m_bufp; ///< Output buffer - bool m_isOpen; ///< True indicates open file/stream + bool m_isOpen = false; ///< True indicates open file/stream std::string m_filename; ///< Filename, for error messages VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread @@ -49,7 +49,6 @@ protected: public: VerilatedSerialize() { - m_isOpen = false; m_bufp = new vluint8_t[bufferSize()]; m_cp = m_bufp; } @@ -94,8 +93,8 @@ protected: // For speed, keep m_cp as the first member of this structure vluint8_t* m_cp; ///< Current pointer into m_bufp buffer vluint8_t* m_bufp; ///< Output buffer - vluint8_t* m_endp; ///< Last valid byte in m_bufp buffer - bool m_isOpen; ///< True indicates open file/stream + vluint8_t* m_endp = nullptr; ///< Last valid byte in m_bufp buffer + bool m_isOpen = false; ///< True indicates open file/stream std::string m_filename; ///< Filename, for error messages VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread @@ -111,10 +110,8 @@ protected: public: VerilatedDeserialize() { - m_isOpen = false; m_bufp = new vluint8_t[bufferSize()]; m_cp = m_bufp; - m_endp = nullptr; } virtual ~VerilatedDeserialize() { close(); @@ -159,12 +156,11 @@ private: class VerilatedSave : public VerilatedSerialize { private: - int m_fd; ///< File descriptor we're writing to + int m_fd = -1; ///< File descriptor we're writing to public: // CONSTRUCTORS - VerilatedSave() - : m_fd(-1) {} + VerilatedSave() {} virtual ~VerilatedSave() override { close(); } // METHODS /// Open the file; call isOpen() to see if errors @@ -180,12 +176,11 @@ public: class VerilatedRestore : public VerilatedDeserialize { private: - int m_fd; ///< File descriptor we're writing to + int m_fd = -1; ///< File descriptor we're writing to public: // CONSTRUCTORS - VerilatedRestore() - : m_fd(-1) {} + VerilatedRestore() {} virtual ~VerilatedRestore() override { close(); } // METHODS diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index baa2bc8ee..ccc9662f4 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -36,11 +36,10 @@ class VerilatedVcd; class VerilatedVcdFile { private: - int m_fd; ///< File descriptor we're writing to + int m_fd = 0; ///< File descriptor we're writing to public: // METHODS - VerilatedVcdFile() - : m_fd(0) {} + VerilatedVcdFile() {} virtual ~VerilatedVcdFile() {} virtual bool open(const std::string& name) VL_MT_UNSAFE; virtual void close() VL_MT_UNSAFE; diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index d34bed58c..6eca5887b 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -167,12 +167,11 @@ public: class VerilatedVpioRange : public VerilatedVpio { const VerilatedRange* m_range; - vlsint32_t m_iteration; + vlsint32_t m_iteration = 0; public: explicit VerilatedVpioRange(const VerilatedRange* range) - : m_range(range) - , m_iteration(0) {} + : m_range(range) {} virtual ~VerilatedVpioRange() override {} static inline VerilatedVpioRange* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); @@ -421,13 +420,13 @@ class VerilatedVpiImp { VpioCbList m_cbObjLists[CB_ENUM_MAX_VALUE]; // Callbacks for each supported reason VpioTimedCbs m_timedCbs; // Time based callbacks - VerilatedVpiError* m_errorInfop; // Container for vpi error info + VerilatedVpiError* m_errorInfop = nullptr; // Container for vpi error info VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread static VerilatedVpiImp s_s; // Singleton public: - VerilatedVpiImp() { m_errorInfop = nullptr; } + VerilatedVpiImp() {} ~VerilatedVpiImp() {} static void assertOneCheck() { s_s.m_assertOne.check(); } static void cbReasonAdd(VerilatedVpioCb* vop) { diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 384c83ff6..01d25be8f 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -51,9 +51,9 @@ protected: class ActiveNamer : public ActiveBaseVisitor { private: // STATE - AstScope* m_scopep; // Current scope to add statement to - AstActive* m_iActivep; // For current scope, the IActive we're building - AstActive* m_cActivep; // For current scope, the SActive(combo) we're building + AstScope* m_scopep = nullptr; // Current scope to add statement to + AstActive* m_iActivep = nullptr; // For current scope, the IActive we're building + AstActive* m_cActivep = nullptr; // For current scope, the SActive(combo) we're building SenTreeSet m_activeSens; // Sen lists for each active we've made typedef std::unordered_map ActiveMap; @@ -131,11 +131,7 @@ public: public: // CONSTRUCTORS - ActiveNamer() { - m_scopep = nullptr; - m_iActivep = nullptr; - m_cActivep = nullptr; - } + ActiveNamer() {} virtual ~ActiveNamer() override {} void main(AstScope* nodep) { iterate(nodep); } }; @@ -150,7 +146,7 @@ public: private: CheckType m_check; // Combo logic or other AstNode* m_alwaysp; // Always we're under - AstNode* m_assignp; // In assign + AstNode* m_assignp = nullptr; // In assign // VISITORS virtual void visit(AstAssignDly* nodep) override { if (m_check != CT_SEQ) { @@ -205,10 +201,9 @@ private: public: // CONSTRUCTORS - ActiveDlyVisitor(AstNode* nodep, CheckType check) { - m_alwaysp = nodep; - m_check = check; - m_assignp = nullptr; + ActiveDlyVisitor(AstNode* nodep, CheckType check) + : m_check(check) + , m_alwaysp(nodep) { iterate(nodep); } virtual ~ActiveDlyVisitor() override {} @@ -225,9 +220,9 @@ private: // STATE ActiveNamer m_namer; // Tracking of active names - AstCFunc* m_scopeFinalp; // Final function for this scope - bool m_itemCombo; // Found a SenItem combo - bool m_itemSequent; // Found a SenItem sequential + AstCFunc* m_scopeFinalp = nullptr; // Final function for this scope + bool m_itemCombo = false; // Found a SenItem combo + bool m_itemSequent = false; // Found a SenItem sequential // VISITORS virtual void visit(AstScope* nodep) override { @@ -411,12 +406,7 @@ private: public: // CONSTRUCTORS - explicit ActiveVisitor(AstNetlist* nodep) - : m_scopeFinalp(nullptr) - , m_itemCombo(false) - , m_itemSequent(false) { - iterate(nodep); - } + explicit ActiveVisitor(AstNetlist* nodep) { iterate(nodep); } virtual ~ActiveVisitor() override {} }; diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index c5a0d3b53..b944618cf 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -45,7 +45,7 @@ private: AstUser1InUse m_inuser1; // STATE - AstTopScope* m_topscopep; // Top scope for adding sentrees under + AstTopScope* m_topscopep = nullptr; // Top scope for adding sentrees under SenTreeFinder m_finder; // Find global sentree's and add them // METHODS @@ -127,10 +127,7 @@ private: public: // CONSTRUCTORS - explicit ActiveTopVisitor(AstNetlist* nodep) - : m_topscopep(nullptr) { - iterate(nodep); - } + explicit ActiveTopVisitor(AstNetlist* nodep) { iterate(nodep); } virtual ~ActiveTopVisitor() override {} }; diff --git a/src/V3Ast.h b/src/V3Ast.h index b693ab752..cacd6e93b 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1263,18 +1263,13 @@ class AstNRelinker { protected: friend class AstNode; enum RelinkWhatEn { RELINK_BAD, RELINK_NEXT, RELINK_OP1, RELINK_OP2, RELINK_OP3, RELINK_OP4 }; - AstNode* m_oldp; // The old node that was linked to this point in the tree - AstNode* m_backp; - RelinkWhatEn m_chg; - AstNode** m_iterpp; + AstNode* m_oldp = nullptr; // The old node that was linked to this point in the tree + AstNode* m_backp = nullptr; + RelinkWhatEn m_chg = RELINK_BAD; + AstNode** m_iterpp = nullptr; public: - AstNRelinker() { - m_oldp = nullptr; - m_backp = nullptr; - m_chg = RELINK_BAD; - m_iterpp = nullptr; - } + AstNRelinker() {} void relink(AstNode* newp); AstNode* oldp() const { return m_oldp; } void dump(std::ostream& str = std::cout) const; @@ -2256,29 +2251,23 @@ class AstNodeVarRef : public AstNodeMath { private: bool m_lvalue; // Left hand side assignment AstVar* m_varp; // [AfterLink] Pointer to variable itself - AstVarScope* m_varScopep; // Varscope for hierarchy - AstNodeModule* m_packagep; // Package hierarchy + AstVarScope* m_varScopep = nullptr; // Varscope for hierarchy + AstNodeModule* m_packagep = nullptr; // Package hierarchy string m_name; // Name of variable string m_hiername; // Scope converted into name-> for emitting - bool m_hierThis; // Hiername points to "this" function + bool m_hierThis = false; // Hiername points to "this" function public: AstNodeVarRef(AstType t, FileLine* fl, const string& name, bool lvalue) : AstNodeMath(t, fl) , m_lvalue(lvalue) - , m_varScopep(nullptr) - , m_packagep(nullptr) - , m_name(name) - , m_hierThis(false) { + , m_name(name) { this->varp(nullptr); } AstNodeVarRef(AstType t, FileLine* fl, const string& name, AstVar* varp, bool lvalue) : AstNodeMath(t, fl) , m_lvalue(lvalue) - , m_varScopep(nullptr) - , m_packagep(nullptr) - , m_name(name) - , m_hierThis(false) { + , m_name(name) { // May have varp==nullptr this->varp(varp); } @@ -2630,7 +2619,7 @@ class AstNodeFTask : public AstNode { private: string m_name; // Name of task string m_cname; // Name of task if DPI import - uint64_t m_dpiOpenParent; // DPI import open array, if !=0, how many callees + uint64_t m_dpiOpenParent = 0; // DPI import open array, if !=0, how many callees bool m_taskPublic : 1; // Public task bool m_attrIsolateAssign : 1; // User isolate_assignments attribute bool m_classMethod : 1; // Class method @@ -2650,7 +2639,6 @@ public: AstNodeFTask(AstType t, FileLine* fl, const string& name, AstNode* stmtsp) : AstNode(t, fl) , m_name(name) - , m_dpiOpenParent(0) , m_taskPublic(false) , m_attrIsolateAssign(false) , m_classMethod(false) @@ -2729,27 +2717,21 @@ class AstNodeFTaskRef : public AstNodeStmt { // A reference to a task (or function) // Functions are not statements, while tasks are. AstNodeStmt needs isStatement() to deal. private: - AstNodeFTask* m_taskp; // [AfterLink] Pointer to task referenced + AstNodeFTask* m_taskp = nullptr; // [AfterLink] Pointer to task referenced string m_name; // Name of variable string m_dotted; // Dotted part of scope the name()ed task/func is under or "" string m_inlinedDots; // Dotted hierarchy flattened out - AstNodeModule* m_packagep; // Package hierarchy - bool m_pli; // Pli system call ($name) + AstNodeModule* m_packagep = nullptr; // Package hierarchy + bool m_pli = false; // Pli system call ($name) public: AstNodeFTaskRef(AstType t, FileLine* fl, bool statement, AstNode* namep, AstNode* pinsp) - : AstNodeStmt(t, fl, statement) - , m_taskp(nullptr) - , m_packagep(nullptr) - , m_pli(false) { + : AstNodeStmt(t, fl, statement) { setOp1p(namep); addNOp3p(pinsp); } AstNodeFTaskRef(AstType t, FileLine* fl, bool statement, const string& name, AstNode* pinsp) : AstNodeStmt(t, fl, statement) - , m_taskp(nullptr) - , m_name(name) - , m_packagep(nullptr) - , m_pli(false) { + , m_name(name) { addNOp3p(pinsp); } ASTNODE_BASE_FUNCS(NodeFTaskRef) @@ -2804,9 +2786,9 @@ private: bool m_internal : 1; // Internally created bool m_recursive : 1; // Recursive module bool m_recursiveClone : 1; // If recursive, what module it clones, otherwise nullptr - int m_level; // 1=top module, 2=cell off top module, ... - int m_varNum; // Incrementing variable number - int m_typeNum; // Incrementing implicit type number + int m_level = 0; // 1=top module, 2=cell off top module, ... + int m_varNum = 0; // Incrementing variable number + int m_typeNum = 0; // Incrementing implicit type number VLifetime m_lifetime; // Lifetime VTimescale m_timeunit; // Global time unit VOptionBool m_unconnectedDrive; // State of `unconnected_drive @@ -2822,10 +2804,7 @@ public: , m_hierBlock(false) , m_internal(false) , m_recursive(false) - , m_recursiveClone(false) - , m_level(0) - , m_varNum(0) - , m_typeNum(0) {} + , m_recursiveClone(false) {} ASTNODE_BASE_FUNCS(NodeModule) virtual void dump(std::ostream& str) const override; virtual bool maybePointedTo() const override { return true; } diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 5d5fadf01..eb47c0b79 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -286,11 +286,11 @@ public: class AstClassPackage : public AstNodeModule { // The static information portion of a class (treated similarly to a package) - AstClass* m_classp; // Class package this is under (weak pointer, hard link is other way) + AstClass* m_classp + = nullptr; // Class package this is under (weak pointer, hard link is other way) public: AstClassPackage(FileLine* fl, const string& name) - : ASTGEN_SUPER(fl, name) - , m_classp(nullptr) {} + : ASTGEN_SUPER(fl, name) {} ASTNODE_NODE_FUNCS(ClassPackage) virtual string verilogKwd() const override { return "/*class*/package"; } virtual const char* broken() const override; @@ -303,14 +303,13 @@ class AstClass : public AstNodeModule { typedef std::map MemberNameMap; // MEMBERS MemberNameMap m_members; // Members or method children - AstClassPackage* m_packagep; // Class package this is under + AstClassPackage* m_packagep = nullptr; // Class package this is under bool m_virtual; // Virtual class void insertCache(AstNode* nodep); public: AstClass(FileLine* fl, const string& name) - : ASTGEN_SUPER(fl, name) - , m_packagep(nullptr) {} + : ASTGEN_SUPER(fl, name) {} ASTNODE_NODE_FUNCS(Class) virtual string verilogKwd() const override { return "class"; } virtual bool isHeavy() const override { return true; } @@ -977,12 +976,11 @@ class AstClassRefDType : public AstNodeDType { // Reference to a class private: AstClass* m_classp; // data type pointed to, BELOW the AstTypedef - AstNodeModule* m_packagep; // Package hierarchy + AstNodeModule* m_packagep = nullptr; // Package hierarchy public: AstClassRefDType(FileLine* fl, AstClass* classp) : ASTGEN_SUPER(fl) - , m_classp(classp) - , m_packagep(nullptr) { + , m_classp(classp) { dtypep(this); } ASTNODE_NODE_FUNCS(ClassRefDType) @@ -1029,29 +1027,23 @@ private: string m_cellName; // "" = no cell, such as when connects to 'input' iface string m_ifaceName; // Interface name string m_modportName; // "" = no modport - AstIface* m_ifacep; // Pointer to interface; note cellp() should override - AstCell* m_cellp; // When exact parent cell known; not a guess - AstModport* m_modportp; // nullptr = unlinked or no modport + AstIface* m_ifacep = nullptr; // Pointer to interface; note cellp() should override + AstCell* m_cellp = nullptr; // When exact parent cell known; not a guess + AstModport* m_modportp = nullptr; // nullptr = unlinked or no modport public: AstIfaceRefDType(FileLine* fl, const string& cellName, const string& ifaceName) : ASTGEN_SUPER(fl) , m_modportFileline(nullptr) , m_cellName(cellName) , m_ifaceName(ifaceName) - , m_modportName("") - , m_ifacep(nullptr) - , m_cellp(nullptr) - , m_modportp(nullptr) {} + , m_modportName("") {} AstIfaceRefDType(FileLine* fl, FileLine* modportFl, const string& cellName, const string& ifaceName, const string& modport) : ASTGEN_SUPER(fl) , m_modportFileline(modportFl) , m_cellName(cellName) , m_ifaceName(ifaceName) - , m_modportName(modport) - , m_ifacep(nullptr) - , m_cellp(nullptr) - , m_modportp(nullptr) {} + , m_modportName(modport) {} ASTNODE_NODE_FUNCS(IfaceRefDType) // METHODS virtual const char* broken() const override; @@ -1149,33 +1141,24 @@ class AstRefDType : public AstNodeDType { private: // Pre-Width must reference the Typeref, not what it points to, as some child // types like AstBracketArrayType will disappear and can't lose the handle - AstTypedef* m_typedefp; // referenced type + AstTypedef* m_typedefp = nullptr; // referenced type // Post-width typedefs are removed and point to type directly - AstNodeDType* m_refDTypep; // data type pointed to, BELOW the AstTypedef + AstNodeDType* m_refDTypep = nullptr; // data type pointed to, BELOW the AstTypedef string m_name; // Name of an AstTypedef - AstNodeModule* m_packagep; // Package hierarchy + AstNodeModule* m_packagep = nullptr; // Package hierarchy public: AstRefDType(FileLine* fl, const string& name) : ASTGEN_SUPER(fl) - , m_typedefp(nullptr) - , m_refDTypep(nullptr) - , m_name(name) - , m_packagep(nullptr) {} + , m_name(name) {} AstRefDType(FileLine* fl, const string& name, AstNode* classOrPackagep, AstNode* paramsp) : ASTGEN_SUPER(fl) - , m_typedefp(nullptr) - , m_refDTypep(nullptr) - , m_name(name) - , m_packagep(nullptr) { + , m_name(name) { setNOp3p(classOrPackagep); addNOp4p(paramsp); } class FlagTypeOfExpr {}; // type(expr) for parser only AstRefDType(FileLine* fl, FlagTypeOfExpr, AstNode* typeofp) - : ASTGEN_SUPER(fl) - , m_typedefp(nullptr) - , m_refDTypep(nullptr) - , m_packagep(nullptr) { + : ASTGEN_SUPER(fl) { setOp2p(typeofp); } ASTNODE_NODE_FUNCS(RefDType) @@ -1281,21 +1264,19 @@ private: AstNodeDType* m_refDTypep; // Elements of this type (after widthing) string m_name; // Name of variable string m_tag; // Holds the string of the verilator tag -- used in XML output. - int m_lsb; // Within this level's packed struct, the LSB of the first bit of the member + int m_lsb = -1; // Within this level's packed struct, the LSB of the first bit of the member // UNSUP: int m_randType; // Randomization type (IEEE) public: AstMemberDType(FileLine* fl, const string& name, VFlagChildDType, AstNodeDType* dtp) : ASTGEN_SUPER(fl) - , m_name(name) - , m_lsb(-1) { + , m_name(name) { childDTypep(dtp); // Only for parser dtypep(nullptr); // V3Width will resolve refDTypep(nullptr); } AstMemberDType(FileLine* fl, const string& name, AstNodeDType* dtp) : ASTGEN_SUPER(fl) - , m_name(name) - , m_lsb(-1) { + , m_name(name) { UASSERT(dtp, "AstMember created with no dtype"); refDTypep(dtp); dtypep(this); @@ -1817,21 +1798,19 @@ class AstCMethodHard : public AstNodeStmt { // Not all calls are statments vs math. AstNodeStmt needs isStatement() to deal. private: string m_name; // Name of method - bool m_pure; // Pure optimizable + bool m_pure = false; // Pure optimizable public: AstCMethodHard(FileLine* fl, AstNode* fromp, VFlagChildDType, const string& name, AstNode* pinsp) : ASTGEN_SUPER(fl, false) - , m_name(name) - , m_pure(false) { + , m_name(name) { setOp1p(fromp); dtypep(nullptr); // V3Width will resolve addNOp2p(pinsp); } AstCMethodHard(FileLine* fl, AstNode* fromp, const string& name, AstNode* pinsp) : ASTGEN_SUPER(fl, false) - , m_name(name) - , m_pure(false) { + , m_name(name) { setOp1p(fromp); addNOp2p(pinsp); } @@ -2416,29 +2395,21 @@ class AstPin : public AstNode { private: int m_pinNum; // Pin number string m_name; // Pin name, or "" for number based interconnect - AstVar* m_modVarp; // Input/output this pin connects to on submodule. - AstParamTypeDType* m_modPTypep; // Param type this pin connects to on submodule. - bool m_param; // Pin connects to parameter - bool m_svImplicit; // Pin is SystemVerilog .name'ed + AstVar* m_modVarp = nullptr; // Input/output this pin connects to on submodule. + AstParamTypeDType* m_modPTypep = nullptr; // Param type this pin connects to on submodule. + bool m_param = false; // Pin connects to parameter + bool m_svImplicit = false; // Pin is SystemVerilog .name'ed public: AstPin(FileLine* fl, int pinNum, const string& name, AstNode* exprp) : ASTGEN_SUPER(fl) - , m_name(name) - , m_param(false) - , m_svImplicit(false) { + , m_name(name) { m_pinNum = pinNum; - m_modVarp = nullptr; - m_modPTypep = nullptr; setNOp1p(exprp); } AstPin(FileLine* fl, int pinNum, AstVarRef* varname, AstNode* exprp) - : ASTGEN_SUPER(fl) - , m_param(false) - , m_svImplicit(false) { + : ASTGEN_SUPER(fl) { m_name = varname->name(); m_pinNum = pinNum; - m_modVarp = nullptr; - m_modPTypep = nullptr; setNOp1p(exprp); } ASTNODE_NODE_FUNCS(Pin) @@ -2605,19 +2576,17 @@ class AstMemberSel : public AstNodeMath { private: // Don't need the class we are extracting from, as the "fromp()"'s datatype can get us to it string m_name; - AstVar* m_varp; // Post link, variable within class that is target of selection + AstVar* m_varp = nullptr; // Post link, variable within class that is target of selection public: AstMemberSel(FileLine* fl, AstNode* fromp, VFlagChildDType, const string& name) : ASTGEN_SUPER(fl) - , m_name(name) - , m_varp(nullptr) { + , m_name(name) { setOp1p(fromp); dtypep(nullptr); // V3Width will resolve } AstMemberSel(FileLine* fl, AstNode* fromp, AstNodeDType* dtp) : ASTGEN_SUPER(fl) - , m_name(dtp->name()) - , m_varp(nullptr) { + , m_name(dtp->name()) { setOp1p(fromp); dtypep(dtp); } @@ -2655,13 +2624,12 @@ class AstModportFTaskRef : public AstNode { private: string m_name; // Name of the variable referenced bool m_export; // Type of the function (import/export) - AstNodeFTask* m_ftaskp; // Link to the function + AstNodeFTask* m_ftaskp = nullptr; // Link to the function public: AstModportFTaskRef(FileLine* fl, const string& name, bool isExport) : ASTGEN_SUPER(fl) , m_name(name) - , m_export(isExport) - , m_ftaskp(nullptr) {} + , m_export(isExport) {} ASTNODE_NODE_FUNCS(ModportFTaskRef) virtual const char* broken() const override { BROKEN_RTN(m_ftaskp && !m_ftaskp->brokeExists()); @@ -2685,13 +2653,12 @@ class AstModportVarRef : public AstNode { private: string m_name; // Name of the variable referenced VDirection m_direction; // Direction of the variable (in/out) - AstVar* m_varp; // Link to the actual Var + AstVar* m_varp = nullptr; // Link to the actual Var public: AstModportVarRef(FileLine* fl, const string& name, VDirection::en direction) : ASTGEN_SUPER(fl) , m_name(name) - , m_direction(direction) - , m_varp(nullptr) {} + , m_direction(direction) {} ASTNODE_NODE_FUNCS(ModportVarRef) virtual const char* broken() const override { BROKEN_RTN(m_varp && !m_varp->brokeExists()); @@ -2743,7 +2710,7 @@ private: string m_name; // Cell name string m_origName; // Original name before dot addition string m_modName; // Module the cell instances - AstNodeModule* m_modp; // [AfterLink] Pointer to module instanced + AstNodeModule* m_modp = nullptr; // [AfterLink] Pointer to module instanced bool m_hasIfaceVar : 1; // True if a Var has been created for this cell bool m_recursive : 1; // Self-recursive module bool m_trace : 1; // Trace this cell @@ -2755,7 +2722,6 @@ public: , m_name(instName) , m_origName(instName) , m_modName(modName) - , m_modp(nullptr) , m_hasIfaceVar(false) , m_recursive(false) , m_trace(true) { @@ -2808,7 +2774,7 @@ class AstCellInline : public AstNode { private: string m_name; // Cell name, possibly {a}__DOT__{b}... string m_origModName; // Original name of the module, ignoring name() changes, for dot lookup - AstScope* m_scopep; // The scope that the cell is inlined into + AstScope* m_scopep = nullptr; // The scope that the cell is inlined into VTimescale m_timeunit; // Parent module time unit public: AstCellInline(FileLine* fl, const string& name, const string& origModName, @@ -2816,7 +2782,6 @@ public: : ASTGEN_SUPER(fl) , m_name(name) , m_origModName(origModName) - , m_scopep(nullptr) , m_timeunit(timeunit) {} ASTNODE_NODE_FUNCS(CellInline) virtual void dump(std::ostream& str) const override; @@ -3178,11 +3143,10 @@ class AstSenTree : public AstNode { // Parents: MODULE | SBLOCK // Children: SENITEM list private: - bool m_multi; // Created from combo logic by ORing multiple clock domains + bool m_multi = false; // Created from combo logic by ORing multiple clock domains public: AstSenTree(FileLine* fl, AstSenItem* sensesp) - : ASTGEN_SUPER(fl) - , m_multi(false) { + : ASTGEN_SUPER(fl) { addNOp1p(sensesp); } ASTNODE_NODE_FUNCS(SenTree) @@ -4500,12 +4464,11 @@ class AstJumpBlock : public AstNodeStmt { // Children: {statement list, with JumpGo and JumpLabel below} private: AstJumpLabel* m_labelp; // [After V3Jump] Pointer to declaration - int m_labelNum; // Set by V3EmitCSyms to tell final V3Emit what to increment + int m_labelNum = 0; // Set by V3EmitCSyms to tell final V3Emit what to increment public: // After construction must call ->labelp to associate with appropriate label AstJumpBlock(FileLine* fl, AstNode* stmtsp) - : ASTGEN_SUPER(fl) - , m_labelNum(0) { + : ASTGEN_SUPER(fl) { addNOp1p(stmtsp); } virtual const char* broken() const override; @@ -5016,7 +4979,7 @@ class AstTraceDecl : public AstNodeStmt { // Parents: {statement list} // Children: expression being traced private: - uint32_t m_code; // Trace identifier code; converted to ASCII by trace routines + uint32_t m_code = 0; // Trace identifier code; converted to ASCII by trace routines const string m_showname; // Name of variable const VNumRange m_bitRange; // Property of var the trace details const VNumRange m_arrayRange; // Property of var the trace details @@ -5031,7 +4994,6 @@ public: AstNode* valuep, const VNumRange& bitRange, const VNumRange& arrayRange, bool isScoped) : ASTGEN_SUPER(fl) - , m_code(0) , m_showname(showname) , m_bitRange(bitRange) , m_arrayRange(arrayRange) @@ -5177,14 +5139,13 @@ class AstScopeName : public AstNodeMath { // Parents: DISPLAY // Children: TEXT private: - bool m_dpiExport; // Is for dpiExport + bool m_dpiExport = false; // Is for dpiExport string scopeNameFormatter(AstText* scopeTextp) const; string scopePrettyNameFormatter(AstText* scopeTextp) const; public: explicit AstScopeName(FileLine* fl) - : ASTGEN_SUPER(fl) - , m_dpiExport(false) { + : ASTGEN_SUPER(fl) { dtypeSetUInt64(); } ASTNODE_NODE_FUNCS(ScopeName) @@ -8823,12 +8784,11 @@ public: class AstMTaskBody : public AstNode { // Hold statements for each MTask private: - ExecMTask* m_execMTaskp; + ExecMTask* m_execMTaskp = nullptr; public: explicit AstMTaskBody(FileLine* fl) - : ASTGEN_SUPER(fl) - , m_execMTaskp(nullptr) {} + : ASTGEN_SUPER(fl) {} ASTNODE_NODE_FUNCS(MTaskBody); virtual const char* broken() const override { BROKEN_RTN(!m_execMTaskp); @@ -8879,7 +8839,7 @@ public: class AstTypeTable : public AstNode { // Container for hash of standard data types // Children: NODEDTYPEs - AstVoidDType* m_voidp; + AstVoidDType* m_voidp = nullptr; AstBasicDType* m_basicps[AstBasicDTypeKwd::_ENUM_MAX]; // typedef std::map DetailedMap; @@ -8887,8 +8847,7 @@ class AstTypeTable : public AstNode { public: explicit AstTypeTable(FileLine* fl) - : ASTGEN_SUPER(fl) - , m_voidp(nullptr) { + : ASTGEN_SUPER(fl) { for (int i = 0; i < AstBasicDTypeKwd::_ENUM_MAX; ++i) m_basicps[i] = nullptr; } ASTNODE_NODE_FUNCS(TypeTable) @@ -8914,19 +8873,15 @@ class AstNetlist : public AstNode { // Parents: none // Children: MODULEs & CFILEs private: - AstTypeTable* m_typeTablep; // Reference to top type table, for faster lookup - AstPackage* m_dollarUnitPkgp; // $unit - AstCFunc* m_evalp; // The '_eval' function - AstExecGraph* m_execGraphp; // Execution MTask graph for threads>1 mode + AstTypeTable* m_typeTablep = nullptr; // Reference to top type table, for faster lookup + AstPackage* m_dollarUnitPkgp = nullptr; // $unit + AstCFunc* m_evalp = nullptr; // The '_eval' function + AstExecGraph* m_execGraphp = nullptr; // Execution MTask graph for threads>1 mode VTimescale m_timeunit; // Global time unit VTimescale m_timeprecision; // Global time precision public: AstNetlist() - : ASTGEN_SUPER(new FileLine(FileLine::builtInFilename())) - , m_typeTablep(nullptr) - , m_dollarUnitPkgp(nullptr) - , m_evalp(nullptr) - , m_execGraphp(nullptr) {} + : ASTGEN_SUPER(new FileLine(FileLine::builtInFilename())) {} ASTNODE_NODE_FUNCS(Netlist) virtual const char* broken() const override { BROKEN_RTN(m_dollarUnitPkgp && !m_dollarUnitPkgp->brokeExists()); diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index 726e07bba..4d52adb37 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -42,11 +42,10 @@ private: // Entire netlist: // AstNodeFTask::user1 -> bool, 1=processed AstUser1InUse m_inuser1; - bool m_anyFuncInBegin; + bool m_anyFuncInBegin = false; public: - BeginState() - : m_anyFuncInBegin(false) {} + BeginState() {} ~BeginState() {} void userMarkChanged(AstNode* nodep) { nodep->user1(true); @@ -61,11 +60,11 @@ class BeginVisitor : public AstNVisitor { private: // STATE BeginState* m_statep; // Current global state - AstNodeModule* m_modp; // Current module - AstNodeFTask* m_ftaskp; // Current function/task + AstNodeModule* m_modp = nullptr; // Current module + AstNodeFTask* m_ftaskp = nullptr; // Current function/task string m_namedScope; // Name of begin blocks above us string m_unnamedScope; // Name of begin blocks, including unnamed blocks - int m_ifDepth; // Current if depth + int m_ifDepth = 0; // Current if depth // METHODS VL_DEBUG_FUNC; // Declare debug() @@ -250,11 +249,8 @@ private: public: // CONSTRUCTORS - BeginVisitor(AstNetlist* nodep, BeginState* statep) { - m_statep = statep; - m_modp = nullptr; - m_ftaskp = nullptr; - m_ifDepth = 0; + BeginVisitor(AstNetlist* nodep, BeginState* statep) + : m_statep(statep) { iterate(nodep); } virtual ~BeginVisitor() override {} diff --git a/src/V3CUse.cpp b/src/V3CUse.cpp index 6153d04c6..9630f3749 100644 --- a/src/V3CUse.cpp +++ b/src/V3CUse.cpp @@ -78,7 +78,7 @@ public: class CUseDTypeVisitor : public AstNVisitor { // MEMBERS CUseState& m_stater; // State for inserter - bool m_impOnly; // In details needed only for implementation + bool m_impOnly = false; // In details needed only for implementation // METHODS virtual void visit(AstClassRefDType* nodep) override { if (nodep->user2SetOnce()) return; // Process once @@ -107,8 +107,7 @@ class CUseDTypeVisitor : public AstNVisitor { public: // CONSTRUCTORS explicit CUseDTypeVisitor(AstNodeModule* nodep, CUseState& stater) - : m_stater(stater) - , m_impOnly(false) { + : m_stater(stater) { iterate(nodep); } virtual ~CUseDTypeVisitor() override {} diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index a2396c765..e3ba1d4db 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -52,8 +52,8 @@ public: class CdcEitherVertex : public V3GraphVertex { AstScope* m_scopep; AstNode* m_nodep; - AstSenTree* m_srcDomainp; - AstSenTree* m_dstDomainp; + AstSenTree* m_srcDomainp = nullptr; + AstSenTree* m_dstDomainp = nullptr; bool m_srcDomainSet : 1; bool m_dstDomainSet : 1; bool m_asyncPath : 1; @@ -63,8 +63,6 @@ public: : V3GraphVertex(graphp) , m_scopep(scopep) , m_nodep(nodep) - , m_srcDomainp(nullptr) - , m_dstDomainp(nullptr) , m_srcDomainSet(false) , m_dstDomainSet(false) , m_asyncPath(false) {} @@ -87,15 +85,13 @@ public: class CdcVarVertex : public CdcEitherVertex { AstVarScope* m_varScp; - int m_cntAsyncRst; - bool m_fromFlop; + int m_cntAsyncRst = 0; + bool m_fromFlop = false; public: CdcVarVertex(V3Graph* graphp, AstScope* scopep, AstVarScope* varScp) : CdcEitherVertex(graphp, scopep, varScp) - , m_varScp(varScp) - , m_cntAsyncRst(0) - , m_fromFlop(false) {} + , m_varScp(varScp) {} virtual ~CdcVarVertex() override {} // ACCESSORS AstVarScope* varScp() const { return m_varScp; } @@ -169,9 +165,9 @@ private: public: // CONSTRUCTORS - CdcDumpVisitor(AstNode* nodep, std::ofstream* ofp, const string& prefix) { - m_ofp = ofp; - m_prefix = prefix; + CdcDumpVisitor(AstNode* nodep, std::ofstream* ofp, const string& prefix) + : m_ofp(ofp) + , m_prefix(prefix) { iterate(nodep); } virtual ~CdcDumpVisitor() override {} diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index 2132773f2..31d2adb7e 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -41,21 +41,14 @@ class ChangedState { public: // STATE - AstNodeModule* m_topModp; // Top module - AstScope* m_scopetopp; // Scope under TOPSCOPE - AstCFunc* m_chgFuncp; // Change function we're building - AstCFunc* m_tlChgFuncp; // Top level change function we're building - int m_numStmts; // Number of statements added to m_chgFuncp - int m_funcNum; // Number of change functions emitted + AstNodeModule* m_topModp = nullptr; // Top module + AstScope* m_scopetopp = nullptr; // Scope under TOPSCOPE + AstCFunc* m_chgFuncp = nullptr; // Change function we're building + AstCFunc* m_tlChgFuncp = nullptr; // Top level change function we're building + int m_numStmts = 0; // Number of statements added to m_chgFuncp + int m_funcNum = 0; // Number of change functions emitted - ChangedState() { - m_topModp = nullptr; - m_chgFuncp = nullptr; - m_scopetopp = nullptr; - m_tlChgFuncp = nullptr; - m_numStmts = 0; - m_funcNum = 0; - } + ChangedState() {} ~ChangedState() {} void maybeCreateChgFuncp() { @@ -284,8 +277,8 @@ private: public: // CONSTRUCTORS - ChangedVisitor(AstNetlist* nodep, ChangedState* statep) { - m_statep = statep; + ChangedVisitor(AstNetlist* nodep, ChangedState* statep) + : m_statep(statep) { iterate(nodep); } virtual ~ChangedVisitor() override {} diff --git a/src/V3Class.cpp b/src/V3Class.cpp index 36532b7e1..a9d2fc39c 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -34,7 +34,7 @@ private: // MEMBERS AstUser1InUse m_inuser1; string m_prefix; // String prefix to add to name based on hier - AstScope* m_classScopep; // Package moving scopes into + AstScope* m_classScopep = nullptr; // Package moving scopes into typedef std::vector> MoveVector; MoveVector m_moves; @@ -116,10 +116,7 @@ private: public: // CONSTRUCTORS - explicit ClassVisitor(AstNetlist* nodep) - : m_classScopep(nullptr) { - iterate(nodep); - } + explicit ClassVisitor(AstNetlist* nodep) { iterate(nodep); } virtual ~ClassVisitor() override { for (MoveVector::iterator it = m_moves.begin(); it != m_moves.end(); ++it) { it->second->addVarp(it->first->unlinkFrBack()); diff --git a/src/V3Config.cpp b/src/V3Config.cpp index 29755d912..4d12d2b06 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -118,15 +118,12 @@ typedef V3ConfigWildcardResolver V3ConfigVarResolver; class V3ConfigFTask { V3ConfigVarResolver m_vars; // Variables in function/task - bool m_isolate; // Isolate function return - bool m_noinline; // Don't inline function/task - bool m_public; // Public function/task + bool m_isolate = false; // Isolate function return + bool m_noinline = false; // Don't inline function/task + bool m_public = false; // Public function/task public: - V3ConfigFTask() - : m_isolate(false) - , m_noinline(false) - , m_public(false) {} + V3ConfigFTask() {} void update(const V3ConfigFTask& f) { // Don't overwrite true with false if (f.m_isolate) m_isolate = true; @@ -164,13 +161,11 @@ class V3ConfigModule { V3ConfigVarResolver m_vars; // Variables in module StringSet m_coverageOffBlocks; // List of block names for coverage_off PragmaSet m_modPragmas; // List of Pragmas for modules - bool m_inline; // Whether to force the inline - bool m_inlineValue; // The inline value (on/off) + bool m_inline = false; // Whether to force the inline + bool m_inlineValue = false; // The inline value (on/off) public: - V3ConfigModule() - : m_inline(false) - , m_inlineValue(false) {} + V3ConfigModule() {} void update(const V3ConfigModule& m) { m_tasks.update(m.m_tasks); diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 1942aa0ad..ca40cbe20 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -60,15 +60,11 @@ private: }; struct CheckState { // State save-restored on each new coverage scope/block - bool m_on; // Should this block get covered? - bool m_inModOff; // In module with no coverage - int m_handle; // Opaque handle for index into line tracking - const AstNode* m_nodep; // Node establishing this state - CheckState() - : m_on(false) - , m_inModOff(false) - , m_handle(0) - , m_nodep(nullptr) {} + bool m_on = false; // Should this block get covered? + bool m_inModOff = false; // In module with no coverage + int m_handle = 0; // Opaque handle for index into line tracking + const AstNode* m_nodep = nullptr; // Node establishing this state + CheckState() {} bool lineCoverageOn(const AstNode* nodep) { return m_on && !m_inModOff && nodep->fileline()->coverageOn() && v3Global.opt.coverageLine(); diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 4fcf257eb..f451e482f 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -45,11 +45,11 @@ private: typedef std::multimap FuncMmap; // STATE - AstNodeModule* m_modp; // Current module - AstScope* m_scopep; // Current scope - bool m_modSingleton; // m_modp is only instanced once - bool m_allowThis; // Allow function non-static - bool m_needThis; // Make function non-static + AstNodeModule* m_modp = nullptr; // Current module + AstScope* m_scopep = nullptr; // Current scope + bool m_modSingleton = false; // m_modp is only instanced once + bool m_allowThis = false; // Allow function non-static + bool m_needThis = false; // Make function non-static FuncMmap m_modFuncs; // Name of public functions added // METHODS @@ -293,14 +293,7 @@ private: public: // CONSTRUCTORS - explicit DescopeVisitor(AstNetlist* nodep) - : m_modp(nullptr) - , m_scopep(nullptr) - , m_modSingleton(false) - , m_allowThis(false) - , m_needThis(false) { - iterate(nodep); - } + explicit DescopeVisitor(AstNetlist* nodep) { iterate(nodep); } virtual ~DescopeVisitor() override {} }; diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index f3cfdebb7..a793aaa43 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -1287,10 +1287,10 @@ unsigned EmitVarTspSorter::m_serialNext = 0; class EmitCImp : EmitCStmts { // MEMBERS - AstNodeModule* m_modp; + AstNodeModule* m_modp = nullptr; std::vector m_blkChangeDetVec; // All encountered changes in block - bool m_slow; // Creating __Slow file - bool m_fast; // Creating non __Slow file (or both) + bool m_slow = false; // Creating __Slow file + bool m_fast = false; // Creating non __Slow file (or both) //--------------------------------------- // METHODS @@ -1771,11 +1771,7 @@ class EmitCImp : EmitCStmts { void maybeSplit(AstNodeModule* modp); public: - EmitCImp() { - m_modp = nullptr; - m_slow = false; - m_fast = false; - } + EmitCImp() {} virtual ~EmitCImp() override {} void mainImp(AstNodeModule* modp, bool slow); void mainInt(AstNodeModule* modp); diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index 9d502288e..0a51bdac0 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -33,8 +33,8 @@ class EmitCBaseVisitor : public AstNVisitor { public: // STATE - V3OutCFile* m_ofp; - bool m_trackText; // Always track AstText nodes + V3OutCFile* m_ofp = nullptr; + bool m_trackText = false; // Always track AstText nodes // METHODS V3OutCFile* ofp() const { return m_ofp; } void puts(const string& str) { ofp()->puts(str); } @@ -106,10 +106,7 @@ public: } // CONSTRUCTORS - EmitCBaseVisitor() { - m_ofp = nullptr; - m_trackText = false; - } + EmitCBaseVisitor() {} virtual ~EmitCBaseVisitor() override {} }; diff --git a/src/V3EmitXml.cpp b/src/V3EmitXml.cpp index e760f600d..8399dfcf1 100644 --- a/src/V3EmitXml.cpp +++ b/src/V3EmitXml.cpp @@ -35,7 +35,7 @@ class EmitXmlFileVisitor : public AstNVisitor { // MEMBERS V3OutFile* m_ofp; - uint64_t m_id; + uint64_t m_id = 0; // METHODS VL_DEBUG_FUNC; // Declare debug() @@ -245,9 +245,8 @@ class EmitXmlFileVisitor : public AstNVisitor { } public: - EmitXmlFileVisitor(AstNode* nodep, V3OutFile* ofp) { - m_ofp = ofp; - m_id = 0; + EmitXmlFileVisitor(AstNode* nodep, V3OutFile* ofp) + : m_ofp(ofp) { iterate(nodep); } virtual ~EmitXmlFileVisitor() override {} @@ -312,7 +311,7 @@ private: // MEMBERS std::ostream& m_os; std::string m_hier; - bool m_hasChildren; + bool m_hasChildren = false; // METHODS VL_DEBUG_FUNC; // Declare debug() @@ -362,9 +361,7 @@ private: public: // CONSTRUCTORS HierCellsXmlVisitor(AstNetlist* nodep, std::ostream& os) - : m_os(os) - , m_hier("") - , m_hasChildren(false) { + : m_os(os) { // Operate on whole netlist nodep->accept(*this); } diff --git a/src/V3File.h b/src/V3File.h index 5e1dda601..b5faee6aa 100644 --- a/src/V3File.h +++ b/src/V3File.h @@ -191,12 +191,11 @@ private: }; class V3OutCFile : public V3OutFile { - int m_guard; // Created header guard + int m_guard = false; // Created header guard int m_private; // 1 = Most recently emitted private:, 2 = public: public: explicit V3OutCFile(const string& filename) - : V3OutFile(filename, V3OutFormatter::LA_C) - , m_guard(false) { + : V3OutFile(filename, V3OutFormatter::LA_C) { resetPrivate(); } virtual ~V3OutCFile() override {} diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 9c0405539..242f488c1 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -68,16 +68,13 @@ public: class GateEitherVertex : public V3GraphVertex { AstScope* m_scopep; // Scope vertex refers to - bool m_reducible; // True if this node should be able to be eliminated - bool m_dedupable; // True if this node should be able to be deduped - bool m_consumed; // Output goes to something meaningful + bool m_reducible = true; // True if this node should be able to be eliminated + bool m_dedupable = true; // True if this node should be able to be deduped + bool m_consumed = false; // Output goes to something meaningful public: GateEitherVertex(V3Graph* graphp, AstScope* scopep) : V3GraphVertex(graphp) - , m_scopep(scopep) - , m_reducible(true) - , m_dedupable(true) - , m_consumed(false) {} + , m_scopep(scopep) {} virtual ~GateEitherVertex() override {} // ACCESSORS virtual string dotStyle() const override { return m_consumed ? "" : "dotted"; } @@ -128,18 +125,14 @@ public: class GateVarVertex : public GateEitherVertex { AstVarScope* m_varScp; - bool m_isTop; - bool m_isClock; - AstNode* m_rstSyncNodep; // Used as reset and not in SenItem, in clocked always - AstNode* m_rstAsyncNodep; // Used as reset and in SenItem, in clocked always + bool m_isTop = false; + bool m_isClock = false; + AstNode* m_rstSyncNodep = nullptr; // Used as reset and not in SenItem, in clocked always + AstNode* m_rstAsyncNodep = nullptr; // Used as reset and in SenItem, in clocked always public: GateVarVertex(V3Graph* graphp, AstScope* scopep, AstVarScope* varScp) : GateEitherVertex(graphp, scopep) - , m_varScp(varScp) - , m_isTop(false) - , m_isClock(false) - , m_rstSyncNodep(nullptr) - , m_rstAsyncNodep(nullptr) {} + , m_varScp(varScp) {} virtual ~GateVarVertex() override {} // ACCESSORS AstVarScope* varScp() const { return m_varScp; } @@ -202,14 +195,14 @@ public: class GateOkVisitor : public GateBaseVisitor { private: // RETURN STATE - bool m_isSimple; // Set false when we know it isn't simple + bool m_isSimple = true; // Set false when we know it isn't simple GateVarRefList m_rhsVarRefs; // VarRefs on rhs of assignment - AstNode* m_substTreep; // What to replace the variable with + AstNode* m_substTreep = nullptr; // What to replace the variable with // STATE bool m_buffersOnly; // Set when we only allow simple buffering, no equations (for clocks) - AstNodeVarRef* m_lhsVarRef; // VarRef on lhs of assignment (what we're replacing) + AstNodeVarRef* m_lhsVarRef = nullptr; // VarRef on lhs of assignment (what we're replacing) bool m_dedupe; // Set when we use isGateDedupable instead of isGateOptimizable - int m_ops; // Operation count + int m_ops = 0; // Operation count // METHODS void clearSimple(const char* because) { @@ -282,12 +275,8 @@ private: public: // CONSTRUCTORS GateOkVisitor(AstNode* nodep, bool buffersOnly, bool dedupe) { - m_isSimple = true; - m_substTreep = nullptr; m_buffersOnly = buffersOnly; - m_lhsVarRef = nullptr; m_dedupe = dedupe; - m_ops = 0; // Iterate iterate(nodep); // Check results @@ -1049,10 +1038,10 @@ class GateDedupeVarVisitor : public GateBaseVisitor { private: // STATE GateDedupeHash m_ghash; // Hash used to find dupes of rhs of assign - AstNodeAssign* m_assignp; // Assign found for dedupe - AstNode* m_ifCondp; // IF condition that assign is under - bool m_always; // Assign is under an always - bool m_dedupable; // Determined the assign to be dedupable + AstNodeAssign* m_assignp = nullptr; // Assign found for dedupe + AstNode* m_ifCondp = nullptr; // IF condition that assign is under + bool m_always = false; // Assign is under an always + bool m_dedupable = true; // Determined the assign to be dedupable // VISITORS virtual void visit(AstNodeAssign* assignp) override { @@ -1100,12 +1089,7 @@ private: public: // CONSTRUCTORS - GateDedupeVarVisitor() { - m_assignp = nullptr; - m_ifCondp = nullptr; - m_always = false; - m_dedupable = true; - } + GateDedupeVarVisitor() {} ~GateDedupeVarVisitor() {} // PUBLIC METHODS AstNodeVarRef* findDupe(AstNode* nodep, AstVarScope* consumerVarScopep, AstActive* activep) { @@ -1147,7 +1131,7 @@ private: // AstUser2InUse m_inuser2; (Allocated for use in GateVisitor) VDouble0 m_numDeduped; // Statistic tracking GateDedupeVarVisitor m_varVisitor; // Looks for a dupe of the logic - int m_depth; // Iteration depth + int m_depth = 0; // Iteration depth virtual VNUser visit(GateVarVertex* vvertexp, VNUser) override { // Check that we haven't been here before @@ -1235,8 +1219,7 @@ private: public: explicit GateDedupeGraphVisitor(V3Graph* graphp) - : GateGraphBaseVisitor(graphp) - , m_depth(0) {} + : GateGraphBaseVisitor(graphp) {} void dedupeTree(GateVarVertex* vvertexp) { vvertexp->accept(*this); } VDouble0 numDeduped() { return m_numDeduped; } }; @@ -1405,10 +1388,10 @@ void GateVisitor::mergeAssigns() { class GateConcatVisitor : public GateBaseVisitor { private: // STATE - AstVarScope* m_vscp; // Varscope we're trying to find - int m_offset; // Current offset of varscope - int m_found_offset; // Found offset of varscope - bool m_found; // Offset found + AstVarScope* m_vscp = nullptr; // Varscope we're trying to find + int m_offset = 0; // Current offset of varscope + int m_found_offset = 0; // Found offset of varscope + bool m_found = false; // Offset found // VISITORS virtual void visit(AstNodeVarRef* nodep) override { @@ -1433,12 +1416,7 @@ private: public: // CONSTRUCTORS - GateConcatVisitor() { - m_vscp = nullptr; - m_offset = 0; - m_found_offset = 0; - m_found = false; - } + GateConcatVisitor() {} virtual ~GateConcatVisitor() override {} // PUBLIC METHODS bool concatOffset(AstConcat* concatp, AstVarScope* vscp, int& offsetr) { @@ -1462,10 +1440,9 @@ class GateClkDecompState { public: int m_offset; AstVarScope* m_last_vsp; - GateClkDecompState(int offset, AstVarScope* vsp) { - m_offset = offset; - m_last_vsp = vsp; - } + GateClkDecompState(int offset, AstVarScope* vsp) + : m_offset(offset) + , m_last_vsp(vsp) {} virtual ~GateClkDecompState() {} }; diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index 07805aff9..73a2e426e 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -47,9 +47,9 @@ private: AstUser3InUse m_inuser3; // STATE - AstActive* m_activep; // Inside activate statement + AstActive* m_activep = nullptr; // Inside activate statement AstNodeModule* m_topModp; // Top module - AstScope* m_scopetopp; // Scope under TOPSCOPE + AstScope* m_scopetopp = nullptr; // Scope under TOPSCOPE // METHODS AstVarScope* genInpClk(AstVarScope* vscp) { @@ -118,10 +118,8 @@ private: public: // CONSTRUCTORS - GenClkRenameVisitor(AstTopScope* nodep, AstNodeModule* topModp) { - m_topModp = topModp; - m_scopetopp = nullptr; - m_activep = nullptr; + GenClkRenameVisitor(AstTopScope* nodep, AstNodeModule* topModp) + : m_topModp(topModp) { iterate(nodep); } virtual ~GenClkRenameVisitor() override {} @@ -138,10 +136,10 @@ private: AstUser1InUse m_inuser1; // STATE - AstActive* m_activep; // Inside activate statement - bool m_tracingCall; // Iterating into a call to a cfunc - AstNodeAssign* m_assignp; // Inside assigndly statement - AstNodeModule* m_topModp; // Top module + bool m_tracingCall = false; // Iterating into a call to a cfunc + AstActive* m_activep = nullptr; // Inside activate statement + AstNodeAssign* m_assignp = nullptr; // Inside assigndly statement + AstNodeModule* m_topModp = nullptr; // Top module // VISITORS virtual void visit(AstTopScope* nodep) override { @@ -216,13 +214,7 @@ private: public: // CONSTRUCTORS - explicit GenClkReadVisitor(AstNetlist* nodep) - : m_activep(nullptr) - , m_tracingCall(false) - , m_assignp(nullptr) - , m_topModp(nullptr) { - iterate(nodep); - } + explicit GenClkReadVisitor(AstNetlist* nodep) { iterate(nodep); } virtual ~GenClkReadVisitor() override {} }; diff --git a/src/V3Global.h b/src/V3Global.h index 012414d71..e3a21aa54 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -73,14 +73,14 @@ class V3Global { V3HierBlockPlan* m_hierPlanp; // Hierarchical verilation plan, nullptr unless hier_block VWidthMinUsage m_widthMinUsage; // What AstNode::widthMin() is used for - int m_debugFileNumber; // Number to append to debug files created - bool m_assertDTypesResolved; // Tree should have dtypep()'s - bool m_constRemoveXs; // Const needs to strip any Xs - bool m_needC11; // Need C++11 - bool m_needHeavy; // Need verilated_heavy.h include - bool m_needTraceDumper; // Need __Vm_dumperp in symbols - bool m_dpi; // Need __Dpi include files - bool m_useParallelBuild; // Use parallel build for model + int m_debugFileNumber = 0; // Number to append to debug files created + bool m_assertDTypesResolved = false; // Tree should have dtypep()'s + bool m_constRemoveXs = false; // Const needs to strip any Xs + bool m_needC11 = false; // Need C++11 + bool m_needHeavy = false; // Need verilated_heavy.h include + bool m_needTraceDumper = false; // Need __Vm_dumperp in symbols + bool m_dpi = false; // Need __Dpi include files + bool m_useParallelBuild = false; // Use parallel build for model // Memory address to short string mapping (for debug) typedef std::unordered_map PtrToIdMap; // The map type @@ -94,15 +94,7 @@ public: 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) - , m_debugFileNumber(0) - , m_assertDTypesResolved(false) - , m_constRemoveXs(false) - , m_needC11(false) - , m_needHeavy(false) - , m_needTraceDumper(false) - , m_dpi(false) - , m_useParallelBuild(false) {} + , m_widthMinUsage(VWidthMinUsage::LINT_WIDTH) {} AstNetlist* makeNetlist(); void boot() { UASSERT(!m_rootp, "call once"); diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index 222712aff..32fa58244 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -35,16 +35,13 @@ class GraphAcycVertex : public V3GraphVertex { protected: friend class GraphAcyc; V3ListEnt m_work; // List of vertices with optimization work left - uint32_t m_storedRank; // Rank held until commit to edge placement - bool m_onWorkList; // True if already on list of work to do - bool m_deleted; // True if deleted + uint32_t m_storedRank = 0; // Rank held until commit to edge placement + bool m_onWorkList = false; // True if already on list of work to do + bool m_deleted = false; // True if deleted public: GraphAcycVertex(V3Graph* graphp, V3GraphVertex* origVertexp) : V3GraphVertex(graphp) - , m_origVertexp(origVertexp) - , m_storedRank(0) - , m_onWorkList(false) - , m_deleted(false) {} + , m_origVertexp(origVertexp) {} virtual ~GraphAcycVertex() override {} V3GraphVertex* origVertexp() const { return m_origVertexp; } void setDelete() { m_deleted = true; } @@ -106,7 +103,7 @@ private: V3List m_work; // List of vertices with optimization work left std::vector m_origEdgeDelp; // List of deletions to do when done V3EdgeFuncP m_origEdgeFuncp; // Function that says we follow this edge (in original graph) - uint32_t m_placeStep; // Number that user() must be equal to to indicate processing + uint32_t m_placeStep = 0; // Number that user() must be equal to to indicate processing static int debug() { return V3Graph::debug(); } @@ -188,11 +185,9 @@ private: public: // CONSTRUCTORS - GraphAcyc(V3Graph* origGraphp, V3EdgeFuncP edgeFuncp) { - m_origGraphp = origGraphp; - m_origEdgeFuncp = edgeFuncp; - m_placeStep = 0; - } + GraphAcyc(V3Graph* origGraphp, V3EdgeFuncP edgeFuncp) + : m_origGraphp(origGraphp) + , m_origEdgeFuncp(edgeFuncp) {} ~GraphAcyc() { for (std::vector::iterator it = m_origEdgeDelp.begin(); it != m_origEdgeDelp.end(); ++it) { diff --git a/src/V3GraphPathChecker.cpp b/src/V3GraphPathChecker.cpp index b985d5877..c9014311e 100644 --- a/src/V3GraphPathChecker.cpp +++ b/src/V3GraphPathChecker.cpp @@ -38,11 +38,10 @@ struct GraphPCNode { // operation. We'll use this in pathExistsInternal() to avoid checking // the same node twice, and again in updateHalfCriticalPath() to assert // there are no cycles. - vluint64_t m_seenAtGeneration; + vluint64_t m_seenAtGeneration = 0; // CONSTRUCTORS - GraphPCNode() - : m_seenAtGeneration(0) { + GraphPCNode() { for (int w = 0; w < GraphWay::NUM_WAYS; w++) m_cp[w] = 0; } ~GraphPCNode() {} diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index 4eebb0ebc..f3259f63b 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -236,8 +236,8 @@ class HierBlockUsageCollectVisitor : public AstNVisitor { // STATE typedef std::set ModuleSet; V3HierBlockPlan* const m_planp; - AstModule* m_modp; // The current module - AstModule* m_hierBlockp; // The nearest parent module that is a hierarchical block + AstModule* m_modp = nullptr; // The current module + AstModule* m_hierBlockp = nullptr; // The nearest parent module that is a hierarchical block ModuleSet m_referred; // Modules that have hier_block pragma V3HierBlock::GParams m_gparams; // list of variables that is AstVarType::GPARAM @@ -293,10 +293,7 @@ class HierBlockUsageCollectVisitor : public AstNVisitor { public: HierBlockUsageCollectVisitor(V3HierBlockPlan* planp, AstNetlist* netlist) - : m_planp(planp) - , m_modp(nullptr) - , m_hierBlockp(nullptr) { - + : m_planp(planp) { iterateChildren(netlist); } VL_DEBUG_FUNC; // Declare debug() diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 5a17ab793..6ed66a421 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -470,9 +470,9 @@ private: public: // CONSTRUCTORS - InlineRelinkVisitor(AstNodeModule* cloneModp, AstNodeModule* oldModp, AstCell* cellp) { - m_modp = oldModp; - m_cellp = cellp; + InlineRelinkVisitor(AstNodeModule* cloneModp, AstNodeModule* oldModp, AstCell* cellp) + : m_modp(oldModp) + , m_cellp(cellp) { iterate(cloneModp); } virtual ~InlineRelinkVisitor() override {} diff --git a/src/V3InstrCount.cpp b/src/V3InstrCount.cpp index 61f40e16c..6d71f3773 100644 --- a/src/V3InstrCount.cpp +++ b/src/V3InstrCount.cpp @@ -37,10 +37,10 @@ private: AstUser4InUse m_inuser4; // MEMBERS - uint32_t m_instrCount; // Running count of instructions + uint32_t m_instrCount = 0; // Running count of instructions const AstNode* m_startNodep; // Start node of count - bool m_tracingCall; // Iterating into a CCall to a CFunc - bool m_inCFunc; // Inside AstCFunc + bool m_tracingCall = false; // Iterating into a CCall to a CFunc + bool m_inCFunc = false; // Inside AstCFunc bool m_assertNoDups; // Check for duplicates std::ostream* m_osp; // Dump file @@ -69,10 +69,7 @@ private: public: // CONSTRUCTORS InstrCountVisitor(AstNode* nodep, bool assertNoDups, std::ostream* osp) - : m_instrCount(0) - , m_startNodep(nodep) - , m_tracingCall(false) - , m_inCFunc(false) + : m_startNodep(nodep) , m_assertNoDups(assertNoDups) , m_osp(osp) { if (nodep) iterate(nodep); @@ -269,13 +266,12 @@ private: // MEMBERS std::ostream* m_osp; // Dump file - unsigned m_depth; // Current tree depth for printing indent + unsigned m_depth = 0; // Current tree depth for printing indent public: // CONSTRUCTORS InstrCountDumpVisitor(AstNode* nodep, std::ostream* osp) - : m_osp(osp) - , m_depth(0) { + : m_osp(osp) { // No check for nullptr output, so... UASSERT_OBJ(osp, nodep, "Don't call if not dumping"); if (nodep) iterate(nodep); diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 886d85730..00e5e9d08 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -280,9 +280,9 @@ class LifeVisitor : public AstNVisitor { private: // STATE LifeState* m_statep; // Current state - bool m_sideEffect; // Side effects discovered in assign RHS - bool m_noopt; // Disable optimization of variables in this block - bool m_tracingCall; // Iterating into a CCall to a CFunc + 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 // LIFE MAP // For each basic block, we'll make a new map of what variables that if/else is changing @@ -444,9 +444,6 @@ public: LifeVisitor(AstNode* nodep, LifeState* statep) { UINFO(4, " LifeVisitor on " << nodep << endl); m_statep = statep; - m_sideEffect = false; - m_noopt = false; - m_tracingCall = false; { m_lifep = new LifeBlock(nullptr, m_statep); iterate(nodep); @@ -486,8 +483,8 @@ private: public: // CONSTRUCTORS - LifeTopVisitor(AstNetlist* nodep, LifeState* statep) { - m_statep = statep; + LifeTopVisitor(AstNetlist* nodep, LifeState* statep) + : m_statep(statep) { iterate(nodep); } virtual ~LifeTopVisitor() override {} diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 577e15a2f..f21f28ff6 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -42,7 +42,7 @@ class LifePostElimVisitor : public AstNVisitor { private: - bool m_tracingCall; // Iterating into a CCall to a CFunc + bool m_tracingCall = false; // Iterating into a CCall to a CFunc // NODE STATE // INPUT: @@ -90,10 +90,7 @@ private: public: // CONSTRUCTORS - explicit LifePostElimVisitor(AstTopScope* nodep) - : m_tracingCall(false) { - iterate(nodep); - } + explicit LifePostElimVisitor(AstTopScope* nodep) { iterate(nodep); } virtual ~LifePostElimVisitor() override {} }; @@ -142,12 +139,12 @@ private: AstUser4InUse m_inuser4; // STATE - uint32_t m_sequence; // Sequence number of assigns/varrefs, + uint32_t m_sequence = 0; // Sequence number of assigns/varrefs, // // local to the current MTask. - const ExecMTask* m_execMTaskp; // Current ExecMTask being processed, + const ExecMTask* m_execMTaskp = nullptr; // Current ExecMTask being processed, // // or nullptr for serial code. VDouble0 m_statAssnDel; // Statistic tracking - bool m_tracingCall; // Currently tracing a CCall to a CFunc + bool m_tracingCall = false; // Currently tracing a CCall to a CFunc // Map each varscope to one or more locations where it's accessed. // These maps will not include any ASSIGNPOST accesses: @@ -159,7 +156,7 @@ private: typedef std::unordered_map PostLocMap; PostLocMap m_assignposts; // AssignPost dly var locations - const V3Graph* m_mtasksGraphp; // Mtask tracking graph + const V3Graph* m_mtasksGraphp = nullptr; // Mtask tracking graph std::unique_ptr m_checker; // METHODS @@ -347,13 +344,7 @@ private: public: // CONSTRUCTORS - explicit LifePostDlyVisitor(AstNetlist* nodep) - : m_sequence(0) - , m_execMTaskp(nullptr) - , m_tracingCall(false) - , m_mtasksGraphp(nullptr) { - iterate(nodep); - } + explicit LifePostDlyVisitor(AstNetlist* nodep) { iterate(nodep); } virtual ~LifePostDlyVisitor() override { V3Stats::addStat("Optimizations, Lifetime postassign deletions", m_statAssnDel); } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 544a0bcec..843e9f2f2 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -706,17 +706,17 @@ LinkDotState* LinkDotState::s_errorThisp = nullptr; class LinkDotFindVisitor : public AstNVisitor { // STATE LinkDotState* m_statep; // State to pass between visitors, including symbol table - AstNodeModule* m_packagep; // Current package - VSymEnt* m_modSymp; // Symbol Entry for current module - VSymEnt* m_curSymp; // Symbol Entry for current table, where to lookup/insert + AstNodeModule* m_packagep = nullptr; // Current package + VSymEnt* m_modSymp = nullptr; // Symbol Entry for current module + VSymEnt* m_curSymp = nullptr; // Symbol Entry for current table, where to lookup/insert string m_scope; // Scope text - AstNodeBlock* m_blockp; // Current Begin/end block - AstNodeFTask* m_ftaskp; // Current function/task - bool m_inRecursion; // Inside a recursive module - int m_paramNum; // Parameter number, for position based connection - int m_blockNum; // Begin block number, 0=none seen - bool m_explicitNew; // Hit a "new" function - int m_modBlockNum; // Begin block number in module, 0=none seen + AstNodeBlock* m_blockp = nullptr; // Current Begin/end block + AstNodeFTask* m_ftaskp = nullptr; // Current function/task + bool m_inRecursion = false; // Inside a recursive module + int m_paramNum = 0; // Parameter number, for position based connection + int m_blockNum = 0; // Begin block number, 0=none seen + bool m_explicitNew = false; // Hit a "new" function + int m_modBlockNum = 0; // Begin block number in module, 0=none seen // METHODS int debug() { return LinkDotState::debug(); } @@ -1252,19 +1252,10 @@ class LinkDotFindVisitor : public AstNVisitor { public: // CONSTRUCTORS - LinkDotFindVisitor(AstNetlist* rootp, LinkDotState* statep) { + LinkDotFindVisitor(AstNetlist* rootp, LinkDotState* statep) + : m_statep(statep) { UINFO(4, __FUNCTION__ << ": " << endl); - m_packagep = nullptr; - m_curSymp = m_modSymp = nullptr; - m_statep = statep; - m_blockp = nullptr; - m_ftaskp = nullptr; - m_inRecursion = false; - m_paramNum = 0; - m_blockNum = 0; - m_explicitNew = false; - m_modBlockNum = 0; - // + iterate(rootp); } virtual ~LinkDotFindVisitor() override {} @@ -1282,7 +1273,7 @@ private: // STATE LinkDotState* m_statep; // State to pass between visitors, including symbol table - AstNodeModule* m_modp; // Current module + AstNodeModule* m_modp = nullptr; // Current module int debug() { return LinkDotState::debug(); } @@ -1427,11 +1418,9 @@ private: public: // CONSTRUCTORS - LinkDotParamVisitor(AstNetlist* rootp, LinkDotState* statep) { + LinkDotParamVisitor(AstNetlist* rootp, LinkDotState* statep) + : m_statep(statep) { UINFO(4, __FUNCTION__ << ": " << endl); - m_statep = statep; - m_modp = nullptr; - // iterate(rootp); } virtual ~LinkDotParamVisitor() override {} @@ -1443,8 +1432,8 @@ class LinkDotScopeVisitor : public AstNVisitor { // STATE LinkDotState* m_statep; // State to pass between visitors, including symbol table - AstScope* m_scopep; // The current scope - VSymEnt* m_modSymp; // Symbol entry for current module + AstScope* m_scopep = nullptr; // The current scope + VSymEnt* m_modSymp = nullptr; // Symbol entry for current module int debug() { return LinkDotState::debug(); } @@ -1582,12 +1571,9 @@ class LinkDotScopeVisitor : public AstNVisitor { public: // CONSTRUCTORS - LinkDotScopeVisitor(AstNetlist* rootp, LinkDotState* statep) { + LinkDotScopeVisitor(AstNetlist* rootp, LinkDotState* statep) + : m_statep(statep) { UINFO(4, __FUNCTION__ << ": " << endl); - m_modSymp = nullptr; - m_scopep = nullptr; - m_statep = statep; - // iterate(rootp); } virtual ~LinkDotScopeVisitor() override {} @@ -1713,13 +1699,13 @@ private: // STATE LinkDotState* m_statep; // State, including dotted symbol table - VSymEnt* m_curSymp; // SymEnt for current lookup point - VSymEnt* m_modSymp; // SymEnt for current module - VSymEnt* m_pinSymp; // SymEnt for pin lookups - AstCell* m_cellp; // Current cell - AstNodeModule* m_modp; // Current module - AstNodeFTask* m_ftaskp; // Current function/task - int m_modportNum; // Uniqueify modport numbers + VSymEnt* m_curSymp = nullptr; // SymEnt for current lookup point + VSymEnt* m_modSymp = nullptr; // SymEnt for current module + VSymEnt* m_pinSymp = nullptr; // SymEnt for pin lookups + AstCell* m_cellp = nullptr; // Current cell + AstNodeModule* m_modp = nullptr; // Current module + AstNodeFTask* m_ftaskp = nullptr; // Current function/task + int m_modportNum = 0; // Uniqueify modport numbers struct DotStates { DotPosition m_dotPos; // Scope part of dotted resolution @@ -2812,17 +2798,9 @@ private: public: // CONSTRUCTORS - LinkDotResolveVisitor(AstNetlist* rootp, LinkDotState* statep) { + LinkDotResolveVisitor(AstNetlist* rootp, LinkDotState* statep) + : m_statep(statep) { UINFO(4, __FUNCTION__ << ": " << endl); - m_statep = statep; - m_modSymp = nullptr; - m_curSymp = nullptr; - m_pinSymp = nullptr; - m_cellp = nullptr; - m_modp = nullptr; - m_ftaskp = nullptr; - m_modportNum = 0; - // iterate(rootp); } virtual ~LinkDotResolveVisitor() override {} diff --git a/src/V3LinkLValue.cpp b/src/V3LinkLValue.cpp index e1c33b58a..12d71736c 100644 --- a/src/V3LinkLValue.cpp +++ b/src/V3LinkLValue.cpp @@ -36,7 +36,7 @@ private: // STATE bool m_setRefLvalue; // Set VarRefs to lvalues for pin assignments - AstNodeFTask* m_ftaskp; // Function or task we're inside + AstNodeFTask* m_ftaskp = nullptr; // Function or task we're inside // METHODS VL_DEBUG_FUNC; // Declare debug() @@ -298,9 +298,8 @@ private: public: // CONSTRUCTORS - LinkLValueVisitor(AstNode* nodep, bool start) { - m_setRefLvalue = start; - m_ftaskp = nullptr; + LinkLValueVisitor(AstNode* nodep, bool start) + : m_setRefLvalue(start) { iterate(nodep); } virtual ~LinkLValueVisitor() override {} diff --git a/src/V3List.h b/src/V3List.h index 54c652a4e..5022e6d38 100644 --- a/src/V3List.h +++ b/src/V3List.h @@ -31,14 +31,12 @@ template class V3List { // List container for linked list of elements of type *T (T is a pointer type) private: // MEMBERS - T m_headp; // First element - T m_tailp; // Last element + T m_headp = nullptr; // First element + T m_tailp = nullptr; // Last element friend class V3ListEnt; public: - V3List() - : m_headp(nullptr) - , m_tailp(nullptr) {} + V3List() {} ~V3List() {} // METHODS T begin() const { return m_headp; } @@ -56,8 +54,8 @@ template class V3ListEnt { // List entry for linked list of elements of type *T (T is a pointer type) private: // MEMBERS - T m_nextp; // Pointer to next element, nullptr=end - T m_prevp; // Pointer to previous element, nullptr=beginning + T m_nextp = nullptr; // Pointer to next element, nullptr=end + T m_prevp = nullptr; // Pointer to previous element, nullptr=beginning friend class V3List; static V3ListEnt* baseToListEnt(void* newbasep, size_t offset) { // "this" must be a element inside of *basep @@ -67,9 +65,7 @@ private: } public: - V3ListEnt() - : m_nextp(nullptr) - , m_prevp(nullptr) {} + V3ListEnt() {} ~V3ListEnt() { #ifdef VL_DEBUG // Load bogus pointers so we can catch deletion bugs diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 31f3009c5..8fb69e93e 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -55,7 +55,8 @@ class CheckMergeableVisitor : public AstNVisitor { private: // STATE - bool m_mergeable; // State tracking whether tree being processed is a mergeable condition + bool m_mergeable + = false; // State tracking whether tree being processed is a mergeable condition // METHODS VL_DEBUG_FUNC; // Declare debug() @@ -85,8 +86,7 @@ private: } public: - CheckMergeableVisitor() - : m_mergeable(false) {} + CheckMergeableVisitor() {} // Return false if this node should not be merged at all because: // - It contains an impure expression diff --git a/src/V3Order.cpp b/src/V3Order.cpp index d03538797..067725491 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -128,7 +128,7 @@ public: V3ListEnt m_readyDomScopeE; // List of next ready dom scope V3List m_readyVertices; // Ready vertices with same domain & scope private: - bool m_onReadyList; // True if DomScope is already on list of ready dom/scopes + bool m_onReadyList = false; // True if DomScope is already on list of ready dom/scopes const AstSenTree* m_domainp; // Domain all vertices belong to const AstScope* m_scopep; // Scope all vertices belong to @@ -138,8 +138,7 @@ private: public: OrderMoveDomScope(const AstSenTree* domainp, const AstScope* scopep) - : m_onReadyList(false) - , m_domainp(domainp) + : m_domainp(domainp) , m_scopep(scopep) {} OrderMoveDomScope* readyDomScopeNextp() const { return m_readyDomScopeE.nextp(); } const AstSenTree* domainp() const { return m_domainp; } @@ -661,25 +660,25 @@ private: // STATE OrderGraph m_graph; // Scoreboard of var usages/dependencies SenTreeFinder m_finder; // Find global sentree's and add them - AstSenTree* m_comboDomainp; // Combo activation tree - AstSenTree* m_deleteDomainp; // Delete this from tree - OrderInputsVertex* m_inputsVxp; // Top level vertex all inputs point from - OrderLogicVertex* m_logicVxp; // Current statement being tracked, nullptr=ignored - AstTopScope* m_topScopep; // Current top scope being processed - AstScope* m_scopetopp; // Scope under TOPSCOPE - AstNodeModule* m_modp; // Current module - AstScope* m_scopep; // Current scope being processed - AstActive* m_activep; // Current activation block - bool m_inSenTree; // Underneath AstSenItem; any varrefs are clocks - bool m_inClocked; // Underneath clocked block - bool m_inClkAss; // Underneath AstAssign - bool m_inPre; // Underneath AstAssignPre - bool m_inPost; // Underneath AstAssignPost - OrderLogicVertex* m_activeSenVxp; // Sensitivity vertex + AstSenTree* m_comboDomainp = nullptr; // Combo activation tree + AstSenTree* m_deleteDomainp = nullptr; // Delete this from tree + OrderInputsVertex* m_inputsVxp = nullptr; // Top level vertex all inputs point from + OrderLogicVertex* m_logicVxp = nullptr; // Current statement being tracked, nullptr=ignored + AstTopScope* m_topScopep = nullptr; // Current top scope being processed + AstScope* m_scopetopp = nullptr; // Scope under TOPSCOPE + AstNodeModule* m_modp = nullptr; // Current module + AstScope* m_scopep = nullptr; // Current scope being processed + AstActive* m_activep = nullptr; // Current activation block + bool m_inSenTree = false; // Underneath AstSenItem; any varrefs are clocks + bool m_inClocked = false; // Underneath clocked block + bool m_inClkAss = false; // Underneath AstAssign + bool m_inPre = false; // Underneath AstAssignPre + bool m_inPost = false; // Underneath AstAssignPost + OrderLogicVertex* m_activeSenVxp = nullptr; // Sensitivity vertex std::deque m_orderUserps; // All created OrderUser's for later deletion. // STATE... for inside process - AstCFunc* m_pomNewFuncp; // Current function being created - int m_pomNewStmts; // Statements in function being created + AstCFunc* m_pomNewFuncp = nullptr; // Current function being created + int m_pomNewStmts = 0; // Statements in function being created V3Graph m_pomGraph; // Graph of logic elements to move V3List m_pomWaiting; // List of nodes needing inputs to become ready protected: @@ -755,12 +754,10 @@ private: // processMTask* routines schedule threaded execution struct MTaskState { typedef std::list Logics; - AstMTaskBody* m_mtaskBodyp; + AstMTaskBody* m_mtaskBodyp = nullptr; Logics m_logics; - ExecMTask* m_execMTaskp; - MTaskState() - : m_mtaskBodyp(nullptr) - , m_execMTaskp(nullptr) {} + ExecMTask* m_execMTaskp = nullptr; + MTaskState() {} }; void processMTasks(); typedef enum { LOGIC_INITIAL, LOGIC_SETTLE } InitialLogicE; @@ -1222,22 +1219,6 @@ private: public: // CONSTRUCTORS OrderVisitor() { - m_topScopep = nullptr; - m_scopetopp = nullptr; - m_modp = nullptr; - m_scopep = nullptr; - m_activep = nullptr; - m_inSenTree = false; - m_inClocked = false; - m_inClkAss = false; - m_inPre = m_inPost = false; - m_comboDomainp = nullptr; - m_deleteDomainp = nullptr; - m_inputsVxp = nullptr; - m_activeSenVxp = nullptr; - m_logicVxp = nullptr; - m_pomNewFuncp = nullptr; - m_pomNewStmts = 0; if (debug()) m_graph.debug(5); // 3 is default if global debug; we want acyc debugging } virtual ~OrderVisitor() override { diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 1e976f65f..604229780 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -185,7 +185,7 @@ private: // // from graph-start to current node, or REVERSE // // from graph-end to current node. T_CostAccessor* m_accessp; // Access cost and CPs on V3GraphVertex's. - vluint64_t m_generation; // Mark each vertex with this number; + vluint64_t m_generation = 0; // Mark each vertex with this number; // // confirm we only process each vertex once. bool m_slowAsserts; // Enable nontrivial asserts typedef SortByValueMap PropCpPendSet; @@ -198,7 +198,6 @@ public: : GraphAlg<>(graphp, edgeFuncp) , m_way(way) , m_accessp(accessp) - , m_generation(0) , m_slowAsserts(slowAsserts) {} // METHODS @@ -445,7 +444,7 @@ private: // Cost estimate for this LogicMTask, derived from V3InstrCount. // In abstract time units. - uint32_t m_cost; + uint32_t m_cost = 0; // Cost of critical paths going FORWARD from graph-start to the start // of this vertex, and also going REVERSE from the end of the graph to @@ -458,7 +457,7 @@ private: // graph. We'll mark each node with the last generation that scanned // it. We can use this to avoid recursing through the same node twice // while searching for a path. - vluint64_t m_generation; + vluint64_t m_generation = 0; // Redundant with the V3GraphEdge's, store a map of relatives so we can // quickly check if we have a given parent or child. @@ -473,9 +472,7 @@ private: public: // CONSTRUCTORS LogicMTask(V3Graph* graphp, MTaskMoveVertex* mtmvVxp) - : AbstractLogicMTask(graphp) - , m_cost(0) - , m_generation(0) { + : AbstractLogicMTask(graphp) { for (int i = 0; i < GraphWay::NUM_WAYS; ++i) m_critPathCost[i] = 0; if (mtmvVxp) { // Else null for test m_vertices.push_back(mtmvVxp); @@ -730,12 +727,11 @@ public: // Information associated with scoreboarding an MTask class MergeCandidate { private: - bool m_removedFromSb; // Not on scoreboard, generally ignore + bool m_removedFromSb = false; // Not on scoreboard, generally ignore vluint64_t m_id; // Serial number for ordering public: // CONSTRUCTORS - MergeCandidate() - : m_removedFromSb(false) { + MergeCandidate() { static vluint64_t serial = 0; ++serial; m_id = serial; @@ -852,23 +848,19 @@ class PartParallelismEst { // The ratio of m_totalGraphCost to longestCpCost gives us an estimate // of the parallelizability of this graph which is only as good as the // guess returned by LogicMTask::cost(). - uint32_t m_totalGraphCost; + uint32_t m_totalGraphCost = 0; // Cost of the longest critical path, in abstract units (the same units // returned by the vertexCost) - uint32_t m_longestCpCost; + uint32_t m_longestCpCost = 0; - size_t m_vertexCount; // Number of vertexes calculated - size_t m_edgeCount; // Number of edges calculated + size_t m_vertexCount = 0; // Number of vertexes calculated + size_t m_edgeCount = 0; // Number of edges calculated public: // CONSTRUCTORS explicit PartParallelismEst(const V3Graph* graphp) - : m_graphp(graphp) - , m_totalGraphCost(0) - , m_longestCpCost(0) - , m_vertexCount(0) - , m_edgeCount(0) {} + : m_graphp(graphp) {} // METHODS uint32_t totalGraphCost() const { return m_totalGraphCost; } @@ -1082,8 +1074,8 @@ private: // MEMBERS V3Graph* m_mtasksp; // Mtask graph uint32_t m_scoreLimit; // Sloppy score allowed when picking merges - uint32_t m_scoreLimitBeforeRescore; // Next score rescore at - unsigned m_mergesSinceRescore; // Merges since last rescore + uint32_t m_scoreLimitBeforeRescore = 0xffffffff; // Next score rescore at + unsigned m_mergesSinceRescore = 0; // Merges since last rescore bool m_slowAsserts; // Take extra time to validate algorithm V3Scoreboard m_sb; // Scoreboard SibSet m_pairs; // Storage for each SiblingMC @@ -1094,8 +1086,6 @@ public: PartContraction(V3Graph* mtasksp, uint32_t scoreLimit, bool slowAsserts) : m_mtasksp(mtasksp) , m_scoreLimit(scoreLimit) - , m_scoreLimitBeforeRescore(0xffffffff) - , m_mergesSinceRescore(0) , m_slowAsserts(slowAsserts) , m_sb(&mergeCandidateScore, slowAsserts) {} @@ -1670,8 +1660,8 @@ const GraphWay* PartContraction::s_shortestWaywardCpInclusiveWay = nullptr; // routine. class DpiImportCallVisitor : public AstNVisitor { private: - bool m_hasDpiHazard; // Found a DPI import call. - bool m_tracingCall; // Iterating into a CCall to a CFunc + bool m_hasDpiHazard = false; // Found a DPI import call. + bool m_tracingCall = false; // Iterating into a CCall to a CFunc // METHODS VL_DEBUG_FUNC; @@ -1696,11 +1686,7 @@ private: public: // CONSTRUCTORS - explicit DpiImportCallVisitor(AstNode* nodep) - : m_hasDpiHazard(false) - , m_tracingCall(false) { - iterate(nodep); - } + explicit DpiImportCallVisitor(AstNode* nodep) { iterate(nodep); } bool hasDpiHazard() const { return m_hasDpiHazard; } virtual ~DpiImportCallVisitor() override {} diff --git a/src/V3Partition.h b/src/V3Partition.h index b53a5d7df..3ca944c49 100644 --- a/src/V3Partition.h +++ b/src/V3Partition.h @@ -78,13 +78,12 @@ private: // TYPES typedef std::unordered_map PtrMap; // MEMBERS - mutable vluint64_t m_nextId; + mutable vluint64_t m_nextId = 0; mutable PtrMap m_id; public: // CONSTRUCTORS - PartPtrIdMap() - : m_nextId(0) {} + PartPtrIdMap() {} // METHODS vluint64_t findId(const void* ptrp) const { PtrMap::const_iterator it = m_id.find(ptrp); diff --git a/src/V3PartitionGraph.h b/src/V3PartitionGraph.h index 674929b34..300bd911c 100644 --- a/src/V3PartitionGraph.h +++ b/src/V3PartitionGraph.h @@ -56,27 +56,22 @@ class ExecMTask : public AbstractMTask { private: AstMTaskBody* m_bodyp; // Task body uint32_t m_id; // Unique id of this mtask. - uint32_t m_priority; // Predicted critical path from the start of + uint32_t m_priority = 0; // Predicted critical path from the start of // this mtask to the ends of the graph that are reachable from this // mtask. In abstract time units. - uint32_t m_cost; // Predicted runtime of this mtask, in the same + uint32_t m_cost = 0; // Predicted runtime of this mtask, in the same // abstract time units as priority(). - uint32_t m_thread; // Thread for static (pack_mtasks) scheduling, + uint32_t m_thread = 0xffffffff; // Thread for static (pack_mtasks) scheduling, // or 0xffffffff if not yet assigned. - const ExecMTask* m_packNextp; // Next for static (pack_mtasks) scheduling - bool m_threadRoot; // Is root thread + const ExecMTask* m_packNextp = nullptr; // Next for static (pack_mtasks) scheduling + bool m_threadRoot = false; // Is root thread VL_UNCOPYABLE(ExecMTask); public: ExecMTask(V3Graph* graphp, AstMTaskBody* bodyp, uint32_t id) : AbstractMTask(graphp) , m_bodyp(bodyp) - , m_id(id) - , m_priority(0) - , m_cost(0) - , m_thread(0xffffffff) - , m_packNextp(nullptr) - , m_threadRoot(false) {} + , m_id(id) {} AstMTaskBody* bodyp() const { return m_bodyp; } virtual uint32_t id() const override { return m_id; } uint32_t priority() const { return m_priority; } diff --git a/src/V3PreLex.h b/src/V3PreLex.h index 92af2a7cf..6a8aa2976 100644 --- a/src/V3PreLex.h +++ b/src/V3PreLex.h @@ -131,17 +131,13 @@ public: FileLine* m_curFilelinep; // Current processing point (see also m_tokFilelinep) V3PreLex* m_lexp; // Lexer, for resource tracking std::deque m_buffers; // Buffer of characters to process - int m_ignNewlines; // Ignore multiline newlines - bool m_eof; // "EOF" buffer - bool m_file; // Buffer is start of new file - int m_termState; // Termination fsm + int m_ignNewlines = 0; // Ignore multiline newlines + bool m_eof = false; // "EOF" buffer + bool m_file = false; // Buffer is start of new file + int m_termState = 0; // Termination fsm VPreStream(FileLine* fl, V3PreLex* lexp) : m_curFilelinep(fl) - , m_lexp(lexp) - , m_ignNewlines(0) - , m_eof(false) - , m_file(false) - , m_termState(0) { + , m_lexp(lexp) { lexStreamDepthAdd(1); } ~VPreStream() { lexStreamDepthAdd(-1); } @@ -157,37 +153,28 @@ class V3PreLex { public: // Used only by V3PreLex.cpp and V3PreProc.cpp V3PreProcImp* m_preimpp; // Preprocessor lexor belongs to std::stack m_streampStack; // Stack of processing files - int m_streamDepth; // Depth of stream processing + int m_streamDepth = 0; // Depth of stream processing YY_BUFFER_STATE m_bufferState; // Flex state FileLine* m_tokFilelinep; // Starting position of current token // State to lexer static V3PreLex* s_currentLexp; ///< Current lexing point - int m_keepComments; ///< Emit comments in output text - int m_keepWhitespace; ///< Emit all whitespace in output text - bool m_pedantic; ///< Obey standard; don't Substitute `error + int m_keepComments = 0; ///< Emit comments in output text + int m_keepWhitespace = 1; ///< Emit all whitespace in output text + bool m_pedantic = false; ///< Obey standard; don't Substitute `error // State from lexer - int m_formalLevel; // Parenthesis counting inside def formals - int m_parenLevel; // Parenthesis counting inside def args - bool m_defCmtSlash; // /*...*/ comment in define had \ ending - bool m_defQuote; // Definition value inside quote + int m_formalLevel = 0; // Parenthesis counting inside def formals + int m_parenLevel = 0; // Parenthesis counting inside def args + bool m_defCmtSlash = false; // /*...*/ comment in define had \ ending + bool m_defQuote = false; // Definition value inside quote string m_defValue; // Definition value being built. - int m_enterExit; // For VL_LINE, the enter/exit level + int m_enterExit = 0; // For VL_LINE, the enter/exit level // CONSTRUCTORS - V3PreLex(V3PreProcImp* preimpp, FileLine* filelinep) { - m_preimpp = preimpp; - m_streamDepth = 0; - m_keepComments = 0; - m_keepWhitespace = 1; - m_pedantic = false; - m_formalLevel = 0; - m_parenLevel = 0; - m_defQuote = false; - m_defCmtSlash = false; - m_tokFilelinep = filelinep; - m_enterExit = 0; + V3PreLex(V3PreProcImp* preimpp, FileLine* filelinep) + : m_preimpp(preimpp) + , m_tokFilelinep(filelinep) { initFirstBuffer(filelinep); } ~V3PreLex() { diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 6ee474814..068452988 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -68,7 +68,7 @@ class VDefineRef { string m_name; // Define last name being defined string m_params; // Define parameter list for next expansion string m_nextarg; // String being built for next argument - int m_parenLevel; // Parenthesis counting inside def args (for PARENT not child) + int m_parenLevel = 0; // Parenthesis counting inside def args (for PARENT not child) std::vector m_args; // List of define arguments public: @@ -81,8 +81,7 @@ public: std::vector& args() { return m_args; } VDefineRef(const string& name, const string& params) : m_name(name) - , m_params(params) - , m_parenLevel(0) {} + , m_params(params) {} ~VDefineRef() {} }; @@ -117,11 +116,11 @@ public: DefinesMap m_defines; ///< Map of defines // STATE - V3PreProc* m_preprocp; ///< Object we're holding data for - V3PreLex* m_lexp; ///< Current lexer state (nullptr = closed) + V3PreProc* m_preprocp = nullptr; ///< Object we're holding data for + V3PreLex* m_lexp = nullptr; ///< Current lexer state (nullptr = closed) std::stack m_includeStack; ///< Stack of includers above current m_lexp - int m_lastLineno; // Last line number (stall detection) - int m_tokensOnLine; // Number of tokens on line (stall detection) + int m_lastLineno = 0; // Last line number (stall detection) + int m_tokensOnLine = 0; // Number of tokens on line (stall detection) enum ProcState { ps_TOP, @@ -150,23 +149,23 @@ public: } std::stack m_states; ///< Current state of parser - int m_off; ///< If non-zero, ifdef level is turned off, don't dump text - bool m_incError; ///< Include error found + int m_off = 0; ///< If non-zero, ifdef level is turned off, don't dump text + bool m_incError = false; ///< Include error found string m_lastSym; ///< Last symbol name found. string m_formals; ///< Last formals found // For getRawToken/ `line insertion string m_lineCmt; ///< Line comment(s) to be returned - bool m_lineCmtNl; ///< Newline needed before inserting lineCmt - int m_lineAdd; ///< Empty lines to return to maintain line count - bool m_rawAtBol; ///< Last rawToken left us at beginning of line + bool m_lineCmtNl = false; ///< Newline needed before inserting lineCmt + int m_lineAdd = 0; ///< Empty lines to return to maintain line count + bool m_rawAtBol = true; ///< Last rawToken left us at beginning of line // For getFinalToken - bool m_finAhead; ///< Have read a token ahead - int m_finToken; ///< Last token read + bool m_finAhead = false; ///< Have read a token ahead + int m_finToken = 0; ///< Last token read string m_finBuf; ///< Last yytext read - bool m_finAtBol; ///< Last getFinalToken left us at beginning of line - FileLine* m_finFilelinep; ///< Location of last returned token (internal only) + bool m_finAtBol = true; ///< Last getFinalToken left us at beginning of line + FileLine* m_finFilelinep = nullptr; ///< Location of last returned token (internal only) // For stringification string m_strify; ///< Text to be stringified @@ -174,8 +173,8 @@ public: // For defines std::stack m_defRefs; ///< Pending define substitution std::stack m_ifdefStack; ///< Stack of true/false emitting evaluations - unsigned m_defDepth; ///< How many `defines deep - bool m_defPutJoin; ///< Insert `` after substitution + unsigned m_defDepth = 0; ///< How many `defines deep + bool m_defPutJoin = false; ///< Insert `` after substitution // For `` join std::stack m_joinStack; ///< Text on lhs of join @@ -261,23 +260,6 @@ public: V3PreProcImp() { m_debug = 0; m_states.push(ps_TOP); - m_off = 0; - m_incError = false; - m_lineChars = ""; - m_lastSym = ""; - m_lineAdd = 0; - m_lineCmtNl = false; - m_rawAtBol = true; - m_finAhead = false; - m_finAtBol = true; - m_defDepth = 0; - m_defPutJoin = false; - m_finToken = 0; - m_finFilelinep = nullptr; - m_lexp = nullptr; - m_preprocp = nullptr; - m_lastLineno = 0; - m_tokensOnLine = 0; } void configure(FileLine* filelinep) { // configure() separate from constructor to avoid calling abstract functions diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index 74a76b881..7bc496b1d 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -30,37 +30,37 @@ class ProtectVisitor : public AstNVisitor { private: - AstVFile* m_vfilep; // DPI-enabled Verilog wrapper - AstCFile* m_cfilep; // C implementation of DPI functions + AstVFile* m_vfilep = nullptr; // DPI-enabled Verilog wrapper + AstCFile* m_cfilep = nullptr; // C implementation of DPI functions // Verilog text blocks - AstTextBlock* m_modPortsp; // Module port list - AstTextBlock* m_comboPortsp; // Combo function port list - AstTextBlock* m_seqPortsp; // Sequential function port list - AstTextBlock* m_comboIgnorePortsp; // Combo ignore function port list - AstTextBlock* m_comboDeclsp; // Combo signal declaration list - AstTextBlock* m_seqDeclsp; // Sequential signal declaration list - AstTextBlock* m_tmpDeclsp; // Temporary signal declaration list - AstTextBlock* m_hashValuep; // CPP hash value - AstTextBlock* m_comboParamsp; // Combo function parameter list - AstTextBlock* m_clkSensp; // Clock sensitivity list - AstTextBlock* m_comboIgnoreParamsp; // Combo ignore parameter list - AstTextBlock* m_seqParamsp; // Sequential parameter list - AstTextBlock* m_nbAssignsp; // Non-blocking assignment list - AstTextBlock* m_seqAssignsp; // Sequential assignment list - AstTextBlock* m_comboAssignsp; // Combo assignment list + AstTextBlock* m_modPortsp = nullptr; // Module port list + AstTextBlock* m_comboPortsp = nullptr; // Combo function port list + AstTextBlock* m_seqPortsp = nullptr; // Sequential function port list + AstTextBlock* m_comboIgnorePortsp = nullptr; // Combo ignore function port list + AstTextBlock* m_comboDeclsp = nullptr; // Combo signal declaration list + AstTextBlock* m_seqDeclsp = nullptr; // Sequential signal declaration list + AstTextBlock* m_tmpDeclsp = nullptr; // Temporary signal declaration list + AstTextBlock* m_hashValuep = nullptr; // CPP hash value + AstTextBlock* m_comboParamsp = nullptr; // Combo function parameter list + AstTextBlock* m_clkSensp = nullptr; // Clock sensitivity list + AstTextBlock* m_comboIgnoreParamsp = nullptr; // Combo ignore parameter list + AstTextBlock* m_seqParamsp = nullptr; // Sequential parameter list + AstTextBlock* m_nbAssignsp = nullptr; // Non-blocking assignment list + AstTextBlock* m_seqAssignsp = nullptr; // Sequential assignment list + AstTextBlock* m_comboAssignsp = nullptr; // Combo assignment list // C text blocks - AstTextBlock* m_cHashValuep; // CPP hash value - AstTextBlock* m_cComboParamsp; // Combo function parameter list - AstTextBlock* m_cComboInsp; // Combo input copy list - AstTextBlock* m_cComboOutsp; // Combo output copy list - AstTextBlock* m_cSeqParamsp; // Sequential parameter list - AstTextBlock* m_cSeqClksp; // Sequential clock copy list - AstTextBlock* m_cSeqOutsp; // Sequential output copy list - AstTextBlock* m_cIgnoreParamsp; // Combo ignore parameter list + AstTextBlock* m_cHashValuep = nullptr; // CPP hash value + AstTextBlock* m_cComboParamsp = nullptr; // Combo function parameter list + AstTextBlock* m_cComboInsp = nullptr; // Combo input copy list + AstTextBlock* m_cComboOutsp = nullptr; // Combo output copy list + AstTextBlock* m_cSeqParamsp = nullptr; // Sequential parameter list + AstTextBlock* m_cSeqClksp = nullptr; // Sequential clock copy list + AstTextBlock* m_cSeqOutsp = nullptr; // Sequential output copy list + AstTextBlock* m_cIgnoreParamsp = nullptr; // Combo ignore parameter list string m_libName; string m_topName; - bool m_foundTop; // Have seen the top module - bool m_hasClk; // True if the top module has sequential logic + bool m_foundTop = false; // Have seen the top module + bool m_hasClk = false; // True if the top module has sequential logic // VISITORS virtual void visit(AstNetlist* nodep) override { @@ -486,35 +486,8 @@ private: public: explicit ProtectVisitor(AstNode* nodep) - : m_vfilep(nullptr) - , m_cfilep(nullptr) - , m_modPortsp(nullptr) - , m_comboPortsp(nullptr) - , m_seqPortsp(nullptr) - , m_comboIgnorePortsp(nullptr) - , m_comboDeclsp(nullptr) - , m_seqDeclsp(nullptr) - , m_tmpDeclsp(nullptr) - , m_hashValuep(nullptr) - , m_comboParamsp(nullptr) - , m_clkSensp(nullptr) - , m_comboIgnoreParamsp(nullptr) - , m_seqParamsp(nullptr) - , m_nbAssignsp(nullptr) - , m_seqAssignsp(nullptr) - , m_comboAssignsp(nullptr) - , m_cHashValuep(nullptr) - , m_cComboParamsp(nullptr) - , m_cComboInsp(nullptr) - , m_cComboOutsp(nullptr) - , m_cSeqParamsp(nullptr) - , m_cSeqClksp(nullptr) - , m_cSeqOutsp(nullptr) - , m_cIgnoreParamsp(nullptr) - , m_libName(v3Global.opt.protectLib()) - , m_topName(v3Global.opt.prefix()) - , m_foundTop(false) - , m_hasClk(false) { + : m_libName(v3Global.opt.protectLib()) + , m_topName(v3Global.opt.prefix()) { iterate(nodep); } }; diff --git a/src/V3SenTree.h b/src/V3SenTree.h index 699c9c63d..bfe49f5d8 100644 --- a/src/V3SenTree.h +++ b/src/V3SenTree.h @@ -74,15 +74,14 @@ private: class SenTreeFinder { private: // STATE - AstTopScope* m_topScopep; // Top scope to add global SenTrees to + AstTopScope* m_topScopep = nullptr; // Top scope to add global SenTrees to SenTreeSet m_trees; // Set of global SenTrees VL_UNCOPYABLE(SenTreeFinder); public: // CONSTRUCTORS - SenTreeFinder() - : m_topScopep(nullptr) {} + SenTreeFinder() {} // METHODS AstSenTree* getSenTree(AstSenTree* senTreep) { diff --git a/src/V3Split.cpp b/src/V3Split.cpp index e3535aef0..f4b317402 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -153,14 +153,13 @@ public: // Edge types class SplitEdge : public V3GraphEdge { - uint32_t m_ignoreInStep; // Step number that if set to, causes this edge to be ignored + uint32_t m_ignoreInStep = 0; // Step number that if set to, causes this edge to be ignored static uint32_t s_stepNum; // Global step number protected: enum { WEIGHT_NORMAL = 10 }; SplitEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top, int weight, bool cutable = CUTABLE) - : V3GraphEdge(graphp, fromp, top, weight, cutable) - , m_ignoreInStep(0) {} + : V3GraphEdge(graphp, fromp, top, weight, cutable) {} virtual ~SplitEdge() override {} public: diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index c7335113d..3f2eb47c0 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -74,8 +74,8 @@ private: // STATE AstVarScope* m_splitVscp; // Variable we want to split bool m_modeMatch; // Remove matching Vscp, else non-matching - bool m_keepStmt; // Current Statement must be preserved - bool m_matches; // Statement below has matching lvalue reference + bool m_keepStmt = false; // Current Statement must be preserved + bool m_matches = false; // Statement below has matching lvalue reference // METHODS virtual void visit(AstVarRef* nodep) override { @@ -116,11 +116,9 @@ private: public: // CONSTRUCTORS - SplitAsCleanVisitor(AstAlways* nodep, AstVarScope* vscp, bool modeMatch) { - m_splitVscp = vscp; - m_modeMatch = modeMatch; - m_keepStmt = false; - m_matches = false; + SplitAsCleanVisitor(AstAlways* nodep, AstVarScope* vscp, bool modeMatch) + : m_splitVscp(vscp) + , m_modeMatch(modeMatch) { iterate(nodep); } virtual ~SplitAsCleanVisitor() override {} diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 0f0c60283..551a89c42 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -393,11 +393,11 @@ class SplitUnpackedVarVisitor : public AstNVisitor, public SplitVarImpl { typedef std::set VarSet; VarSet m_foundTargetVar; UnpackRefMap m_refs; - AstNodeModule* m_modp; + AstNodeModule* m_modp = nullptr; // AstNodeStmt, AstCell, AstNodeFTaskRef, or AstAlways(Public) for sensitivity - AstNode* m_contextp; - AstNodeFTask* m_inFTask; - size_t m_numSplit; + AstNode* m_contextp = nullptr; + AstNodeFTask* m_inFTask = nullptr; + size_t m_numSplit = 0; // List for SplitPackedVarVisitor SplitVarRefsMap m_refsForPackedSplit; @@ -766,11 +766,7 @@ class SplitUnpackedVarVisitor : public AstNVisitor, public SplitVarImpl { public: explicit SplitUnpackedVarVisitor(AstNetlist* nodep) - : m_refs() - , m_modp(nullptr) - , m_contextp(nullptr) - , m_inFTask(nullptr) - , m_numSplit(0) { + : m_refs() { iterate(nodep); } ~SplitUnpackedVarVisitor() { @@ -872,7 +868,7 @@ class PackedVarRef { }; std::vector m_lhs, m_rhs; AstBasicDType* m_basicp; // Cache the ptr since varp->dtypep()->basicp() is expensive - bool m_dedupDone; + bool m_dedupDone = false; static void dedupRefs(std::vector& refs) { // Use raw pointer to dedup typedef std::map NodeIndices; @@ -901,8 +897,7 @@ public: return m_rhs; } explicit PackedVarRef(AstVar* varp) - : m_basicp(varp->dtypep()->basicp()) - , m_dedupDone(false) {} + : m_basicp(varp->dtypep()->basicp()) {} void append(const PackedVarRefEntry& e, bool lvalue) { UASSERT(!m_dedupDone, "cannot add after dedup()"); if (lvalue) diff --git a/src/V3String.h b/src/V3String.h index 7cbb7d322..0c40cc763 100644 --- a/src/V3String.h +++ b/src/V3String.h @@ -112,8 +112,8 @@ class VHashSha256 { // MEMBERS uint32_t m_inthash[8]; // Intermediate hash, in host order string m_remainder; // Unhashed data - bool m_final; // Finalized - size_t m_totLength; // Total all-chunk length as needed by output digest + bool m_final = false; // Finalized + size_t m_totLength = 0; // Total all-chunk length as needed by output digest public: // CONSTRUCTORS VHashSha256() { @@ -125,8 +125,6 @@ public: m_inthash[5] = 0x9b05688c; m_inthash[6] = 0x1f83d9ab; m_inthash[7] = 0x5be0cd19; - m_final = false; - m_totLength = 0; } explicit VHashSha256(const string& data) : VHashSha256() { diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index b03f8a7ca..86aac57b2 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -183,7 +183,7 @@ private: // // STATE int m_origStep; // Step number where subst was recorded - bool m_ok; // No misassignments found + bool m_ok = true; // No misassignments found // METHODS SubstVarEntry* findEntryp(AstVarRef* nodep) { @@ -210,10 +210,9 @@ private: public: // CONSTRUCTORS - SubstUseVisitor(AstNode* nodep, int origStep) { + SubstUseVisitor(AstNode* nodep, int origStep) + : m_origStep(origStep) { UINFO(9, " SubstUseVisitor " << origStep << " " << nodep << endl); - m_ok = true; - m_origStep = origStep; iterate(nodep); } virtual ~SubstUseVisitor() override {} diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 8a0fefb29..78ef2688b 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -40,13 +40,11 @@ // Graph subclasses class TaskBaseVertex : public V3GraphVertex { - AstNode* m_impurep; // Node causing impure function w/ outside references - bool m_noInline; // Marked with pragma + AstNode* m_impurep = nullptr; // Node causing impure function w/ outside references + bool m_noInline = false; // Marked with pragma public: explicit TaskBaseVertex(V3Graph* graphp) - : V3GraphVertex(graphp) - , m_impurep(nullptr) - , m_noInline(false) {} + : V3GraphVertex(graphp) {} virtual ~TaskBaseVertex() override {} bool pure() const { return m_impurep == nullptr; } AstNode* impureNode() const { return m_impurep; } @@ -111,8 +109,8 @@ private: typedef std::vector Initials; // MEMBERS VarToScopeMap m_varToScopeMap; // Map for Var -> VarScope mappings - AstAssignW* m_assignwp; // Current assignment - AstNodeFTask* m_ctorp; // Class constructor + AstAssignW* m_assignwp = nullptr; // Current assignment + AstNodeFTask* m_ctorp = nullptr; // Class constructor V3Graph m_callGraph; // Task call graph TaskBaseVertex* m_curVxp; // Current vertex we're adding to Initials m_initialps; // Initial blocks to move @@ -261,9 +259,7 @@ private: public: // CONSTRUCTORS - explicit TaskStateVisitor(AstNetlist* nodep) - : m_assignwp(nullptr) - , m_ctorp(nullptr) { + explicit TaskStateVisitor(AstNetlist* nodep) { m_curVxp = new TaskCodeVertex(&m_callGraph); AstNode::user3ClearTree(); AstNode::user4ClearTree(); diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 14f5190bd..ed61c40f9 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -80,16 +80,13 @@ public: class TristateVertex : public V3GraphVertex { AstNode* m_nodep; - bool m_isTristate; // Logic indicates a tristate - bool m_feedsTri; // Propagates to a tristate node (on RHS) - bool m_processed; // Tristating was cleaned up + bool m_isTristate = false; // Logic indicates a tristate + bool m_feedsTri = false; // Propagates to a tristate node (on RHS) + bool m_processed = false; // Tristating was cleaned up public: TristateVertex(V3Graph* graphp, AstNode* nodep) : V3GraphVertex(graphp) - , m_nodep(nodep) - , m_isTristate(false) - , m_feedsTri(false) - , m_processed(false) {} + , m_nodep(nodep) {} virtual ~TristateVertex() override {} // ACCESSORS AstNode* nodep() const { return m_nodep; } diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index fc9be7f44..fc5ac583a 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -63,11 +63,10 @@ private: AstNodeDType* m_errp; // Node that was found, for error reporting if not known type AstNodeDType* m_dtypep; // Data type for the 'from' slice VNumRange m_fromRange; // Numeric range bounds for the 'from' slice - FromData(AstNodeDType* errp, AstNodeDType* dtypep, const VNumRange& fromRange) { - m_errp = errp; - m_dtypep = dtypep; - m_fromRange = fromRange; - } + FromData(AstNodeDType* errp, AstNodeDType* dtypep, const VNumRange& fromRange) + : m_errp(errp) + , m_dtypep(dtypep) + , m_fromRange(fromRange) {} ~FromData() {} }; FromData fromDataForArray(AstNode* nodep, AstNode* basefromp) { diff --git a/src/VlcBucket.h b/src/VlcBucket.h index 6e4bfb4ad..97df0c4b1 100644 --- a/src/VlcBucket.h +++ b/src/VlcBucket.h @@ -28,9 +28,9 @@ class VlcBuckets { private: // MEMBERS - vluint64_t* m_datap; ///< Pointer to first bucket (dynamically allocated) - vluint64_t m_dataSize; ///< Current entries in m_datap - vluint64_t m_bucketsCovered; ///< Num buckets with sufficient coverage + vluint64_t* m_datap = nullptr; ///< Pointer to first bucket (dynamically allocated) + vluint64_t m_dataSize = 0; ///< Current entries in m_datap + vluint64_t m_bucketsCovered = 0; ///< Num buckets with sufficient coverage static inline vluint64_t covBit(vluint64_t point) { return 1ULL << (point & 63); } inline vluint64_t allocSize() const { return sizeof(vluint64_t) * m_dataSize / 64; } @@ -51,12 +51,7 @@ private: public: // CONSTRUCTORS - VlcBuckets() { - m_dataSize = 0; - m_datap = nullptr; - m_bucketsCovered = 0; - allocate(1024); - } + VlcBuckets() { allocate(1024); } ~VlcBuckets() { m_dataSize = 0; VL_DO_CLEAR(free(m_datap), m_datap = nullptr); diff --git a/src/VlcOptions.h b/src/VlcOptions.h index 74e8c6380..423bfd1eb 100644 --- a/src/VlcOptions.h +++ b/src/VlcOptions.h @@ -35,11 +35,11 @@ class VlcOptions { // MEMBERS (general options) // clang-format off string m_annotateOut; // main switch: --annotate I - bool m_annotateAll; // main switch: --annotate-all - int m_annotateMin; // main switch: --annotate-min I + bool m_annotateAll=false; // main switch: --annotate-all + int m_annotateMin=10; // main switch: --annotate-min I VlStringSet m_readFiles; // main switch: --read - bool m_rank; // main switch: --rank - bool m_unlink; // main switch: --unlink + bool m_rank=false; // main switch: --rank + bool m_unlink=false; // main switch: --unlink string m_writeFile; // main switch: --write string m_writeInfoFile; // main switch: --write-info // clang-format on @@ -51,12 +51,7 @@ private: public: // CONSTRUCTORS - VlcOptions() { - m_annotateAll = false; - m_annotateMin = 10; - m_rank = false; - m_unlink = false; - } + VlcOptions() {} ~VlcOptions() {} // METHODS diff --git a/src/VlcPoint.h b/src/VlcPoint.h index 6b3115188..426aa2dd4 100644 --- a/src/VlcPoint.h +++ b/src/VlcPoint.h @@ -34,17 +34,14 @@ private: // MEMBERS string m_name; //< Name of the point vluint64_t m_pointNum; //< Point number - vluint64_t m_testsCovering; //< Number tests with non-zero coverage of this point - vluint64_t m_count; //< Count of hits across all tests + vluint64_t m_testsCovering = 0; //< Number tests with non-zero coverage of this point + vluint64_t m_count = 0; //< Count of hits across all tests public: // CONSTRUCTORS - VlcPoint(const string& name, int pointNum) { - m_name = name; - m_pointNum = pointNum; - m_testsCovering = 0; - m_count = 0; - } + VlcPoint(const string& name, int pointNum) + : m_name(name) + , m_pointNum(pointNum) {} ~VlcPoint() {} // ACCESSORS const string& name() const { return m_name; } @@ -99,7 +96,7 @@ private: typedef std::map NameMap; // Sorted by name (ordered) NameMap m_nameMap; //< Name to point-number std::vector m_points; //< List of all points - vluint64_t m_numPoints; //< Total unique points + vluint64_t m_numPoints = 0; //< Total unique points public: // ITERATORS @@ -109,8 +106,7 @@ public: ByName::iterator end() { return m_nameMap.end(); } // CONSTRUCTORS - VlcPoints() - : m_numPoints(0) {} + VlcPoints() {} ~VlcPoints() {} // METHODS diff --git a/src/VlcSource.h b/src/VlcSource.h index 9e438d9b2..68b3deca0 100644 --- a/src/VlcSource.h +++ b/src/VlcSource.h @@ -31,17 +31,14 @@ private: // MEMBERS int m_lineno; ///< Line number int m_column; ///< Column number - vluint64_t m_count; ///< Count - bool m_ok; ///< Coverage is above threshold + vluint64_t m_count = 0; ///< Count + bool m_ok = false; ///< Coverage is above threshold public: // CONSTRUCTORS - VlcSourceCount(int lineno, int column) { - m_lineno = lineno; - m_column = column; - m_count = 0; - m_ok = false; - } + VlcSourceCount(int lineno, int column) + : m_lineno(lineno) + , m_column(column) {} ~VlcSourceCount() {} // ACCESSORS diff --git a/src/VlcTest.h b/src/VlcTest.h index 97ad08897..423699734 100644 --- a/src/VlcTest.h +++ b/src/VlcTest.h @@ -35,21 +35,17 @@ private: string m_name; //< Name of the test double m_computrons; //< Runtime for the test vluint64_t m_testrun; //< Test run number, for database use - vluint64_t m_rank; //< Execution rank suggestion - vluint64_t m_rankPoints; //< Ranked additional points - vluint64_t m_user; //< User data for algorithms (not persisted in .dat file) + vluint64_t m_rank = 0; //< Execution rank suggestion + vluint64_t m_rankPoints = 0; //< Ranked additional points + vluint64_t m_user = 0; //< User data for algorithms (not persisted in .dat file) VlcBuckets m_buckets; //< Coverage data for each coverage point public: // CONSTRUCTORS - VlcTest(const string& name, vluint64_t testrun, double comp) { - m_name = name; - m_computrons = comp; - m_testrun = testrun; - m_rank = 0; - m_rankPoints = 0; - m_user = 0; - } + VlcTest(const string& name, vluint64_t testrun, double comp) + : m_name(name) + , m_computrons(comp) + , m_testrun(testrun) {} ~VlcTest() {} // ACCESSORS