Internals: cppcheck cleanups. No functional change intended.

This commit is contained in:
Wilson Snyder 2022-10-02 23:04:55 -04:00
parent 90009b9ec7
commit 10fc1f757c
15 changed files with 29 additions and 26 deletions

View File

@ -137,7 +137,7 @@ class VlDelayScheduler final {
public: public:
// CONSTRUCTORS // CONSTRUCTORS
VlDelayScheduler(VerilatedContext& context) explicit VlDelayScheduler(VerilatedContext& context)
: m_context{context} {} : m_context{context} {}
// METHODS // METHODS
// Resume coroutines waiting for the current simulation time // Resume coroutines waiting for the current simulation time
@ -329,8 +329,8 @@ public:
// CONSTRUCTORS // CONSTRUCTORS
// Construct // Construct
VlCoroutine(VlPromise* p) VlCoroutine(VlPromise* promisep)
: m_promisep{p} { : m_promisep{promisep} {
m_promisep->m_corop = this; m_promisep->m_corop = this;
} }
// Move. Update the pointers each time the return object is moved // Move. Update the pointers each time the return object is moved

View File

@ -109,7 +109,7 @@ public:
// Set elements of 'this' to 'a & !b' element-wise // Set elements of 'this' to 'a & !b' element-wise
void andNot(const VlTriggerVec<T_size>& a, const VlTriggerVec<T_size>& b) { void andNot(const VlTriggerVec<T_size>& a, const VlTriggerVec<T_size>& b) {
for (size_t i = 0; i < m_flags.size(); ++i) m_flags[i] = a.m_flags[i] & !b.m_flags[i]; for (size_t i = 0; i < m_flags.size(); ++i) m_flags[i] = a.m_flags[i] && !b.m_flags[i];
} }
}; };
@ -1104,14 +1104,17 @@ public:
m_objp->m_deleter = &deleter; m_objp->m_deleter = &deleter;
refCountInc(); refCountInc();
} }
// cppcheck-suppress noExplicitConstructor
VlClassRef(T_Class* objp) VlClassRef(T_Class* objp)
: m_objp{objp} { : m_objp{objp} {
refCountInc(); refCountInc();
} }
// cppcheck-suppress noExplicitConstructor
VlClassRef(const VlClassRef& copied) VlClassRef(const VlClassRef& copied)
: m_objp{copied.m_objp} { : m_objp{copied.m_objp} {
refCountInc(); refCountInc();
} }
// cppcheck-suppress noExplicitConstructor
VlClassRef(VlClassRef&& moved) VlClassRef(VlClassRef&& moved)
: m_objp{vlstd::exchange(moved.m_objp, nullptr)} {} : m_objp{vlstd::exchange(moved.m_objp, nullptr)} {}
~VlClassRef() { refCountDec(); } ~VlClassRef() { refCountDec(); }

View File

