Internals: Fix cppcheck warnings

This commit is contained in:
Wilson Snyder 2023-08-31 18:29:58 -04:00
parent ffbbd438ae
commit 8c480fd39e
9 changed files with 24 additions and 15 deletions

View File

@ -102,6 +102,8 @@ class VlCoroutineHandle final {
public: public:
// CONSTRUCTORS // CONSTRUCTORS
// Construct // Construct
// non-explicit:
// cppcheck-suppress noExplicitConstructor
VlCoroutineHandle(VlProcessRef process) VlCoroutineHandle(VlProcessRef process)
: m_coro{nullptr} : m_coro{nullptr}
, m_process{process} { , m_process{process} {
@ -114,6 +116,8 @@ public:
if (m_process) m_process->state(VlProcess::WAITING); if (m_process) m_process->state(VlProcess::WAITING);
} }
// Move the handle, leaving a nullptr // Move the handle, leaving a nullptr
// non-explicit:
// cppcheck-suppress noExplicitConstructor
VlCoroutineHandle(VlCoroutineHandle&& moved) VlCoroutineHandle(VlCoroutineHandle&& moved)
: m_coro{std::exchange(moved.m_coro, nullptr)} : m_coro{std::exchange(moved.m_coro, nullptr)}
, m_process{std::exchange(moved.m_process, nullptr)} , m_process{std::exchange(moved.m_process, nullptr)}

View File

@ -358,7 +358,7 @@ private:
public: public:
// CONSTRUCTORS // CONSTRUCTORS
DynScopeVisitor(AstNetlist* nodep) { explicit DynScopeVisitor(AstNetlist* nodep) {
// Create Dynamic scope class prototypes and objects // Create Dynamic scope class prototypes and objects
visit(nodep); visit(nodep);
@ -431,7 +431,7 @@ private:
return taskp; return taskp;
} }
string generateTaskName(AstNode* fromp, string kind) { string generateTaskName(AstNode* fromp, const string& kind) {
// TODO: Ensure no collisions occur // TODO: Ensure no collisions occur
return "__V" + kind + (!fromp->name().empty() ? (fromp->name() + "__") : "UNNAMED__") return "__V" + kind + (!fromp->name().empty() ? (fromp->name() + "__") : "UNNAMED__")
+ cvtToHex(fromp); + cvtToHex(fromp);
@ -566,7 +566,7 @@ private:
public: public:
// CONSTRUCTORS // CONSTRUCTORS
ForkVisitor(AstNetlist* nodep) { visit(nodep); } explicit ForkVisitor(AstNetlist* nodep) { visit(nodep); }
~ForkVisitor() override = default; ~ForkVisitor() override = default;
}; };

View File

@ -281,7 +281,7 @@ private:
bool m_traceCoverage = false; // main switch: --trace-coverage bool m_traceCoverage = false; // main switch: --trace-coverage
bool m_traceParams = true; // main switch: --trace-params bool m_traceParams = true; // main switch: --trace-params
bool m_traceStructs = false; // main switch: --trace-structs bool m_traceStructs = false; // main switch: --trace-structs
bool m_noTraceTop; // main switch: --no-trace-top bool m_noTraceTop = false; // main switch: --no-trace-top
bool m_traceUnderscore = false; // main switch: --trace-underscore bool m_traceUnderscore = false; // main switch: --trace-underscore
bool m_underlineZero = false; // main switch: --underline-zero; undocumented old Verilator 2 bool m_underlineZero = false; // main switch: --underline-zero; undocumented old Verilator 2
bool m_verilate = true; // main switch: --verilate bool m_verilate = true; // main switch: --verilate

View File

@ -214,7 +214,7 @@ private:
} }
iterateAndNextNull(nodep->rhsp()); iterateAndNextNull(nodep->rhsp());
{ {
VL_RESTORER(m_assignLhs); // VL_RESTORER(m_assignLhs); // Not needed; part of RESTORER_START_STATEMENT()
m_assignLhs = true; m_assignLhs = true;
iterateAndNextNull(nodep->lhsp()); iterateAndNextNull(nodep->lhsp());
} }

View File

@ -158,7 +158,7 @@ void transformForks(AstNetlist* const netlistp);
void schedule(AstNetlist*); void schedule(AstNetlist*);
// Sub-steps // Sub-steps
LogicByScope breakCycles(AstNetlist* netlistp, LogicByScope& combinationalLogic); LogicByScope breakCycles(AstNetlist* netlistp, const LogicByScope& combinationalLogic);
LogicRegions partition(LogicByScope& clockedLogic, LogicByScope& combinationalLogic, LogicRegions partition(LogicByScope& clockedLogic, LogicByScope& combinationalLogic,
LogicByScope& hybridLogic); LogicByScope& hybridLogic);
LogicReplicas replicateLogic(LogicRegions&); LogicReplicas replicateLogic(LogicRegions&);

