diff --git a/include/verilated.h b/include/verilated.h index 52d4e0976..db5c59052 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -104,9 +104,9 @@ class VerilatedModule { private: const char* m_namep; ///< Module name VerilatedModule(); ///< N/A, always use named constructor below - VerilatedModule(const VerilatedModule& ); ///< N/A, no copying modules + VerilatedModule(const VerilatedModule& ); ///< N/A, no copy constructor public: - VerilatedModule(const char* namep); ///< Create module with given hierarchy name + explicit VerilatedModule(const char* namep); ///< Create module with given hierarchy name ~VerilatedModule(); const char* name() const { return m_namep; } ///< Return name of module }; diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index 5fb6c938f..0e2cdb0f8 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -75,6 +75,7 @@ public: virtual vluint64_t count() const { return *m_countp; } virtual void zero() const { *m_countp = 0; } // CONSTRUCTORS + // cppcheck-suppress noExplicitConstructor VerilatedCoverItemSpec(T* countp) : m_countp(countp) { zero(); } virtual ~VerilatedCoverItemSpec() {} }; diff --git a/include/verilated_cov.h b/include/verilated_cov.h index caa56259e..a66d12c41 100644 --- a/include/verilated_cov.h +++ b/include/verilated_cov.h @@ -84,6 +84,7 @@ template< class T> std::string vlCovCvtToStr (const T& t) { struct VlCovCvtToCStr { string m_str; // Casters + // cppcheck-suppress noExplicitConstructor template< class T> VlCovCvtToCStr (const T& t) { ostringstream os; os<=20050714) // SystemC 2.1.v1 +// cppcheck-suppress unusedFunction void VerilatedVcdSc::write_comment (const std::string &) {} void VerilatedVcdSc::trace (const unsigned int &, const std::string &, const char **) {} @@ -74,6 +75,7 @@ void VerilatedVcdSc::trace (const unsigned int &, const std::string &, const cha //-------------------------------------------------- #elif (SYSTEMC_VERSION>20011000) // SystemC 2.0.1 +// cppcheck-suppress unusedFunction void VerilatedVcdSc::write_comment (const sc_string &) {} void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char **) {} @@ -116,6 +118,7 @@ void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char //-------------------------------------------------- #else // SystemC 1.2.1beta +// cppcheck-suppress unusedFunction void VerilatedVcdSc::write_comment (const sc_string &) {} void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char **) {} diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 2110fcbdc..5d9e3baa9 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -431,6 +431,7 @@ void VerilatedVpiError::selfTest() { vpiHandle vpi_register_cb(p_cb_data cb_data_p) { _VL_VPI_ERROR_RESET(); // reset vpi error status + // cppcheck-suppress nullPointer if (VL_UNLIKELY(!cb_data_p)) { _VL_VPI_WARNING(__FILE__, __LINE__, "%s : callback data pointer is null", VL_FUNC); return NULL; @@ -440,7 +441,7 @@ vpiHandle vpi_register_cb(p_cb_data cb_data_p) { QData time = 0; if (cb_data_p->time) time = _VL_SET_QII(cb_data_p->time->high, cb_data_p->time->low); VerilatedVpioCb* vop = new VerilatedVpioCb(cb_data_p, VL_TIME_Q()+time); - VL_DEBUG_IF_PLI(VL_PRINTF("-vltVpi: vpi_register_cb %d %p delay=%" VL_PRI64 "d\n",cb_data_p->reason,vop,time);); + VL_DEBUG_IF_PLI(VL_PRINTF("-vltVpi: vpi_register_cb %d %p delay=%" VL_PRI64 "u\n",cb_data_p->reason,vop,time);); VerilatedVpi::cbTimedAdd(vop); return vop->castVpiHandle(); } @@ -1244,6 +1245,7 @@ void vpi_put_value_array(vpiHandle object, p_vpi_arrayvalue arrayvalue_p, // time processing void vpi_get_time(vpiHandle object, p_vpi_time time_p) { + // cppcheck-suppress nullPointer if (VL_UNLIKELY(!time_p)) { _VL_VPI_WARNING(__FILE__, __LINE__, "Ignoring vpi_get_time with NULL value pointer"); return; @@ -1303,6 +1305,7 @@ PLI_INT32 vpi_vprintf(PLI_BYTE8* formatp, va_list ap) { PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, PLI_BYTE8 *format, va_list ap) { FILE* fp = VL_CVT_I_FP(mcd); _VL_VPI_ERROR_RESET(); // reset vpi error status + // cppcheck-suppress nullPointer if (VL_UNLIKELY(!fp)) return 0; int chars = vfprintf(fp, format, ap); return chars; diff --git a/include/verilated_vpi.h b/include/verilated_vpi.h index 4acc99a9f..ead2edf9c 100644 --- a/include/verilated_vpi.h +++ b/include/verilated_vpi.h @@ -130,7 +130,7 @@ public: class VerilatedVpioConst : public VerilatedVpio { vlsint32_t m_num; public: - VerilatedVpioConst(vlsint32_t num) : m_num(num) {} + explicit VerilatedVpioConst(vlsint32_t num) : m_num(num) {} virtual ~VerilatedVpioConst() {} static inline VerilatedVpioConst* castp(vpiHandle h) { return dynamic_cast((VerilatedVpio*)h); } virtual const vluint32_t type() { return vpiUndefined; } @@ -141,7 +141,7 @@ class VerilatedVpioRange : public VerilatedVpio { const VerilatedRange* m_range; vlsint32_t m_iteration; public: - VerilatedVpioRange(const VerilatedRange* range) : m_range(range), m_iteration(0) {} + explicit VerilatedVpioRange(const VerilatedRange* range) : m_range(range), m_iteration(0) {} virtual ~VerilatedVpioRange() {} static inline VerilatedVpioRange* castp(vpiHandle h) { return dynamic_cast((VerilatedVpio*)h); } virtual const vluint32_t type() { return vpiRange; } @@ -163,7 +163,7 @@ public: class VerilatedVpioScope : public VerilatedVpio { const VerilatedScope* m_scopep; public: - VerilatedVpioScope(const VerilatedScope* scopep) + explicit VerilatedVpioScope(const VerilatedScope* scopep) : m_scopep(scopep) {} virtual ~VerilatedVpioScope() {} static inline VerilatedVpioScope* castp(vpiHandle h) { return dynamic_cast((VerilatedVpio*)h); } @@ -255,7 +255,7 @@ class VerilatedVpioVarIter : public VerilatedVpio { VerilatedVarNameMap::iterator m_it; bool m_started; public: - VerilatedVpioVarIter(const VerilatedScope* scopep) + explicit VerilatedVpioVarIter(const VerilatedScope* scopep) : m_scopep(scopep), m_started(false) { } virtual ~VerilatedVpioVarIter() {} static inline VerilatedVpioVarIter* castp(vpiHandle h) { return dynamic_cast((VerilatedVpio*)h); } diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 5a215bf02..2599eb696 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -421,7 +421,7 @@ private: } public: // CONSTUCTORS - ActiveVisitor(AstNetlist* nodep) { + explicit ActiveVisitor(AstNetlist* nodep) { m_scopeFinalp = NULL; m_itemCombo = false; m_itemSequent = false; diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index 264876f38..af89730e0 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -147,7 +147,7 @@ private: } public: // CONSTUCTORS - ActiveTopVisitor(AstNetlist* nodep) { + explicit ActiveTopVisitor(AstNetlist* nodep) { m_topscopep = NULL; nodep->accept(*this); } diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 7b7d96a1f..29bf6a53c 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -317,7 +317,7 @@ private: } public: // CONSTRUCTORS - AssertVisitor(AstNetlist* nodep) { + explicit AssertVisitor(AstNetlist* nodep) { m_beginp = NULL; m_modp = NULL; // Process diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index c4fa770d8..ba9dacc7a 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -122,7 +122,7 @@ private: public: // CONSTRUCTORS - AssertPreVisitor(AstNetlist* nodep) { + explicit AssertPreVisitor(AstNetlist* nodep) { m_seniDefaultp = NULL; clearAssertInfo(); // Process diff --git a/src/V3Ast.h b/src/V3Ast.h index 6e8c446c0..0d17f4ce1 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -53,6 +53,7 @@ public: enum en m_e; // cppcheck-suppress uninitVar // responsiblity of each subclass inline AstType () {} + // cppcheck-suppress noExplicitConstructor inline AstType (en _e) : m_e(_e) {} explicit inline AstType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -87,7 +88,9 @@ public: return names[m_e]; }; inline AstNumeric () : m_e(UNSIGNED) {} + // cppcheck-suppress noExplicitConstructor inline AstNumeric (en _e) : m_e(_e) {} + // cppcheck-suppress noExplicitConstructor inline AstNumeric (VSignedState signst) { if (signst==signedst_UNSIGNED) m_e=UNSIGNED; else if (signst==signedst_SIGNED) m_e=SIGNED; @@ -121,6 +124,7 @@ public: }; enum en m_e; inline AstPragmaType () : m_e(ILLEGAL) {} + // cppcheck-suppress noExplicitConstructor inline AstPragmaType (en _e) : m_e(_e) {} explicit inline AstPragmaType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -144,6 +148,7 @@ public: }; enum en m_e; inline AstCFuncType () : m_e(FT_NORMAL) {} + // cppcheck-suppress noExplicitConstructor inline AstCFuncType (en _e) : m_e(_e) {} explicit inline AstCFuncType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -212,6 +217,7 @@ public: return names[m_e]; }; inline AstEdgeType () : m_e(ET_ILLEGAL) {} + // cppcheck-suppress noExplicitConstructor inline AstEdgeType (en _e) : m_e(_e) {} explicit inline AstEdgeType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -279,6 +285,7 @@ public: return names[m_e]; }; inline AstAttrType () : m_e(ILLEGAL) {} + // cppcheck-suppress noExplicitConstructor inline AstAttrType (en _e) : m_e(_e) {} explicit inline AstAttrType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -338,6 +345,7 @@ public: UASSERT(0==strcmp(AstBasicDTypeKwd(_ENUM_MAX).dpiType()," MAX"),"Enum array mismatch"); } inline AstBasicDTypeKwd () : m_e(UNKNOWN) {} + // cppcheck-suppress noExplicitConstructor inline AstBasicDTypeKwd (en _e) : m_e(_e) {} explicit inline AstBasicDTypeKwd (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -432,6 +440,7 @@ public: }; enum en m_e; inline AstVarType () : m_e(UNKNOWN) {} + // cppcheck-suppress noExplicitConstructor inline AstVarType (en _e) : m_e(_e) {} explicit inline AstVarType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -469,6 +478,7 @@ public: enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* inline AstBranchPred () : m_e(BP_UNKNOWN) {} + // cppcheck-suppress noExplicitConstructor inline AstBranchPred (en _e) : m_e(_e) {} explicit inline AstBranchPred (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -500,6 +510,7 @@ public: enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* inline AstVarAttrClocker () : m_e(CLOCKER_UNKNOWN) {} + // cppcheck-suppress noExplicitConstructor inline AstVarAttrClocker (en _e) : m_e(_e) {} explicit inline AstVarAttrClocker (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -530,6 +541,7 @@ public: }; enum en m_e; inline VAlwaysKwd () : m_e(ALWAYS) {} + // cppcheck-suppress noExplicitConstructor inline VAlwaysKwd (en _e) : m_e(_e) {} explicit inline VAlwaysKwd (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -554,6 +566,7 @@ public: }; enum en m_e; inline VCaseType () : m_e(CT_CASE) {} + // cppcheck-suppress noExplicitConstructor inline VCaseType (en _e) : m_e(_e) {} explicit inline VCaseType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -576,6 +589,7 @@ public: }; enum en m_e; inline AstDisplayType () : m_e(DT_DISPLAY) {} + // cppcheck-suppress noExplicitConstructor inline AstDisplayType (en _e) : m_e(_e) {} explicit inline AstDisplayType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -600,6 +614,7 @@ public: }; enum en m_e; inline AstParseRefExp() : m_e(PX_NONE) {} + // cppcheck-suppress noExplicitConstructor inline AstParseRefExp (en _e) : m_e(_e) {} explicit inline AstParseRefExp (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -897,16 +912,19 @@ public: // CREATORS class Illegal {}; // for creator type-overload selection class FullValue {}; // for creator type-overload selection - V3Hash(Illegal) { m_both=0; } + explicit V3Hash(Illegal) { m_both=0; } // Saving and restoring inside a userp - V3Hash(AstNUser* up) { m_both=up->castInt(); } + explicit V3Hash(AstNUser* up) { m_both=up->castInt(); } V3Hash operator+= (const V3Hash& rh) { setBoth(depth()+rh.depth(), (hshval()*31+rh.hshval())); return *this; }; // Creating from raw data (sameHash functions) V3Hash() { setBoth(1,0); } + // cppcheck-suppress noExplicitConstructor V3Hash(uint32_t val) { setBoth(1,val); } + // cppcheck-suppress noExplicitConstructor V3Hash(const void* vp) { setBoth(1,cvtToHash(vp)); } + // cppcheck-suppress noExplicitConstructor V3Hash(const string& name); V3Hash(V3Hash h1, V3Hash h2) { setBoth(1,h1.hshval()*31+h2.hshval()); } @@ -991,7 +1009,7 @@ public: protected: // CONSTUCTORS AstNode() {init(); } - AstNode(FileLine* fileline) {init(); m_fileline = fileline; } + explicit AstNode(FileLine* fileline) {init(); m_fileline = fileline; } virtual AstNode* clone() = 0; // Generally, cloneTree is what you want instead virtual void cloneRelink() {} void cloneRelinkTree(); @@ -1274,7 +1292,7 @@ inline void AstNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); } class AstNodeMath : public AstNode { // Math -- anything that's part of an expression tree public: - AstNodeMath(FileLine* fl) + explicit AstNodeMath(FileLine* fl) : AstNode(fl) {} ASTNODE_BASE_FUNCS(NodeMath) // METHODS @@ -1291,7 +1309,7 @@ public: class AstNodeTermop : public AstNodeMath { // Terminal operator -- a operator with no "inputs" public: - AstNodeTermop(FileLine* fl) + explicit AstNodeTermop(FileLine* fl) : AstNodeMath(fl) {} ASTNODE_BASE_FUNCS(NodeTermop) // Know no children, and hot function, so skip iterator for speed @@ -1435,7 +1453,7 @@ public: class AstNodeStmt : public AstNode { // Statement -- anything that's directly under a function public: - AstNodeStmt(FileLine* fl) + explicit AstNodeStmt(FileLine* fl) : AstNode(fl) {} ASTNODE_BASE_FUNCS(NodeStmt) // METHODS @@ -1525,7 +1543,7 @@ public: class AstNodeSenItem : public AstNode { // An AstSenItem or AstSenGate public: - AstNodeSenItem(FileLine* fl) : AstNode(fl) {} + explicit AstNodeSenItem(FileLine* fl) : AstNode(fl) {} ASTNODE_BASE_FUNCS(NodeSenItem) virtual bool isClocked() const = 0; virtual bool isCombo() const = 0; @@ -1612,7 +1630,7 @@ private: static int s_uniqueNum; // Unique number assigned to each dtype during creation for IEEE matching public: // CONSTRUCTORS - AstNodeDType(FileLine* fl) : AstNode(fl) { + explicit AstNodeDType(FileLine* fl) : AstNode(fl) { m_width=0; m_widthMin=0; m_generic=false; } ASTNODE_BASE_FUNCS(NodeDType) @@ -1701,7 +1719,7 @@ private: AstNodeDType* m_refDTypep; // Elements of this type (after widthing) AstNode* rangenp() const { return op2p(); } // op2 = Array(s) of variable public: - AstNodeArrayDType(FileLine* fl) : AstNodeDType(fl) { + explicit AstNodeArrayDType(FileLine* fl) : AstNodeDType(fl) { m_refDTypep = NULL; } ASTNODE_BASE_FUNCS(NodeArrayDType) diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 3864abb21..05916c980 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -2604,7 +2604,7 @@ public: class AstBreak : public AstNodeStmt { public: - AstBreak(FileLine* fileline) + explicit AstBreak(FileLine* fileline) : AstNodeStmt (fileline) {} ASTNODE_NODE_FUNCS(Break, BREAK) virtual string verilogKwd() const { return "break"; }; @@ -2614,7 +2614,7 @@ public: class AstContinue : public AstNodeStmt { public: - AstContinue(FileLine* fileline) + explicit AstContinue(FileLine* fileline) : AstNodeStmt (fileline) {} ASTNODE_NODE_FUNCS(Continue, CONTINUE) virtual string verilogKwd() const { return "continue"; }; @@ -2907,7 +2907,7 @@ public: class AstStop : public AstNodeStmt { public: - AstStop(FileLine* fl) + explicit AstStop(FileLine* fl) : AstNodeStmt(fl) {} ASTNODE_NODE_FUNCS(Stop, STOP) virtual bool isGateOptimizable() const { return false; } @@ -2923,7 +2923,7 @@ public: class AstFinish : public AstNodeStmt { public: - AstFinish(FileLine* fl) + explicit AstFinish(FileLine* fl) : AstNodeStmt(fl) {} ASTNODE_NODE_FUNCS(Finish, FINISH) virtual bool isGateOptimizable() const { return false; } @@ -3072,7 +3072,7 @@ private: string scopeNameFormatter(AstText* textp) const; string scopePrettyNameFormatter(AstText* textp) const; public: - AstScopeName(FileLine* fl) : AstNodeMath(fl), m_dpiExport(false) { + explicit AstScopeName(FileLine* fl) : AstNodeMath(fl), m_dpiExport(false) { dtypeSetUInt64(); } ASTNODE_NODE_FUNCS(ScopeName, SCOPENAME) virtual V3Hash sameHash() const { return V3Hash(); } @@ -3122,7 +3122,7 @@ private: public: AstRand(FileLine* fl, AstNodeDType* dtp, bool reset) : AstNodeTermop(fl) { dtypep(dtp); m_reset=reset; } - AstRand(FileLine* fl) : AstNodeTermop(fl), m_reset(false) { } + explicit AstRand(FileLine* fl) : AstNodeTermop(fl), m_reset(false) { } ASTNODE_NODE_FUNCS(Rand, RAND) virtual string emitVerilog() { return "%f$random"; } virtual string emitC() { @@ -3139,7 +3139,7 @@ public: class AstTime : public AstNodeTermop { public: - AstTime(FileLine* fl) : AstNodeTermop(fl) { + explicit AstTime(FileLine* fl) : AstNodeTermop(fl) { dtypeSetUInt64(); } ASTNODE_NODE_FUNCS(Time, TIME) virtual string emitVerilog() { return "%f$time"; } @@ -3154,7 +3154,7 @@ public: class AstTimeD : public AstNodeTermop { public: - AstTimeD(FileLine* fl) : AstNodeTermop(fl) { + explicit AstTimeD(FileLine* fl) : AstNodeTermop(fl) { dtypeSetDouble(); } ASTNODE_NODE_FUNCS(TimeD, TIMED) virtual string emitVerilog() { return "%f$realtime"; } @@ -5082,7 +5082,7 @@ class AstTypeTable : public AstNode { typedef map DetailedMap; DetailedMap m_detailedMap; public: - AstTypeTable(FileLine* fl) : AstNode(fl) { + explicit AstTypeTable(FileLine* fl) : AstNode(fl) { for (int i=0; iiterateChildren(*this); calc_tasks(); diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index abc7fee87..5f6e81206 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -197,7 +197,7 @@ private: } public: // CONSTUCTORS - BrokenMarkVisitor(AstNetlist* nodep) { + explicit BrokenMarkVisitor(AstNetlist* nodep) { nodep->accept(*this); } virtual ~BrokenMarkVisitor() {} @@ -241,7 +241,7 @@ private: } public: // CONSTUCTORS - BrokenCheckVisitor(AstNetlist* nodep) { + explicit BrokenCheckVisitor(AstNetlist* nodep) { nodep->accept(*this); } virtual ~BrokenCheckVisitor() {} diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 01cef885d..bc6c26cf1 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -112,7 +112,7 @@ private: } public: // CONSTUCTORS - CaseLintVisitor(AstNodeCase* nodep) { + explicit CaseLintVisitor(AstNodeCase* nodep) { m_caseExprp = NULL; nodep->accept(*this); } @@ -475,7 +475,7 @@ private: public: // CONSTUCTORS - CaseVisitor(AstNetlist* nodep) { + explicit CaseVisitor(AstNetlist* nodep) { m_caseNoOverlapsAllCovered = false; nodep->accept(*this); } diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index baf77c5c0..cab7b8a6a 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -176,7 +176,7 @@ private: public: // CONSTUCTORS - CastVisitor(AstNetlist* nodep) { + explicit CastVisitor(AstNetlist* nodep) { nodep->accept(*this); } virtual ~CastVisitor() {} diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index f704fd738..1808daee6 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -184,7 +184,7 @@ private: } public: // CONSTUCTORS - CdcWidthVisitor(AstNode* nodep) { + explicit CdcWidthVisitor(AstNode* nodep) { m_maxLineno = 0; m_maxFilenameLen = 0; nodep->accept(*this); @@ -726,7 +726,7 @@ private: public: // CONSTUCTORS - CdcVisitor(AstNode* nodep) { + explicit CdcVisitor(AstNode* nodep) { m_logicVertexp = NULL; m_scopep = NULL; m_modp = NULL; diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 192c245d5..8afab109f 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -280,7 +280,7 @@ private: public: // CONSTUCTORS - CleanVisitor(AstNetlist* nodep) { + explicit CleanVisitor(AstNetlist* nodep) { nodep->accept(*this); } virtual ~CleanVisitor() {} diff --git a/src/V3ClkGater.cpp b/src/V3ClkGater.cpp index b9945a54a..de7f72dd8 100644 --- a/src/V3ClkGater.cpp +++ b/src/V3ClkGater.cpp @@ -66,7 +66,7 @@ class GaterVarVertex; class GaterVertex : public V3GraphVertex { static uint32_t s_rankNum; public: - GaterVertex(V3Graph* graphp) + explicit GaterVertex(V3Graph* graphp) : V3GraphVertex(graphp) { s_rankNum++; rank(s_rankNum); } @@ -79,7 +79,7 @@ uint32_t GaterVertex::s_rankNum = 0; class GaterHeadVertex : public GaterVertex { public: - GaterHeadVertex(V3Graph* graphp) + explicit GaterHeadVertex(V3Graph* graphp) : GaterVertex(graphp) {} virtual ~GaterHeadVertex() {} virtual int typeNum() const { return __LINE__; } // C++ typeof() equivelent @@ -89,7 +89,7 @@ public: class GaterPliVertex : public GaterVertex { public: - GaterPliVertex(V3Graph* graphp) + explicit GaterPliVertex(V3Graph* graphp) : GaterVertex(graphp) {} virtual ~GaterPliVertex() {} virtual int typeNum() const { return __LINE__; } // C++ typeof() equivelent @@ -217,7 +217,7 @@ private: } public: // CONSTUCTORS - GaterCondVisitor(AstNode* nodep) { + explicit GaterCondVisitor(AstNode* nodep) { m_isSimple = true; nodep->accept(*this); } @@ -878,7 +878,7 @@ class GaterVisitor : public GaterBaseVisitor { public: // CONSTUCTORS - GaterVisitor(AstNode* nodep) { + explicit GaterVisitor(AstNode* nodep) { // AstAlways visitor does the real work, so most zeroing needs to be in clear() clear(); nodep->accept(*this); diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index ef1c08e39..36a3d1327 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -386,7 +386,7 @@ private: public: // CONSTUCTORS - ClockVisitor(AstNetlist* nodep) { + explicit ClockVisitor(AstNetlist* nodep) { m_modp=NULL; m_activep=NULL; m_evalFuncp = NULL; m_topScopep=NULL; diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index 9ee44d537..ed412d38d 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -169,7 +169,7 @@ private: } public: // CONSTRUCTORS - CombMarkVisitor(AstNode* nodep) { + explicit CombMarkVisitor(AstNode* nodep) { nodep->accept(*this); } virtual ~CombMarkVisitor() {} @@ -457,7 +457,7 @@ private: public: // CONSTUCTORS - CombineVisitor(AstNetlist* nodep) { + explicit CombineVisitor(AstNetlist* nodep) { m_modp=NULL; m_funcp = NULL; m_state = STATE_IDLE; diff --git a/src/V3Const.cpp b/src/V3Const.cpp index a761be478..3b5125364 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -54,7 +54,7 @@ private: } public: // CONSTUCTORS - ConstVarMarkVisitor(AstNode* nodep) { + explicit ConstVarMarkVisitor(AstNode* nodep) { AstNode::user4ClearTree(); // Check marked InUse before we're called nodep->accept(*this); } @@ -76,7 +76,7 @@ private: } public: // CONSTUCTORS - ConstVarFindVisitor(AstNode* nodep) { + explicit ConstVarFindVisitor(AstNode* nodep) { m_found = false; nodep->iterateAndNext(*this, NULL); } @@ -2292,7 +2292,7 @@ public: }; // CONSTUCTORS - ConstVisitor(ProcMode pmode) { + explicit ConstVisitor(ProcMode pmode) { m_params = false; m_required = false; m_doExpensive = false; diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index b5ad49408..414336391 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -378,7 +378,7 @@ private: public: // CONSTUCTORS - CoverageVisitor(AstNetlist* rootp) { + explicit CoverageVisitor(AstNetlist* rootp) { // Operate on all modules m_checkBlock = true; m_beginHier = ""; diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index 8a0010e9f..435ad416e 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -121,7 +121,7 @@ private: public: // CONSTUCTORS - CoverageJoinVisitor(AstNetlist* nodep) { + explicit CoverageJoinVisitor(AstNetlist* nodep) { nodep->accept(*this); } virtual ~CoverageJoinVisitor() { diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index ac2e20faf..e06ab77dc 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -58,7 +58,7 @@ private: } public: // CONSTRUCTORS - DeadModVisitor(AstNodeModule* nodep) { + explicit DeadModVisitor(AstNodeModule* nodep) { nodep->accept(*this); } virtual ~DeadModVisitor() {} diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 178b9bf0d..cd5cfd392 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -450,7 +450,7 @@ private: public: // CONSTUCTORS - DelayedVisitor(AstNetlist* nodep) { + explicit DelayedVisitor(AstNetlist* nodep) { m_inDly = false; m_activep=NULL; m_cfuncp=NULL; diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index a5f734800..0d36f74a9 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -157,7 +157,7 @@ private: public: // CONSTUCTORS - DepthVisitor(AstNetlist* nodep) { + explicit DepthVisitor(AstNetlist* nodep) { m_modp=NULL; m_funcp=NULL; m_stmtp=NULL; diff --git a/src/V3DepthBlock.cpp b/src/V3DepthBlock.cpp index 61be83491..03ff3ca7b 100644 --- a/src/V3DepthBlock.cpp +++ b/src/V3DepthBlock.cpp @@ -125,7 +125,7 @@ private: public: // CONSTUCTORS - DepthBlockVisitor(AstNetlist* nodep) { + explicit DepthBlockVisitor(AstNetlist* nodep) { m_modp=NULL; m_depth=0; // diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 3d91b3360..20eb46563 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -247,7 +247,7 @@ private: } public: // CONSTRUCTORS - DescopeVisitor(AstNetlist* nodep) { + explicit DescopeVisitor(AstNetlist* nodep) { m_modp = NULL; m_scopep = NULL; m_needThis = false; diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 618ab77d5..63d32492d 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -656,7 +656,7 @@ public: } } else if (nodep->isQuad()) { vluint64_t num = nodep->toUQuad(); - if (num<10) ofp()->printf("VL_ULL(%" VL_PRI64 "d)", num); + if (num<10) ofp()->printf("VL_ULL(%" VL_PRI64 "u)", num); else ofp()->printf("VL_ULL(0x%" VL_PRI64 "x)", num); } else { uint32_t num = nodep->toUInt(); @@ -2434,7 +2434,7 @@ class EmitCTrace : EmitCStmts { } public: - EmitCTrace(bool slow) { + explicit EmitCTrace(bool slow) { m_funcp = NULL; m_slow = slow; } diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index df84d2e47..38a361f0a 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -106,7 +106,7 @@ private: } public: // CONSTUCTORS - EmitCBaseCounterVisitor(AstNode* nodep) { + explicit EmitCBaseCounterVisitor(AstNode* nodep) { m_count = 0; nodep->accept(*this); } diff --git a/src/V3EmitCInlines.cpp b/src/V3EmitCInlines.cpp index 93dab1f1c..15eff33a0 100644 --- a/src/V3EmitCInlines.cpp +++ b/src/V3EmitCInlines.cpp @@ -71,7 +71,7 @@ class EmitCInlines : EmitCBaseVisitor { //--------------------------------------- // ACCESSORS public: - EmitCInlines(AstNetlist* nodep) { + explicit EmitCInlines(AstNetlist* nodep) { nodep->accept(*this); if (v3Global.needHInlines()) { emitInt(); diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 88a010ad2..0dd453b7f 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -244,7 +244,7 @@ class EmitCSyms : EmitCBaseVisitor { //--------------------------------------- // ACCESSORS public: - EmitCSyms(AstNetlist* nodep) { + explicit EmitCSyms(AstNetlist* nodep) { m_funcp = NULL; m_modp = NULL; m_coverBins = 0; diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 4d1f5add9..34deab6fd 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -234,7 +234,7 @@ public: } public: - EmitMkVisitor(AstNetlist*) { + explicit EmitMkVisitor(AstNetlist*) { emitClassMake(); emitOverallMake(); } diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 23a30f69b..ebfcce8b7 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -589,7 +589,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor { } public: - EmitVBaseVisitor(AstSenTree* domainp=NULL) { // Domain for printing one a ALWAYS under a ACTIVE + explicit EmitVBaseVisitor(AstSenTree* domainp=NULL) { // Domain for printing one a ALWAYS under a ACTIVE m_suppressSemi = false; m_sensesp = domainp; } diff --git a/src/V3Error.h b/src/V3Error.h index aced98bdf..38bcf42fd 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -104,8 +104,9 @@ public: }; enum en m_e; inline V3ErrorCode () : m_e(EC_MIN) {} + // cppcheck-suppress noExplicitConstructor inline V3ErrorCode (en _e) : m_e(_e) {} - V3ErrorCode (const char* msgp); // Matching code or ERROR + explicit V3ErrorCode (const char* msgp); // Matching code or ERROR explicit inline V3ErrorCode (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } const char* ascii() const { diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index d415641b3..0935b1297 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -921,7 +921,7 @@ private: public: // CONSTUCTORS - ExpandVisitor(AstNetlist* nodep) { + explicit ExpandVisitor(AstNetlist* nodep) { m_stmtp=NULL; nodep->accept(*this); } diff --git a/src/V3File.cpp b/src/V3File.cpp index be4bf36f7..b32d9e885 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -363,6 +363,7 @@ private: } return out; } + // cppcheck-suppress unusedFunction string readFilterLine() { // Slow, but we don't need it much UINFO(9,"readFilterLine\n"); @@ -380,6 +381,7 @@ private: UINFO(6,"filter-line-in: "<=6) { UINFO(6,"filter-out: "< StrList; @@ -86,7 +87,7 @@ public: bool readWholefile(const string& filename, StrList& outl); // CONSTRUCTORS - V3InFilter(const string& command); + explicit V3InFilter(const string& command); ~V3InFilter(); }; @@ -183,7 +184,7 @@ private: class V3OutCFile : public V3OutFile { int m_private; public: - V3OutCFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_C) { + explicit V3OutCFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_C) { resetPrivate(); } virtual ~V3OutCFile() {} @@ -208,7 +209,7 @@ public: class V3OutScFile : public V3OutCFile { public: - V3OutScFile(const string& filename) : V3OutCFile(filename) {} + explicit V3OutScFile(const string& filename) : V3OutCFile(filename) {} virtual ~V3OutScFile() {} virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); } virtual void putsIntTopInclude() { @@ -219,7 +220,7 @@ public: class V3OutSpFile : public V3OutCFile { public: - V3OutSpFile(const string& filename) : V3OutCFile(filename) {} + explicit V3OutSpFile(const string& filename) : V3OutCFile(filename) {} virtual ~V3OutSpFile() {} virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); } virtual void putsIntTopInclude() { @@ -230,21 +231,21 @@ public: class V3OutVFile : public V3OutFile { public: - V3OutVFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_VERILOG) {} + explicit V3OutVFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_VERILOG) {} virtual ~V3OutVFile() {} virtual void putsHeader() { puts("// Verilated -*- Verilog -*-\n"); } }; class V3OutXmlFile : public V3OutFile { public: - V3OutXmlFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_XML) {} + explicit V3OutXmlFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_XML) {} virtual ~V3OutXmlFile() {} virtual void putsHeader() { puts("\n"); } }; class V3OutMkFile : public V3OutFile { public: - V3OutMkFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_MK) {} + explicit V3OutMkFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_MK) {} virtual ~V3OutMkFile() {} virtual void putsHeader() { puts("# Verilated -*- Makefile -*-\n"); } // No automatic indentation yet. diff --git a/src/V3FileLine.h b/src/V3FileLine.h index 1c5e73697..b4ece08f1 100644 --- a/src/V3FileLine.h +++ b/src/V3FileLine.h @@ -102,9 +102,9 @@ public: FileLine (const string& filename, int lineno) { m_lineno=lineno; m_filenameno = singleton().nameToNumber(filename); m_warnOn=defaultFileLine().m_warnOn; } - FileLine (FileLine* fromp) { + explicit FileLine (FileLine* fromp) { m_lineno=fromp->m_lineno; m_filenameno = fromp->m_filenameno; m_warnOn=fromp->m_warnOn; } - FileLine (EmptySecret); + explicit FileLine (EmptySecret); ~FileLine() { } FileLine* create(const string& filename, int lineno) { return new FileLine(filename,lineno); } FileLine* create(int lineno) { return create(filename(), lineno); } diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 7ccdb3770..0f0e5ec30 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -496,7 +496,7 @@ private: public: // CONSTUCTORS - GateVisitor(AstNode* nodep) { + explicit GateVisitor(AstNode* nodep) { AstNode::user1ClearTree(); m_logicVertexp = NULL; m_scopep = NULL; @@ -1202,7 +1202,7 @@ private: } public: - GateMergeAssignsGraphVisitor(V3Graph* graphp) { + explicit GateMergeAssignsGraphVisitor(V3Graph* graphp) { m_assignp = NULL; m_activep = NULL; m_logicvp = NULL; @@ -1253,7 +1253,7 @@ private: public: // CONSTUCTORS - GateDeassignVisitor(AstNode* nodep) { + explicit GateDeassignVisitor(AstNode* nodep) { nodep->accept(*this); } virtual ~GateDeassignVisitor() {} diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index 736bb6f9f..cbee8f4c6 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -213,7 +213,7 @@ private: } public: // CONSTRUCTORS - GenClkReadVisitor(AstNetlist* nodep) { + explicit GenClkReadVisitor(AstNetlist* nodep) { m_activep = NULL; m_assignp = NULL; m_topModp = NULL; diff --git a/src/V3Global.h b/src/V3Global.h index 97e8f8d2b..f1376bf03 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -46,6 +46,7 @@ public: }; enum en m_e; inline VWidthMinUsage () : m_e(LINT_WIDTH) {} + // cppcheck-suppress noExplicitConstructor inline VWidthMinUsage (en _e) : m_e(_e) {} explicit inline VWidthMinUsage (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -63,7 +64,6 @@ class V3Global { VWidthMinUsage m_widthMinUsage; // What AstNode::widthMin() is used for int m_debugFileNumber; // Number to append to debug files created - int m_assertWidthsMatch; // Tree should have width()==widthMin() bool m_assertDTypesResolved; // Tree should have dtypep()'s bool m_constRemoveXs; // Const needs to strip any Xs bool m_needHInlines; // Need __Inlines file diff --git a/src/V3Graph.h b/src/V3Graph.h index 80f80a976..09970af4a 100644 --- a/src/V3Graph.h +++ b/src/V3Graph.h @@ -167,7 +167,7 @@ protected: // CONSTRUCTORS V3GraphVertex(V3Graph* graphp, const V3GraphVertex& old); public: - V3GraphVertex(V3Graph* graphp); + explicit V3GraphVertex(V3Graph* graphp); //! Clone copy constructor. Doesn't copy edges or user/userp. virtual V3GraphVertex* clone(V3Graph* graphp) const { return new V3GraphVertex(graphp, *this); } diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index 504f4f09f..8f664b598 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -319,6 +319,7 @@ void GraphAcyc::simplifyOne (GraphAcycVertex* avertexp) { && (!outEdgep->cutable() || inEdgep->weight()weight() )) ? inEdgep : outEdgep); + // cppcheck-suppress leakReturnValNotUsed edgeFromEdge(templateEdgep, inVertexp, outVertexp); // Remove old edge inEdgep->unlinkDelete(); inEdgep = NULL; @@ -353,6 +354,7 @@ void GraphAcyc::simplifyOut (GraphAcycVertex* avertexp) { return; } // Make a new edge connecting the two vertices directly + // cppcheck-suppress leakReturnValNotUsed edgeFromEdge(inEdgep, inVertexp, outVertexp); // Remove old edge inEdgep->unlinkDelete(); inEdgep = NULL; diff --git a/src/V3Hashed.cpp b/src/V3Hashed.cpp index 02a6d59cd..06b0feb3b 100644 --- a/src/V3Hashed.cpp +++ b/src/V3Hashed.cpp @@ -96,7 +96,7 @@ private: public: // CONSTUCTORS - HashedVisitor(AstNode* nodep) { + explicit HashedVisitor(AstNode* nodep) { nodeHashIterate(nodep); //UINFO(9," stmthash "<accept(*this); @@ -227,7 +227,7 @@ private: public: // CONSTUCTORS - InlineCollectVisitor(AstNodeModule* nodep) { // passed OLD module, not new one + explicit InlineCollectVisitor(AstNodeModule* nodep) { // passed OLD module, not new one nodep->accept(*this); } virtual ~InlineCollectVisitor() {} @@ -537,7 +537,7 @@ private: public: // CONSTUCTORS - InlineVisitor(AstNode* nodep) { + explicit InlineVisitor(AstNode* nodep) { m_modp = NULL; nodep->accept(*this); } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 8a9007775..52d3069dc 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -139,7 +139,7 @@ private: } public: // CONSTUCTORS - InstVisitor(AstNode* nodep) { + explicit InstVisitor(AstNode* nodep) { m_modp=NULL; m_cellp=NULL; // @@ -229,7 +229,7 @@ private: } public: // CONSTUCTORS - InstDeVisitor(AstNode* nodep) { + explicit InstDeVisitor(AstNode* nodep) { m_cellRangep=NULL; m_instNum=0; m_instLsb=0; diff --git a/src/V3LangCode.h b/src/V3LangCode.h index a9209cf90..60e746dcc 100644 --- a/src/V3LangCode.h +++ b/src/V3LangCode.h @@ -64,8 +64,9 @@ public: // enum en m_e; inline V3LangCode () : m_e(L_ERROR) {} + // cppcheck-suppress noExplicitConstructor inline V3LangCode (en _e) : m_e(_e) {} - V3LangCode (const char* textp); + explicit V3LangCode (const char* textp); explicit inline V3LangCode (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } }; diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 69f2a653f..9f583ed3e 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -93,10 +93,10 @@ public: LifeVarEntry(SIMPLEASSIGN, AstNodeAssign* assp) { init(true); simpleAssign(assp); } - LifeVarEntry(COMPLEXASSIGN) { + explicit LifeVarEntry(COMPLEXASSIGN) { init(false); complexAssign(); } - LifeVarEntry(CONSUMED) { + explicit LifeVarEntry(CONSUMED) { init(false); consumed(); } ~LifeVarEntry() {} @@ -455,14 +455,14 @@ public: m_sideEffect = false; m_noopt = false; { - // Cpp check bug, it is deleted - // cppcheck-suppress leak m_lifep = new LifeBlock (NULL, m_statep); nodep->accept(*this); - delete m_lifep; m_lifep=NULL; + if (m_lifep) { delete m_lifep; m_lifep=NULL; } } } - virtual ~LifeVisitor() {} + virtual ~LifeVisitor() { + if (m_lifep) { delete m_lifep; m_lifep=NULL; } + } }; //###################################################################### diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index cce02402d..6ba6cb353 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -86,7 +86,7 @@ private: } public: // CONSTRUCTORS - LifePostElimVisitor(AstTopScope* nodep) { + explicit LifePostElimVisitor(AstTopScope* nodep) { nodep->accept(*this); } virtual ~LifePostElimVisitor() {} @@ -178,7 +178,7 @@ private: } public: // CONSTRUCTORS - LifePostDlyVisitor(AstNetlist* nodep) { + explicit LifePostDlyVisitor(AstNetlist* nodep) { nodep->accept(*this); } virtual ~LifePostDlyVisitor() { diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index 4a75efb2a..ada7f12a2 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -66,7 +66,7 @@ public: class LibraryVertex : public V3GraphVertex { public: - LibraryVertex(V3Graph* graphp) + explicit LibraryVertex(V3Graph* graphp) : V3GraphVertex(graphp) {} virtual ~LibraryVertex() {} virtual string name() const { return "*LIBRARY*"; } diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index 4aeb3d3ee..a19cb6c6d 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -246,7 +246,7 @@ private: } public: // CONSTUCTORS - LinkJumpVisitor(AstNetlist* nodep) { + explicit LinkJumpVisitor(AstNetlist* nodep) { m_modp = NULL; m_ftaskp = NULL; m_loopp = NULL; diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 76ea8c6a8..e21fb5370 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -349,7 +349,7 @@ private: public: // CONSTUCTORS - LinkParseVisitor(AstNetlist* rootp) { + explicit LinkParseVisitor(AstNetlist* rootp) { m_varp = NULL; m_modp = NULL; m_ftaskp = NULL; diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 90ae80ce7..53a42e841 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -399,7 +399,7 @@ private: public: // CONSTUCTORS - LinkResolveVisitor(AstNetlist* rootp) { + explicit LinkResolveVisitor(AstNetlist* rootp) { m_ftaskp = NULL; m_modp = NULL; m_assertp = NULL; @@ -451,7 +451,7 @@ private: } public: // CONSTUCTORS - LinkBotupVisitor(AstNetlist* rootp) { + explicit LinkBotupVisitor(AstNetlist* rootp) { m_modp = NULL; // rootp->accept(*this); diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index 75c569b8f..cfa81f8a0 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -93,7 +93,7 @@ private: } public: // CONSTRUCTORS - LocalizeDehierVisitor(AstNetlist* nodep) { + explicit LocalizeDehierVisitor(AstNetlist* nodep) { nodep->accept(*this); } virtual ~LocalizeDehierVisitor() {} @@ -233,7 +233,7 @@ private: } public: // CONSTRUCTORS - LocalizeVisitor(AstNetlist* nodep) { + explicit LocalizeVisitor(AstNetlist* nodep) { m_cfuncp = NULL; nodep->accept(*this); } diff --git a/src/V3Name.cpp b/src/V3Name.cpp index 3bd52c632..9dea48823 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -137,7 +137,7 @@ private: } public: // CONSTUCTORS - NameVisitor(AstNetlist* nodep) { + explicit NameVisitor(AstNetlist* nodep) { nodep->accept(*this); } virtual ~NameVisitor() {} diff --git a/src/V3Number.h b/src/V3Number.h index 98050967e..bacf082d2 100644 --- a/src/V3Number.h +++ b/src/V3Number.h @@ -129,7 +129,7 @@ private: public: // CONSTRUCTORS - V3Number(FileLine* fileline) { init(fileline, 1); } + explicit V3Number(FileLine* fileline) { init(fileline, 1); } V3Number(FileLine* fileline, int width) { init(fileline, width); } // 0=unsized V3Number(FileLine* fileline, int width, uint32_t value) { init(fileline, width); m_value[0]=value; opCleanThis(); } V3Number(FileLine* fileline, const char* source); // Create from a verilog 32'hxxxx number. diff --git a/src/V3Options.cpp b/src/V3Options.cpp index a30e75ec1..45c7cb60a 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1002,6 +1002,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) { getline(*ifp, line); // Strip simple comments string oline; + // cppcheck-suppress StlMissingComparison for (string::const_iterator pos = line.begin(); pos != line.end(); ++pos) { if (inCmt) { if (*pos=='*' && *(pos+1)=='/') { diff --git a/src/V3Options.h b/src/V3Options.h index 2534c2a3a..53749713c 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -175,6 +175,8 @@ class V3Options { static string getenvSYSTEMPERLGuts(); + V3Options(const V3Options&); ///< N/A, no copy constructor + public: // CREATORS V3Options(); diff --git a/src/V3Order.cpp b/src/V3Order.cpp index e24428da3..d067a7c3b 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -363,7 +363,7 @@ private: public: // CONSTUCTORS - OrderClkMarkVisitor(AstNode* nodep) { + explicit OrderClkMarkVisitor(AstNode* nodep) { m_hasClk = false; m_inClocked = false; m_inAss = false; @@ -410,7 +410,7 @@ private: public: // CONSTUCTORS - OrderClkAssVisitor(AstNode* nodep) { + explicit OrderClkAssVisitor(AstNode* nodep) { m_clkAss = false; nodep->accept(*this); } diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index a4bc6cb41..7a733653c 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -104,6 +104,7 @@ struct OrderVEdgeType { } enum en m_e; inline OrderVEdgeType () : m_e(VERTEX_UNKNOWN) {} + // cppcheck-suppress noExplicitConstructor inline OrderVEdgeType (en _e) : m_e(_e) {} explicit inline OrderVEdgeType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } diff --git a/src/V3Param.cpp b/src/V3Param.cpp index d5b42f934..486541af7 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -88,7 +88,7 @@ private: struct ModInfo { AstNodeModule* m_modp; // Module with specified name VarCloneMap m_cloneMap; // Map of old-varp -> new cloned varp - ModInfo(AstNodeModule* modp) { m_modp=modp; } + explicit ModInfo(AstNodeModule* modp) { m_modp=modp; } }; typedef map ModNameMap; ModNameMap m_modNameMap; // Hash of created module flavors by name @@ -385,7 +385,7 @@ private: public: // CONSTUCTORS - ParamVisitor(AstNetlist* nodep) { + explicit ParamVisitor(AstNetlist* nodep) { m_longId = 0; // nodep->accept(*this); diff --git a/src/V3Parse.h b/src/V3Parse.h index 14a0a5fa6..e56ac0f48 100644 --- a/src/V3Parse.h +++ b/src/V3Parse.h @@ -36,6 +36,7 @@ class V3Parse { private: V3ParseImp* m_impp; + V3Parse(const V3Parse&); ///< N/A, no copy constructor public: // CONSTRUCTORS // We must allow reading multiple files into one parser diff --git a/src/V3ParseSym.h b/src/V3ParseSym.h index adc840bef..014b9e1de 100644 --- a/src/V3ParseSym.h +++ b/src/V3ParseSym.h @@ -133,7 +133,7 @@ public: } public: // CREATORS - V3ParseSym(AstNetlist* rootp) + explicit V3ParseSym(AstNetlist* rootp) : m_syms(rootp) { s_anonNum = 0; // Number of next anonymous object pushScope(findNewTable(rootp)); diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 39163d931..8f1242530 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -85,7 +85,7 @@ private: public: // CONSTRUCTORS - PremitAssignVisitor(AstNodeAssign* nodep) { + explicit PremitAssignVisitor(AstNodeAssign* nodep) { UINFO(4," PremitAssignVisitor on "<accept(*this); @@ -383,7 +383,7 @@ private: public: // CONSTUCTORS - PremitVisitor(AstNetlist* nodep) { + explicit PremitVisitor(AstNetlist* nodep) { m_modp = NULL; m_funcp = NULL; m_stmtp = NULL; diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index c253d0afd..3588d3a19 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -294,7 +294,7 @@ private: } public: // CONSTUCTORS - ScopeVisitor(AstNetlist* nodep) { + explicit ScopeVisitor(AstNetlist* nodep) { m_aboveCellp = NULL; m_aboveScopep = NULL; m_modp = NULL; @@ -402,7 +402,7 @@ private: } public: // CONSTUCTORS - ScopeCleanupVisitor(AstNetlist* nodep) { + explicit ScopeCleanupVisitor(AstNetlist* nodep) { m_scopep = NULL; nodep->accept(*this); } diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 8bc4decb6..ac4dc9253 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -655,6 +655,7 @@ private: AstNodeFTask* funcp = nodep->taskp()->castNodeFTask(); if (!funcp) nodep->v3fatalSrc("Not linked"); // cppcheck-suppress redundantAssignment if (m_params) { V3Width::widthParamsEdit(funcp); } funcp=NULL; // Make sure we've sized the function + // cppcheck-suppress redundantAssignment funcp = nodep->taskp()->castNodeFTask(); if (!funcp) nodep->v3fatalSrc("Not linked"); // Apply function call values to function V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index 6403271cf..076cb817b 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -185,7 +185,7 @@ class SliceCloneVisitor : public AstNVisitor { } public: // CONSTUCTORS - SliceCloneVisitor(AstNode* nodep) { + explicit SliceCloneVisitor(AstNode* nodep) { nodep->accept(*this); } virtual ~SliceCloneVisitor() {} @@ -487,7 +487,7 @@ class SliceVisitor : public AstNVisitor { public: // CONSTUCTORS - SliceVisitor(AstNetlist* rootp) { + explicit SliceVisitor(AstNetlist* rootp) { m_assignp = NULL; m_lhsVarRefp = NULL; rootp->accept(*this); diff --git a/src/V3Split.cpp b/src/V3Split.cpp index effdfbd8a..1c967edc7 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -69,7 +69,7 @@ class SplitPliVertex : public V3GraphVertex { public: - SplitPliVertex(V3Graph* graphp) + explicit SplitPliVertex(V3Graph* graphp) : V3GraphVertex(graphp) {} virtual ~SplitPliVertex() {} virtual string name() const { return "*PLI*"; } diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index b0cd367e9..7a3da7f70 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -71,7 +71,7 @@ private: } public: // CONSTUCTORS - SplitAsFindVisitor(AstAlways* nodep) { + explicit SplitAsFindVisitor(AstAlways* nodep) { m_splitVscp = NULL; nodep->accept(*this); } @@ -200,7 +200,7 @@ private: public: // CONSTUCTORS - SplitAsVisitor(AstNetlist* nodep) { + explicit SplitAsVisitor(AstNetlist* nodep) { m_splitVscp = NULL; AstNode::user1ClearTree(); // user1p() used on entire tree nodep->accept(*this); diff --git a/src/V3Stats.h b/src/V3Stats.h index 067316293..d686927a6 100644 --- a/src/V3Stats.h +++ b/src/V3Stats.h @@ -37,7 +37,7 @@ public: ~V3Double0() {} // Implicit conversion operators: - inline V3Double0 (const vluint64_t v) : m_d(v) { } + inline explicit V3Double0 (const vluint64_t v) : m_d(v) { } inline operator double () const { return m_d; } // Explicit operators: diff --git a/src/V3StatsReport.cpp b/src/V3StatsReport.cpp index 34b7d39fc..098680176 100644 --- a/src/V3StatsReport.cpp +++ b/src/V3StatsReport.cpp @@ -177,7 +177,7 @@ public: } // CONSTRUCTORS - StatsReport(ofstream* aofp) + explicit StatsReport(ofstream* aofp) : os(*aofp) { header(); sumit(); diff --git a/src/V3String.h b/src/V3String.h index 99c256e58..355de273d 100644 --- a/src/V3String.h +++ b/src/V3String.h @@ -54,7 +54,7 @@ class VHashSha1 { public: // CONSTRUCTORS VHashSha1() { init(); } - VHashSha1(const string& data) { init(); insert(data); } + explicit VHashSha1(const string& data) { init(); insert(data); } ~VHashSha1() {} // METHODS @@ -93,7 +93,7 @@ class VName { static size_t s_minLength; // Length to preserve if over maxLength public: // CONSTRUCTORS - VName (const string& name) : m_name(name) {} + explicit VName (const string& name) : m_name(name) {} ~VName() {} // METHODS void name(const string& name) { m_name = name; m_hashed = ""; } diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index 3f248d733..8aa380184 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -86,7 +86,7 @@ class SubstVarEntry { public: // CONSTRUCTORS - SubstVarEntry (AstVar* varp) { // Construction for when a var is used + explicit SubstVarEntry (AstVar* varp) { // Construction for when a var is used m_varp = varp; m_whole.m_use = false; m_wordAssign = false; @@ -379,7 +379,7 @@ private: } public: // CONSTUCTORS - SubstVisitor(AstNode* nodep) { + explicit SubstVisitor(AstNode* nodep) { AstNode::user1ClearTree(); // user1p() used on entire tree AstNode::user2ClearTree(); // user2p() used on entire tree m_ops = 0; diff --git a/src/V3SymTable.h b/src/V3SymTable.h index 62f6b64d3..fa7c51e28 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -226,6 +226,8 @@ private: VSymEnt* m_symRootp; // Root symbol table SymStack m_symsp; // All symbol tables, to cleanup + VSymGraph(const VSymGraph&); ///< N/A, no copy constructor + protected: friend class VSymEnt; void pushNewEnt(VSymEnt* entp) { m_symsp.push_back(entp); } @@ -256,7 +258,7 @@ public: } public: // CREATORS - VSymGraph(AstNetlist* nodep) { + explicit VSymGraph(AstNetlist* nodep) { m_symRootp = new VSymEnt(this, nodep); } ~VSymGraph() { diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 18e32b2bd..b2f121903 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -60,7 +60,7 @@ public: virtual void varRefCb(AstVarRef* nodep); ///< Call other-this function on all new var references // CONSTRUCTORS - TableSimulateVisitor(TableVisitor* cbthis) { + explicit TableSimulateVisitor(TableVisitor* cbthis) { m_cbthis = cbthis; } virtual ~TableSimulateVisitor() {} @@ -437,7 +437,7 @@ private: } public: // CONSTRUCTORS - TableVisitor(AstNetlist* nodep) { + explicit TableVisitor(AstNetlist* nodep) { m_modp = NULL; m_modTables = 0; m_scopep = NULL; diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 802457e11..494447d95 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -49,7 +49,7 @@ class TaskBaseVertex : public V3GraphVertex { AstNode* m_impurep; // Node causing impure function w/ outside references bool m_noInline; // Marked with pragma public: - TaskBaseVertex(V3Graph* graphp) + explicit TaskBaseVertex(V3Graph* graphp) : V3GraphVertex(graphp), m_impurep(NULL), m_noInline(false) {} virtual ~TaskBaseVertex() {} bool pure() const { return m_impurep==NULL; } @@ -79,7 +79,7 @@ public: class TaskCodeVertex : public TaskBaseVertex { // Top vertex for all calls not under another task public: - TaskCodeVertex(V3Graph* graphp) + explicit TaskCodeVertex(V3Graph* graphp) : TaskBaseVertex(graphp) {} virtual ~TaskCodeVertex() {} virtual string name() const { return "*CODE*"; } @@ -234,7 +234,7 @@ private: } public: // CONSTUCTORS - TaskStateVisitor(AstNetlist* nodep) { + explicit TaskStateVisitor(AstNetlist* nodep) { m_assignwp = NULL; m_curVxp = new TaskCodeVertex(&m_callGraph); AstNode::user3ClearTree(); @@ -277,7 +277,7 @@ private: } public: // CONSTUCTORS - TaskRelinkVisitor(AstBegin* nodep) { // Passed temporary tree + explicit TaskRelinkVisitor(AstBegin* nodep) { // Passed temporary tree nodep->accept(*this); } virtual ~TaskRelinkVisitor() {} diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index f35111006..52c366783 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -677,7 +677,7 @@ private: public: // CONSTUCTORS - TraceVisitor(AstNetlist* nodep) { + explicit TraceVisitor(AstNetlist* nodep) { m_funcp = NULL; m_tracep = NULL; m_topModp = NULL; diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 91bbf7148..00398afb9 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -108,9 +108,6 @@ private: basep->addStmtsp(callp); return funcp; } - void addCFuncStmt(AstCFunc* basep, AstNode* nodep, VNumRange arrayRange) { - basep->addStmtsp(nodep); - } void addTraceDecl(const VNumRange& arrayRange, int widthOverride) { // If !=0, is packed struct/array where basicp size misreflects one element VNumRange bitRange; @@ -305,7 +302,7 @@ private: public: // CONSTUCTORS - TraceDeclVisitor(AstNetlist* nodep) { + explicit TraceDeclVisitor(AstNetlist* nodep) { m_scopetopp = NULL; m_initFuncp = NULL; m_initSubFuncp = NULL; diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 7f787a9da..18280dd84 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -1302,7 +1302,7 @@ class TristateVisitor : public TristateBaseVisitor { public: // CONSTUCTORS - TristateVisitor(AstNode* nodep) { + explicit TristateVisitor(AstNode* nodep) { m_graphing = false; m_modp = NULL; m_cellp = NULL; diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 8fd105119..9ca63c752 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -60,7 +60,7 @@ class UndrivenVarEntry { public: // CONSTRUCTORS - UndrivenVarEntry (AstVar* varp) { // Construction for when a var is used + explicit UndrivenVarEntry (AstVar* varp) { // Construction for when a var is used UINFO(9, "create "<v3error("Replication value isn't a constant."); return; } uint32_t times = constp->toUInt(); if (times==0 && !nodep->backp()->castConcat()) { // Concat Visitor will clean it up. - nodep->v3error("Replication value of 0 is only legal under a concatenation."); times=1; + nodep->v3error("Replication value of 0 is only legal under a concatenation."); } nodep->dtypeSetString(); } diff --git a/src/V3WidthCommit.h b/src/V3WidthCommit.h index ed71a5482..1b49c1b3c 100644 --- a/src/V3WidthCommit.h +++ b/src/V3WidthCommit.h @@ -151,7 +151,7 @@ private: } public: // CONSTUCTORS - WidthCommitVisitor(AstNetlist* nodep) { + explicit WidthCommitVisitor(AstNetlist* nodep) { // Were changing widthMin's, so the table is now somewhat trashed nodep->typeTablep()->clearCache(); nodep->accept(*this); diff --git a/src/VlcSource.h b/src/VlcSource.h index 6ff542945..771fcea6a 100644 --- a/src/VlcSource.h +++ b/src/VlcSource.h @@ -77,7 +77,7 @@ private: public: // CONSTRUCTORS - VlcSource(const string& name) { + explicit VlcSource(const string& name) { m_name = name; m_needed = false; } diff --git a/src/cppcheck_filtered b/src/cppcheck_filtered index 6e1c6e2bd..69a45e689 100755 --- a/src/cppcheck_filtered +++ b/src/cppcheck_filtered @@ -64,6 +64,7 @@ sub process { next if $line =~ m!id="missingInclude" .*systemc.h!; next if $line =~ m!id="missingInclude" .*svdpi.h!; next if $line =~ m!id="unusedFunction" .*sv! && $line =~ m!verilated_dpi.cpp!; + next if $line =~ m!id="unusedFunction" .*vpi! && $line =~ m!verilated_vpi.cpp!; next if $line =~ m!id="unusedPrivateFunction" .*::debug!; # Doesn't know UINFO will use it next if $line =~ m!file=".*obj_dbg/V3ParseBison.c".* id="unreachableCode"!; # Output @@ -124,6 +125,12 @@ sub _suppress { # delete(nodep); nodep=NULL; # This is ok, it's how we prevent later using nodep return 1; } + if (($id eq "uselessAssignment" + || $id eq "uselessAssignmentPtrArg") + && $line =~ /;.*p *= *NULL;/) { + # delete(nodep); nodep=NULL; # This is ok, it's how we prevent later using nodep + return 1; + } } } return undef; diff --git a/src/verilog.l b/src/verilog.l index a188f3858..8163af4d0 100644 --- a/src/verilog.l +++ b/src/verilog.l @@ -986,7 +986,7 @@ double V3ParseImp::parseDouble(const char* textp, size_t length) { double d = strtod(strgp, &endp); size_t parsed_len = endp-strgp; if (parsed_len != strlen(strgp)) { yyerrorf("Syntax error parsing real: %s",strgp); } - delete strgp; + delete[] strgp; return d; }