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

View File

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

View File

@ -281,7 +281,7 @@ private:
bool m_traceCoverage = false; // main switch: --trace-coverage
bool m_traceParams = true; // main switch: --trace-params
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_underlineZero = false; // main switch: --underline-zero; undocumented old Verilator 2
bool m_verilate = true; // main switch: --verilate

View File

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

View File

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

View File

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

View File

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

View File

@ -2781,7 +2781,7 @@ private:
VL_DO_DANGLING(pushDeletep(nodep), nodep);
return true;
}
if (AstNodeFTask* const methodp = VN_CAST(foundp, NodeFTask)) {
if (VN_IS(foundp, NodeFTask)) {
nodep->replaceWith(new AstMethodCall{nodep->fileline(),
nodep->fromp()->unlinkFrBack(),
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.
if (VN_IS(nodep1, Const)) std::swap(nodep1, nodep2);
const Castable castable
= WidthVisitor::computeCastable(nodep1->dtypep(), nodep2->dtypep(), nodep2);
if (castable == SAMEISH || castable == COMPATIBLE) {
return nodep1->dtypep();
} else if (castable == DYNAMIC_CLASS) {
return nodep2->dtypep();
{
const Castable castable
= WidthVisitor::computeCastable(nodep1->dtypep(), nodep2->dtypep(), nodep2);
if (castable == SAMEISH || castable == COMPATIBLE) {
return nodep1->dtypep();
} else if (castable == DYNAMIC_CLASS) {
return nodep2->dtypep();
}
}
AstClassRefDType* classDtypep1 = VN_CAST(nodep1->dtypep(), ClassRefDType);

View File

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