mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Internals: Fix cppcheck warnings. No functional change intended.
This commit is contained in:
parent
73d6de4471
commit
66d85b3381
@ -1641,6 +1641,7 @@ std::string VL_STACKTRACE_N() VL_MT_SAFE {
|
||||
strings = backtrace_symbols(buffer, nptrs);
|
||||
#endif
|
||||
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (!strings) return "Unable to backtrace\n";
|
||||
|
||||
std::string out = "Backtrace:\n";
|
||||
|
@ -362,6 +362,7 @@ public: // But only for verilated*.cpp
|
||||
private:
|
||||
VerilatedFpList fdToFpList(IData fdi) VL_REQUIRES(m_fdMutex) {
|
||||
VerilatedFpList fp;
|
||||
// cppcheck-suppress integeroverflow shifttoomanybitssigned
|
||||
if ((fdi & (1 << 31)) != 0) {
|
||||
// Non-MCD case
|
||||
const IData idx = fdi & VL_MASK_I(31);
|
||||
|
@ -404,11 +404,13 @@ public:
|
||||
|
||||
// CONSTRUCTORS
|
||||
// Construct
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
VlCoroutine(VlPromise* promisep)
|
||||
: m_promisep{promisep} {
|
||||
m_promisep->m_corop = this;
|
||||
}
|
||||
// Move. Update the pointers each time the return object is moved
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
VlCoroutine(VlCoroutine&& other)
|
||||
: m_promisep{std::exchange(other.m_promisep, nullptr)} {
|
||||
if (m_promisep) m_promisep->m_corop = this;
|
||||
|
@ -1113,7 +1113,7 @@ public:
|
||||
// CONSTRUCTORS
|
||||
VlClassRef() = default;
|
||||
// Init with nullptr
|
||||
VlClassRef(VlNull){};
|
||||
explicit VlClassRef(VlNull){};
|
||||
template <typename... T_Args>
|
||||
VlClassRef(VlDeleter& deleter, T_Args&&... args)
|
||||
: m_objp{new T_Class{std::forward<T_Args>(args)...}} {
|
||||
|
@ -1001,9 +1001,9 @@ bool AstNode::sameTreeIter(const AstNode* node1p, const AstNode* node2p, bool ig
|
||||
//======================================================================
|
||||
// Debugging
|
||||
|
||||
void AstNode::checkTreeIter(const AstNode* backp) const {
|
||||
void AstNode::checkTreeIter(const AstNode* prevBackp) const {
|
||||
// private: Check a tree and children
|
||||
UASSERT_OBJ(backp == this->backp(), this, "Back node inconsistent");
|
||||
UASSERT_OBJ(prevBackp == this->backp(), this, "Back node inconsistent");
|
||||
switch (this->type()) {
|
||||
#include "V3Ast__gen_op_checks.h"
|
||||
default: VL_UNREACHABLE; // LCOV_EXCL_LINE
|
||||
|
@ -1543,7 +1543,7 @@ class AstNode VL_NOT_FINAL {
|
||||
private:
|
||||
AstNode* cloneTreeIter();
|
||||
AstNode* cloneTreeIterList();
|
||||
void checkTreeIter(const AstNode* backp) const VL_MT_SAFE;
|
||||
void checkTreeIter(const AstNode* prevBackp) const VL_MT_SAFE;
|
||||
bool gateTreeIter() const;
|
||||
static bool sameTreeIter(const AstNode* node1p, const AstNode* node2p, bool ignNext,
|
||||
bool gateOnly);
|
||||
@ -2439,9 +2439,10 @@ class VNRef final : public std::reference_wrapper<T_Node> {
|
||||
|
||||
public:
|
||||
template <typename U>
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
VNRef(U&& x)
|
||||
: std::reference_wrapper<T_Node>{x} {}
|
||||
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
VNRef(const std::reference_wrapper<T_Node>& other)
|
||||
: std::reference_wrapper<T_Node>{other} {}
|
||||
};
|
||||
|
@ -1718,7 +1718,7 @@ public:
|
||||
class AstStackTraceF final : public AstNodeExpr {
|
||||
// $stacktrace used as function
|
||||
public:
|
||||
AstStackTraceF(FileLine* fl)
|
||||
explicit AstStackTraceF(FileLine* fl)
|
||||
: ASTGEN_SUPER_StackTraceF(fl) {
|
||||
dtypeSetString();
|
||||
}
|
||||
@ -1809,7 +1809,7 @@ public:
|
||||
class AstTimePrecision final : public AstNodeExpr {
|
||||
// Verilog $timeprecision
|
||||
public:
|
||||
AstTimePrecision(FileLine* fl)
|
||||
explicit AstTimePrecision(FileLine* fl)
|
||||
: ASTGEN_SUPER_TimePrecision(fl) {
|
||||
dtypeSetSigned32();
|
||||
}
|
||||
@ -1825,7 +1825,7 @@ class AstTimeUnit final : public AstNodeExpr {
|
||||
VTimescale m_timeunit; // Parent module time unit
|
||||
// Verilog $timeunit
|
||||
public:
|
||||
AstTimeUnit(FileLine* fl)
|
||||
explicit AstTimeUnit(FileLine* fl)
|
||||
: ASTGEN_SUPER_TimeUnit(fl) {
|
||||
dtypeSetSigned32();
|
||||
}
|
||||
|
@ -2936,7 +2936,7 @@ public:
|
||||
class AstStackTraceT final : public AstNodeStmt {
|
||||
// $stacktrace used as task
|
||||
public:
|
||||
AstStackTraceT(FileLine* fl)
|
||||
explicit AstStackTraceT(FileLine* fl)
|
||||
: ASTGEN_SUPER_StackTraceT(fl) {}
|
||||
ASTGEN_MEMBERS_AstStackTraceT;
|
||||
string verilogKwd() const override { return "$stacktrace"; }
|
||||
|
@ -110,7 +110,7 @@ class DataflowExtractVisitor final : public VNVisitor {
|
||||
if (!VN_IS(modp, Module)) continue;
|
||||
|
||||
for (const auto& pair : m_extractionCandidates(modp)) {
|
||||
AstNodeExpr* const nodep = pair.first;
|
||||
AstNodeExpr* const cnodep = pair.first;
|
||||
|
||||
// Do not extract expressions without any variable references
|
||||
if (pair.second.empty()) continue;
|
||||
@ -132,18 +132,18 @@ class DataflowExtractVisitor final : public VNVisitor {
|
||||
}
|
||||
|
||||
// Create temporary variable
|
||||
FileLine* const flp = nodep->fileline();
|
||||
const string name = names.get(nodep);
|
||||
AstVar* const varp = new AstVar{flp, VVarType::MODULETEMP, name, nodep->dtypep()};
|
||||
FileLine* const flp = cnodep->fileline();
|
||||
const string name = names.get(cnodep);
|
||||
AstVar* const varp = new AstVar{flp, VVarType::MODULETEMP, name, cnodep->dtypep()};
|
||||
varp->trace(false);
|
||||
modp->addStmtsp(varp);
|
||||
|
||||
// Replace expression with temporary variable
|
||||
nodep->replaceWith(new AstVarRef{flp, varp, VAccess::READ});
|
||||
cnodep->replaceWith(new AstVarRef{flp, varp, VAccess::READ});
|
||||
|
||||
// Add assignment driving temporary variable
|
||||
modp->addStmtsp(
|
||||
new AstAssignW{flp, new AstVarRef{flp, varp, VAccess::WRITE}, nodep});
|
||||
new AstAssignW{flp, new AstVarRef{flp, varp, VAccess::WRITE}, cnodep});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ void V3DfgPasses::cse(DfgGraph& dfg, V3DfgCseContext& ctx) {
|
||||
removeUnused(dfg);
|
||||
}
|
||||
|
||||
void V3DfgPasses::inlineVars(DfgGraph& dfg) {
|
||||
void V3DfgPasses::inlineVars(const DfgGraph& dfg) {
|
||||
for (DfgVertexVar *vtxp = dfg.varVerticesBeginp(), *nextp; vtxp; vtxp = nextp) {
|
||||
nextp = vtxp->verticesNext();
|
||||
if (DfgVarPacked* const varp = vtxp->cast<DfgVarPacked>()) {
|
||||
|
@ -103,7 +103,7 @@ AstModule* dfgToAst(DfgGraph&, V3DfgOptimizationContext&);
|
||||
// Common subexpression elimination
|
||||
void cse(DfgGraph&, V3DfgCseContext&);
|
||||
// Inline fully driven variables
|
||||
void inlineVars(DfgGraph&);
|
||||
void inlineVars(const DfgGraph&);
|
||||
// Peephole optimizations
|
||||
void peephole(DfgGraph&, V3DfgPeepholeContext&);
|
||||
// Remove redundant variables
|
||||
|
@ -257,7 +257,7 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr
|
||||
return;
|
||||
}
|
||||
|
||||
bool unitbad;
|
||||
bool unitbad = false;
|
||||
const VTimescale unit{unitStr, unitbad /*ref*/};
|
||||
if (unitbad && !(unitStr.empty() && allowEmpty)) {
|
||||
fl->v3error("`timescale timeunit syntax error: '" << unitStr << "'");
|
||||
|
@ -836,7 +836,7 @@ class OrderProcess final : VNDeleter {
|
||||
void processMovePrepReady();
|
||||
void processMoveReadyOne(OrderMoveVertex* vertexp);
|
||||
void processMoveDoneOne(OrderMoveVertex* vertexp);
|
||||
void processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* domScopep, int level);
|
||||
void processMoveOne(OrderMoveVertex* vertexp, const OrderMoveDomScope* domScopep, int level);
|
||||
AstActive* processMoveOneLogic(const OrderLogicVertex* lvertexp, AstCFunc*& newFuncpr,
|
||||
int& newStmtsr);
|
||||
|
||||
@ -1180,7 +1180,7 @@ void OrderProcess::processMoveDoneOne(OrderMoveVertex* vertexp) {
|
||||
}
|
||||
}
|
||||
|
||||
void OrderProcess::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* domScopep,
|
||||
void OrderProcess::processMoveOne(OrderMoveVertex* vertexp, const OrderMoveDomScope* domScopep,
|
||||
int level) {
|
||||
UASSERT_OBJ(vertexp->domScopep() == domScopep, vertexp, "Domain mismatch; list misbuilt?");
|
||||
const OrderLogicVertex* const lvertexp = vertexp->logicp();
|
||||
|
@ -197,7 +197,7 @@ private:
|
||||
// Set of MTaskMoveVertex's assigned to this mtask. LogicMTask does not
|
||||
// own the MTaskMoveVertex objects, we merely keep pointers to them
|
||||
// here.
|
||||
VxList m_vertices;
|
||||
VxList m_mvertices;
|
||||
|
||||
// Cost estimate for this LogicMTask, derived from V3InstrCount.
|
||||
// In abstract time units.
|
||||
@ -234,7 +234,7 @@ public:
|
||||
: AbstractLogicMTask{graphp} {
|
||||
for (uint32_t& item : m_critPathCost) item = 0;
|
||||
if (mtmvVxp) { // Else null for test
|
||||
m_vertices.push_back(mtmvVxp);
|
||||
m_mvertices.push_back(mtmvVxp);
|
||||
if (const OrderLogicVertex* const olvp = mtmvVxp->logicp()) {
|
||||
m_cost += V3InstrCount::count(olvp->nodep(), true);
|
||||
}
|
||||
@ -252,10 +252,10 @@ public:
|
||||
|
||||
void moveAllVerticesFrom(LogicMTask* otherp) {
|
||||
// splice() is constant time
|
||||
m_vertices.splice(m_vertices.end(), otherp->m_vertices);
|
||||
m_mvertices.splice(m_mvertices.end(), otherp->m_mvertices);
|
||||
m_cost += otherp->m_cost;
|
||||
}
|
||||
const VxList* vertexListp() const override { return &m_vertices; }
|
||||
const VxList* vertexListp() const override { return &m_mvertices; }
|
||||
static uint64_t incGeneration() {
|
||||
static uint64_t s_generation = 0;
|
||||
++s_generation;
|
||||
|
@ -382,7 +382,7 @@ private:
|
||||
int unrollCount() const {
|
||||
return m_params ? v3Global.opt.unrollCount() * 16 : v3Global.opt.unrollCount();
|
||||
}
|
||||
bool jumpingOver(AstNode* nodep) {
|
||||
bool jumpingOver(AstNode* nodep) const {
|
||||
// True to jump over this node - all visitors must call this up front
|
||||
return (m_jumpp && m_jumpp->labelp() != nodep);
|
||||
}
|
||||
|
@ -605,7 +605,6 @@ private:
|
||||
auto* const sensesp = m_finder.getSenTree(nodep->sensesp());
|
||||
nodep->sensesp()->unlinkFrBack()->deleteTree();
|
||||
// Get this sentree's trigger scheduler
|
||||
FileLine* const flp = nodep->fileline();
|
||||
// Replace self with a 'co_await trigSched.trigger()'
|
||||
auto* const triggerMethodp = new AstCMethodHard{
|
||||
flp, new AstVarRef{flp, getCreateTriggerSchedulerp(sensesp), VAccess::WRITE},
|
||||
|
@ -3765,7 +3765,7 @@ private:
|
||||
|
||||
AstNodeExpr* nestedvalueConcat_patternUOrStruct(AstNodeUOrStructDType* memp_vdtypep,
|
||||
AstPatMember* defaultp, AstNodeExpr* newp,
|
||||
AstPattern* nodep, DTypeMap dtypemap) {
|
||||
AstPattern* nodep, const DTypeMap& dtypemap) {
|
||||
AstPatMember* patp = nullptr;
|
||||
for (AstMemberDType* memp_nested = memp_vdtypep->membersp(); memp_nested;
|
||||
memp_nested = VN_AS(memp_nested->nextp(), MemberDType)) {
|
||||
@ -3787,7 +3787,7 @@ private:
|
||||
AstPatMember* Defaultpatp_patternUOrStruct(AstPattern* nodep, AstMemberDType* memp,
|
||||
AstPatMember* patp,
|
||||
AstNodeUOrStructDType* memp_vdtypep,
|
||||
AstPatMember* defaultp, DTypeMap dtypemap) {
|
||||
AstPatMember* defaultp, const DTypeMap& dtypemap) {
|
||||
const string memp_DType = memp->virtRefDTypep()->prettyDTypeName();
|
||||
const auto it = dtypemap.find(memp_DType);
|
||||
if (it != dtypemap.end()) {
|
||||
@ -6127,17 +6127,17 @@ private:
|
||||
} else if (expDTypep->isDouble() && !underp->isDouble()) {
|
||||
AstNode* const oldp
|
||||
= underp; // Need FINAL on children; otherwise splice would block it
|
||||
underp = spliceCvtD(VN_AS(underp, NodeExpr));
|
||||
spliceCvtD(VN_AS(underp, NodeExpr));
|
||||
underp = userIterateSubtreeReturnEdits(oldp, WidthVP{SELF, FINAL}.p());
|
||||
} else if (!expDTypep->isDouble() && underp->isDouble()) {
|
||||
AstNode* const oldp
|
||||
= underp; // Need FINAL on children; otherwise splice would block it
|
||||
underp = spliceCvtS(VN_AS(underp, NodeExpr), true, expDTypep->width()); // Round RHS
|
||||
spliceCvtS(VN_AS(underp, NodeExpr), true, expDTypep->width()); // Round RHS
|
||||
underp = userIterateSubtreeReturnEdits(oldp, WidthVP{SELF, FINAL}.p());
|
||||
} else if (expDTypep->isString() && !underp->dtypep()->isString()) {
|
||||
AstNode* const oldp
|
||||
= underp; // Need FINAL on children; otherwise splice would block it
|
||||
underp = spliceCvtString(VN_AS(underp, NodeExpr));
|
||||
spliceCvtString(VN_AS(underp, NodeExpr));
|
||||
underp = userIterateSubtreeReturnEdits(oldp, WidthVP{SELF, FINAL}.p());
|
||||
} else {
|
||||
const AstBasicDType* const expBasicp = expDTypep->basicp();
|
||||
|
Loading…
Reference in New Issue
Block a user