View File

@ -398,7 +398,7 @@ LogicByScope fixCuts(AstNetlist* netlistp,
} // namespace } // namespace
LogicByScope breakCycles(AstNetlist* netlistp, LogicByScope& combinationalLogic) { LogicByScope breakCycles(AstNetlist* netlistp, const LogicByScope& combinationalLogic) {
// Build the dataflow (dependency) graph // Build the dataflow (dependency) graph
const std::unique_ptr<Graph> graphp = buildGraph(combinationalLogic); const std::unique_ptr<Graph> graphp = buildGraph(combinationalLogic);

View File

@ -41,7 +41,7 @@ class VAnyPackagedTask final {
struct PTWrapper final : PTWrapperBase { struct PTWrapper final : PTWrapperBase {
std::packaged_task<Signature> m_pt; std::packaged_task<Signature> m_pt;
PTWrapper(std::packaged_task<Signature>&& pt) explicit PTWrapper(std::packaged_task<Signature>&& pt)
: m_pt(std::move(pt)) {} : m_pt(std::move(pt)) {}
void operator()() final override { m_pt(); } void operator()() final override { m_pt(); }
@ -53,6 +53,8 @@ class VAnyPackagedTask final {
public: public:
// CONSTRUCTORS // CONSTRUCTORS
template <typename Signature> template <typename Signature>
// non-explicit:
// cppcheck-suppress noExplicitConstructor
VAnyPackagedTask(std::packaged_task<Signature>&& pt) VAnyPackagedTask(std::packaged_task<Signature>&& pt)
: m_ptWrapperp{std::make_unique<PTWrapper<Signature>>(std::move(pt))} {} : m_ptWrapperp{std::make_unique<PTWrapper<Signature>>(std::move(pt))} {}

View File

@ -2781,7 +2781,7 @@ private:
VL_DO_DANGLING(pushDeletep(nodep), nodep); VL_DO_DANGLING(pushDeletep(nodep), nodep);
return true; return true;
} }
if (AstNodeFTask* const methodp = VN_CAST(foundp, NodeFTask)) { if (VN_IS(foundp, NodeFTask)) {
nodep->replaceWith(new AstMethodCall{nodep->fileline(), nodep->replaceWith(new AstMethodCall{nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
nodep->name(), nullptr}); nodep->name(), nullptr});
@ -7554,12 +7554,14 @@ AstNodeDType* V3Width::getCommonClassTypep(AstNode* nodep1, AstNode* nodep2) {
// First handle cases with null values and when one class is a super class of the other. // First handle cases with null values and when one class is a super class of the other.
if (VN_IS(nodep1, Const)) std::swap(nodep1, nodep2); if (VN_IS(nodep1, Const)) std::swap(nodep1, nodep2);
const Castable castable {
= WidthVisitor::computeCastable(nodep1->dtypep(), nodep2->dtypep(), nodep2); const Castable castable
if (castable == SAMEISH || castable == COMPATIBLE) { = WidthVisitor::computeCastable(nodep1->dtypep(), nodep2->dtypep(), nodep2);
return nodep1->dtypep(); if (castable == SAMEISH || castable == COMPATIBLE) {
} else if (castable == DYNAMIC_CLASS) { return nodep1->dtypep();
return nodep2->dtypep(); } else if (castable == DYNAMIC_CLASS) {
return nodep2->dtypep();
}
} }
AstClassRefDType* classDtypep1 = VN_CAST(nodep1->dtypep(), ClassRefDType); AstClassRefDType* classDtypep1 = VN_CAST(nodep1->dtypep(), ClassRefDType);

View File

@ -248,6 +248,7 @@ private:
adtypep, adtypep,
"Array extraction with width miscomputed " << adtypep->width() << "/" "Array extraction with width miscomputed " << adtypep->width() << "/"
<< fromRange.elements()); << fromRange.elements());
// cppcheck-suppress zerodivcond
const int elwidth = adtypep->width() / fromRange.elements(); const int elwidth = adtypep->width() / fromRange.elements();
AstSel* const newp = new AstSel{ AstSel* const newp = new AstSel{
nodep->fileline(), fromp, nodep->fileline(), fromp,