diff --git a/include/verilated_timing.h b/include/verilated_timing.h index 45de319c4..d4f4f7cb3 100644 --- a/include/verilated_timing.h +++ b/include/verilated_timing.h @@ -137,7 +137,7 @@ class VlDelayScheduler final { public: // CONSTRUCTORS - VlDelayScheduler(VerilatedContext& context) + explicit VlDelayScheduler(VerilatedContext& context) : m_context{context} {} // METHODS // Resume coroutines waiting for the current simulation time @@ -329,8 +329,8 @@ public: // CONSTRUCTORS // Construct - VlCoroutine(VlPromise* p) - : m_promisep{p} { + VlCoroutine(VlPromise* promisep) + : m_promisep{promisep} { m_promisep->m_corop = this; } // Move. Update the pointers each time the return object is moved diff --git a/include/verilated_types.h b/include/verilated_types.h index 044848e5e..11132d570 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -109,7 +109,7 @@ public: // Set elements of 'this' to 'a & !b' element-wise void andNot(const VlTriggerVec& a, const VlTriggerVec& b) { - for (size_t i = 0; i < m_flags.size(); ++i) m_flags[i] = a.m_flags[i] & !b.m_flags[i]; + for (size_t i = 0; i < m_flags.size(); ++i) m_flags[i] = a.m_flags[i] && !b.m_flags[i]; } }; @@ -1104,14 +1104,17 @@ public: m_objp->m_deleter = &deleter; refCountInc(); } + // cppcheck-suppress noExplicitConstructor VlClassRef(T_Class* objp) : m_objp{objp} { refCountInc(); } + // cppcheck-suppress noExplicitConstructor VlClassRef(const VlClassRef& copied) : m_objp{copied.m_objp} { refCountInc(); } + // cppcheck-suppress noExplicitConstructor VlClassRef(VlClassRef&& moved) : m_objp{vlstd::exchange(moved.m_objp, nullptr)} {} ~VlClassRef() { refCountDec(); } diff --git a/src/V3Ast.h b/src/V3Ast.h index 612748513..71a86943c 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -2324,7 +2324,7 @@ template bool AstNode::predicateImpl(ConstCorrectAstNode* nodep, const std::function& p) { // Implementation similar to foreach, but abort traversal as soon as result is determined. - if (!p) { + if (VL_UNCOVERABLE(!p)) { nodep->v3fatal("AstNode::foreach called with unbound function"); // LCOV_EXCL_LINE } else { using T_Arg_NonConst = typename std::remove_const::type; diff --git a/src/V3AstNodeDType.h b/src/V3AstNodeDType.h index 1c9e6c506..c30a18abf 100644 --- a/src/V3AstNodeDType.h +++ b/src/V3AstNodeDType.h @@ -97,7 +97,7 @@ public: m_widthMin = widthMin; } // For backward compatibility inherit width and signing from the subDType/base type - void widthFromSub(AstNodeDType* nodep) { + void widthFromSub(const AstNodeDType* nodep) { m_width = nodep->m_width; m_widthMin = nodep->m_widthMin; m_numeric = nodep->m_numeric; diff --git a/src/V3DfgDfgToAst.cpp b/src/V3DfgDfgToAst.cpp index 8c9e13b91..9666b203c 100644 --- a/src/V3DfgDfgToAst.cpp +++ b/src/V3DfgDfgToAst.cpp @@ -89,21 +89,21 @@ AstShiftRS* makeNode( // // LCOV_EXCL_START template <> AstCCast* makeNode(const DfgCCast* vtxp, AstNodeMath*) { - vtxp->v3fatal("not implemented"); + vtxp->v3fatalSrc("not implemented"); } template <> AstAtoN* makeNode(const DfgAtoN* vtxp, AstNodeMath*) { - vtxp->v3fatal("not implemented"); + vtxp->v3fatalSrc("not implemented"); } template <> AstCompareNN* makeNode(const DfgCompareNN* vtxp, AstNodeMath*, AstNodeMath*) { - vtxp->v3fatal("not implemented"); + vtxp->v3fatalSrc("not implemented"); } template <> AstSliceSel* makeNode( const DfgSliceSel* vtxp, AstNodeMath*, AstNodeMath*, AstNodeMath*) { - vtxp->v3fatal("not implemented"); + vtxp->v3fatalSrc("not implemented"); } // LCOV_EXCL_STOP diff --git a/src/V3DfgPasses.h b/src/V3DfgPasses.h index 595f7ee8b..2cfa69a24 100644 --- a/src/V3DfgPasses.h +++ b/src/V3DfgPasses.h @@ -33,7 +33,7 @@ class V3DfgCseContext final { public: VDouble0 m_eliminated; // Number of common sub-expressions eliminated - V3DfgCseContext(const std::string& label) + explicit V3DfgCseContext(const std::string& label) : m_label{label} {} ~V3DfgCseContext(); }; @@ -43,7 +43,7 @@ class DfgRemoveVarsContext final { public: VDouble0 m_removed; // Number of redundant variables removed - DfgRemoveVarsContext(const std::string& label) + explicit DfgRemoveVarsContext(const std::string& label) : m_label{label} {} ~DfgRemoveVarsContext(); }; @@ -73,7 +73,7 @@ public: V3DfgCseContext m_cseContext1{m_label + " 2nd"}; V3DfgPeepholeContext m_peepholeContext{m_label}; DfgRemoveVarsContext m_removeVarsContext{m_label}; - V3DfgOptimizationContext(const std::string& label); + explicit V3DfgOptimizationContext(const std::string& label); ~V3DfgOptimizationContext(); const std::string& prefix() const { return m_prefix; } diff --git a/src/V3DfgPeephole.h b/src/V3DfgPeephole.h index 10fe177f6..5d346456d 100644 --- a/src/V3DfgPeephole.h +++ b/src/V3DfgPeephole.h @@ -132,7 +132,7 @@ struct V3DfgPeepholeContext final { // Count of applications for each optimization (for statistics) VDouble0 m_count[VDfgPeepholePattern::_ENUM_END]; - V3DfgPeepholeContext(const std::string& label); + explicit V3DfgPeepholeContext(const std::string& label); ~V3DfgPeepholeContext(); }; diff --git a/src/V3Number.cpp b/src/V3Number.cpp index 00e7b1524..8861cde38 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -76,7 +76,7 @@ constexpr int MAX_SPRINTF_DOUBLE_SIZE //====================================================================== // Errors -void V3Number::v3errorEnd(std::ostringstream& str) const { +void V3Number::v3errorEnd(const std::ostringstream& str) const { std::ostringstream nsstr; nsstr << str.str(); if (m_nodep) { @@ -88,7 +88,7 @@ void V3Number::v3errorEnd(std::ostringstream& str) const { } } -void V3Number::v3errorEndFatal(std::ostringstream& str) const { +void V3Number::v3errorEndFatal(const std::ostringstream& str) const { v3errorEnd(str); assert(0); // LCOV_EXCL_LINE VL_UNREACHABLE; diff --git a/src/V3Number.h b/src/V3Number.h index f149c6ae6..82bfeacdf 100644 --- a/src/V3Number.h +++ b/src/V3Number.h @@ -541,8 +541,8 @@ private: string displayed(const string& vformat) const { return displayed(m_fileline, vformat); } public: - void v3errorEnd(std::ostringstream& sstr) const; - void v3errorEndFatal(std::ostringstream& sstr) const VL_ATTR_NORETURN; + void v3errorEnd(const std::ostringstream& sstr) const; + void v3errorEndFatal(const std::ostringstream& sstr) const VL_ATTR_NORETURN; void width(int width, bool sized = true) { m_data.m_sized = sized; m_data.resize(width); diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 0a28b981f..ea2313c48 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -208,7 +208,7 @@ class OrderBuildVisitor final : public VNVisitor { "AstSenTrees should have been made global in V3ActiveTop"); UASSERT_OBJ(m_scopep, nodep, "AstActive not under AstScope"); UASSERT_OBJ(!m_logicVxp, nodep, "AstActive under logic"); - UASSERT_OBJ(!m_inClocked && !m_domainp & !m_hybridp, nodep, "Should not nest"); + UASSERT_OBJ(!m_inClocked && !m_domainp && !m_hybridp, nodep, "Should not nest"); // This is the original sensitivity of the block (i.e.: not the ref into the TRIGGERVEC) diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 18dfc06b6..3ff5e8b56 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -915,9 +915,9 @@ class ParamVisitor final : public VNVisitor { // Process interface cells, then non-interface cells, which may reference an interface // cell. while (!m_cellps.empty()) { - const auto itm = m_cellps.cbegin(); - AstNode* const cellp = itm->second; - m_cellps.erase(itm); + const auto itim = m_cellps.cbegin(); + AstNode* const cellp = itim->second; + m_cellps.erase(itim); AstNodeModule* srcModp = nullptr; if (const auto* modCellp = VN_CAST(cellp, Cell)) { diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 348cbb4b9..94b48c99b 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -928,7 +928,7 @@ class PartPropagateCp final { public: // CONSTRUCTORS - PartPropagateCp(bool slowAsserts) + explicit PartPropagateCp(bool slowAsserts) : m_slowAsserts{slowAsserts} {} // METHODS diff --git a/src/V3Sched.cpp b/src/V3Sched.cpp index dc3ac1c2c..ebf0dfea9 100644 --- a/src/V3Sched.cpp +++ b/src/V3Sched.cpp @@ -97,7 +97,7 @@ AstAssign* setVar(AstVarScope* vscp, uint32_t val) { return new AstAssign{flp, refp, valp}; }; -void remapSensitivities(LogicByScope& lbs, +void remapSensitivities(const LogicByScope& lbs, std::unordered_map senTreeMap) { for (const auto& pair : lbs) { AstActive* const activep = pair.second; diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index 5ebb7ea7b..6f60cd266 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -105,7 +105,7 @@ private: AstScope* m_scopep = nullptr; // Current scope AstActive* m_activep = nullptr; // Current active AstNode* m_procp = nullptr; // NodeProcedure/CFunc/Fork we're under - double m_timescaleFactor; // Factor to scale delays by + double m_timescaleFactor = 1.0; // Factor to scale delays by // Unique names V3UniqueNames m_contAssignVarNames{"__VassignWtmp__"}; // Names for temp AssignW vars diff --git a/src/V3Width.cpp b/src/V3Width.cpp index eb249b88e..e7901340a 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -4363,7 +4363,7 @@ private: fmt = ch; } else if (inPct && (isdigit(ch) || ch == '.' || ch == '-')) { fmt += ch; - } else if (tolower(inPct)) { + } else if (inPct) { inPct = false; bool added = false; switch (tolower(ch)) {