mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Internals: cppcheck cleanups. No functional change intended.
This commit is contained in:
parent
ffe76717c6
commit
8741fd17ad
@ -107,6 +107,10 @@ class VlRandomizer final {
|
|||||||
bool parseSolution(std::iostream& file);
|
bool parseSolution(std::iostream& file);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// CONSTRUCTORS
|
||||||
|
VlRandomizer() = default;
|
||||||
|
~VlRandomizer() = default;
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
// Finds the next solution satisfying the constraints
|
// Finds the next solution satisfying the constraints
|
||||||
bool next(VlRNG& rngr);
|
bool next(VlRNG& rngr);
|
||||||
|
@ -597,6 +597,7 @@ public:
|
|||||||
// Can't just overload operator[] or provide a "at" reference to set,
|
// 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
|
// because we need to be able to insert only when the value is set
|
||||||
T_Value& at(int32_t index) {
|
T_Value& at(int32_t index) {
|
||||||
|
// cppcheck-suppress variableScope
|
||||||
static thread_local T_Value t_throwAway;
|
static thread_local T_Value t_throwAway;
|
||||||
// Needs to work for dynamic arrays, so does not use T_MaxSize
|
// Needs to work for dynamic arrays, so does not use T_MaxSize
|
||||||
if (VL_UNLIKELY(index < 0 || index >= m_deque.size())) {
|
if (VL_UNLIKELY(index < 0 || index >= m_deque.size())) {
|
||||||
@ -1794,9 +1795,9 @@ public:
|
|||||||
|
|
||||||
struct VlNull final {
|
struct VlNull final {
|
||||||
operator bool() const { return false; }
|
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
|
// Verilog class reference container
|
||||||
|
@ -2349,8 +2349,8 @@ public:
|
|||||||
&& std::is_base_of<AstNode, T_Node>::value,
|
&& std::is_base_of<AstNode, T_Node>::value,
|
||||||
"Callable 'f' must have a signature compatible with 'void(AstClass*, T_Node*)', "
|
"Callable 'f' must have a signature compatible with 'void(AstClass*, T_Node*)', "
|
||||||
"with 'T_Node' being a subtype of 'AstNode'");
|
"with 'T_Node' being a subtype of 'AstNode'");
|
||||||
if (AstClassExtends* const extendsp = this->extendsp()) {
|
if (AstClassExtends* const cextendsp = this->extendsp()) {
|
||||||
extendsp->classp()->foreachMember(f);
|
cextendsp->classp()->foreachMember(f);
|
||||||
}
|
}
|
||||||
for (AstNode* stmtp = stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
for (AstNode* stmtp = stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
||||||
if (AstNode::privateTypeTest<T_Node>(stmtp)) f(this, static_cast<T_Node*>(stmtp));
|
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,
|
&& std::is_base_of<AstNode, T_Node>::value,
|
||||||
"Predicate 'p' must have a signature compatible with 'bool(const AstClass*, "
|
"Predicate 'p' must have a signature compatible with 'bool(const AstClass*, "
|
||||||
"const T_Node*)', with 'T_Node' being a subtype of 'AstNode'");
|
"const T_Node*)', with 'T_Node' being a subtype of 'AstNode'");
|
||||||
if (AstClassExtends* const extendsp = this->extendsp()) {
|
if (AstClassExtends* const cextendsp = this->extendsp()) {
|
||||||
if (extendsp->classp()->existsMember(p)) return true;
|
if (cextendsp->classp()->existsMember(p)) return true;
|
||||||
}
|
}
|
||||||
for (AstNode* stmtp = stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
for (AstNode* stmtp = stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
||||||
if (AstNode::privateTypeTest<T_Node>(stmtp)) {
|
if (AstNode::privateTypeTest<T_Node>(stmtp)) {
|
||||||
|
@ -548,6 +548,7 @@ class ConstBitOpTreeVisitor final : public VNVisitorConst {
|
|||||||
VL_RESTORER(m_leafp);
|
VL_RESTORER(m_leafp);
|
||||||
Restorer restorer{*this};
|
Restorer restorer{*this};
|
||||||
LeafInfo leafInfo{m_lsb};
|
LeafInfo leafInfo{m_lsb};
|
||||||
|
// cppcheck-suppress danglingLifetime
|
||||||
m_leafp = &leafInfo;
|
m_leafp = &leafInfo;
|
||||||
AstNodeExpr* opp = right ? nodep->rhsp() : nodep->lhsp();
|
AstNodeExpr* opp = right ? nodep->rhsp() : nodep->lhsp();
|
||||||
const bool origFailed = m_failed;
|
const bool origFailed = m_failed;
|
||||||
|
@ -206,11 +206,11 @@ public:
|
|||||||
UDEBUGONLY(UASSERT_OBJ(isSupportedDType(nodep->dtypep()), nodep, "Unsupported dtype"););
|
UDEBUGONLY(UASSERT_OBJ(isSupportedDType(nodep->dtypep()), nodep, "Unsupported dtype"););
|
||||||
// For simplicity, all packed types are represented with a fixed type
|
// For simplicity, all packed types are represented with a fixed type
|
||||||
if (AstUnpackArrayDType* const typep = VN_CAST(nodep->dtypep(), UnpackArrayDType)) {
|
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->fileline(), dtypeForWidth(typep->subDTypep()->width()),
|
||||||
typep->rangep()->cloneTree(false)};
|
typep->rangep()->cloneTree(false)};
|
||||||
v3Global.rootp()->typeTablep()->addTypesp(dtypep);
|
v3Global.rootp()->typeTablep()->addTypesp(adtypep);
|
||||||
return dtypep;
|
return adtypep;
|
||||||
}
|
}
|
||||||
return dtypeForWidth(nodep->width());
|
return dtypeForWidth(nodep->width());
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class V3DfgRegularizeContext final {
|
|||||||
public:
|
public:
|
||||||
VDouble0 m_temporariesIntroduced; // Number of temporaries introduced
|
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)
|
explicit V3DfgRegularizeContext(const std::string& label)
|
||||||
: m_label{label} {}
|
: m_label{label} {}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
VL_DEFINE_DEBUG_FUNCTIONS;
|
VL_DEFINE_DEBUG_FUNCTIONS;
|
||||||
|
|
||||||
std::string V3DfgRegularizeContext::tmpNamePrefix(DfgGraph& dfg) {
|
std::string V3DfgRegularizeContext::tmpNamePrefix(const DfgGraph& dfg) {
|
||||||
// cppcheck-suppress unreadVariable // cppcheck bug
|
// cppcheck-suppress unreadVariable // cppcheck bug
|
||||||
V3Hash hash{dfg.modulep()->name()};
|
V3Hash hash{dfg.modulep()->name()};
|
||||||
hash += m_label;
|
hash += m_label;
|
||||||
|
@ -1556,10 +1556,10 @@ class RandomizeVisitor final : public VNVisitor {
|
|||||||
if (receiverp) {
|
if (receiverp) {
|
||||||
// Called on a rand member variable/constraint. Set the variable/constraint's
|
// Called on a rand member variable/constraint. Set the variable/constraint's
|
||||||
// mode
|
// mode
|
||||||
const RandomizeMode mode = {.asInt = receiverp->user1()};
|
const RandomizeMode rmode = {.asInt = receiverp->user1()};
|
||||||
UASSERT_OBJ(mode.usesMode, ftaskRefp, "Failed to set usesMode");
|
UASSERT_OBJ(rmode.usesMode, ftaskRefp, "Failed to set usesMode");
|
||||||
AstCMethodHard* const atp
|
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();
|
atp->dtypeSetUInt32();
|
||||||
m_stmtp->replaceWith(new AstAssign{fl, atp, rhsp});
|
m_stmtp->replaceWith(new AstAssign{fl, atp, rhsp});
|
||||||
} else {
|
} else {
|
||||||
@ -1571,10 +1571,10 @@ class RandomizeVisitor final : public VNVisitor {
|
|||||||
pushDeletep(m_stmtp);
|
pushDeletep(m_stmtp);
|
||||||
} else {
|
} else {
|
||||||
UASSERT_OBJ(receiverp, ftaskRefp, "Should have receiver");
|
UASSERT_OBJ(receiverp, ftaskRefp, "Should have receiver");
|
||||||
const RandomizeMode mode = {.asInt = receiverp->user1()};
|
const RandomizeMode rmode = {.asInt = receiverp->user1()};
|
||||||
UASSERT_OBJ(mode.usesMode, ftaskRefp, "Failed to set usesMode");
|
UASSERT_OBJ(rmode.usesMode, ftaskRefp, "Failed to set usesMode");
|
||||||
AstCMethodHard* const atp
|
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();
|
atp->dtypeSetUInt32();
|
||||||
ftaskRefp->replaceWith(atp);
|
ftaskRefp->replaceWith(atp);
|
||||||
VL_DO_DANGLING(pushDeletep(ftaskRefp), ftaskRefp);
|
VL_DO_DANGLING(pushDeletep(ftaskRefp), ftaskRefp);
|
||||||
|
Loading…
Reference in New Issue
Block a user