@ -2324,7 +2324,7 @@ template <typename T_Arg, bool Default>
bool AstNode::predicateImpl(ConstCorrectAstNode<T_Arg>* nodep, bool AstNode::predicateImpl(ConstCorrectAstNode<T_Arg>* nodep,
const std::function<bool(T_Arg*)>& p) { const std::function<bool(T_Arg*)>& p) {
// Implementation similar to foreach, but abort traversal as soon as result is determined. // Implementation similar to foreach, but abort traversal as soon as result is determined.
if (!p) { if (VL_UNCOVERABLE(!p)) {
nodep->v3fatal("AstNode::foreach called with unbound function"); // LCOV_EXCL_LINE nodep->v3fatal("AstNode::foreach called with unbound function"); // LCOV_EXCL_LINE
} else { } else {
using T_Arg_NonConst = typename std::remove_const<T_Arg>::type; using T_Arg_NonConst = typename std::remove_const<T_Arg>::type;

View File

@ -97,7 +97,7 @@ public:
m_widthMin = widthMin; m_widthMin = widthMin;
} }
// For backward compatibility inherit width and signing from the subDType/base type // For backward compatibility inherit width and signing from the subDType/base type
void widthFromSub(AstNodeDType* nodep) { void widthFromSub(const AstNodeDType* nodep) {
m_width = nodep->m_width; m_width = nodep->m_width;
m_widthMin = nodep->m_widthMin; m_widthMin = nodep->m_widthMin;
m_numeric = nodep->m_numeric; m_numeric = nodep->m_numeric;

View File

@ -89,21 +89,21 @@ AstShiftRS* makeNode<AstShiftRS, AstNodeMath*, AstNodeMath*>( //
// LCOV_EXCL_START // LCOV_EXCL_START
template <> template <>
AstCCast* makeNode<AstCCast, AstNodeMath*>(const DfgCCast* vtxp, AstNodeMath*) { AstCCast* makeNode<AstCCast, AstNodeMath*>(const DfgCCast* vtxp, AstNodeMath*) {
vtxp->v3fatal("not implemented"); vtxp->v3fatalSrc("not implemented");
} }
template <> template <>
AstAtoN* makeNode<AstAtoN, AstNodeMath*>(const DfgAtoN* vtxp, AstNodeMath*) { AstAtoN* makeNode<AstAtoN, AstNodeMath*>(const DfgAtoN* vtxp, AstNodeMath*) {
vtxp->v3fatal("not implemented"); vtxp->v3fatalSrc("not implemented");
} }
template <> template <>
AstCompareNN* makeNode<AstCompareNN, AstNodeMath*, AstNodeMath*>(const DfgCompareNN* vtxp, AstCompareNN* makeNode<AstCompareNN, AstNodeMath*, AstNodeMath*>(const DfgCompareNN* vtxp,
AstNodeMath*, AstNodeMath*) { AstNodeMath*, AstNodeMath*) {
vtxp->v3fatal("not implemented"); vtxp->v3fatalSrc("not implemented");
} }
template <> template <>
AstSliceSel* makeNode<AstSliceSel, AstNodeMath*, AstNodeMath*, AstNodeMath*>( AstSliceSel* makeNode<AstSliceSel, AstNodeMath*, AstNodeMath*, AstNodeMath*>(
const DfgSliceSel* vtxp, AstNodeMath*, AstNodeMath*, AstNodeMath*) { const DfgSliceSel* vtxp, AstNodeMath*, AstNodeMath*, AstNodeMath*) {
vtxp->v3fatal("not implemented"); vtxp->v3fatalSrc("not implemented");
} }
// LCOV_EXCL_STOP // LCOV_EXCL_STOP

View File

@ -33,7 +33,7 @@ class V3DfgCseContext final {
public: public:
VDouble0 m_eliminated; // Number of common sub-expressions eliminated VDouble0 m_eliminated; // Number of common sub-expressions eliminated
V3DfgCseContext(const std::string& label) explicit V3DfgCseContext(const std::string& label)
: m_label{label} {} : m_label{label} {}
~V3DfgCseContext(); ~V3DfgCseContext();
}; };
@ -43,7 +43,7 @@ class DfgRemoveVarsContext final {
public: public:
VDouble0 m_removed; // Number of redundant variables removed VDouble0 m_removed; // Number of redundant variables removed
DfgRemoveVarsContext(const std::string& label) explicit DfgRemoveVarsContext(const std::string& label)
: m_label{label} {} : m_label{label} {}
~DfgRemoveVarsContext(); ~DfgRemoveVarsContext();
}; };
@ -73,7 +73,7 @@ public:
V3DfgCseContext m_cseContext1{m_label + " 2nd"}; V3DfgCseContext m_cseContext1{m_label + " 2nd"};
V3DfgPeepholeContext m_peepholeContext{m_label}; V3DfgPeepholeContext m_peepholeContext{m_label};
DfgRemoveVarsContext m_removeVarsContext{m_label}; DfgRemoveVarsContext m_removeVarsContext{m_label};
V3DfgOptimizationContext(const std::string& label); explicit V3DfgOptimizationContext(const std::string& label);
~V3DfgOptimizationContext(); ~V3DfgOptimizationContext();
const std::string& prefix() const { return m_prefix; } const std::string& prefix() const { return m_prefix; }

View File

@ -132,7 +132,7 @@ struct V3DfgPeepholeContext final {
// Count of applications for each optimization (for statistics) // Count of applications for each optimization (for statistics)
VDouble0 m_count[VDfgPeepholePattern::_ENUM_END]; VDouble0 m_count[VDfgPeepholePattern::_ENUM_END];
V3DfgPeepholeContext(const std::string& label); explicit V3DfgPeepholeContext(const std::string& label);
~V3DfgPeepholeContext(); ~V3DfgPeepholeContext();
}; };

View File

@ -76,7 +76,7 @@ constexpr int MAX_SPRINTF_DOUBLE_SIZE
//====================================================================== //======================================================================
// Errors // Errors
void V3Number::v3errorEnd(std::ostringstream& str) const { void V3Number::v3errorEnd(const std::ostringstream& str) const {
std::ostringstream nsstr; std::ostringstream nsstr;
nsstr << str.str(); nsstr << str.str();
if (m_nodep) { if (m_nodep) {
@ -88,7 +88,7 @@ void V3Number::v3errorEnd(std::ostringstream& str) const {
} }
} }
void V3Number::v3errorEndFatal(std::ostringstream& str) const { void V3Number::v3errorEndFatal(const std::ostringstream& str) const {
v3errorEnd(str); v3errorEnd(str);
assert(0); // LCOV_EXCL_LINE assert(0); // LCOV_EXCL_LINE
VL_UNREACHABLE; VL_UNREACHABLE;

View File

@ -541,8 +541,8 @@ private:
string displayed(const string& vformat) const { return displayed(m_fileline, vformat); } string displayed(const string& vformat) const { return displayed(m_fileline, vformat); }
public: public:
void v3errorEnd(std::ostringstream& sstr) const; void v3errorEnd(const std::ostringstream& sstr) const;
void v3errorEndFatal(std::ostringstream& sstr) const VL_ATTR_NORETURN; void v3errorEndFatal(const std::ostringstream& sstr) const VL_ATTR_NORETURN;
void width(int width, bool sized = true) { void width(int width, bool sized = true) {
m_data.m_sized = sized; m_data.m_sized = sized;
m_data.resize(width); m_data.resize(width);

View File

@ -208,7 +208,7 @@ class OrderBuildVisitor final : public VNVisitor {
"AstSenTrees should have been made global in V3ActiveTop"); "AstSenTrees should have been made global in V3ActiveTop");
UASSERT_OBJ(m_scopep, nodep, "AstActive not under AstScope"); UASSERT_OBJ(m_scopep, nodep, "AstActive not under AstScope");
UASSERT_OBJ(!m_logicVxp, nodep, "AstActive under logic"); UASSERT_OBJ(!m_logicVxp, nodep, "AstActive under logic");
UASSERT_OBJ(!m_inClocked && !m_domainp & !m_hybridp, nodep, "Should not nest"); UASSERT_OBJ(!m_inClocked && !m_domainp && !m_hybridp, nodep, "Should not nest");
// This is the original sensitivity of the block (i.e.: not the ref into the TRIGGERVEC) // This is the original sensitivity of the block (i.e.: not the ref into the TRIGGERVEC)

View File

@ -915,9 +915,9 @@ class ParamVisitor final : public VNVisitor {
// Process interface cells, then non-interface cells, which may reference an interface // Process interface cells, then non-interface cells, which may reference an interface
// cell. // cell.
while (!m_cellps.empty()) { while (!m_cellps.empty()) {
const auto itm = m_cellps.cbegin(); const auto itim = m_cellps.cbegin();
AstNode* const cellp = itm->second; AstNode* const cellp = itim->second;
m_cellps.erase(itm); m_cellps.erase(itim);
AstNodeModule* srcModp = nullptr; AstNodeModule* srcModp = nullptr;
if (const auto* modCellp = VN_CAST(cellp, Cell)) { if (const auto* modCellp = VN_CAST(cellp, Cell)) {

View File

@ -928,7 +928,7 @@ class PartPropagateCp final {
public: public:
// CONSTRUCTORS // CONSTRUCTORS
PartPropagateCp(bool slowAsserts) explicit PartPropagateCp(bool slowAsserts)
: m_slowAsserts{slowAsserts} {} : m_slowAsserts{slowAsserts} {}
// METHODS // METHODS

View File

@ -97,7 +97,7 @@ AstAssign* setVar(AstVarScope* vscp, uint32_t val) {
return new AstAssign{flp, refp, valp}; return new AstAssign{flp, refp, valp};
}; };
void remapSensitivities(LogicByScope& lbs, void remapSensitivities(const LogicByScope& lbs,
std::unordered_map<const AstSenTree*, AstSenTree*> senTreeMap) { std::unordered_map<const AstSenTree*, AstSenTree*> senTreeMap) {
for (const auto& pair : lbs) { for (const auto& pair : lbs) {
AstActive* const activep = pair.second; AstActive* const activep = pair.second;

View File

@ -105,7 +105,7 @@ private:
AstScope* m_scopep = nullptr; // Current scope AstScope* m_scopep = nullptr; // Current scope
AstActive* m_activep = nullptr; // Current active AstActive* m_activep = nullptr; // Current active
AstNode* m_procp = nullptr; // NodeProcedure/CFunc/Fork we're under AstNode* m_procp = nullptr; // NodeProcedure/CFunc/Fork we're under
double m_timescaleFactor; // Factor to scale delays by double m_timescaleFactor = 1.0; // Factor to scale delays by
// Unique names // Unique names
V3UniqueNames m_contAssignVarNames{"__VassignWtmp__"}; // Names for temp AssignW vars V3UniqueNames m_contAssignVarNames{"__VassignWtmp__"}; // Names for temp AssignW vars

View File

@ -4363,7 +4363,7 @@ private:
fmt = ch; fmt = ch;
} else if (inPct && (isdigit(ch) || ch == '.' || ch == '-')) { } else if (inPct && (isdigit(ch) || ch == '.' || ch == '-')) {
fmt += ch; fmt += ch;
} else if (tolower(inPct)) { } else if (inPct) {
inPct = false; inPct = false;
bool added = false; bool added = false;
switch (tolower(ch)) { switch (tolower(ch)) {