diff --git a/include/verilated.cpp b/include/verilated.cpp index 619b29425..1ef9e52fc 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -2909,7 +2909,7 @@ void VerilatedContext::statsPrintSummary() VL_MT_UNSAFE { VL_PRINTF("- Verilator: %s at %s; walltime %0.3f s; speed %s/s\n", endwhy.c_str(), simtime.c_str(), walltime, simtimePerf.c_str()); const double modelMB = VlOs::memUsageBytes() / 1024.0 / 1024.0; - VL_PRINTF("- Verilator: cpu %0.3f s on %d threads; alloced %0.0f MB\n", cputime, + VL_PRINTF("- Verilator: cpu %0.3f s on %u threads; alloced %0.0f MB\n", cputime, threadsInModels(), modelMB); } diff --git a/include/verilated_random.h b/include/verilated_random.h index e1e77f3b1..75cb92afc 100644 --- a/include/verilated_random.h +++ b/include/verilated_random.h @@ -48,7 +48,7 @@ public: int width() const { return m_width; } void* datap() const { return m_datap; } bool set(std::string&&) const; - void emit(std::ostream& s) const; + void emit(std::ostream& s) const override; }; class VlRandomConst final : public VlRandomExpr { @@ -61,7 +61,7 @@ public: , m_width{width} { assert(width <= sizeof(m_val) * 8); } - void emit(std::ostream& s) const; + void emit(std::ostream& s) const override; }; class VlRandomExtract final : public VlRandomExpr { @@ -72,7 +72,7 @@ public: VlRandomExtract(std::shared_ptr expr, unsigned idx) : m_expr{expr} , m_idx{idx} {} - void emit(std::ostream& s) const; + void emit(std::ostream& s) const override; }; class VlRandomBinOp final : public VlRandomExpr { @@ -85,7 +85,7 @@ public: : m_op{op} , m_lhs{lhs} , m_rhs{rhs} {} - void emit(std::ostream& s) const; + void emit(std::ostream& s) const override; }; //============================================================================= diff --git a/src/V3Ast.h b/src/V3Ast.h index 6366bb630..a16e2396b 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -253,17 +253,17 @@ public: , m_final{false} , m_initial{false} {} class Extends {}; - VBaseOverride(Extends) + explicit VBaseOverride(Extends) : m_extends{true} , m_final{false} , m_initial{false} {} class Final {}; - VBaseOverride(Final) + explicit VBaseOverride(Final) : m_extends{false} , m_final{true} , m_initial{false} {} class Initial {}; - VBaseOverride(Initial) + explicit VBaseOverride(Initial) : m_extends{false} , m_final{false} , m_initial{true} {} diff --git a/src/V3AstNodeOther.h b/src/V3AstNodeOther.h index 1fbd52caf..387327867 100644 --- a/src/V3AstNodeOther.h +++ b/src/V3AstNodeOther.h @@ -2445,7 +2445,7 @@ class AstAlwaysPost final : public AstNodeProcedure { // Like always but 'post' scheduled, e.g. for array NBA commits public: - AstAlwaysPost(FileLine* fl) + explicit AstAlwaysPost(FileLine* fl) : ASTGEN_SUPER_AlwaysPost(fl, nullptr) {} ASTGEN_MEMBERS_AstAlwaysPost; }; diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 3eaa09ec7..58fa93eed 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -1632,10 +1632,7 @@ void AstClassRefDType::dumpSmall(std::ostream& str) const { this->AstNodeDType::dumpSmall(str); str << "class:" << name(); } -string AstClassRefDType::prettyDTypeName(bool) const { - return "class{}"s + prettyName(); - return prettyTypeName(); -} +string AstClassRefDType::prettyDTypeName(bool) const { return "class{}"s + prettyName(); } string AstClassRefDType::name() const { return classp() ? classp()->name() : ""; } void AstNodeCoverOrAssert::dump(std::ostream& str) const { this->AstNodeStmt::dump(str); diff --git a/src/V3DfgCache.h b/src/V3DfgCache.h index a85af80e0..09df39f6c 100644 --- a/src/V3DfgCache.h +++ b/src/V3DfgCache.h @@ -64,6 +64,7 @@ public: struct Hash final { size_t operator()(const KeySel& key) const { + // cppcheck-suppress unreadVariable // cppcheck bug V3Hash hash{vertexHash(key.m_fromp)}; hash += key.m_lsb; hash += key.m_width; @@ -83,6 +84,7 @@ class KeyUnary final { const DfgVertex* const m_source0p; public: + // cppcheck-suppress noExplicitConstructor KeyUnary(DfgVertex* source0p) : m_source0p{source0p} {} @@ -110,6 +112,7 @@ public: struct Hash final { size_t operator()(const KeyBinary& key) const { + // cppcheck-suppress unreadVariable // cppcheck bug V3Hash hash{vertexHash(key.m_source0p)}; hash += vertexHash(key.m_source1p); return hash.value(); @@ -137,6 +140,7 @@ public: struct Hash final { size_t operator()(const KeyTernary& key) const { + // cppcheck-suppress unreadVariable // cppcheck bug V3Hash hash{vertexHash(key.m_source0p)}; hash += vertexHash(key.m_source1p); hash += vertexHash(key.m_source2p); @@ -348,7 +352,7 @@ class V3DfgCache final { inline CacheType& cacheForType(); public: - V3DfgCache(DfgGraph& dfg) + explicit V3DfgCache(DfgGraph& dfg) : m_dfg{dfg} {} // Find a vertex of type 'Vertex', with the given operands, or create a new one and add it. diff --git a/src/V3DfgRegularize.cpp b/src/V3DfgRegularize.cpp index 7ab1529d6..b2c836334 100644 --- a/src/V3DfgRegularize.cpp +++ b/src/V3DfgRegularize.cpp @@ -27,6 +27,7 @@ VL_DEFINE_DEBUG_FUNCTIONS; std::string V3DfgRegularizeContext::tmpNamePrefix(DfgGraph& dfg) { + // cppcheck-suppress unreadVariable // cppcheck bug V3Hash hash{dfg.modulep()->name()}; hash += m_label; std::string name = hash.toString(); diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index a86918fc5..d0edca27d 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2264,9 +2264,9 @@ class LinkDotResolveVisitor final : public VNVisitor { << "... Location of interface class's function\n" << interfaceSubp->warnContextSecondary()); } - const auto it = m_ifClassImpNames.find(interfaceSubp->name()); - if (!existsInChild && it != m_ifClassImpNames.end() - && it->second != interfaceSubp) { // Not exact same function from diamond + const auto itn = m_ifClassImpNames.find(interfaceSubp->name()); + if (!existsInChild && itn != m_ifClassImpNames.end() + && itn->second != interfaceSubp) { // Not exact same function from diamond implementsClassp->v3error( "Class " << implementsClassp->prettyNameQ() << impOrExtends << baseClassp->prettyNameQ() diff --git a/src/V3List.h b/src/V3List.h index 4abedc532..c35ec4b2d 100644 --- a/src/V3List.h +++ b/src/V3List.h @@ -81,7 +81,7 @@ class V3List final { } VL_ATTR_ALWINLINE - static void prefetch(T_Base* elementp, T_Base* fallbackp) { + static void prefetch(const T_Base* elementp, const T_Base* fallbackp) { UDEBUGONLY(UASSERT(fallbackp, "Prefetch fallback pointer must be non nullptr");); // This compiles to a branchless prefetch with cmove, with the address always valid VL_PREFETCH_RW(elementp ? elementp : fallbackp); @@ -104,7 +104,7 @@ class V3List final { T_Base* m_currp; // Currently iterated element, or 'nullptr' for 'end()' iterator VL_ATTR_ALWINLINE - SimpleItertatorImpl(T_Base* elementp) + explicit SimpleItertatorImpl(T_Base* elementp) : m_currp{elementp} {} VL_ATTR_ALWINLINE @@ -159,7 +159,7 @@ class V3List final { ListType& m_list; // The proxied list - UnlinkableProxy(ListType& list) + explicit UnlinkableProxy(ListType& list) : m_list{list} {} // Unlinkable iterator class template. This only supports enough for range based for loops. @@ -179,11 +179,11 @@ class V3List final { T_Base* m_nextp; // Next element after current, or 'nullptr' for 'end()' iterator VL_ATTR_ALWINLINE - UnlinkableItertatorImpl(T_Base* elementp) + explicit UnlinkableItertatorImpl(T_Base* elementp) : m_currp{elementp} , m_nextp{toLinks(m_currp).m_nextp} {} VL_ATTR_ALWINLINE - UnlinkableItertatorImpl(std::nullptr_t) + explicit UnlinkableItertatorImpl(std::nullptr_t) : m_currp{nullptr} , m_nextp{nullptr} {} diff --git a/src/V3OrderMoveGraph.h b/src/V3OrderMoveGraph.h index 02013103d..6d4b346c6 100644 --- a/src/V3OrderMoveGraph.h +++ b/src/V3OrderMoveGraph.h @@ -110,6 +110,7 @@ class OrderMoveDomScope final { struct Hash final { size_t operator()(const DomScopeMapKey& key) const { + // cppcheck-suppress unreadVariable // cppcheck bug V3Hash hash{reinterpret_cast(key.m_domainp)}; hash += reinterpret_cast(key.m_scopep); return hash.value(); @@ -199,7 +200,7 @@ class OrderMoveGraphSerializer final { public: // CONSTRUCTOR - OrderMoveGraphSerializer(OrderMoveGraph& moveGraph) { + explicit OrderMoveGraphSerializer(OrderMoveGraph& moveGraph) { // Set V3GraphVertex::user() to the number of incoming edges (upstream dependencies) for (V3GraphVertex& vtx : moveGraph.vertices()) { const uint32_t nDeps = vtx.inEdges().size(); diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index a8fafd90d..310876d8f 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -183,9 +183,11 @@ class PremitVisitor final : public VNVisitor { void visit(AstWhile* nodep) override { UINFO(4, " WHILE " << nodep << endl); + // cppcheck-suppress shadowVariable // Also restored below START_STATEMENT_OR_RETURN(nodep); iterateAndNextNull(nodep->precondsp()); { + // cppcheck-suppress shadowVariable // Also restored above VL_RESTORER(m_inWhileCondp); m_inWhileCondp = nodep; iterateAndNextNull(nodep->condp()); diff --git a/src/V3VariableOrder.cpp b/src/V3VariableOrder.cpp index 6b6baa81d..292ce3dc2 100644 --- a/src/V3VariableOrder.cpp +++ b/src/V3VariableOrder.cpp @@ -58,7 +58,7 @@ class GatherMTaskAffinity final : VNVisitorConst { VL_UNMOVABLE(GatherMTaskAffinity); // VISIT - void visit(AstNodeVarRef* nodep) { + void visit(AstNodeVarRef* nodep) override { // Cheaper than relying on emplace().second if (nodep->user1SetOnce()) return; AstVar* const varp = nodep->varp(); @@ -74,17 +74,17 @@ class GatherMTaskAffinity final : VNVisitorConst { affinity[m_id] = true; } - void visit(AstCFunc* nodep) { + void visit(AstCFunc* nodep) override { if (nodep->user1SetOnce()) return; // Prevent repeat traversals/recursion iterateChildrenConst(nodep); } - void visit(AstNodeCCall* nodep) { + void visit(AstNodeCCall* nodep) override { iterateChildrenConst(nodep); // Arguments iterateConst(nodep->funcp()); // Callee } - void visit(AstNode* nodep) { iterateChildrenConst(nodep); } + void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } public: static void apply(const ExecMTask* mTaskp, MTaskAffinityMap& results) { diff --git a/src/V3WidthCommit.cpp b/src/V3WidthCommit.cpp index 46523196a..ec9589e02 100644 --- a/src/V3WidthCommit.cpp +++ b/src/V3WidthCommit.cpp @@ -187,11 +187,13 @@ private: void visit(AstNodeFTask* nodep) override { iterateChildren(nodep); editDType(nodep); - AstClass* classp = VN_CAST(m_modp, Class); - if (nodep->classMethod() && nodep->pureVirtual() && classp && !classp->isInterfaceClass() - && !classp->isVirtual()) { - nodep->v3error( - "Illegal to have 'pure virtual' in non-virtual class (IEEE 1800-2023 8.21)"); + { + const AstClass* const classp = VN_CAST(m_modp, Class); + if (nodep->classMethod() && nodep->pureVirtual() && classp + && !classp->isInterfaceClass() && !classp->isVirtual()) { + nodep->v3error( + "Illegal to have 'pure virtual' in non-virtual class (IEEE 1800-2023 8.21)"); + } } bool extended = false; if (const AstClass* const classp = VN_CAST(m_modp, Class)) {