Internals: Fix remaining cppcheck errors (#6319)

Fixed the non const-related issue and added suppressions for the const
ones. With that `make cppcheck` should be clean.
This commit is contained in:
Geza Lore 2025-08-21 09:43:37 +01:00 committed by GitHub
parent bd91b619ad
commit 327d55d13d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
64 changed files with 266 additions and 134 deletions

View File

@ -495,7 +495,7 @@ public:
private:
// MEMBERS
Deque m_deque; // State of the assoc array
T_Value m_defaultValue; // Default value
T_Value m_defaultValue{}; // Default value
public:
// CONSTRUCTORS

View File

@ -1477,7 +1477,7 @@ string AstNode::instanceStr() const {
}
return "";
}
void AstNode::v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex) {
void AstNode::v3errorEnd(const std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex) {
// Don't look for instance name when warning is disabled.
// In case of large number of warnings, this can
// take significant amount of time
@ -1497,7 +1497,8 @@ void AstNode::v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error::s().
m_fileline->v3errorEnd(nsstr, instanceStrExtra);
}
}
void AstNode::v3errorEndFatal(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex) {
void AstNode::v3errorEndFatal(const std::ostringstream& str) const
VL_RELEASE(V3Error::s().m_mutex) {
v3errorEnd(str);
assert(0); // LCOV_EXCL_LINE
VL_UNREACHABLE;

View File

@ -2439,8 +2439,8 @@ public:
static AstNodeDType* getCommonClassTypep(AstNode* nodep1, AstNode* nodep2);
// METHODS - dump and error
void v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex);
void v3errorEndFatal(std::ostringstream& str) const VL_ATTR_NORETURN
void v3errorEnd(const std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex);
void v3errorEndFatal(const std::ostringstream& str) const VL_ATTR_NORETURN
VL_RELEASE(V3Error::s().m_mutex);
string warnContextPrimary() const VL_REQUIRES(V3Error::s().m_mutex) {
return fileline()->warnContextPrimary();

View File

@ -657,6 +657,7 @@ public:
dtypeFrom(dtp);
}
// cppcheck-suppress constParameterPointer
// cppcheck-suppress constParameterCallback
AstCast(FileLine* fl, AstNodeExpr* fromp, AstNodeDType* dtp)
: ASTGEN_SUPER_Cast(fl) {
this->fromp(fromp);

View File

@ -98,6 +98,7 @@ public:
// Sets ofp() and outFileNodep() to the given pointers, without closing a file these pointers
// currently point to.
void setOutputFile(V3OutCFile* ofp, AstCFile* nodep) {
// cppcheck-suppress danglingLifetime // ofp is often on stack in caller, it's fine.
m_ofp = ofp;
m_outFileNodep = nodep;
}

View File

@ -907,7 +907,7 @@ class EmitCTrace final : EmitCFunc {
puts(");\n");
}
void emitTraceValue(AstTraceInc* nodep, int arrayindex) {
void emitTraceValue(const AstTraceInc* nodep, int arrayindex) {
if (AstVarRef* const varrefp = VN_CAST(nodep->valuep(), VarRef)) {
const AstVar* const varp = varrefp->varp();
if (varp->isEvent()) puts("&");

View File

@ -693,7 +693,7 @@ class EmitCModel final : public EmitCFunc {
// VISITORS
public:
explicit EmitCModel(AstNetlist* netlistp) { main(netlistp->topModulep()); }
explicit EmitCModel(AstNodeModule* topModulep) { main(topModulep); }
};
//######################################################################
@ -701,5 +701,5 @@ public:
void V3EmitC::emitcModel() {
UINFO(2, __FUNCTION__ << ":");
{ EmitCModel{v3Global.rootp()}; }
{ EmitCModel{v3Global.rootp()->topModulep()}; }
}

View File

@ -91,8 +91,7 @@ class EmitCSyms final : EmitCBaseVisitorConst {
struct CmpDpi final {
bool operator()(const AstCFunc* lhsp, const AstCFunc* rhsp) const {
if (lhsp->dpiImportPrototype() != rhsp->dpiImportPrototype()) {
// cppcheck-suppress comparisonOfFuncReturningBoolError
return lhsp->dpiImportPrototype() < rhsp->dpiImportPrototype();
return rhsp->dpiImportPrototype();
}
return lhsp->name() < rhsp->name();
}
@ -285,11 +284,7 @@ class EmitCSyms final : EmitCBaseVisitorConst {
if (v3Global.dpi()) {
// add dpi scopes to m_scopeNames if not already there
for (const auto& scp : m_dpiScopeNames) {
if (m_scopeNames.find(scp.first) == m_scopeNames.end()) {
m_scopeNames.emplace(scp.first, scp.second);
}
}
for (const auto& scp : m_dpiScopeNames) m_scopeNames.emplace(scp.first, scp.second);
}
// Sort by names, so line/process order matters less
@ -358,8 +353,8 @@ class EmitCSyms final : EmitCBaseVisitorConst {
ScopeFuncData(nodep, m_cfuncp, m_modp));
} else {
if (m_dpiScopeNames.find(nodep->scopeDpiName()) == m_dpiScopeNames.end()) {
// cppcheck-suppress stlFindInsert
m_dpiScopeNames.emplace(nodep->scopeDpiName(),
// cppcheck-suppress stlFindInsert
ScopeData{nodep, nodep->scopeDpiName(),
nodep->scopePrettyDpiName(), "<null>", timeunit,
"SCOPE_OTHER"});

View File

@ -273,7 +273,7 @@ private:
m_concatenableListsByDescSize.resize(totalBucketsNum);
// Recalculate stats
concatenableFilesTotalScore = 0;
for (WorkList* listp : m_concatenableListsByDescSize) {
for (const WorkList* const listp : m_concatenableListsByDescSize) {
concatenableFilesTotalScore += listp->m_totalScore;
}
}

View File

@ -125,9 +125,9 @@ class V3EmitMkJsonEmitter final {
std::vector<std::string> childDeps;
std::vector<std::string> sources;
for (const auto& childr : children) {
childDeps.emplace_back((childr)->hierPrefix());
sources.emplace_back(makeDir + "/" + childr->hierWrapperFilename(true));
for (const V3HierBlock* const childp : children) {
childDeps.emplace_back(childp->hierPrefix());
sources.emplace_back(makeDir + "/" + childp->hierWrapperFilename(true));
}
const string vFile = hblockp->vFileIfNecessary();

View File

@ -132,8 +132,8 @@ void V3ErrorGuarded::v3errorPrep(V3ErrorCode code) VL_REQUIRES(m_mutex) {
m_errorSuppressed = false;
}
void V3ErrorGuarded::v3errorEnd(std::ostringstream& sstr, const string& extra, FileLine* fileline)
VL_REQUIRES(m_mutex) {
void V3ErrorGuarded::v3errorEnd(const std::ostringstream& sstr, const string& extra,
FileLine* fileline) VL_REQUIRES(m_mutex) {
static bool s_firedTooMany = false;
v3errorEndGuts(sstr, extra, fileline);
m_message.clear();
@ -151,7 +151,7 @@ void V3ErrorGuarded::v3errorEnd(std::ostringstream& sstr, const string& extra, F
}
// cppcheck-has-bug-suppress constParameter
void V3ErrorGuarded::v3errorEndGuts(std::ostringstream& sstr, const string& extra,
void V3ErrorGuarded::v3errorEndGuts(const std::ostringstream& sstr, const string& extra,
FileLine* fileline) VL_REQUIRES(m_mutex) {
// 'extra' is appended to the message, and is is excluded in check for
// duplicate messages. Currently used for reporting instance name.
@ -260,6 +260,7 @@ void V3ErrorGuarded::v3errorEndGuts(std::ostringstream& sstr, const string& extr
}
if (m_message.code().severityFatal()) {
static bool inFatal = false;
// cppcheck-suppress duplicateConditionalAssign // Used by VlcMain.cpp
if (!inFatal) {
inFatal = true;
#ifndef V3ERROR_NO_GLOBAL_
@ -380,7 +381,7 @@ std::ostringstream& V3Error::v3errorPrepFileLine(V3ErrorCode code, const char* f
v3errorPrep(code) << file << ":" << std::dec << line << ": ";
return v3errorStr();
}
void V3Error::v3errorEnd(std::ostringstream& sstr, const string& extra, FileLine* fileline)
void V3Error::v3errorEnd(const std::ostringstream& sstr, const string& extra, FileLine* fileline)
VL_RELEASE(s().m_mutex) {
s().v3errorEnd(sstr, extra, fileline);
V3Error::s().m_mutex.unlock();

View File

@ -393,9 +393,9 @@ private:
// METHODS
void v3errorPrep(V3ErrorCode code) VL_REQUIRES(m_mutex);
std::ostringstream& v3errorStr() VL_REQUIRES(m_mutex) { return m_errorStr; }
void v3errorEnd(std::ostringstream& sstr, const string& extra, FileLine* fileline)
void v3errorEnd(const std::ostringstream& sstr, const string& extra, FileLine* fileline)
VL_REQUIRES(m_mutex);
void v3errorEndGuts(std::ostringstream& sstr, const string& extra, FileLine* fileline)
void v3errorEndGuts(const std::ostringstream& sstr, const string& extra, FileLine* fileline)
VL_REQUIRES(m_mutex);
public:
@ -586,7 +586,7 @@ public:
VL_ACQUIRE(s().m_mutex);
static std::ostringstream& v3errorStr() VL_REQUIRES(s().m_mutex) { return s().v3errorStr(); }
// static, but often overridden in classes.
static void v3errorEnd(std::ostringstream& sstr, const string& extra, FileLine* fileline)
static void v3errorEnd(const std::ostringstream& sstr, const string& extra, FileLine* fileline)
VL_RELEASE(s().m_mutex);
static void vlAbort();
};
@ -728,7 +728,7 @@ void v3errorEndFatal(std::ostringstream& sstr)
static int level = -1; \
if (VL_UNLIKELY(level < 0)) { \
std::string tag{VL_STRINGIFY(__VA_ARGS__)}; \
tag[0] = std::tolower(tag[0]); \
if (!tag.empty()) tag[0] = std::tolower(tag[0]); \
const unsigned debugTag = v3Global.opt.debugLevel(tag); \
const unsigned debugSrc = v3Global.opt.debugSrcLevel(__FILE__); \
const unsigned debugLevel = debugTag >= debugSrc ? debugTag : debugSrc; \

View File

@ -32,7 +32,7 @@
#include <sys/types.h>
// clang-format off
#if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
#if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(VL_CPPCHECK)
# define INFILTER_PIPE // Allow pipe filtering. Needs fork()
#endif
@ -389,6 +389,7 @@ private:
close(fd);
return true;
}
// cppcheck-suppress constParameterReference
bool readContentsFilter(const string& filename, StrList& outl) {
(void)filename; // Prevent unused variable warning
(void)outl; // Prevent unused variable warning

View File

@ -499,9 +499,9 @@ string FileLine::prettySource() const VL_MT_SAFE {
string FileLine::warnContext() const {
if (!v3Global.opt.context()) return "";
string out;
if (firstLineno() == lastLineno() && firstColumn()) {
const string sourceLine = prettySource();
string out;
// Don't show super-long lines as can fill screen and unlikely to help user
if (!sourceLine.empty() && sourceLine.length() < SHOW_SOURCE_MAX_LENGTH
&& sourceLine.length() >= static_cast<size_t>(lastColumn() - 1)) {

View File

@ -336,7 +336,8 @@ class ForceConvertVisitor final : public VNVisitor {
public:
// CONSTRUCTOR
explicit ForceConvertVisitor(AstNetlist* nodep, ForceState& state)
// cppcheck-suppress constParameterCallback
ForceConvertVisitor(AstNetlist* nodep, ForceState& state)
: m_state{state} {
// Transform all force and release statements
iterateAndNextNull(nodep->modulesp());

View File

@ -548,7 +548,7 @@ class ForkVisitor final : public VNVisitor {
return varp;
}
AstTask* makeTask(FileLine* fl, AstNode* stmtsp, string name) {
AstTask* makeTask(FileLine* fl, AstNode* stmtsp, const std::string& name) {
stmtsp = AstNode::addNext(static_cast<AstNode*>(m_capturedVarsp), stmtsp);
AstTask* const taskp = new AstTask{fl, name, stmtsp};
return taskp;

View File

@ -63,7 +63,7 @@ void V3Global::readFiles() {
"work", "Cannot find verilated_std_waiver.vlt containing built-in lint waivers: ");
}
// Read .vlt files
for (auto& filelib : v3Global.opt.vltFiles()) {
for (const VFileLibName& filelib : v3Global.opt.vltFiles()) {
parser.parseFile(new FileLine{FileLine::commandLineFilename()}, filelib.filename(), false,
filelib.libname(), "Cannot find file containing .vlt file: ");
}

View File

@ -105,7 +105,8 @@ template V3GraphEdge* V3GraphVertex::findConnectingEdgep<GraphWay::FORWARD>(V3Gr
template V3GraphEdge* V3GraphVertex::findConnectingEdgep<GraphWay::REVERSE>(V3GraphVertex*);
// cppcheck-has-bug-suppress constParameter
void V3GraphVertex::v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex) {
void V3GraphVertex::v3errorEnd(const std::ostringstream& str) const
VL_RELEASE(V3Error::s().m_mutex) {
std::ostringstream nsstr;
nsstr << str.str();
if (debug()) nsstr << "\n-vertex: " << this << '\n';
@ -115,7 +116,7 @@ void V3GraphVertex::v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error
V3Error::v3errorEnd(nsstr, "", nullptr);
}
}
void V3GraphVertex::v3errorEndFatal(std::ostringstream& str) const
void V3GraphVertex::v3errorEndFatal(const std::ostringstream& str) const
VL_RELEASE(V3Error::s().m_mutex) {
v3errorEnd(str);
assert(0); // LCOV_EXCL_LINE

View File

@ -197,8 +197,6 @@ public:
class V3GraphVertex VL_NOT_FINAL {
VL_RTTI_IMPL_BASE(V3GraphVertex)
// Vertices may be a 'gate'/wire statement OR a variable
protected:
friend class V3Graph;
friend class V3GraphEdge;
friend class GraphAcyc;
@ -307,8 +305,9 @@ public:
bool outSize1() const { return m_outs.hasSingleElement(); }
// METHODS
/// Error reporting
void v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex) VL_MT_DISABLED;
void v3errorEndFatal(std::ostringstream& str) const
void v3errorEnd(const std::ostringstream& str) const
VL_RELEASE(V3Error::s().m_mutex) VL_MT_DISABLED;
void v3errorEndFatal(const std::ostringstream& str) const
VL_RELEASE(V3Error::s().m_mutex) VL_MT_DISABLED;
/// Edges are routed around this vertex to point from "from" directly to "to"
void rerouteEdges(V3Graph* graphp) VL_MT_DISABLED;

View File

@ -58,8 +58,11 @@ public:
V3GraphVertex* origVertexp() const { return m_origVertexp; }
void setDelete() { m_deleted = true; }
bool isDelete() const { return m_deleted; }
// cppcheck-suppress uselessOverride // cppcheck is wrong ...
string name() const override { return m_origVertexp->name(); }
// cppcheck-suppress uselessOverride // cppcheck is wrong ...
string dotColor() const override { return m_origVertexp->dotColor(); }
// cppcheck-suppress uselessOverride // cppcheck is wrong ...
FileLine* fileline() const override { return m_origVertexp->fileline(); }
};

View File

@ -428,13 +428,13 @@ struct GraphSortEdgeCmp final {
void V3Graph::sortVertices() {
// Sort list of vertices by rank, then fanout
std::vector<V3GraphVertex*> vertices;
for (V3GraphVertex& vertex : m_vertices) vertices.push_back(&vertex);
std::stable_sort(vertices.begin(), vertices.end(), GraphSortVertexCmp());
std::vector<V3GraphVertex*> vertexps;
for (V3GraphVertex& vertex : m_vertices) vertexps.push_back(&vertex);
std::stable_sort(vertexps.begin(), vertexps.end(), GraphSortVertexCmp());
// Re-insert in sorted order
for (V3GraphVertex* const ip : vertices) {
m_vertices.unlink(ip);
m_vertices.linkBack(ip);
for (V3GraphVertex* const vertexp : vertexps) {
m_vertices.unlink(vertexp);
m_vertices.linkBack(vertexp);
}
}

View File

@ -129,7 +129,7 @@ static void V3HierWriteCommonInputs(const V3HierBlock* hblockp, std::ostream* of
V3HierBlock::StrGParams V3HierBlock::stringifyParams(const V3HierBlockParams::GParams& gparams,
bool forGOption) {
StrGParams strParams;
for (const auto& gparam : gparams) {
for (const AstVar* const gparam : gparams) {
if (const AstConst* const constp = VN_CAST(gparam->valuep(), Const)) {
string s;
// Only constant parameter needs to be set to -G because already checked in
@ -262,7 +262,7 @@ void V3HierBlock::writeCommandArgsFile(bool forCMake) const {
*of << "--cc\n";
if (!forCMake) {
for (const auto& hierblockp : m_children) {
for (const V3HierBlock* const hierblockp : m_children) {
*of << v3Global.opt.makeDir() << "/" << hierblockp->hierWrapperFilename(true) << "\n";
}
*of << "-Mdir " << v3Global.opt.makeDir() << "/" << hierPrefix() << " \n";
@ -271,7 +271,9 @@ void V3HierBlock::writeCommandArgsFile(bool forCMake) const {
const V3StringList& commandOpts = commandArgs(false);
for (const string& opt : commandOpts) *of << opt << "\n";
*of << hierBlockArgs().front() << "\n";
for (const auto& hierblockp : m_children) *of << hierblockp->hierBlockArgs().front() << "\n";
for (const V3HierBlock* const hierblockp : m_children) {
*of << hierblockp->hierBlockArgs().front() << "\n";
}
*of << v3Global.opt.allArgsStringForHierBlock(false) << "\n";
}

View File

@ -383,7 +383,7 @@ class InlineRelinkVisitor final : public VNVisitor {
iterateChildren(nodep);
}
void visit(AstNodeAssign* nodep) override {
if (AstVarRef* const varrefp = VN_CAST(nodep->lhsp(), VarRef)) {
if (const AstVarRef* const varrefp = VN_CAST(nodep->lhsp(), VarRef)) {
if (m_initialStatic && varrefp->varp()->user2() && varrefp->varp()->user4()) {
// Initial assignment to i/o we are overriding, can remove
UINFO(9, "Remove InitialStatic " << nodep);
@ -400,7 +400,7 @@ class InlineRelinkVisitor final : public VNVisitor {
&& !VN_IS(nodep->backp(), AssignAlias)
// Forced signals do not use aliases
&& !nodep->varp()->isForced()) {
AstVar* const varp = nodep->varp();
const AstVar* const varp = nodep->varp();
if (AstConst* const constp = VN_CAST(varp->user2p(), Const)) {
nodep->replaceWith(constp->cloneTree(false));
VL_DO_DANGLING(nodep->deleteTree(), nodep);
@ -426,7 +426,7 @@ class InlineRelinkVisitor final : public VNVisitor {
if (pos == string::npos || pos == 0) {
break;
} else {
tryname = tryname.substr(0, pos);
tryname.resize(pos);
}
}
iterateChildren(nodep);

View File

@ -186,6 +186,7 @@ private:
// VISITORS
void visit(AstVar* nodep) override {
// cppcheck-suppress constVariablePointer
AstNode* const dtp = nodep->dtypep()->skipRefp();
if (VN_IS(dtp, UnpackArrayDType)
&& VN_IS(VN_AS(dtp, UnpackArrayDType)->subDTypep()->skipRefp(), IfaceRefDType)) {
@ -236,6 +237,7 @@ private:
m_cellRangep = nodep->rangep();
AstVar* const ifaceVarp = VN_CAST(nodep->nextp(), Var);
// cppcheck-suppress constVariablePointer
AstNodeDType* const ifaceVarDtp
= ifaceVarp ? ifaceVarp->dtypep()->skipRefp() : nullptr;
const bool isIface
@ -579,7 +581,7 @@ public:
class InstStatic final {
InstStatic() = default; // Static class
static AstNodeExpr* extendOrSel(FileLine* fl, AstNodeExpr* rhsp, AstNode* cmpWidthp) {
static AstNodeExpr* extendOrSel(FileLine* fl, AstNodeExpr* rhsp, const AstNode* cmpWidthp) {
if (cmpWidthp->width() > rhsp->width()) {
rhsp = (rhsp->isSigned() ? static_cast<AstNodeExpr*>(new AstExtendS{fl, rhsp})
: static_cast<AstNodeExpr*>(new AstExtend{fl, rhsp}));

View File

@ -637,14 +637,14 @@ class LinkCellsVisitor final : public VNVisitor {
}
nodep->unlinkFrBack();
VL_DO_DANGLING(pushDeletep(nodep), nodep);
} else if (!libFoundp && globalFoundp && globalFoundp != nodep) {
} else if (globalFoundp && globalFoundp != nodep) {
// ...__LIB__ stripped by prettyName
const string newName = nodep->libname() + "__LIB__" + nodep->origName();
UINFO(9, "Module rename as in multiple libraries " << newName << " <- " << nodep);
insertModInLib(nodep->origName(), nodep->libname(), nodep); // Original name
nodep->name(newName);
insertModInLib(nodep->name(), "__GLOBAL", nodep);
} else if (!libFoundp) {
} else {
insertModInLib(nodep->origName(), nodep->libname(), nodep);
insertModInLib(nodep->name(), "__GLOBAL", nodep);
}

View File

@ -99,7 +99,7 @@ class LinkLValueVisitor final : public VNVisitor {
{
m_setRefLvalue = VAccess::WRITE;
m_setContinuously = VN_IS(nodep, AssignW) || VN_IS(nodep, AssignAlias);
if (AstAssignW* assignwp = VN_CAST(nodep, AssignW)) {
if (const AstAssignW* const assignwp = VN_CAST(nodep, AssignW)) {
if (assignwp->strengthSpecp()) m_setStrengthSpecified = true;
}
{
@ -250,6 +250,7 @@ class LinkLValueVisitor final : public VNVisitor {
iterateAndNextNull(nodep->rhsp());
iterateAndNextNull(nodep->thsp());
}
// cppcheck-suppress constParameterPointer
void prepost_visit(AstNodeTriop* nodep) {
VL_RESTORER(m_setRefLvalue);
m_setRefLvalue = VAccess::NOCHANGE;

View File

@ -95,6 +95,7 @@ void V3LinkLevel::timescaling(const ModVec& mods) {
for (AstNodeModule* modp : mods) {
for (AstNode *nextp, *childp = modp->stmtsp(); childp; childp = nextp) {
nextp = childp->nextp();
// cppcheck-suppress constVariablePointer
if (AstPragma* pragp = VN_CAST(childp, Pragma)) {
if (pragp->pragType() == VPragmaType::TIMEUNIT_SET) {
modp->timeunit(pragp->timescale());
@ -205,6 +206,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
NameSet ioNames;
NameSet dupNames;
// For all modules, skipping over new top
// cppcheck-suppress constVariablePointer
for (AstNodeModule* oldmodp = VN_AS(rootp->modulesp()->nextp(), NodeModule);
oldmodp && oldmodp->level() <= 2; oldmodp = VN_AS(oldmodp->nextp(), NodeModule)) {
for (AstNode* subnodep = oldmodp->stmtsp(); subnodep; subnodep = subnodep->nextp()) {

View File

@ -141,10 +141,11 @@ class LinkResolveVisitor final : public VNVisitor {
nodep->varp()->usedParam(true);
// Look for where genvar is valid
bool ok = false;
for (AstGenFor* forp : m_underGenFors) {
// cppcheck-suppress constVariablePointer
for (AstGenFor* const forp : m_underGenFors) {
if (ok) break;
if (forp->initsp())
forp->initsp()->foreach([&](AstVarRef* refp) { //
forp->initsp()->foreach([&](const AstVarRef* refp) { //
if (refp->varp() == nodep->varp()) ok = true;
});
}
@ -199,6 +200,7 @@ class LinkResolveVisitor final : public VNVisitor {
}
// UINFOTREE(1, letp, "", "let-let");
// UINFOTREE(1, nodep, "", "let-ref");
// cppcheck-suppress constVariablePointer
AstStmtExpr* const letStmtp = VN_AS(letp->stmtsp(), StmtExpr);
AstNodeExpr* const newp = letStmtp->exprp()->cloneTree(false);
const V3TaskConnects tconnects = V3Task::taskConnects(nodep, letp->stmtsp());
@ -398,7 +400,7 @@ class LinkResolveVisitor final : public VNVisitor {
return newFormat;
}
static void expectDescriptor(AstNode* /*nodep*/, AstNodeVarRef* filep) {
static void expectDescriptor(AstNode* /*nodep*/, const AstNodeVarRef* filep) {
// This might fail on complex expressions like arrays
// We use attrFileDescr() only for lint suppression, so that's ok
if (filep && filep->varp()) filep->varp()->attrFileDescr(true);

View File

@ -556,7 +556,7 @@ string V3Number::ascii(bool prefixed, bool cleanVerilog) const VL_MT_STABLE {
if (prefixed) {
if (sized()) {
out << width() << "'";
} else if (autoExtend() && !sized() && width() == 1) {
} else if (autoExtend() && width() == 1) {
out << "'";
if (bitIs0(0)) {
out << '0';
@ -636,7 +636,7 @@ string V3Number::displayPad(size_t fmtsize, char pad, bool left, const string& i
return left ? (in + padding) : (padding + in);
}
string V3Number::displayed(AstNode* nodep, const string& vformat) const VL_MT_STABLE {
string V3Number::displayed(const AstNode* nodep, const string& vformat) const VL_MT_STABLE {
return displayed(nodep->fileline(), vformat);
}
@ -2040,7 +2040,7 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
NUM_ASSERT_LOGIC_ARGS2(lhs, rhs);
setZero();
// Find MSB and check for zero.
const int words = lhs.words();
const int lWords = lhs.words();
const int umsbp1 = lhs.mostSetBitP1(); // dividend
const int vmsbp1 = rhs.mostSetBitP1(); // divisor
if (VL_UNLIKELY(vmsbp1 == 0) // rwp==0 so division by zero. Return 0.
@ -2077,8 +2077,8 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
uint32_t vn[VL_MULS_MAX_WORDS + 1]; // v normalized
// Zero for ease of debugging and to save having to zero for shifts
for (int i = 0; i < words; ++i) m_data.num()[i].m_value = 0;
for (int i = 0; i < words + 1; ++i) { un[i] = vn[i] = 0; } // +1 as vn may get extra word
for (int i = 0; i < lWords; ++i) m_data.num()[i].m_value = 0;
for (int i = 0; i < lWords + 1; ++i) { un[i] = vn[i] = 0; } // +1 as vn may get extra word
// Algorithm requires divisor MSB to be set
// Copy and shift to normalize divisor so MSB of vn[vw-1] is set
@ -2155,7 +2155,7 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
for (int i = 0; i < vw; ++i) {
m_data.num()[i].m_value = (un[i] >> s) | (shift_mask & (un[i + 1] << (32 - s)));
}
for (int i = vw; i < words; ++i) m_data.num()[i].m_value = 0;
for (int i = vw; i < lWords; ++i) m_data.num()[i].m_value = 0;
opCleanThis();
UINFO(9, " opmoddiv-mod " << lhs << " " << rhs << " now=" << *this);
return *this;

View File

@ -590,7 +590,7 @@ public:
// ACCESSORS
string ascii(bool prefixed = true, bool cleanVerilog = false) const VL_MT_STABLE;
string displayed(AstNode* nodep, const string& vformat) const VL_MT_STABLE;
string displayed(const AstNode* nodep, const string& vformat) const VL_MT_STABLE;
string displayed(FileLine* fl, const string& vformat) const VL_MT_STABLE;
static bool displayedFmtLegal(char format, bool isScan); // Is this a valid format letter?
int width() const VL_MT_SAFE { return m_data.width(); }

View File

@ -419,6 +419,7 @@ string V3Options::allArgsString() const VL_MT_SAFE {
// Delete some options for Verilation of the hierarchical blocks.
string V3Options::allArgsStringForHierBlock(bool forTop) const {
// cppcheck-suppress shadowFunction
std::set<string> vFiles;
for (const auto& vFile : m_vFiles) vFiles.insert(vFile.filename());
string out;
@ -813,6 +814,7 @@ string V3Options::getSupported(const string& var) {
// If update below, also update V3Options::showVersion()
if (var == "COROUTINES" && coroutineSupport()) {
return "1";
// cppcheck-suppress knownConditionTrueFalse
} else if (var == "SYSTEMC" && systemCFound()) {
return "1";
} else {
@ -1762,6 +1764,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc,
}
});
for (int i = V3ErrorCode::EC_FIRST_WARN; i < V3ErrorCode::_ENUM_MAX; ++i) {
// cppcheck-suppress shadowFunction
for (const string prefix : {"-Wno-", "-Wwarn-"})
parser.addSuggestionCandidate(prefix + V3ErrorCode{i}.ascii());
}

View File

@ -357,6 +357,7 @@ private:
public:
// CONSTRUCTORS
// cppcheck-suppress constParameterCallback
LogicMTask(V3Graph* graphp, OrderMoveVertex* mVtxp)
: V3GraphVertex{graphp}
, m_id{s_nextId++} {
@ -676,6 +677,7 @@ void SiblingMC::unlinkA() {
void SiblingMC::unlinkB() { m_bp->bSiblingMCs().unlink(this); }
// cppcheck-suppress duplInheritedMember
bool SiblingMC::mergeWouldCreateCycle() const {
return (LogicMTask::pathExistsFrom(m_ap, m_bp, nullptr)
|| LogicMTask::pathExistsFrom(m_bp, m_ap, nullptr));
@ -696,6 +698,7 @@ LogicMTask* MTaskEdge::furtherMTaskp() const {
LogicMTask* MTaskEdge::fromMTaskp() const { return static_cast<LogicMTask*>(fromp()); }
LogicMTask* MTaskEdge::toMTaskp() const { return static_cast<LogicMTask*>(top()); }
// cppcheck-suppress duplInheritedMember
bool MTaskEdge::mergeWouldCreateCycle() const {
return LogicMTask::pathExistsFrom(fromMTaskp(), toMTaskp(), this);
}
@ -1204,6 +1207,7 @@ public:
mergeCanp->rescore();
const uint64_t actualScore = mergeCanp->score();
// cppcheck-suppress knownConditionTrueFalse // they are in fact different
if (actualScore > cachedScore) {
// Cached score is out-of-date.
// Mark this elem as in need of a rescore and continue.
@ -1322,7 +1326,7 @@ public:
private:
template <GraphWay::en N_Way>
NewCp newCp(LogicMTask* mtaskp, LogicMTask* otherp, MTaskEdge* mergeEdgep) {
NewCp newCp(const LogicMTask* mtaskp, const LogicMTask* otherp, const MTaskEdge* mergeEdgep) {
constexpr GraphWay way{N_Way};
// Return new wayward-CP for mtaskp reflecting its upcoming merge
// with otherp. Set 'result.propagate' if mtaskp's wayward

View File

@ -374,10 +374,10 @@ class ParamProcessor final {
// equivalence predicate function.
if (AstRefDType* const refp = VN_CAST(nodep, RefDType)) nodep = refp->skipRefToNonRefp();
const string paramStr = paramValueString(nodep);
// cppcheck-has-bug-suppress unreadVariable
// cppcheck-suppress unreadVariable
V3Hash hash = V3Hasher::uncachedHash(nodep) + paramStr;
// Force hash collisions -- for testing only
// cppcheck-has-bug-suppress unreadVariable
// cppcheck-suppress unreadVariable
if (VL_UNLIKELY(v3Global.opt.debugCollision())) hash = V3Hash{paramStr};
int num;
const auto pair = m_valueMap.emplace(hash, 0);

View File

@ -282,7 +282,7 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, const string& name,
return nodep;
}
string V3ParseGrammar::unquoteString(FileLine* fileline, string text) {
string V3ParseGrammar::unquoteString(FileLine* fileline, const std::string& text) {
string errMsg;
string res = VString::unquoteSVString(text, errMsg);
if (!errMsg.empty()) fileline->v3error(errMsg.c_str());

View File

@ -259,7 +259,7 @@ size_t V3ParseImp::ppInputToLex(char* buf, size_t max_size) {
size_t len = front.length();
if (len > (max_size - got)) { // Front string too big
const string remainder = front.substr(max_size - got);
front = front.substr(0, max_size - got);
front.resize(max_size - got);
m_ppBuffers.push_front(remainder); // Put back remainder for next time
len = (max_size - got);
}
@ -383,7 +383,7 @@ void V3ParseImp::dumpInputsFile() {
void V3ParseImp::dumpTokensAhead(int line) { // LCOV_EXCL_START
int i = 0;
UINFO(1, "dumpTokensAhead @ " << line << " [ ] " << yylval);
for (auto t : m_tokensAhead) {
for (const V3ParseBisonYYSType& t : m_tokensAhead) {
UINFO(1, "dumpTokensAhead @ " << line << " [" << i << "] " << t);
++i;
}

View File

@ -107,9 +107,9 @@ struct VMemberQualifiers final {
// We can't use bison's %union as we want to pass the fileline with all tokens
struct V3ParseBisonYYSType final {
FileLine* fl;
int token; // Read token, aka tok
VBaseOverride baseOverride;
FileLine* fl = nullptr;
int token = 0; // Read token, aka tok
VBaseOverride baseOverride{};
bool flag = false; // Passed up some rules
union {
V3Number* nump;
@ -157,7 +157,7 @@ class V3ParseImp final {
int m_lexPrevToken = 0; // previous parsed token (for lexer)
bool m_afterColonColon = false; // The previous token was '::'
V3ParseBisonYYSType m_tokenLastBison; // Token we last sent to Bison
V3ParseBisonYYSType m_tokenLastBison{}; // Token we last sent to Bison
std::deque<V3ParseBisonYYSType> m_tokensAhead; // Tokens we parsed ahead of parser
std::deque<string*> m_stringps; // Created strings for later cleanup

View File

@ -57,7 +57,7 @@ void yyourtext(const char* textp, size_t size) {
static void linenoInc() { LEXP->linenoInc(); }
static bool pedantic() { return LEXP->m_pedantic; }
static void yyerror(char* msg) { LEXP->curFilelinep()->v3error(msg); }
static void yyerror(const char* msg) { LEXP->curFilelinep()->v3error(msg); }
static void yyerrorf(const char* msg) { LEXP->curFilelinep()->v3error(msg); }
static void appendDefValue(const char* t, size_t l) { LEXP->appendDefValue(t, l); }
@ -548,7 +548,7 @@ again:
if (len > (max_size - got)) { // Front string too big
len = (max_size - got);
string remainder = front.substr(len);
front = front.substr(0, len);
front.resize(len);
streamp->m_buffers.push_front(remainder); // Put back remainder for next time
}
strncpy(buf + got, front.c_str(), len);

View File

@ -124,7 +124,6 @@ public:
// STATE
const V3PreProc* m_preprocp = nullptr; ///< Object we're holding data for
V3PreLex* m_lexp = nullptr; ///< Current lexer state (nullptr = closed)
std::stack<V3PreLex*> m_includeStack; ///< Stack of includers above current m_lexp
int m_lastLineno = 0; // Last line number (stall detection)
int m_tokensOnLine = 0; // Number of tokens on line (stall detection)
@ -275,6 +274,7 @@ public:
// CONSTRUCTORS
V3PreProcImp() { m_states.push(ps_TOP); }
// cppcheck-suppress duplInheritedMember
void configure(FileLine* filelinep) {
// configure() separate from constructor to avoid calling abstract functions
m_preprocp = this; // Silly, but to make code more similar to Verilog-Perl
@ -721,9 +721,10 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
backslashesc = false;
}
if (!quote && !triquote) {
if (std::isalpha(*cp) || *cp == '_'
if (std::isalpha(*cp) //
|| *cp == '_' //
|| *cp == '$' // Won't replace system functions, since no $ in argValueByName
|| (argName != "" && (std::isdigit(*cp) || *cp == '$'))) {
|| (argName != "" && std::isdigit(*cp))) {
argName += *cp;
continue;
}
@ -737,7 +738,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
// Normally `` is removed later, but with no token after, we're
// otherwise stuck, so remove proceeding ``
if (out.size() >= 2 && out.substr(out.size() - 2) == "``") {
out = out.substr(0, out.size() - 2);
out.resize(out.size() - 2);
}
} else {
out += subst;

View File

@ -100,7 +100,7 @@ protected:
// from the V3LangCode to the various Lex BEGIN states. The language
// of this source file is updated here, in case there have been any
// intervening +<lang>ext+ options since it was first encountered.
FileLine* const modfileline = new FileLine{modfilename};
const FileLine* const modfileline = new FileLine{modfilename};
modfileline->language(v3Global.opt.fileLanguage(modfilename));
V3Parse::ppPushText(
parsep, ("`begin_keywords \""s + modfileline->language().ascii() + "\"\n"));

View File

@ -146,7 +146,7 @@ class PremitVisitor final : public VNVisitor {
checkNode(nodep);
}
static bool rhsReadsLhs(AstNodeAssign* nodep) {
static bool rhsReadsLhs(const AstNodeAssign* nodep) {
const VNUser3InUse user3InUse;
nodep->lhsp()->foreach([](const AstVarRef* refp) {
if (refp->access().isWriteOrRW()) refp->varp()->user3(true);

View File

@ -89,7 +89,7 @@ class ProtectVisitor final : public VNVisitor {
iterateChildren(nodep);
// cppcheck-has-bug-suppress unreadVariable
// cppcheck-suppress unreadVariable
const V3Hash hash = V3Hasher::uncachedHash(m_cfilep);
m_hashValuep->addText(fl, cvtToStr(hash.value()) + ";\n");
m_cHashValuep->addText(fl, cvtToStr(hash.value()) + "U;\n");
@ -481,7 +481,7 @@ class ProtectVisitor final : public VNVisitor {
void handleInput(AstVar* varp) { m_modPortsp->addNodesp(varp->cloneTree(false)); }
static void addLocalVariable(AstTextBlock* textp, AstVar* varp, const char* suffix) {
static void addLocalVariable(AstTextBlock* textp, const AstVar* varp, const char* suffix) {
AstVar* const newVarp
= new AstVar{varp->fileline(), VVarType::VAR, varp->name() + suffix, varp->dtypep()};
textp->addNodesp(newVarp);
@ -520,8 +520,8 @@ class ProtectVisitor final : public VNVisitor {
}
}
static bool checkIfClockExists(AstNodeModule* modp) {
for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
static bool checkIfClockExists(const AstNodeModule* modp) {
for (const AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (const AstVar* const varp = VN_CAST(stmtp, Var)) {
if (varp->direction() == VDirection::INPUT
&& (varp->isUsedClock()

View File

@ -89,7 +89,7 @@ std::vector<const AstSenTree*> getSenTreesUsedBy(const std::vector<const LogicBy
}
void remapSensitivities(const LogicByScope& lbs,
std::unordered_map<const AstSenTree*, AstSenTree*> senTreeMap) {
const std::unordered_map<const AstSenTree*, AstSenTree*>& senTreeMap) {
for (const auto& pair : lbs) {
AstActive* const activep = pair.second;
AstSenTree* const senTreep = activep->sentreep();
@ -111,9 +111,10 @@ AstSenTree* findTriggeredIface(const AstVarScope* vscp,
const auto ifaceIt = vifTrigged.find(vscp->varp()->sensIfacep());
if (ifaceIt != vifTrigged.end()) return ifaceIt->second;
for (const auto& memberIt : vifMemberTriggered) {
if (memberIt.first.m_ifacep == vscp->varp()->sensIfacep()) { return memberIt.second; }
if (memberIt.first.m_ifacep == vscp->varp()->sensIfacep()) return memberIt.second;
}
vscp->v3fatalSrc("Did not find virtual interface trigger");
return nullptr; // unreachable, appease MSVC
}
//============================================================================

View File

@ -342,7 +342,7 @@ void transformForks(AstNetlist* const netlistp) {
m_funcp = nodep;
m_awaitMoved = false;
iterateChildren(nodep);
// cppcheck-has-bug-suppress knownConditionTrueFalse
// cppcheck-suppress knownConditionTrueFalse
if (nodep->isCoroutine() && m_awaitMoved
&& !nodep->stmtsp()->exists([](AstCAwait*) { return true; })) {
// co_return at the end (either that or a co_await is required in a coroutine

View File

@ -57,7 +57,7 @@ private:
AstAssign* m_trigAssignp = nullptr; // Previous/current trigger assignment
AstIface* m_trigAssignIfacep = nullptr; // Interface type whose trigger is assigned
// by m_trigAssignp
AstVar* m_trigAssignMemberVarp; // Member pointer whose trigger is assigned
AstVar* m_trigAssignMemberVarp = nullptr; // Member pointer whose trigger is assigned
V3UniqueNames m_vifTriggerNames{"__VvifTrigger"}; // Unique names for virt iface
// triggers
VirtIfaceTriggers m_triggers; // Interfaces and corresponding trigger vars

View File

@ -269,9 +269,9 @@ class ScopeVisitor final : public VNVisitor {
// Make new scope variable
if (!nodep->user1p()) {
AstScope* scopep = m_scopep;
if (AstIfaceRefDType* const ifacerefp = VN_CAST(nodep->dtypep(), IfaceRefDType)) {
if (const AstIfaceRefDType* const ifrefp = VN_CAST(nodep->dtypep(), IfaceRefDType)) {
// Attach every non-virtual interface variable its inner scope
if (ifacerefp->cellp()) scopep = VN_AS(ifacerefp->cellp()->user2p(), Scope);
if (ifrefp->cellp()) scopep = VN_AS(ifrefp->cellp()->user2p(), Scope);
}
AstVarScope* const varscp = new AstVarScope{nodep->fileline(), scopep, nodep};
UINFO(6, " New scope " << varscp);

View File

@ -42,7 +42,7 @@ public:
static uint32_t s_serial = 0;
m_key.m_id = ++s_serial;
}
ScoreboardTestElem() = default;
ScoreboardTestElem() = delete;
uint64_t id() const { return m_key.m_id; }
void rescore() { m_key.m_score = m_newScore; }

View File

@ -437,6 +437,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl {
iterate(nodep);
}
}
// cppcheck-suppress duplInheritedMember
void pushDeletep(AstNode* nodep) { // overriding VNVisitor::pusDeletep()
UASSERT_OBJ(m_modp, nodep, "Must not nullptr");
m_forPackedSplit.m_refs[m_modp].remove(nodep);
@ -889,7 +890,7 @@ public:
UASSERT(m_dedupDone, "cannot read before dedup()");
return m_rhs;
}
explicit PackedVarRef(AstVar* varp)
explicit PackedVarRef(const AstVar* varp)
: m_basicp{varp->dtypep()->basicp()} {}
void append(const PackedVarRefEntry& e, const VAccess& access) {
UASSERT(!m_dedupDone, "cannot add after dedup()");

View File

@ -79,7 +79,7 @@ private:
m_stackSize = 0;
return savedCount;
}
void endVisitBase(uint32_t savedCount, AstNode* nodep) {
void endVisitBase(uint32_t savedCount, const AstNode* nodep) {
UINFO(8, "cost " << std::setw(6) << std::left << m_stackSize << " " << nodep);
if (!m_ignoreRemaining) m_stackSize += savedCount;
}

View File

@ -164,7 +164,7 @@ public:
static double getStatSum(const string& name) {
// O(n^2) if called a lot; present assumption is only a small call count
for (auto& itr : s_allStats) {
for (const V3Statistic& itr : s_allStats) {
const V3Statistic* const repp = &itr;
if (repp->name() == name) return repp->value();
}

View File

@ -510,7 +510,7 @@ void VHashSha256::insertFile(const string& filename) {
if (fd < 0) return;
std::array<char, BUFFER_SIZE + 1> buf;
while (const size_t got = ::read(fd, &buf, BUFFER_SIZE)) {
while (const ssize_t got = ::read(fd, &buf, BUFFER_SIZE)) {
if (got <= 0) break;
insert(&buf, got);
}
@ -761,7 +761,7 @@ VSpellCheck::EditDistance VSpellCheck::cutoffDistance(size_t goal_len, size_t ca
}
string VSpellCheck::bestCandidateInfo(const string& goal, EditDistance& distancer) const {
string bestCandidate;
string best;
const size_t gLen = goal.length();
distancer = LENGTH_LIMIT * 10;
for (const string& candidate : m_candidates) {
@ -779,13 +779,13 @@ string VSpellCheck::bestCandidateInfo(const string& goal, EditDistance& distance
<< " candidate=" << candidate);
if (dist < distancer && dist <= cutoff) {
distancer = dist;
bestCandidate = candidate;
best = candidate;
}
}
// If goal matches candidate avoid suggesting replacing with self
if (distancer == 0) return "";
return bestCandidate;
return best;
}
void VSpellCheck::selfTestDistanceOne(const string& a, const string& b, EditDistance expected) {

View File

@ -261,11 +261,11 @@ public:
}
}
}
string cellErrorScopes(AstNode* lookp, string prettyName = "") {
string cellErrorScopes(const AstNode* lookp, string prettyName = "") {
if (prettyName == "") prettyName = lookp->prettyName();
string scopes;
for (IdNameMap::iterator it = m_idNameMap.begin(); it != m_idNameMap.end(); ++it) {
AstNode* const itemp = it->second->nodep();
const AstNode* const itemp = it->second->nodep();
if (VN_IS(itemp, Cell) || (VN_IS(itemp, Module) && VN_AS(itemp, Module)->isTop())) {
if (scopes != "") scopes += ", ";
scopes += AstNode::prettyName(it->first);

View File

@ -112,6 +112,7 @@ public:
// the edge user field. We also want easy access to the 'id'
// which uniquely identifies a single bidir edge. Luckily we
// can do both efficiently.
// cppcheck-suppress badBitmaskCheck
const uint64_t userValue = (static_cast<uint64_t>(cost) << 32) | edgeId;
(new V3GraphEdge{this, fp, tp, cost})->user(userValue);
(new V3GraphEdge{this, tp, fp, cost})->user(userValue);
@ -121,6 +122,7 @@ public:
return static_cast<uint32_t>(edgep->user());
}
// cppcheck-suppress duplInheritedMember
bool empty() const { return m_vertices.empty(); }
const std::list<Vertex*> keysToVertexList(const std::vector<T_Key>& odds) {

View File

@ -213,12 +213,14 @@ private:
if (chkvis.isCoverage()) {
chkvis.clearOptimizable(nodep, "Table removes coverage points");
}
// cppcheck-suppress knownConditionTrueFalse // set by TableSimulateVisitor
if (!m_outWidthBytes || !m_inWidthBits) {
chkvis.clearOptimizable(nodep, "Table has no outputs");
}
if (chkvis.instrCount() < TABLE_MIN_NODE_COUNT) {
chkvis.clearOptimizable(nodep, "Table has too few nodes involved");
}
// cppcheck-suppress knownConditionTrueFalse
if (space > TABLE_MAX_BYTES) {
chkvis.clearOptimizable(nodep, "Table takes too much space");
}

View File

@ -316,6 +316,7 @@ class TraceDeclVisitor final : public VNVisitor {
void removeRedundantPrefixPushPop() {
for (const auto& pair : m_scopeInitFuncps) {
// cppcheck-suppress constVariablePointer
for (AstCFunc* const funcp : pair.second) {
AstNode* prevp = nullptr;
AstNode* currp = funcp->stmtsp();

View File

@ -862,11 +862,6 @@ class TristateVisitor final : public TristateBaseVisitor {
if (varRefp->varp()->isNet()) {
m_assigns[varRefp->varp()].push_back(nodep);
} else if (nodep->strengthSpecp()) {
if (!varRefp->varp()->isNet())
nodep->v3warn(E_UNSUPPORTED, "Unsupported: Signal strengths are unsupported "
"on the following variable type: "
<< varRefp->varp()->varType());
nodep->strengthSpecp()->unlinkFrBack()->deleteTree();
}
} else if (nodep->strengthSpecp()) {

View File

@ -435,8 +435,7 @@ class UndrivenVisitor final : public VNVisitorConst {
&& entryp->getNodep()) {
if (m_alwaysCombp
&& (!entryp->isDrivenAlwaysCombWhole()
|| (entryp->isDrivenAlwaysCombWhole()
&& m_alwaysCombp != entryp->getAlwCombp()
|| (m_alwaysCombp != entryp->getAlwCombp()
&& m_alwaysCombp->fileline() != entryp->getAlwCombFileLinep()))) {
nodep->v3warn(
MULTIDRIVEN,

View File

@ -469,7 +469,7 @@ class UnknownVisitor final : public VNVisitor {
nodep->bitp()->cloneTreePure(false)};
// Note below has null backp(); the Edit function knows how to deal with that.
condp = V3Const::constifyEdit(condp);
AstNodeDType* nodeDtp = nodep->dtypep()->skipRefp();
const AstNodeDType* const nodeDtp = nodep->dtypep()->skipRefp();
if (condp->isOne()) {
// We don't need to add a conditional; we know the existing expression is ok
VL_DO_DANGLING(condp->deleteTree(), condp);

View File

@ -210,6 +210,7 @@ class VariableOrder final {
sortAndAppend(m2v[emptyVec]);
}
// cppcheck-suppress constParameterPointer
void orderModuleVars(AstNodeModule* modp) {
// Unlink all module variables from the module, compute attributes
for (AstNode *nodep = modp->stmtsp(), *nextp; nodep; nodep = nextp) {

View File

@ -34,7 +34,7 @@ void V3Waiver::addEntry(V3ErrorCode errorCode, const std::string& filename, cons
string trimmsg = msg;
if (!v3Global.opt.waiverMultiline()) {
const size_t pos = trimmsg.find('\n');
trimmsg = trimmsg.substr(0, pos);
trimmsg.resize(pos);
if (pos != std::string::npos) trimmsg += '*';
}
{ // Remove line numbers and context "\n [0-9] | ", "\n ^[~]+"

View File

@ -4138,7 +4138,6 @@ class WidthVisitor final : public VNVisitor {
// All variables in the dot hierarchy must be randomizable
if (randVarp && !randVarp->isRand()) randVarp->rand(VRandAttr::RAND_INLINE);
}
if (!argp) continue; // Errored out, bail
// randVarp is now the leftmost element from the dot hierarchy in argp->exprp()
if (randVarp == fromVarp) {
// The passed in variable is MemberSel'ected from the MethodCall target
@ -4523,9 +4522,9 @@ class WidthVisitor final : public VNVisitor {
if (nodep->isScoped()) { // = ClassOrPackage::new
UASSERT_OBJ(nodep->classOrPackagep(), nodep, "Unlinked classOrPackage");
warnp = nodep->classOrPackagep();
if (AstClass* const classp = VN_CAST(warnp, Class)) {
if (AstClass* const clsp = VN_CAST(warnp, Class)) {
AstClassRefDType* const adtypep
= new AstClassRefDType{nodep->fileline(), classp, nullptr};
= new AstClassRefDType{nodep->fileline(), clsp, nullptr};
v3Global.rootp()->typeTablep()->addTypesp(adtypep);
refp = adtypep;
}
@ -5908,16 +5907,15 @@ class WidthVisitor final : public VNVisitor {
if (nodep->modVarp() && nodep->modVarp()->isGParam()) {
// Widthing handled as special init() case
bool didWidth = false;
if (auto* const patternp = VN_CAST(nodep->exprp(), Pattern)) {
if (const AstVar* const modVarp = nodep->modVarp()) {
// Convert BracketArrayDType
userIterate(modVarp->childDTypep(),
WidthVP{SELF, BOTH}.p()); // May relink pointed to node
AstNodeDType* const setDtp = modVarp->childDTypep()->cloneTree(false);
if (!patternp->childDTypep()) patternp->childDTypep(setDtp);
userIterateChildren(nodep, WidthVP{setDtp, BOTH}.p());
didWidth = true;
}
if (AstPattern* const patternp = VN_CAST(nodep->exprp(), Pattern)) {
const AstVar* const modVarp = nodep->modVarp();
// Convert BracketArrayDType
userIterate(modVarp->childDTypep(),
WidthVP{SELF, BOTH}.p()); // May relink pointed to node
AstNodeDType* const setDtp = modVarp->childDTypep()->cloneTree(false);
if (!patternp->childDTypep()) patternp->childDTypep(setDtp);
userIterateChildren(nodep, WidthVP{setDtp, BOTH}.p());
didWidth = true;
}
if (!didWidth) userIterateChildren(nodep, WidthVP{SELF, BOTH}.p());
} else if (!m_paramsOnly) {
@ -6151,14 +6149,14 @@ class WidthVisitor final : public VNVisitor {
break;
} else {
AstVar* const portp = ports[i];
AstAttrOf* const protop = protos[i];
AstAttrOf* const rprotop = protos[i];
AstNodeDType* const declDtp = portp->dtypep();
AstNodeDType* const protoDtp = protop->fromp()->dtypep();
if (portp->name() != protop->name()) {
AstNodeDType* const protoDtp = rprotop->fromp()->dtypep();
if (portp->name() != rprotop->name()) {
protoDtp->v3warn(PROTOTYPEMIS,
"In prototype for "
<< nodep->prettyNameQ() << ", argument " << (i + 1)
<< " named " << protop->prettyNameQ()
<< " named " << rprotop->prettyNameQ()
<< " mismatches out-of-block argument name "
<< portp->prettyNameQ() << " (IEEE 1800-2023 8.24)\n"
<< protoDtp->warnContextPrimary() << '\n'
@ -6466,9 +6464,8 @@ class WidthVisitor final : public VNVisitor {
} else {
argp->v3error("Non-variable arguments for 'std::randomize()'.");
}
if (!argp) continue;
}
if (nullp) { nullp->v3error("'std::randomize()' does not accept 'null' as arguments."); }
if (nullp) nullp->v3error("'std::randomize()' does not accept 'null' as arguments.");
}
void visit(AstNodeFTaskRef* nodep) override {
// For arguments, is assignment-like context; see IEEE rules in AstNodeAssign

View File

@ -111,7 +111,7 @@ public:
void dump(bool bucketsToo) {
UINFO(2, "dumpTests...");
VlcTest::dumpHeader();
for (const auto& testp : m_tests) testp->dump(bucketsToo);
for (const VlcTest* const testp : m_tests) testp->dump(bucketsToo);
}
VlcTest* newTest(const string& name, uint64_t testrun, double comp) {
VlcTest* const testp = new VlcTest{name, testrun, comp};

View File

@ -15,6 +15,8 @@ unusedScopedObject
useInitializationList
useStlAlgorithm
// Do not warn that analysis failed due to complexity
checkLevelNormal
// Seems useless
missingIncludeSystem
// Tedious
@ -22,6 +24,12 @@ unmatchedSuppression
// Not our code
*:include/gtkwave/*
*:include/vltstd/*
// flex/bison output
*:verilog.c
*:V3Lexer_pregen.yy.cpp
*:V3PreLex_pregen.yy.cpp
// Just check the hand written code
missingInclude:examples/*
// We intentionally redefine AstNode methods to improve type safety
duplInheritedMember:src/V3AstNode*.h
duplInheritedMember:src/obj_*/V3Ast__gen_impl.h
@ -32,3 +40,108 @@ unusedPrivateFunction:src/V3Const.cpp
// These are all inappropriate
constVariablePointer:src/V3DfgPeephole.cpp
constParameterPointer:src/V3DfgPeephole.cpp
// TODO: these need fixing/signing off in source
constParameterPointer:src/V3EmitCFunc.cpp
constVariablePointer:src/V3EmitCFunc.cpp
constParameterPointer:src/V3EmitCFunc.h
constVariablePointer:src/V3EmitCFunc.h
constParameterPointer:src/V3EmitCImp.cpp
constParameterPointer:src/V3EmitCModel.cpp
constVariablePointer:src/V3EmitCModel.cpp
constVariablePointer:src/V3EmitCSyms.cpp
constVariablePointer:src/V3EmitV.cpp
constParameterReference:src/V3Error.cpp
constParameterPointer:src/V3ExecGraph.cpp
constVariablePointer:src/V3ExecGraph.cpp
constVariableReference:src/V3ExecGraph.cpp
constParameterPointer:src/V3Expand.cpp
constParameterPointer:src/V3FileLine.cpp
constParameterReference:src/V3FileLine.cpp
constParameterPointer:src/V3Force.cpp
constParameterPointer:src/V3Fork.cpp
constVariablePointer:src/V3Fork.cpp
constParameterPointer:src/V3FuncOpt.cpp
constVariablePointer:src/V3FuncOpt.cpp
constParameterPointer:src/V3Gate.cpp
constVariablePointer:src/V3Gate.cpp
constVariableReference:src/V3Gate.cpp
constParameterPointer:src/V3GraphAcyc.cpp
constVariableReference:src/V3GraphAcyc.cpp
constVariablePointer:src/V3GraphAlg.cpp
constVariableReference:src/V3GraphAlg.cpp
constParameterPointer:src/V3Graph.cpp
constVariableReference:src/V3Graph.cpp
constParameterPointer:src/V3LinkDot.cpp
constVariablePointer:src/V3LinkDot.cpp
constVariablePointer:src/V3LinkInc.cpp
constVariablePointer:src/V3LinkJump.cpp
constVariablePointer:src/V3LinkLevel.cpp
constParameterPointer:src/V3LinkParse.cpp
constVariablePointer:src/V3LinkParse.cpp
constVariablePointer:src/V3MergeCond.cpp
constParameterPointer:src/V3OrderCFuncEmitter.h
constVariablePointer:src/V3OrderMoveGraph.cpp
constParameterPointer:src/V3OrderParallel.cpp
constVariablePointer:src/V3OrderParallel.cpp
constVariableReference:src/V3OrderParallel.cpp
constParameterPointer:src/V3OrderProcessDomains.cpp
constVariablePointer:src/V3OrderProcessDomains.cpp
constVariablePointer:src/V3OrderSerial.cpp
constParameterPointer:src/V3Param.cpp
constVariablePointer:src/V3Param.cpp
constParameterPointer:src/V3ParseImp.cpp
constVariableReference:src/V3ParseImp.cpp
constVariableReference:src/V3PreProc.cpp
constParameterPointer:src/V3Randomize.cpp
constVariablePointer:src/V3Randomize.cpp
constVariablePointer:src/V3SchedAcyclic.cpp
constVariableReference:src/V3SchedAcyclic.cpp
constParameterPointer:src/V3Sched.cpp
constParameterReference:src/V3Sched.cpp
constVariablePointer:src/V3Sched.cpp
constParameterPointer:src/V3SchedPartition.cpp
constVariablePointer:src/V3SchedPartition.cpp
constVariableReference:src/V3SchedPartition.cpp
constParameterPointer:src/V3SchedReplicate.cpp
constParameterReference:src/V3SchedReplicate.cpp
constVariableReference:src/V3SchedReplicate.cpp
constVariablePointer:src/V3SchedTiming.cpp
constVariableReference:src/V3SchedTiming.cpp
constParameterPointer:src/V3SchedVirtIface.cpp
constVariablePointer:src/V3SchedVirtIface.cpp
constVariablePointer:src/V3SenExprBuilder.h
constVariablePointer:src/V3Slice.cpp
constParameterPointer:src/V3Split.cpp
constVariablePointer:src/V3Split.cpp
constParameterPointer:src/V3SplitVar.cpp
constParameterReference:src/V3SplitVar.cpp
constVariablePointer:src/V3SplitVar.cpp
constParameterPointer:src/V3Subst.cpp
constParameterPointer:src/V3Task.cpp
constParameterReference:src/V3Task.cpp
constVariablePointer:src/V3Task.cpp
constVariableReference:src/V3Task.cpp
constParameterPointer:src/V3Timing.cpp
constVariablePointer:src/V3Timing.cpp
constVariableReference:src/V3Timing.cpp
constVariablePointer:src/V3Trace.cpp
constParameterPointer:src/V3Tristate.cpp
constParameterReference:src/V3Tristate.cpp
constVariablePointer:src/V3Tristate.cpp
constVariableReference:src/V3Tristate.cpp
constVariablePointer:src/V3TSP.cpp
constVariableReference:src/V3TSP.cpp
constParameterPointer:src/V3Undriven.cpp
constVariablePointer:src/V3Undriven.cpp
constParameterPointer:src/V3Unroll.cpp
constVariablePointer:src/V3Unroll.cpp
constParameterPointer:src/V3WidthCommit.cpp
constVariablePointer:src/V3WidthCommit.cpp
constParameterPointer:src/V3Width.cpp
constParameterReference:src/V3Width.cpp
constVariablePointer:src/V3Width.cpp
constVariableReference:src/V3Width.cpp
constVariablePointer:src/V3WidthSel.cpp
constParameterPointer:verilog.y

View File

@ -250,7 +250,7 @@ public:
return createArray(dtypep, rangearraysp, isPacked);
}
}
string unquoteString(FileLine* fileline, string text) VL_MT_DISABLED;
string unquoteString(FileLine* fileline, const std::string& text) VL_MT_DISABLED;
void checkDpiVer(FileLine* fileline, const string& str) {
if (str != "DPI-C" && !v3Global.opt.bboxSys()) {
fileline->v3error("Unsupported DPI type '" << str << "': Use 'DPI-C'");

View File

@ -93,7 +93,6 @@ for s in [
'Unsupported: Public functions with >64 bit outputs; ',
'Unsupported: Replication to form ',
'Unsupported: Shifting of by over 32-bit number isn\'t supported.',
'Unsupported: Signal strengths are unsupported ',
'Unsupported: Size-changing cast on non-basic data type',
'Unsupported: Slice of non-constant bounds',
'Unsupported: Unclocked assertion',