Internals: cppcheck cleanups. No functional change intended.

This commit is contained in:
Wilson Snyder 2024-08-23 18:24:34 -04:00
parent ffe76717c6
commit 8741fd17ad
8 changed files with 23 additions and 17 deletions

View File

@ -107,6 +107,10 @@ class VlRandomizer final {
bool parseSolution(std::iostream& file);
public:
// CONSTRUCTORS
VlRandomizer() = default;
~VlRandomizer() = default;
// METHODS
// Finds the next solution satisfying the constraints
bool next(VlRNG& rngr);

View File

@ -597,6 +597,7 @@ public:
// Can't just overload operator[] or provide a "at" reference to set,
// because we need to be able to insert only when the value is set
T_Value& at(int32_t index) {
// cppcheck-suppress variableScope
static thread_local T_Value t_throwAway;
// Needs to work for dynamic arrays, so does not use T_MaxSize
if (VL_UNLIKELY(index < 0 || index >= m_deque.size())) {
@ -1794,9 +1795,9 @@ public:
struct VlNull final {
operator bool() const { return false; }
bool operator==(void* ptr) const { return !ptr; }
bool operator==(const void* ptr) const { return !ptr; }
};
inline bool operator==(void* ptr, VlNull) { return !ptr; }
inline bool operator==(const void* ptr, VlNull) { return !ptr; }
//===================================================================
// Verilog class reference container

View File

@ -2349,8 +2349,8 @@ public:
&& std::is_base_of<AstNode, T_Node>::value,
"Callable 'f' must have a signature compatible with 'void(AstClass*, T_Node*)', "
"with 'T_Node' being a subtype of 'AstNode'");
if (AstClassExtends* const extendsp = this->extendsp()) {
extendsp->classp()->foreachMember(f);
if (AstClassExtends* const cextendsp = this->extendsp()) {
cextendsp->classp()->foreachMember(f);
}
for (AstNode* stmtp = stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (AstNode::privateTypeTest<T_Node>(stmtp)) f(this, static_cast<T_Node*>(stmtp));
@ -2364,8 +2364,8 @@ public:
&& std::is_base_of<AstNode, T_Node>::value,
"Predicate 'p' must have a signature compatible with 'bool(const AstClass*, "
"const T_Node*)', with 'T_Node' being a subtype of 'AstNode'");
if (AstClassExtends* const extendsp = this->extendsp()) {
if (extendsp->classp()->existsMember(p)) return true;
if (AstClassExtends* const cextendsp = this->extendsp()) {
if (cextendsp->classp()->existsMember(p)) return true;
}
for (AstNode* stmtp = stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (AstNode::privateTypeTest<T_Node>(stmtp)) {

View File

@ -548,6 +548,7 @@ class ConstBitOpTreeVisitor final : public VNVisitorConst {
VL_RESTORER(m_leafp);
Restorer restorer{*this};
LeafInfo leafInfo{m_lsb};
// cppcheck-suppress danglingLifetime
m_leafp = &leafInfo;
AstNodeExpr* opp = right ? nodep->rhsp() : nodep->lhsp();
const bool origFailed = m_failed;

View File

@ -206,11 +206,11 @@ public:
UDEBUGONLY(UASSERT_OBJ(isSupportedDType(nodep->dtypep()), nodep, "Unsupported dtype"););
// For simplicity, all packed types are represented with a fixed type
if (AstUnpackArrayDType* const typep = VN_CAST(nodep->dtypep(), UnpackArrayDType)) {
AstNodeDType* const dtypep = new AstUnpackArrayDType{
AstNodeDType* const adtypep = new AstUnpackArrayDType{
typep->fileline(), dtypeForWidth(typep->subDTypep()->width()),
typep->rangep()->cloneTree(false)};
v3Global.rootp()->typeTablep()->addTypesp(dtypep);
return dtypep;
v3Global.rootp()->typeTablep()->addTypesp(adtypep);
return adtypep;
}
return dtypeForWidth(nodep->width());
}

View File

@ -49,7 +49,7 @@ class V3DfgRegularizeContext final {
public:
VDouble0 m_temporariesIntroduced; // Number of temporaries introduced
std::string tmpNamePrefix(DfgGraph&); // Return prefix to use for given graph
std::string tmpNamePrefix(const DfgGraph&); // Return prefix to use for given graph
explicit V3DfgRegularizeContext(const std::string& label)
: m_label{label} {}

View File

@ -26,7 +26,7 @@
VL_DEFINE_DEBUG_FUNCTIONS;
std::string V3DfgRegularizeContext::tmpNamePrefix(DfgGraph& dfg) {
std::string V3DfgRegularizeContext::tmpNamePrefix(const DfgGraph& dfg) {
// cppcheck-suppress unreadVariable // cppcheck bug
V3Hash hash{dfg.modulep()->name()};
hash += m_label;

View File

@ -1556,10 +1556,10 @@ class RandomizeVisitor final : public VNVisitor {
if (receiverp) {
// Called on a rand member variable/constraint. Set the variable/constraint's
// mode
const RandomizeMode mode = {.asInt = receiverp->user1()};
UASSERT_OBJ(mode.usesMode, ftaskRefp, "Failed to set usesMode");
const RandomizeMode rmode = {.asInt = receiverp->user1()};
UASSERT_OBJ(rmode.usesMode, ftaskRefp, "Failed to set usesMode");
AstCMethodHard* const atp
= new AstCMethodHard{fl, lhsp, "at", new AstConst{fl, mode.index}};
= new AstCMethodHard{fl, lhsp, "at", new AstConst{fl, rmode.index}};
atp->dtypeSetUInt32();
m_stmtp->replaceWith(new AstAssign{fl, atp, rhsp});
} else {
@ -1571,10 +1571,10 @@ class RandomizeVisitor final : public VNVisitor {
pushDeletep(m_stmtp);
} else {
UASSERT_OBJ(receiverp, ftaskRefp, "Should have receiver");
const RandomizeMode mode = {.asInt = receiverp->user1()};
UASSERT_OBJ(mode.usesMode, ftaskRefp, "Failed to set usesMode");
const RandomizeMode rmode = {.asInt = receiverp->user1()};
UASSERT_OBJ(rmode.usesMode, ftaskRefp, "Failed to set usesMode");
AstCMethodHard* const atp
= new AstCMethodHard{fl, lhsp, "at", new AstConst{fl, mode.index}};
= new AstCMethodHard{fl, lhsp, "at", new AstConst{fl, rmode.index}};
atp->dtypeSetUInt32();
ftaskRefp->replaceWith(atp);
VL_DO_DANGLING(pushDeletep(ftaskRefp), ftaskRefp);