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