diff --git a/include/verilated.cpp b/include/verilated.cpp index 5105bca90..ec82b6a16 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1641,6 +1641,7 @@ std::string VL_STACKTRACE_N() VL_MT_SAFE { strings = backtrace_symbols(buffer, nptrs); #endif + // cppcheck-suppress knownConditionTrueFalse if (!strings) return "Unable to backtrace\n"; std::string out = "Backtrace:\n"; diff --git a/include/verilated_imp.h b/include/verilated_imp.h index afc3d01c8..ad6d96cac 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -362,6 +362,7 @@ public: // But only for verilated*.cpp private: VerilatedFpList fdToFpList(IData fdi) VL_REQUIRES(m_fdMutex) { VerilatedFpList fp; + // cppcheck-suppress integeroverflow shifttoomanybitssigned if ((fdi & (1 << 31)) != 0) { // Non-MCD case const IData idx = fdi & VL_MASK_I(31); diff --git a/include/verilated_timing.h b/include/verilated_timing.h index f39d88ed6..bead97e9d 100644 --- a/include/verilated_timing.h +++ b/include/verilated_timing.h @@ -404,11 +404,13 @@ public: // CONSTRUCTORS // Construct + // cppcheck-suppress noExplicitConstructor VlCoroutine(VlPromise* promisep) : m_promisep{promisep} { m_promisep->m_corop = this; } // Move. Update the pointers each time the return object is moved + // cppcheck-suppress noExplicitConstructor VlCoroutine(VlCoroutine&& other) : m_promisep{std::exchange(other.m_promisep, nullptr)} { if (m_promisep) m_promisep->m_corop = this; diff --git a/include/verilated_types.h b/include/verilated_types.h index 4d080e942..d6d6879e2 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -1113,7 +1113,7 @@ public: // CONSTRUCTORS VlClassRef() = default; // Init with nullptr - VlClassRef(VlNull){}; + explicit VlClassRef(VlNull){}; template VlClassRef(VlDeleter& deleter, T_Args&&... args) : m_objp{new T_Class{std::forward(args)...}} { diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 20652b369..2f8f609a1 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1001,9 +1001,9 @@ bool AstNode::sameTreeIter(const AstNode* node1p, const AstNode* node2p, bool ig //====================================================================== // Debugging -void AstNode::checkTreeIter(const AstNode* backp) const { +void AstNode::checkTreeIter(const AstNode* prevBackp) const { // private: Check a tree and children - UASSERT_OBJ(backp == this->backp(), this, "Back node inconsistent"); + UASSERT_OBJ(prevBackp == this->backp(), this, "Back node inconsistent"); switch (this->type()) { #include "V3Ast__gen_op_checks.h" default: VL_UNREACHABLE; // LCOV_EXCL_LINE diff --git a/src/V3Ast.h b/src/V3Ast.h index 486daa879..30efa7ffa 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1543,7 +1543,7 @@ class AstNode VL_NOT_FINAL { private: AstNode* cloneTreeIter(); AstNode* cloneTreeIterList(); - void checkTreeIter(const AstNode* backp) const VL_MT_SAFE; + void checkTreeIter(const AstNode* prevBackp) const VL_MT_SAFE; bool gateTreeIter() const; static bool sameTreeIter(const AstNode* node1p, const AstNode* node2p, bool ignNext, bool gateOnly); @@ -2439,9 +2439,10 @@ class VNRef final : public std::reference_wrapper { public: template + // cppcheck-suppress noExplicitConstructor VNRef(U&& x) : std::reference_wrapper{x} {} - + // cppcheck-suppress noExplicitConstructor VNRef(const std::reference_wrapper& other) : std::reference_wrapper{other} {} }; diff --git a/src/V3AstNodeExpr.h b/src/V3AstNodeExpr.h index ffac83677..464c4e5a7 100644 --- a/src/V3AstNodeExpr.h +++ b/src/V3AstNodeExpr.h @@ -1718,7 +1718,7 @@ public: class AstStackTraceF final : public AstNodeExpr { // $stacktrace used as function public: - AstStackTraceF(FileLine* fl) + explicit AstStackTraceF(FileLine* fl) : ASTGEN_SUPER_StackTraceF(fl) { dtypeSetString(); } @@ -1809,7 +1809,7 @@ public: class AstTimePrecision final : public AstNodeExpr { // Verilog $timeprecision public: - AstTimePrecision(FileLine* fl) + explicit AstTimePrecision(FileLine* fl) : ASTGEN_SUPER_TimePrecision(fl) { dtypeSetSigned32(); } @@ -1825,7 +1825,7 @@ class AstTimeUnit final : public AstNodeExpr { VTimescale m_timeunit; // Parent module time unit // Verilog $timeunit public: - AstTimeUnit(FileLine* fl) + explicit AstTimeUnit(FileLine* fl) : ASTGEN_SUPER_TimeUnit(fl) { dtypeSetSigned32(); } diff --git a/src/V3AstNodeOther.h b/src/V3AstNodeOther.h index 6725d14c4..6b816d971 100644 --- a/src/V3AstNodeOther.h +++ b/src/V3AstNodeOther.h @@ -2936,7 +2936,7 @@ public: class AstStackTraceT final : public AstNodeStmt { // $stacktrace used as task public: - AstStackTraceT(FileLine* fl) + explicit AstStackTraceT(FileLine* fl) : ASTGEN_SUPER_StackTraceT(fl) {} ASTGEN_MEMBERS_AstStackTraceT; string verilogKwd() const override { return "$stacktrace"; } diff --git a/src/V3DfgOptimizer.cpp b/src/V3DfgOptimizer.cpp index 94f880edb..958d73202 100644 --- a/src/V3DfgOptimizer.cpp +++ b/src/V3DfgOptimizer.cpp @@ -110,7 +110,7 @@ class DataflowExtractVisitor final : public VNVisitor { if (!VN_IS(modp, Module)) continue; for (const auto& pair : m_extractionCandidates(modp)) { - AstNodeExpr* const nodep = pair.first; + AstNodeExpr* const cnodep = pair.first; // Do not extract expressions without any variable references if (pair.second.empty()) continue; @@ -132,18 +132,18 @@ class DataflowExtractVisitor final : public VNVisitor { } // Create temporary variable - FileLine* const flp = nodep->fileline(); - const string name = names.get(nodep); - AstVar* const varp = new AstVar{flp, VVarType::MODULETEMP, name, nodep->dtypep()}; + FileLine* const flp = cnodep->fileline(); + const string name = names.get(cnodep); + AstVar* const varp = new AstVar{flp, VVarType::MODULETEMP, name, cnodep->dtypep()}; varp->trace(false); modp->addStmtsp(varp); // Replace expression with temporary variable - nodep->replaceWith(new AstVarRef{flp, varp, VAccess::READ}); + cnodep->replaceWith(new AstVarRef{flp, varp, VAccess::READ}); // Add assignment driving temporary variable modp->addStmtsp( - new AstAssignW{flp, new AstVarRef{flp, varp, VAccess::WRITE}, nodep}); + new AstAssignW{flp, new AstVarRef{flp, varp, VAccess::WRITE}, cnodep}); } } } diff --git a/src/V3DfgPasses.cpp b/src/V3DfgPasses.cpp index 26e1b3b6b..4e03c3870 100644 --- a/src/V3DfgPasses.cpp +++ b/src/V3DfgPasses.cpp @@ -137,7 +137,7 @@ void V3DfgPasses::cse(DfgGraph& dfg, V3DfgCseContext& ctx) { removeUnused(dfg); } -void V3DfgPasses::inlineVars(DfgGraph& dfg) { +void V3DfgPasses::inlineVars(const DfgGraph& dfg) { for (DfgVertexVar *vtxp = dfg.varVerticesBeginp(), *nextp; vtxp; vtxp = nextp) { nextp = vtxp->verticesNext(); if (DfgVarPacked* const varp = vtxp->cast()) { diff --git a/src/V3DfgPasses.h b/src/V3DfgPasses.h index 93c0d94fa..7d8ed5913 100644 --- a/src/V3DfgPasses.h +++ b/src/V3DfgPasses.h @@ -103,7 +103,7 @@ AstModule* dfgToAst(DfgGraph&, V3DfgOptimizationContext&); // Common subexpression elimination void cse(DfgGraph&, V3DfgCseContext&); // Inline fully driven variables -void inlineVars(DfgGraph&); +void inlineVars(const DfgGraph&); // Peephole optimizations void peephole(DfgGraph&, V3DfgPeepholeContext&); // Remove redundant variables diff --git a/src/V3Options.cpp b/src/V3Options.cpp index fbc408488..2e0368743 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -257,7 +257,7 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr return; } - bool unitbad; + bool unitbad = false; const VTimescale unit{unitStr, unitbad /*ref*/}; if (unitbad && !(unitStr.empty() && allowEmpty)) { fl->v3error("`timescale timeunit syntax error: '" << unitStr << "'"); diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 1e3f50987..8bd94252b 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -836,7 +836,7 @@ class OrderProcess final : VNDeleter { void processMovePrepReady(); void processMoveReadyOne(OrderMoveVertex* vertexp); void processMoveDoneOne(OrderMoveVertex* vertexp); - void processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* domScopep, int level); + void processMoveOne(OrderMoveVertex* vertexp, const OrderMoveDomScope* domScopep, int level); AstActive* processMoveOneLogic(const OrderLogicVertex* lvertexp, AstCFunc*& newFuncpr, int& newStmtsr); @@ -1180,7 +1180,7 @@ void OrderProcess::processMoveDoneOne(OrderMoveVertex* vertexp) { } } -void OrderProcess::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* domScopep, +void OrderProcess::processMoveOne(OrderMoveVertex* vertexp, const OrderMoveDomScope* domScopep, int level) { UASSERT_OBJ(vertexp->domScopep() == domScopep, vertexp, "Domain mismatch; list misbuilt?"); const OrderLogicVertex* const lvertexp = vertexp->logicp(); diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index a49b98f7f..87a631ea0 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -197,7 +197,7 @@ private: // Set of MTaskMoveVertex's assigned to this mtask. LogicMTask does not // own the MTaskMoveVertex objects, we merely keep pointers to them // here. - VxList m_vertices; + VxList m_mvertices; // Cost estimate for this LogicMTask, derived from V3InstrCount. // In abstract time units. @@ -234,7 +234,7 @@ public: : AbstractLogicMTask{graphp} { for (uint32_t& item : m_critPathCost) item = 0; if (mtmvVxp) { // Else null for test - m_vertices.push_back(mtmvVxp); + m_mvertices.push_back(mtmvVxp); if (const OrderLogicVertex* const olvp = mtmvVxp->logicp()) { m_cost += V3InstrCount::count(olvp->nodep(), true); } @@ -252,10 +252,10 @@ public: void moveAllVerticesFrom(LogicMTask* otherp) { // splice() is constant time - m_vertices.splice(m_vertices.end(), otherp->m_vertices); + m_mvertices.splice(m_mvertices.end(), otherp->m_mvertices); m_cost += otherp->m_cost; } - const VxList* vertexListp() const override { return &m_vertices; } + const VxList* vertexListp() const override { return &m_mvertices; } static uint64_t incGeneration() { static uint64_t s_generation = 0; ++s_generation; diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 08eefad33..1fd4a64d4 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -382,7 +382,7 @@ private: int unrollCount() const { return m_params ? v3Global.opt.unrollCount() * 16 : v3Global.opt.unrollCount(); } - bool jumpingOver(AstNode* nodep) { + bool jumpingOver(AstNode* nodep) const { // True to jump over this node - all visitors must call this up front return (m_jumpp && m_jumpp->labelp() != nodep); } diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index eb76178f8..2ff9c4a85 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -605,7 +605,6 @@ private: auto* const sensesp = m_finder.getSenTree(nodep->sensesp()); nodep->sensesp()->unlinkFrBack()->deleteTree(); // Get this sentree's trigger scheduler - FileLine* const flp = nodep->fileline(); // Replace self with a 'co_await trigSched.trigger()' auto* const triggerMethodp = new AstCMethodHard{ flp, new AstVarRef{flp, getCreateTriggerSchedulerp(sensesp), VAccess::WRITE}, diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 27bb1ed7d..b4a4fb442 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -3765,7 +3765,7 @@ private: AstNodeExpr* nestedvalueConcat_patternUOrStruct(AstNodeUOrStructDType* memp_vdtypep, AstPatMember* defaultp, AstNodeExpr* newp, - AstPattern* nodep, DTypeMap dtypemap) { + AstPattern* nodep, const DTypeMap& dtypemap) { AstPatMember* patp = nullptr; for (AstMemberDType* memp_nested = memp_vdtypep->membersp(); memp_nested; memp_nested = VN_AS(memp_nested->nextp(), MemberDType)) { @@ -3787,7 +3787,7 @@ private: AstPatMember* Defaultpatp_patternUOrStruct(AstPattern* nodep, AstMemberDType* memp, AstPatMember* patp, AstNodeUOrStructDType* memp_vdtypep, - AstPatMember* defaultp, DTypeMap dtypemap) { + AstPatMember* defaultp, const DTypeMap& dtypemap) { const string memp_DType = memp->virtRefDTypep()->prettyDTypeName(); const auto it = dtypemap.find(memp_DType); if (it != dtypemap.end()) { @@ -6127,17 +6127,17 @@ private: } else if (expDTypep->isDouble() && !underp->isDouble()) { AstNode* const oldp = underp; // Need FINAL on children; otherwise splice would block it - underp = spliceCvtD(VN_AS(underp, NodeExpr)); + spliceCvtD(VN_AS(underp, NodeExpr)); underp = userIterateSubtreeReturnEdits(oldp, WidthVP{SELF, FINAL}.p()); } else if (!expDTypep->isDouble() && underp->isDouble()) { AstNode* const oldp = underp; // Need FINAL on children; otherwise splice would block it - underp = spliceCvtS(VN_AS(underp, NodeExpr), true, expDTypep->width()); // Round RHS + spliceCvtS(VN_AS(underp, NodeExpr), true, expDTypep->width()); // Round RHS underp = userIterateSubtreeReturnEdits(oldp, WidthVP{SELF, FINAL}.p()); } else if (expDTypep->isString() && !underp->dtypep()->isString()) { AstNode* const oldp = underp; // Need FINAL on children; otherwise splice would block it - underp = spliceCvtString(VN_AS(underp, NodeExpr)); + spliceCvtString(VN_AS(underp, NodeExpr)); underp = userIterateSubtreeReturnEdits(oldp, WidthVP{SELF, FINAL}.p()); } else { const AstBasicDType* const expBasicp = expDTypep->basicp();