forked from github/verilator
Internal: cppcheck fixes. No functional change intended.
This commit is contained in:
parent
4b3731d318
commit
833780fac1
50
Makefile.in
50
Makefile.in
@ -302,34 +302,56 @@ install-all: installbin installman installdata install-msg
|
||||
install-here: installman info
|
||||
|
||||
# Use --xml flag to see the cppcheck code to use for suppression
|
||||
CPPCHECK_CPP = $(wildcard \
|
||||
$(srcdir)/examples/*/*.cpp \
|
||||
$(srcdir)/include/*.cpp \
|
||||
$(srcdir)/src/*.cpp )
|
||||
CPPCHECK_H = $(wildcard \
|
||||
CPPCHECK1_CPP = $(wildcard $(srcdir)/include/*.cpp)
|
||||
CPPCHECK2_CPP = $(wildcard $(srcdir)/examples/*/*.cpp)
|
||||
CPPCHECK3_CPP = $(wildcard $(srcdir)/src/Vlc*.cpp)
|
||||
CPPCHECK4_CPP = $(wildcard $(srcdir)/src/V3[A-D]*.cpp $(srcdir)/src/Verilator*.cpp)
|
||||
CPPCHECK5_CPP = $(wildcard $(srcdir)/src/V3[E-I]*.cpp)
|
||||
CPPCHECK6_CPP = $(wildcard $(srcdir)/src/V3[P-Z]*.cpp)
|
||||
CPPCHECK7_CPP = $(wildcard $(srcdir)/src/V3[L-R]*.cpp)
|
||||
CPPCHECK8_CPP = $(wildcard $(srcdir)/src/V3[S-Z]*.cpp)
|
||||
CHECK_CPP = $(CPPCHECK1_CPP) $(CPPCHECK2_CPP) $(CPPCHECK3_CPP) $(CPPCHECK4_CPP) \
|
||||
$(CPPCHECK5_CPP) $(CPPCHECK6_CPP) $(CPPCHECK7_CPP) $(CPPCHECK8_CPP)
|
||||
CHECK_H = $(wildcard \
|
||||
$(srcdir)/include/*.h \
|
||||
$(srcdir)/src/*.h )
|
||||
CPPCHECK_YL = $(wildcard \
|
||||
CHECK_YL = $(wildcard \
|
||||
$(srcdir)/src/*.y \
|
||||
$(srcdir)/src/*.l )
|
||||
CPPCHECK = src/cppcheck_filtered cppcheck
|
||||
CPPCHECK_FLAGS = --enable=all --inline-suppr \
|
||||
--suppress=unusedScopedObject --suppress=cstyleCast --suppress=useInitializationList \
|
||||
--suppress=nullPointerRedundantCheck
|
||||
--suppress=cstyleCast --suppress=useInitializationList \
|
||||
--suppress=nullPointer --suppress=nullPointerRedundantCheck --suppress=ctunullpointer \
|
||||
--suppress=unusedFunction --suppress=unusedScopedObject \
|
||||
--suppress=useStlAlgorithm
|
||||
CPPCHECK_FLAGS += --xml
|
||||
CPPCHECK_DEP = $(subst .cpp,.cppcheck,$(CPPCHECK_CPP))
|
||||
CPPCHECK_DEP = $(subst .cpp,.cppcheck,$(CHECK_CPP))
|
||||
CPPCHECK_INC = -I$(srcdir)/include -I$(srcdir)/src/obj_dbg -I$(srcdir)/src
|
||||
|
||||
cppcheck: $(CPPCHECK_DEP)
|
||||
%.cppcheck: %.cpp
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $<
|
||||
cppcheck: cppcheck-1 cppcheck-2 cppcheck-3 cppcheck-4 cppcheck-5 cppcheck-6 cppcheck-7 cppcheck-8
|
||||
cppcheck-1:
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $(CPPCHECK1_CPP)
|
||||
cppcheck-2:
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $(CPPCHECK2_CPP)
|
||||
cppcheck-3:
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $(CPPCHECK3_CPP)
|
||||
cppcheck-4:
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $(CPPCHECK4_CPP)
|
||||
cppcheck-5:
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $(CPPCHECK5_CPP)
|
||||
cppcheck-6:
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $(CPPCHECK6_CPP)
|
||||
cppcheck-7:
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $(CPPCHECK7_CPP)
|
||||
cppcheck-8:
|
||||
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $(CPPCHECK8_CPP)
|
||||
|
||||
CLANGTIDY = clang-tidy
|
||||
CLANGTIDY_FLAGS = -config='' \
|
||||
-header-filter='.*' \
|
||||
-checks='-fuchsia-*,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables,-cppcoreguidelines-avoid-goto,-modernize-avoid-c-arrays,-readability-magic-numbers,-readability-simplify-boolean-expr,-cppcoreguidelines-macro-usage' \
|
||||
|
||||
CLANGTIDY_DEP = $(subst .cpp,.cpp.tidy,$(CPPCHECK_CPP))
|
||||
CLANGTIDY_DEP = $(subst .cpp,.cpp.tidy,$(CHECK_CPP))
|
||||
CLANGTIDY_DEFS = -DVL_DEBUG=1 -DVL_CPPCHECK=1
|
||||
|
||||
clang-tidy: $(CLANGTIDY_DEP)
|
||||
@ -350,7 +372,7 @@ format: clang-format yapf format-pl-exec
|
||||
|
||||
CLANGFORMAT = clang-format-14
|
||||
CLANGFORMAT_FLAGS = -i
|
||||
CLANGFORMAT_FILES = $(CPPCHECK_CPP) $(CPPCHECK_H) $(CPPCHECK_YL) test_regress/t/*.c* test_regress/t/*.h
|
||||
CLANGFORMAT_FILES = $(CHECK_CPP) $(CHECK_H) $(CHECK_YL) test_regress/t/*.c* test_regress/t/*.h
|
||||
|
||||
clang-format:
|
||||
@$(CLANGFORMAT) --version | egrep 14.0 > /dev/null \
|
||||
|
@ -491,11 +491,11 @@ WDataOutP VL_POW_WWW(int obits, int, int rbits, WDataOutP owp, const WDataInP lw
|
||||
// obits==lbits, rbits can be different
|
||||
owp[0] = 1;
|
||||
for (int i = 1; i < VL_WORDS_I(obits); i++) owp[i] = 0;
|
||||
// cppcheck-suppress variableScope
|
||||
// cppcheck-has-bug-suppress variableScope
|
||||
VlWide<VL_MULS_MAX_WORDS> powstore; // Fixed size, as MSVC++ doesn't allow [words] here
|
||||
VlWide<VL_MULS_MAX_WORDS> lastpowstore; // Fixed size, as MSVC++ doesn't allow [words] here
|
||||
VlWide<VL_MULS_MAX_WORDS> lastoutstore; // Fixed size, as MSVC++ doesn't allow [words] here
|
||||
// cppcheck-suppress variableScope
|
||||
// cppcheck-has-bug-suppress variableScope
|
||||
VL_ASSIGN_W(obits, powstore, lwp);
|
||||
for (int bit = 0; bit < rbits; bit++) {
|
||||
if (bit > 0) { // power = power*power
|
||||
@ -1227,7 +1227,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
_vl_vsss_skipspace(fp, floc, fromp, fstr);
|
||||
_vl_vsss_read_str(fp, floc, fromp, fstr, t_tmp, "+-.0123456789eE");
|
||||
if (!t_tmp[0]) goto done;
|
||||
// cppcheck-suppress unusedStructMember // It's used
|
||||
// cppcheck-has-bug-suppress unusedStructMember, unreadVariable
|
||||
union {
|
||||
double r;
|
||||
int64_t ld;
|
||||
@ -1682,7 +1682,7 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M
|
||||
inPct = true;
|
||||
} else if (!inPct) { // Normal text
|
||||
prefix += *posp;
|
||||
} else if (inPct && posp[0] == '0') { // %0
|
||||
} else if (*posp == '0') { // %0
|
||||
} else { // Format character
|
||||
switch (std::tolower(*posp)) {
|
||||
case '%':
|
||||
@ -1906,7 +1906,7 @@ VlReadMem::VlReadMem(bool hex, int bits, const std::string& filename, QData star
|
||||
if (VL_UNLIKELY(!m_fp)) {
|
||||
// We don't report the Verilog source filename as it slow to have to pass it down
|
||||
VL_WARN_MT(filename.c_str(), 0, "", "$readmem file not found");
|
||||
// cppcheck-suppress resourceLeak // m_fp is nullptr - bug in cppcheck
|
||||
// cppcheck-has-bug-suppress resourceLeak // m_fp is nullptr
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2044,7 +2044,7 @@ VlWriteMem::VlWriteMem(bool hex, int bits, const std::string& filename, QData st
|
||||
m_fp = std::fopen(filename.c_str(), "w");
|
||||
if (VL_UNLIKELY(!m_fp)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$writemem file not found");
|
||||
// cppcheck-suppress resourceLeak // m_fp is nullptr - bug in cppcheck
|
||||
// cppcheck-has-bug-suppress resourceLeak // m_fp is nullptr
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2227,6 +2227,7 @@ static const char* vl_time_str(int scale) VL_PURE {
|
||||
double vl_time_multiplier(int scale) VL_PURE {
|
||||
// Return timescale multipler -18 to +18
|
||||
// For speed, this does not check for illegal values
|
||||
// cppcheck-has-bug-suppress arrayIndexOutOfBoundsCond
|
||||
if (scale < 0) {
|
||||
static const double neg10[] = {1.0,
|
||||
0.1,
|
||||
@ -2247,6 +2248,7 @@ double vl_time_multiplier(int scale) VL_PURE {
|
||||
0.0000000000000001,
|
||||
0.00000000000000001,
|
||||
0.000000000000000001};
|
||||
// cppcheck-has-bug-suppress arrayIndexOutOfBoundsCond
|
||||
return neg10[-scale];
|
||||
} else {
|
||||
static const double pow10[] = {1.0,
|
||||
@ -2268,6 +2270,7 @@ double vl_time_multiplier(int scale) VL_PURE {
|
||||
10000000000000000.0,
|
||||
100000000000000000.0,
|
||||
1000000000000000000.0};
|
||||
// cppcheck-has-bug-suppress arrayIndexOutOfBoundsCond
|
||||
return pow10[scale];
|
||||
}
|
||||
}
|
||||
@ -2754,6 +2757,7 @@ VerilatedSyms::VerilatedSyms(VerilatedContext* contextp)
|
||||
: _vm_contextp__(contextp ? contextp : Verilated::threadContextp()) {
|
||||
VerilatedContext::checkMagic(_vm_contextp__);
|
||||
Verilated::threadContextp(_vm_contextp__);
|
||||
// cppcheck-has-bug-suppress noCopyConstructor
|
||||
__Vm_evalMsgQp = new VerilatedEvalMsgQueue;
|
||||
}
|
||||
|
||||
|
@ -274,6 +274,7 @@ extern uint64_t vl_time_stamp64() VL_ATTR_WEAK;
|
||||
extern double sc_time_stamp() VL_ATTR_WEAK; // Verilator 4.032 and newer
|
||||
inline uint64_t vl_time_stamp64() {
|
||||
// clang9.0.1 requires & although we really do want the weak symbol value
|
||||
// cppcheck-suppress duplicateValueTernary
|
||||
return VL_LIKELY(&sc_time_stamp) ? static_cast<uint64_t>(sc_time_stamp()) : 0;
|
||||
}
|
||||
# endif
|
||||
@ -593,6 +594,7 @@ static inline IData VL_REDAND_IW(int lbits, WDataInP const lwp) VL_PURE {
|
||||
EData combine = lwp[0];
|
||||
for (int i = 1; i < words - 1; ++i) combine &= lwp[i];
|
||||
combine &= ~VL_MASK_E(lbits) | lwp[words - 1];
|
||||
// cppcheck-has-bug-suppress knownConditionTrueFalse
|
||||
return ((~combine) == 0);
|
||||
}
|
||||
|
||||
@ -1024,12 +1026,14 @@ static inline WDataOutP VL_MULS_WWW(int lbits, WDataOutP owp, WDataInP const lwp
|
||||
if (lneg) { // Negate lhs
|
||||
lwusp = lwstore;
|
||||
VL_NEGATE_W(words, lwstore, lwp);
|
||||
// cppcheck-has-bug-suppress unreadVariable
|
||||
lwstore[words - 1] &= VL_MASK_E(lbits); // Clean it
|
||||
}
|
||||
const EData rneg = VL_SIGN_E(lbits, rwp[words - 1]);
|
||||
if (rneg) { // Negate rhs
|
||||
rwusp = rwstore;
|
||||
VL_NEGATE_W(words, rwstore, rwp);
|
||||
// cppcheck-has-bug-suppress unreadVariable
|
||||
rwstore[words - 1] &= VL_MASK_E(lbits); // Clean it
|
||||
}
|
||||
VL_MUL_W(words, owp, lwusp, rwusp);
|
||||
|
@ -362,7 +362,7 @@ public: // But only for verilated*.cpp
|
||||
private:
|
||||
VerilatedFpList fdToFpList(IData fdi) VL_REQUIRES(m_fdMutex) {
|
||||
VerilatedFpList fp;
|
||||
// cppcheck-suppress integeroverflow shifttoomanybitssigned
|
||||
// cppverilator-suppress integerOverflow shiftTooManyBitsSigned
|
||||
if ((fdi & (1 << 31)) != 0) {
|
||||
// Non-MCD case
|
||||
const IData idx = fdi & VL_MASK_I(31);
|
||||
|
@ -852,6 +852,7 @@ void AstNode::iterateAndNext(VNVisitor& v) {
|
||||
#ifdef VL_DEBUG // Otherwise too hot of a function for debug
|
||||
UASSERT_OBJ(!(nodep && !nodep->m_backp), nodep, "iterateAndNext node has no back");
|
||||
#endif
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (nodep) ASTNODE_PREFETCH(nodep->m_nextp);
|
||||
while (nodep) { // effectively: if (!this) return; // Callers rely on this
|
||||
if (nodep->m_nextp) ASTNODE_PREFETCH(nodep->m_nextp->m_nextp);
|
||||
|
@ -1464,9 +1464,11 @@ public:
|
||||
string emitC() override {
|
||||
return m_reset ? "VL_RAND_RESET_%nq(%nw, %P)"
|
||||
: seedp()
|
||||
? (urandom() ? "VL_URANDOM_SEEDED_%nq%lq(%li)" : "VL_RANDOM_SEEDED_%nq%lq(%li)")
|
||||
: isWide() ? "VL_RANDOM_%nq(%nw, %P)" //
|
||||
: "VL_RANDOM_%nq()";
|
||||
// cppcheck-has-bug-suppress knownConditionTrueFalse
|
||||
? (urandom() ? "VL_URANDOM_SEEDED_%nq%lq(%li)" //
|
||||
: "VL_RANDOM_SEEDED_%nq%lq(%li)")
|
||||
: (isWide() ? "VL_RANDOM_%nq(%nw, %P)" //
|
||||
: "VL_RANDOM_%nq()");
|
||||
}
|
||||
bool cleanOut() const override { return false; }
|
||||
bool isGateOptimizable() const override { return false; }
|
||||
|
@ -1193,6 +1193,7 @@ AstVarScope* AstConstPool::findTable(AstInitArray* initp) {
|
||||
UASSERT_OBJ(VN_IS(valuep, Const), valuep, "Const pool table entry must be Const");
|
||||
}
|
||||
// Try to find an existing table with the same content
|
||||
// cppcheck-has-bug-suppress unreadVariable
|
||||
const V3Hash hash = V3Hasher::uncachedHash(initp);
|
||||
const auto& er = m_tables.equal_range(hash.value());
|
||||
for (auto it = er.first; it != er.second; ++it) {
|
||||
@ -1222,6 +1223,7 @@ static bool sameInit(const AstConst* ap, const AstConst* bp) {
|
||||
|
||||
AstVarScope* AstConstPool::findConst(AstConst* initp, bool mergeDType) {
|
||||
// Try to find an existing constant with the same value
|
||||
// cppcheck-has-bug-suppress unreadVariable
|
||||
const V3Hash hash = initp->num().toHash();
|
||||
const auto& er = m_consts.equal_range(hash.value());
|
||||
for (auto it = er.first; it != er.second; ++it) {
|
||||
|
@ -255,12 +255,14 @@ private:
|
||||
// There's no space for a IF. We know upperValue is thus down to a specific
|
||||
// exact value, so just return the tree value
|
||||
// Note can't clone here, as we're going to check for equivalence above
|
||||
return m_valueItem[upperValue];
|
||||
AstNode* const foundp = m_valueItem[upperValue];
|
||||
return foundp;
|
||||
} else {
|
||||
// Make left and right subtrees
|
||||
// cexpr[msb:lsb] == 1
|
||||
AstNode* tree0p = replaceCaseFastRecurse(cexprp, msb - 1, upperValue | 0);
|
||||
AstNode* tree1p = replaceCaseFastRecurse(cexprp, msb - 1, upperValue | (1UL << msb));
|
||||
AstNode* tree1p = replaceCaseFastRecurse(
|
||||
cexprp, msb - 1, upperValue | (1UL << static_cast<uint32_t>(msb)));
|
||||
|
||||
if (tree0p == tree1p) {
|
||||
// Same logic on both sides, so we can just return one of 'em
|
||||
|
@ -558,8 +558,7 @@ private:
|
||||
} // Fully computed
|
||||
|
||||
std::set<AstSenTree*> senouts; // List of all sensitivities for new signal
|
||||
if (const CdcLogicVertex* const vvertexp = dynamic_cast<CdcLogicVertex*>(vertexp)) {
|
||||
if (vvertexp) {} // Unused
|
||||
if (dynamic_cast<CdcLogicVertex*>(vertexp)) {
|
||||
} else if (const CdcVarVertex* const vvertexp = dynamic_cast<CdcVarVertex*>(vertexp)) {
|
||||
// If primary I/O, give it domain of the input
|
||||
const AstVar* const varp = vvertexp->varScp()->varp();
|
||||
|
@ -101,10 +101,10 @@ class DfgGraph final {
|
||||
DfgGraph* m_graphp; // The referenced graph
|
||||
|
||||
public:
|
||||
UserDataInUse(DfgGraph* graphp)
|
||||
explicit UserDataInUse(DfgGraph* graphp)
|
||||
: m_graphp{graphp} {}
|
||||
VL_UNCOPYABLE(UserDataInUse);
|
||||
UserDataInUse(UserDataInUse&& that) {
|
||||
explicit UserDataInUse(UserDataInUse&& that) {
|
||||
UASSERT(that.m_graphp, "Moving from empty");
|
||||
m_graphp = vlstd::exchange(that.m_graphp, nullptr);
|
||||
}
|
||||
@ -353,6 +353,7 @@ public:
|
||||
UDEBUGONLY(UASSERT_OBJ(userCurrent, this, "DfgVertex user data used without reserving"););
|
||||
if (m_userCnt != userCurrent) {
|
||||
m_userCnt = userCurrent;
|
||||
// cppcheck-has-bug-suppress uninitvar
|
||||
VL_ATTR_UNUSED T* const resultp = new (storagep) T{};
|
||||
UDEBUGONLY(UASSERT_OBJ(resultp == storagep, this, "Something is odd"););
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class SplitIntoComponents final {
|
||||
}
|
||||
}
|
||||
|
||||
SplitIntoComponents(DfgGraph& dfg, std::string label)
|
||||
SplitIntoComponents(DfgGraph& dfg, const std::string& label)
|
||||
: m_dfg{dfg}
|
||||
, m_prefix{dfg.name() + (label.empty() ? "" : "-") + label + "-component-"} {
|
||||
// Component number is stored as DfgVertex::user<size_t>()
|
||||
@ -356,6 +356,7 @@ class ExtractCyclicComponents final {
|
||||
// Unlink the source edge (source is reconnected by 'relink'
|
||||
edge.unlinkSource();
|
||||
// Apply the fixup
|
||||
// cppcheck-has-bug-suppress constVariable
|
||||
DfgVertexVar& clone = getClone(vtx, sourceComponent);
|
||||
relink(*(clone.as<T_Vertex>()), source, idx);
|
||||
});
|
||||
@ -517,7 +518,7 @@ class ExtractCyclicComponents final {
|
||||
}
|
||||
|
||||
// CONSTRUCTOR - entry point
|
||||
explicit ExtractCyclicComponents(DfgGraph& dfg, std::string label)
|
||||
explicit ExtractCyclicComponents(DfgGraph& dfg, const std::string& label)
|
||||
: m_dfg{dfg}
|
||||
, m_prefix{dfg.name() + (label.empty() ? "" : "-") + label + "-component-"} {
|
||||
// VertexState is stored as user data
|
||||
|
@ -283,7 +283,7 @@ void V3DfgPasses::optimize(DfgGraph& dfg, V3DfgOptimizationContext& ctx) {
|
||||
|
||||
int passNumber = 0;
|
||||
|
||||
const auto apply = [&](int dumpLevel, const string name, std::function<void()> pass) {
|
||||
const auto apply = [&](int dumpLevel, const string& name, std::function<void()> pass) {
|
||||
pass();
|
||||
if (dumpDfg() >= dumpLevel) {
|
||||
const string strippedName = VString::removeWhitespace(name);
|
||||
|
@ -322,10 +322,8 @@ class EmitCSyms final : EmitCBaseVisitor {
|
||||
// UINFO(9,"scnameins sp "<<nodep->name()<<" sp "<<nodep->scopePrettySymName()
|
||||
// <<" ss"<<name<<endl);
|
||||
const int timeunit = m_modp ? m_modp->timeunit().powerOfTen() : 0;
|
||||
if (m_scopeNames.find(name) == m_scopeNames.end()) {
|
||||
m_scopeNames.emplace(
|
||||
name, ScopeData(name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER"));
|
||||
}
|
||||
m_scopeNames.emplace(
|
||||
name, ScopeData(name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER"));
|
||||
if (nodep->dpiExport()) {
|
||||
UASSERT_OBJ(m_cfuncp, nodep, "ScopeName not under DPI function");
|
||||
m_scopeFuncs.insert(std::make_pair(name + " " + m_cfuncp->name(),
|
||||
@ -984,7 +982,7 @@ void EmitCSyms::emitDpiHdr() {
|
||||
const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.h";
|
||||
AstCFile* const cfilep = newCFile(filename, false /*slow*/, false /*source*/);
|
||||
cfilep->support(true);
|
||||
V3OutCFile hf(filename);
|
||||
V3OutCFile hf{filename};
|
||||
m_ofp = &hf;
|
||||
|
||||
m_ofp->putsHeader();
|
||||
@ -1029,6 +1027,7 @@ void EmitCSyms::emitDpiHdr() {
|
||||
puts("#endif\n");
|
||||
|
||||
ofp()->putsEndGuard();
|
||||
m_ofp = nullptr;
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
@ -1083,6 +1082,7 @@ void EmitCSyms::emitDpiImp() {
|
||||
puts("\n");
|
||||
}
|
||||
}
|
||||
m_ofp = nullptr;
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
|
@ -740,10 +740,7 @@ public:
|
||||
// Emit to an output file
|
||||
|
||||
class EmitVFileVisitor final : public EmitVBaseVisitor {
|
||||
// MEMBERS
|
||||
V3OutFile* m_ofp;
|
||||
// METHODS
|
||||
V3OutFile* ofp() const { return m_ofp; }
|
||||
void puts(const string& str) override { ofp()->puts(str); }
|
||||
void putbs(const string& str) override { ofp()->putbs(str); }
|
||||
void putfs(AstNode*, const string& str) override { putbs(str); }
|
||||
@ -751,9 +748,9 @@ class EmitVFileVisitor final : public EmitVBaseVisitor {
|
||||
void putsNoTracking(const string& str) override { ofp()->putsNoTracking(str); }
|
||||
|
||||
public:
|
||||
EmitVFileVisitor(AstNode* nodep, V3OutFile* ofp, bool trackText, bool suppressUnknown)
|
||||
: EmitVBaseVisitor{suppressUnknown, nullptr}
|
||||
, m_ofp{ofp} {
|
||||
EmitVFileVisitor(AstNode* nodep, V3OutVFile* ofp, bool trackText, bool suppressUnknown)
|
||||
: EmitVBaseVisitor{suppressUnknown, nullptr} {
|
||||
m_ofp = ofp;
|
||||
m_trackText = trackText;
|
||||
iterate(nodep);
|
||||
}
|
||||
|
@ -184,6 +184,7 @@ void V3Error::suppressThisWarning() {
|
||||
|
||||
string V3Error::warnMore() { return string(msgPrefix().size(), ' '); }
|
||||
|
||||
// cppcheck-has-bug-suppress constParameter
|
||||
void V3Error::v3errorEnd(std::ostringstream& sstr, const string& extra) {
|
||||
#if defined(__COVERITY__) || defined(__cppcheck__)
|
||||
if (s_errorCode == V3ErrorCode::EC_FATAL) __coverity_panic__(x);
|
||||
|
@ -122,20 +122,16 @@ class V3FileDependImp final {
|
||||
public:
|
||||
// ACCESSOR METHODS
|
||||
void addSrcDepend(const string& filename) {
|
||||
if (m_filenameSet.find(filename) == m_filenameSet.end()) {
|
||||
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
|
||||
m_filenameSet.insert(filename);
|
||||
const auto itFoundPair = m_filenameSet.insert(filename);
|
||||
if (itFoundPair.second) {
|
||||
DependFile df{filename, false};
|
||||
df.loadStats(); // Get size now, in case changes during the run
|
||||
m_filenameList.insert(df);
|
||||
}
|
||||
}
|
||||
void addTgtDepend(const string& filename) {
|
||||
if (m_filenameSet.find(filename) == m_filenameSet.end()) {
|
||||
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
|
||||
m_filenameSet.insert(filename);
|
||||
m_filenameList.insert(DependFile{filename, true});
|
||||
}
|
||||
const auto itFoundPair = m_filenameSet.insert(filename);
|
||||
if (itFoundPair.second) m_filenameList.insert(DependFile{filename, true});
|
||||
}
|
||||
void writeDepend(const string& filename);
|
||||
std::vector<string> getAllDeps() const;
|
||||
@ -424,7 +420,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
// cppcheck-suppress unusedFunction unusedPrivateFunction
|
||||
// cppverilator-suppress unusedFunction unusedPrivateFunction
|
||||
string readFilterLine() {
|
||||
// Slow, but we don't need it much
|
||||
UINFO(9, "readFilterLine\n");
|
||||
@ -446,7 +442,7 @@ private:
|
||||
UINFO(6, "filter-line-in: " << line);
|
||||
return line;
|
||||
}
|
||||
// cppcheck-suppress unusedFunction unusedPrivateFunction
|
||||
// cppverilator-suppress unusedFunction unusedPrivateFunction
|
||||
void writeFilter(const string& out) {
|
||||
if (debug() >= 6) {
|
||||
UINFO(6, "filter-out: " << out);
|
||||
|
@ -242,8 +242,9 @@ class V3OutCFile VL_NOT_FINAL : public V3OutFile {
|
||||
int m_guard = false; // Created header guard
|
||||
int m_private; // 1 = Most recently emitted private:, 2 = public:
|
||||
public:
|
||||
explicit V3OutCFile(const string& filename)
|
||||
: V3OutFile{filename, V3OutFormatter::LA_C} {
|
||||
explicit V3OutCFile(const string& filename,
|
||||
V3OutFormatter::Language lang = V3OutFormatter::LA_C)
|
||||
: V3OutFile{filename, lang} {
|
||||
resetPrivate();
|
||||
}
|
||||
~V3OutCFile() override = default;
|
||||
@ -279,10 +280,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class V3OutVFile final : public V3OutFile {
|
||||
class V3OutVFile final : public V3OutCFile {
|
||||
public:
|
||||
explicit V3OutVFile(const string& filename)
|
||||
: V3OutFile{filename, V3OutFormatter::LA_VERILOG} {}
|
||||
: V3OutCFile{filename, V3OutFormatter::LA_VERILOG} {}
|
||||
~V3OutVFile() override = default;
|
||||
virtual void putsHeader() { puts("// Verilated -*- Verilog -*-\n"); }
|
||||
};
|
||||
|
@ -379,6 +379,7 @@ bool FileLine::warnIsOff(V3ErrorCode code) const VL_MT_SAFE {
|
||||
return false;
|
||||
}
|
||||
|
||||
// cppverilator-suppress constParameter
|
||||
void FileLine::v3errorEnd(std::ostringstream& sstr, const string& extra) {
|
||||
std::ostringstream nsstr;
|
||||
if (lastLineno()) nsstr << this;
|
||||
|
@ -128,6 +128,7 @@ V3GraphEdge* V3GraphVertex::findConnectingEdgep(GraphWay way, const V3GraphVerte
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// cppcheck-has-bug-suppress constParameter
|
||||
void V3GraphVertex::v3errorEnd(std::ostringstream& str) const {
|
||||
std::ostringstream nsstr;
|
||||
nsstr << str.str();
|
||||
@ -300,7 +301,7 @@ void V3Graph::dump(std::ostream& os) {
|
||||
}
|
||||
}
|
||||
|
||||
void V3Graph::dumpEdge(std::ostream& os, V3GraphVertex* vertexp, V3GraphEdge* edgep) {
|
||||
void V3Graph::dumpEdge(std::ostream& os, const V3GraphVertex* vertexp, const V3GraphEdge* edgep) {
|
||||
if (edgep->weight() && (edgep->fromp() == vertexp || edgep->top() == vertexp)) {
|
||||
os << "\t\t";
|
||||
if (edgep->fromp() == vertexp) os << "-> " << edgep->top()->name();
|
||||
|
@ -88,7 +88,7 @@ protected:
|
||||
friend class GraphAcyc;
|
||||
// METHODS
|
||||
double orderDFSIterate(V3GraphVertex* vertexp);
|
||||
void dumpEdge(std::ostream& os, V3GraphVertex* vertexp, V3GraphEdge* edgep);
|
||||
void dumpEdge(std::ostream& os, const V3GraphVertex* vertexp, const V3GraphEdge* edgep);
|
||||
void verticesUnlink() { m_vertices.reset(); }
|
||||
// ACCESSORS
|
||||
|
||||
|
@ -197,8 +197,8 @@ private:
|
||||
&& !nodep->internal()) {
|
||||
// We only complain once per file, otherwise library-like files
|
||||
// have a huge mess of warnings
|
||||
if (m_declfnWarned.find(nodep->fileline()->filename()) == m_declfnWarned.end()) {
|
||||
m_declfnWarned.insert(nodep->fileline()->filename());
|
||||
const auto itFoundPair = m_declfnWarned.insert(nodep->fileline()->filename());
|
||||
if (itFoundPair.second) {
|
||||
nodep->v3warn(DECLFILENAME, "Filename '"
|
||||
<< nodep->fileline()->filebasenameNoExt()
|
||||
<< "' does not match " << nodep->typeName()
|
||||
|
@ -1140,7 +1140,7 @@ class LinkDotFindVisitor final : public VNVisitor {
|
||||
bool ins = false;
|
||||
if (!foundp) {
|
||||
ins = true;
|
||||
} else if (!findvarp && foundp && m_curSymp->findIdFlat(nodep->name())) {
|
||||
} else if (!findvarp && m_curSymp->findIdFlat(nodep->name())) {
|
||||
nodep->v3error("Unsupported in C: Variable has same name as "
|
||||
<< LinkDotState::nodeTextType(foundp->nodep()) << ": "
|
||||
<< nodep->prettyNameQ());
|
||||
|
@ -267,10 +267,8 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
|
||||
varp->protect(false);
|
||||
newmodp->addStmtsp(varp);
|
||||
varp->sigPublic(true); // User needs to be able to get to it...
|
||||
if (oldvarp->isIO()) {
|
||||
oldvarp->primaryIO(false);
|
||||
varp->primaryIO(true);
|
||||
}
|
||||
oldvarp->primaryIO(false);
|
||||
varp->primaryIO(true);
|
||||
if (varp->direction().isRefOrConstRef()) {
|
||||
varp->v3warn(E_UNSUPPORTED,
|
||||
"Unsupported: ref/const ref as primary input/output: "
|
||||
|
@ -491,7 +491,10 @@ private:
|
||||
|
||||
// Close pending merge, if there is one at the end of the whole sub-tree list
|
||||
if (m_mgFirstp) mergeEnd();
|
||||
m_stmtPropertiesp = nullptr;
|
||||
} while (!m_workQueuep->empty());
|
||||
|
||||
m_workQueuep = nullptr;
|
||||
}
|
||||
|
||||
// Skip past AstArraySel and AstWordSel with const index
|
||||
@ -716,6 +719,7 @@ private:
|
||||
iterateAndNextNull(recursivep->elsesp());
|
||||
// Close a pending merge to ensure merge state is
|
||||
// reset as expected at the end of this function
|
||||
// cppcheck-has-bug-suppress knownConditionTrueFalse
|
||||
if (m_mgFirstp) mergeEnd();
|
||||
}
|
||||
}
|
||||
|
@ -75,9 +75,9 @@ public:
|
||||
|
||||
// ACCESSOR METHODS
|
||||
void addIncDirUser(const string& incdir) {
|
||||
if (m_incDirUserSet.find(incdir) == m_incDirUserSet.end()) {
|
||||
const auto itFoundPair = m_incDirUserSet.insert(incdir);
|
||||
if (itFoundPair.second) {
|
||||
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
|
||||
m_incDirUserSet.insert(incdir);
|
||||
m_incDirUsers.push_back(incdir);
|
||||
m_incDirFallbacks.remove(incdir); // User has priority over Fallback
|
||||
m_incDirFallbackSet.erase(incdir); // User has priority over Fallback
|
||||
@ -86,11 +86,8 @@ public:
|
||||
void addIncDirFallback(const string& incdir) {
|
||||
if (m_incDirUserSet.find(incdir)
|
||||
== m_incDirUserSet.end()) { // User has priority over Fallback
|
||||
if (m_incDirFallbackSet.find(incdir) == m_incDirFallbackSet.end()) {
|
||||
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
|
||||
m_incDirFallbackSet.insert(incdir);
|
||||
m_incDirFallbacks.push_back(incdir);
|
||||
}
|
||||
const auto itFoundPair = m_incDirFallbackSet.insert(incdir);
|
||||
if (itFoundPair.second) m_incDirFallbacks.push_back(incdir);
|
||||
}
|
||||
}
|
||||
void addLangExt(const string& langext, const V3LangCode& lc) {
|
||||
@ -100,11 +97,8 @@ public:
|
||||
}
|
||||
|
||||
void addLibExtV(const string& libext) {
|
||||
if (m_libExtVSet.find(libext) == m_libExtVSet.end()) {
|
||||
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
|
||||
m_libExtVSet.insert(libext);
|
||||
m_libExtVs.push_back(libext);
|
||||
}
|
||||
const auto itFoundPair = m_libExtVSet.insert(libext);
|
||||
if (itFoundPair.second) m_libExtVs.push_back(libext);
|
||||
}
|
||||
V3OptionsImp() = default;
|
||||
~V3OptionsImp() = default;
|
||||
|
@ -155,6 +155,7 @@ string V3Os::filenameNonExt(const string& filename) {
|
||||
|
||||
string V3Os::filenameSubstitute(const string& filename) {
|
||||
string out;
|
||||
// cppcheck-has-bug-suppress unusedLabel
|
||||
enum : uint8_t { NONE, PAREN, CURLY } brackets = NONE;
|
||||
for (string::size_type pos = 0; pos < filename.length(); ++pos) {
|
||||
if ((filename[pos] == '$') && (pos + 1 < filename.length())) {
|
||||
|
@ -342,8 +342,10 @@ class ParamProcessor final {
|
||||
// particularly robust for type parameters. We should really have a type
|
||||
// equivalence predicate function.
|
||||
const string key = paramValueKey(nodep);
|
||||
// cppcheck-has-bug-suppress unreadVariable
|
||||
V3Hash hash = V3Hasher::uncachedHash(nodep);
|
||||
// Force hash collisions -- for testing only
|
||||
// cppcheck-has-bug-suppress unreadVariable
|
||||
if (VL_UNLIKELY(v3Global.opt.debugCollision())) hash = V3Hash{};
|
||||
int num;
|
||||
const auto it = m_valueMap.find(hash);
|
||||
|
@ -142,7 +142,7 @@ class V3ParseImp final {
|
||||
static V3ParseImp* s_parsep; // Current THIS, bison() isn't class based
|
||||
FileLine* m_lexFileline = nullptr; // Filename/linenumber currently active for lexing
|
||||
|
||||
FileLine* m_bisonLastFileline; // Filename/linenumber of last token
|
||||
FileLine* m_bisonLastFileline = nullptr; // Filename/linenumber of last token
|
||||
|
||||
bool m_inLibrary = false; // Currently reading a library vs. regular file
|
||||
int m_lexKwdDepth = 0; // Inside a `begin_keywords
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
void reinsert(AstNode* nodep, VSymEnt* parentp = nullptr) {
|
||||
reinsert(nodep, parentp, nodep->name());
|
||||
}
|
||||
// cppcheck-suppress passedByValue
|
||||
void reinsert(AstNode* nodep, VSymEnt* parentp, string name) {
|
||||
if (!parentp) parentp = symCurrentp();
|
||||
if (name == "") { // New name with space in name so can't collide with users
|
||||
|
@ -176,7 +176,7 @@ public: // Used only by V3PreLex.cpp and V3PreProc.cpp
|
||||
int m_enterExit = 0; // For VL_LINE, the enter/exit level
|
||||
int m_protLength = 0; // unencoded length for BASE64
|
||||
int m_protBytes = 0; // decoded length for BASE64
|
||||
Enctype m_encType; // encoding type for `pragma protect
|
||||
Enctype m_encType{}; // encoding type for `pragma protect
|
||||
|
||||
// CONSTRUCTORS
|
||||
V3PreLex(V3PreProcImp* preimpp, FileLine* filelinep)
|
||||
|
@ -90,6 +90,7 @@ private:
|
||||
|
||||
iterateChildren(nodep);
|
||||
|
||||
// cppcheck-has-bug-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");
|
||||
|
@ -493,12 +493,12 @@ const TriggerKit createTriggers(AstNetlist* netlistp, AstCFunc* const initFuncp,
|
||||
|
||||
// Add the initialization statements
|
||||
if (initialTrigsp) {
|
||||
AstVarScope* const vscp = scopeTopp->createTemp("__V" + name + "DidInit", 1);
|
||||
AstVarRef* const condp = new AstVarRef{flp, vscp, VAccess::READ};
|
||||
AstVarScope* const tempVscp = scopeTopp->createTemp("__V" + name + "DidInit", 1);
|
||||
AstVarRef* const condp = new AstVarRef{flp, tempVscp, VAccess::READ};
|
||||
AstIf* const ifp = new AstIf{flp, new AstNot{flp, condp}};
|
||||
funcp->addStmtsp(ifp);
|
||||
ifp->branchPred(VBranchPred::BP_UNLIKELY);
|
||||
ifp->addThensp(setVar(vscp, 1));
|
||||
ifp->addThensp(setVar(tempVscp, 1));
|
||||
ifp->addThensp(initialTrigsp);
|
||||
}
|
||||
|
||||
@ -574,10 +574,10 @@ std::pair<AstVarScope*, AstNodeStmt*> makeEvalLoop(AstNetlist* netlistp, const s
|
||||
// If we exceeded the iteration limit, die
|
||||
{
|
||||
const uint32_t limit = v3Global.opt.convergeLimit();
|
||||
AstVarRef* const refp = new AstVarRef{flp, counterp, VAccess::READ};
|
||||
AstVarRef* const counterRefp = new AstVarRef{flp, counterp, VAccess::READ};
|
||||
AstConst* const constp = new AstConst{flp, AstConst::DTyped{}, counterp->dtypep()};
|
||||
constp->num().setLong(limit);
|
||||
AstNodeExpr* const condp = new AstGt{flp, refp, constp};
|
||||
AstNodeExpr* const condp = new AstGt{flp, counterRefp, constp};
|
||||
AstIf* const failp = new AstIf{flp, condp};
|
||||
failp->branchPred(VBranchPred::BP_UNLIKELY);
|
||||
ifp->addThensp(failp);
|
||||
@ -588,9 +588,9 @@ std::pair<AstVarScope*, AstNodeStmt*> makeEvalLoop(AstNetlist* netlistp, const s
|
||||
const string& line = cvtToStr(locp->lineno());
|
||||
const auto add = [&](const string& text) { blockp->addText(flp, text, true); };
|
||||
add("#ifdef VL_DEBUG\n");
|
||||
AstCCall* const callp = new AstCCall{flp, trigDumpp};
|
||||
callp->dtypeSetVoid();
|
||||
blockp->addNodesp(callp->makeStmt());
|
||||
AstCCall* const newcallp = new AstCCall{flp, trigDumpp};
|
||||
newcallp->dtypeSetVoid();
|
||||
blockp->addNodesp(newcallp->makeStmt());
|
||||
add("#endif\n");
|
||||
add("VL_FATAL_MT(\"" + file + "\", " + line + ", \"\", ");
|
||||
add("\"" + name + " region did not converge.\");\n");
|
||||
|
@ -296,7 +296,6 @@ void transformForks(AstNetlist* const netlistp) {
|
||||
AstVarScope* const vscp = refp->varScopep();
|
||||
if (!vscp->user2p()) {
|
||||
// Clone the var to the new function
|
||||
AstVar* const varp = refp->varp();
|
||||
AstVar* const newvarp
|
||||
= new AstVar{varp->fileline(), VVarType::BLOCKTEMP, varp->name(), varp};
|
||||
newvarp->funcLocal(true);
|
||||
@ -308,7 +307,7 @@ void transformForks(AstNetlist* const netlistp) {
|
||||
vscp->user2p(newvscp);
|
||||
callp->addArgsp(new AstVarRef{refp->fileline(), vscp, VAccess::READ});
|
||||
}
|
||||
auto* const newvscp = VN_AS(vscp->user2p(), VarScope);
|
||||
AstVarScope* const newvscp = VN_AS(vscp->user2p(), VarScope);
|
||||
refp->varScopep(newvscp);
|
||||
refp->varp(newvscp->varp());
|
||||
});
|
||||
|
@ -244,7 +244,7 @@ public:
|
||||
}
|
||||
|
||||
// CONSTRUCTOR
|
||||
SenExprBuilder(AstScope* scopep)
|
||||
explicit SenExprBuilder(AstScope* scopep)
|
||||
: m_scopep{scopep} {}
|
||||
};
|
||||
|
||||
|
@ -382,7 +382,7 @@ private:
|
||||
int unrollCount() const {
|
||||
return m_params ? v3Global.opt.unrollCount() * 16 : v3Global.opt.unrollCount();
|
||||
}
|
||||
bool jumpingOver(AstNode* nodep) const {
|
||||
bool jumpingOver(const AstNode* nodep) const {
|
||||
// True to jump over this node - all visitors must call this up front
|
||||
return (m_jumpp && m_jumpp->labelp() != nodep);
|
||||
}
|
||||
|
@ -675,6 +675,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl {
|
||||
setContextAndIterate(assignp, nodes[1]);
|
||||
}
|
||||
}
|
||||
// cppcheck-has-bug-suppress constParameter
|
||||
size_t collapse(UnpackRefMap& refs) {
|
||||
size_t numSplit = 0;
|
||||
for (const auto& pair : refs) {
|
||||
|
@ -121,8 +121,9 @@ class StatsReport final {
|
||||
const V3Statistic* repp = &(*it);
|
||||
if (repp->stage() != "*" && repp->printit()) {
|
||||
if (maxWidth < repp->name().length()) maxWidth = repp->name().length();
|
||||
if (stageInt.find(repp->stage()) == stageInt.end()) {
|
||||
stageInt.emplace(repp->stage(), stage++);
|
||||
const auto itFoundPair = stageInt.emplace(repp->stage(), stage);
|
||||
if (itFoundPair.second) {
|
||||
++stage;
|
||||
stages.push_back(repp->stage());
|
||||
}
|
||||
byName.emplace(repp->name(), repp);
|
||||
|
@ -486,10 +486,8 @@ void V3TSP::tspSort(const V3TSP::StateVec& states, V3TSP::StateVec* resultp) {
|
||||
for (V3TSP::StateVec::iterator it = prelim_result.begin(); it != prelim_result.end();
|
||||
++it) {
|
||||
const TspStateBase* const elemp = *it;
|
||||
if (seen.find(elemp) == seen.end()) {
|
||||
seen.insert(elemp);
|
||||
resultp->push_back(elemp);
|
||||
}
|
||||
const auto itFoundPair = seen.insert(elemp);
|
||||
if (itFoundPair.second) resultp->push_back(elemp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1055,7 +1055,8 @@ def write_ast_op_checks(filename):
|
||||
backp = tailp = opp;
|
||||
opp = {next};
|
||||
}} while (opp);
|
||||
if (headp && tailp) {{}} // Prevent unused
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
if (false && headp && tailp) {{}} // Prevent unused
|
||||
UASSERT_OBJ(headp->m_headtailp == tailp, headp, "Tail in headtailp is inconsistent");
|
||||
UASSERT_OBJ(tailp->m_headtailp == headp, tailp, "Head in headtailp is inconsistent");
|
||||
}}
|
||||
|
@ -20,7 +20,6 @@ def process(cppcheck_args):
|
||||
if Args.debug:
|
||||
print("\t" + cmd)
|
||||
fh = os.popen(cmd)
|
||||
uniq = {}
|
||||
errs = False
|
||||
last_error = ""
|
||||
for line in fh:
|
||||
@ -30,27 +29,23 @@ def process(cppcheck_args):
|
||||
line = re.sub(r'^\s+', '', line)
|
||||
# Sometimes tacked at end-of-line
|
||||
line = re.sub(r'Checking usage of global functions\.+', '', line)
|
||||
# General gunk
|
||||
if line in uniq:
|
||||
continue
|
||||
uniq[line] = 1
|
||||
line = re.sub(r' file0="[^"]+"', r'', line)
|
||||
|
||||
if re.search(r'^<\?xml version', line):
|
||||
continue
|
||||
if re.search(r'^<cppcheck', line):
|
||||
continue
|
||||
if re.search(r'^<results', line):
|
||||
continue
|
||||
if re.search(r'^</results>', line):
|
||||
continue
|
||||
if re.search(r'^<errors', line):
|
||||
continue
|
||||
if re.search(r'^</error>', line):
|
||||
continue
|
||||
if re.search(r'^</errors>', line):
|
||||
continue
|
||||
# --suppress=unmatchedSuppression doesn't work
|
||||
if re.search(r'^<error.*id="unmatchedSuppression"', line):
|
||||
if re.search(r'^<results', line):
|
||||
continue
|
||||
if re.search(r'^</results>', line):
|
||||
continue
|
||||
if re.search(r'^<symbol>', line):
|
||||
continue
|
||||
# An earlier id line is more specific
|
||||
if re.search(r'Cppcheck cannot find all the include files', line):
|
||||
@ -64,11 +59,6 @@ def process(cppcheck_args):
|
||||
if re.search(r'^\s+$', line):
|
||||
continue
|
||||
|
||||
# Specific suppressions (see _suppress also)
|
||||
# Doesn't know UINFO will use it
|
||||
if re.search(r'id="unusedPrivateFunction" .*::debug', line):
|
||||
continue
|
||||
|
||||
# Output
|
||||
if re.search(r'^cppcheck --', line):
|
||||
if Args.debug:
|
||||
@ -87,7 +77,7 @@ def process(cppcheck_args):
|
||||
match = re.search(r'<location.* file="([^"]+)"\s+line="(\d+)"', line)
|
||||
if match:
|
||||
file = match.group(1)
|
||||
linenum = match.group(2)
|
||||
linenum = int(match.group(2))
|
||||
match = re.search(r' id="([^"]+)"', last_error)
|
||||
eid = match.group(1) if match else '?'
|
||||
if _suppress(file, linenum, eid):
|
||||
@ -95,7 +85,7 @@ def process(cppcheck_args):
|
||||
if file == "*":
|
||||
suppress = True
|
||||
if not suppress:
|
||||
print(file + ":" + linenum + ": " + last_error)
|
||||
print("%s:%s: %s" % (file, linenum, last_error))
|
||||
suppress = True
|
||||
|
||||
if not suppress:
|
||||
@ -121,16 +111,42 @@ def _suppress(filename, linenum, eid):
|
||||
filename = re.sub(r'^\.\./(.*)', r'src/\1', filename)
|
||||
|
||||
# Specific suppressions
|
||||
if eid == 'asctimeCalled' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'constParameter' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'ctuOneDefinitionRuleViolation' and re.search(
|
||||
r'vltstd/', filename):
|
||||
return True
|
||||
if eid == 'duplicateConditionalAssign' and re.search(
|
||||
r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'knownConditionTrueFalse' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'missingInclude' and re.search(r'systemc.h', filename):
|
||||
return True
|
||||
if eid == 'missingInclude' and re.search(r'svdpi.h', filename):
|
||||
return True
|
||||
if eid == 'shiftNegativeLHS' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'shiftTooManyBits' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'shiftTooManyBitsSigned' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'nullPointerArithmetic' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'unmatchedSuppression':
|
||||
return True
|
||||
if eid == 'unusedFunction' and re.search(r'verilated_dpi.cpp', filename):
|
||||
return True
|
||||
if eid == 'unusedFunction' and re.search(r'verilated_vpi.cpp', filename):
|
||||
return True
|
||||
if eid == 'unreachableCode' and re.search(r'V3ParseBison.c', filename):
|
||||
return True
|
||||
if eid == 'unreadVariable' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'uselessAssignmentPtrArg' and re.search(r'gtkwave/', filename):
|
||||
return True
|
||||
if eid == 'variableScope' and re.search(r'fstapi.c', filename):
|
||||
return True
|
||||
|
||||
@ -143,10 +159,12 @@ def _suppress(filename, linenum, eid):
|
||||
lineno = 0
|
||||
for line in fh:
|
||||
lineno += 1
|
||||
if lineno + 1 == linenum:
|
||||
match = re.search(r'cppcheck-suppress((\s+\S+)+)', line)
|
||||
if ((lineno + 1) == linenum):
|
||||
match = re.search(
|
||||
r'(cppcheck|cppcheck-has-bug|cppverilator)-suppress((\s+\S+)+)',
|
||||
line)
|
||||
if match:
|
||||
for supid in match.group(1).split():
|
||||
for supid in match.group(2).split():
|
||||
if (supid == eid or (eid in SuppressMap
|
||||
and supid == SuppressMap[eid])):
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user