From b8e804f05bd3262a757a7a84b4e03652e02781dd Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 25 Jul 2021 13:38:27 -0400 Subject: [PATCH] Internals: Some clang-tidy cleanups. No functional change intended. --- include/verilated.cpp | 12 ++++++------ include/verilated_cov.cpp | 5 +++-- include/verilated_dpi.cpp | 4 ++-- include/verilated_fst_c.cpp | 30 ++++++++++++++++-------------- include/verilated_imp.h | 2 +- include/verilated_threads.cpp | 3 ++- include/verilated_vcd_c.cpp | 11 ++++++----- include/verilated_vpi.cpp | 23 +++++++++++++---------- src/V3Active.cpp | 6 +++--- src/V3Ast.h | 2 +- src/V3Branch.cpp | 4 ++-- src/V3Const.cpp | 19 +++++++++++-------- src/V3EmitCConstInit.h | 4 ++-- src/V3EmitCFunc.h | 2 +- src/V3EmitCMain.cpp | 2 ++ src/V3LinkInc.cpp | 1 - src/V3MergeCond.cpp | 6 +++--- src/V3Number.cpp | 8 ++++---- src/V3Param.cpp | 2 +- src/V3Simulate.h | 1 + src/V3SplitVar.cpp | 3 ++- src/V3Stats.h | 6 ------ src/V3TSP.cpp | 2 +- src/V3Task.cpp | 8 ++++---- 24 files changed, 87 insertions(+), 79 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index e01f32a78..e7320e50d 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -215,7 +215,7 @@ std::string _vl_string_vprintf(const char* formatp, va_list ap) VL_MT_SAFE { char* const bufp = new char[len + 1]; VL_VSNPRINTF(bufp, len + 1, formatp, ap); - const std::string out{bufp, len}; + std::string out{bufp, len}; // Not const to allow move optimization delete[] bufp; return out; } @@ -970,14 +970,14 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } static inline bool _vl_vsss_eof(FILE* fp, int floc) VL_MT_SAFE { - if (fp) { + if (VL_LIKELY(fp)) { return std::feof(fp) ? true : false; // true : false to prevent MSVC++ warning } else { return floc < 0; } } static inline void _vl_vsss_advance(FILE* fp, int& floc) VL_MT_SAFE { - if (fp) { + if (VL_LIKELY(fp)) { std::fgetc(fp); } else { floc -= 8; @@ -986,7 +986,7 @@ static inline void _vl_vsss_advance(FILE* fp, int& floc) VL_MT_SAFE { static inline int _vl_vsss_peek(FILE* fp, int& floc, const WDataInP fromp, const std::string& fstr) VL_MT_SAFE { // Get a character without advancing - if (fp) { + if (VL_LIKELY(fp)) { const int data = std::fgetc(fp); if (data == EOF) return EOF; ungetc(data, fp); @@ -2259,7 +2259,7 @@ VerilatedContext::VerilatedContext() Verilated::threadContextp(this); m_ns.m_profThreadsFilename = "profile_threads.dat"; m_fdps.resize(31); - std::fill(m_fdps.begin(), m_fdps.end(), (FILE*)0); + std::fill(m_fdps.begin(), m_fdps.end(), static_cast(nullptr)); m_fdFreeMct.resize(30); for (std::size_t i = 0, id = 1; i < m_fdFreeMct.size(); ++i, ++id) m_fdFreeMct[i] = id; } @@ -2422,7 +2422,7 @@ void VerilatedContext::internalsDump() const VL_MT_SAFE { void VerilatedContextImp::commandArgsAddGuts(int argc, const char** argv) VL_REQUIRES(m_argMutex) { if (!m_args.m_argVecLoaded) m_args.m_argVec.clear(); for (int i = 0; i < argc; ++i) { - m_args.m_argVec.push_back(argv[i]); + m_args.m_argVec.emplace_back(argv[i]); commandArgVl(argv[i]); } m_args.m_argVecLoaded = true; // Can't just test later for empty vector, no arguments is ok diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index 78757fc4a..9f04c5429 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -143,8 +143,9 @@ private: std::string rtn; for (const char* pos = text.c_str(); *pos; ++pos) { if (!std::isprint(*pos) || *pos == '%' || *pos == '"') { - char hex[10]; - VL_SNPRINTF(hex, 10, "%%%02X", pos[0]); + constexpr size_t LEN_MAX_HEX = 20; + char hex[LEN_MAX_HEX]; + VL_SNPRINTF(hex, LEN_MAX_HEX, "%%%02X", pos[0]); rtn += hex; } else { rtn += *pos; diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index 986de1453..69fbada12 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -386,7 +386,7 @@ static void _vl_svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogic // Return bit from simulator open array static svBit _vl_svGetBitArrElem(const svOpenArrayHandle s, int nargs, int indx1, int indx2, - int indx3, int indx4) VL_MT_SAFE { + int indx3, int) VL_MT_SAFE { // One extra index supported, as need bit number const VerilatedDpiOpenVar* const varp = _vl_openhandle_varp(s); void* const datap = _vl_sv_adjusted_datap(varp, nargs, indx1, indx2, indx3); @@ -401,7 +401,7 @@ static svBit _vl_svGetBitArrElem(const svOpenArrayHandle s, int nargs, int indx1 } // Update simulator open array from bit static void _vl_svPutBitArrElem(const svOpenArrayHandle d, svBit value, int nargs, int indx1, - int indx2, int indx3, int indx4) VL_MT_SAFE { + int indx2, int indx3, int) VL_MT_SAFE { // One extra index supported, as need bit number value &= 1; // Make sure clean const VerilatedDpiOpenVar* const varp = _vl_openhandle_varp(d); diff --git a/include/verilated_fst_c.cpp b/include/verilated_fst_c.cpp index 4aea35c20..933f8d88e 100644 --- a/include/verilated_fst_c.cpp +++ b/include/verilated_fst_c.cpp @@ -53,29 +53,31 @@ //============================================================================= // Check that vltscope_t matches fstScopeType -static_assert((int)FST_ST_VCD_MODULE == (int)VLT_TRACE_SCOPE_MODULE, + +static_assert(static_cast(FST_ST_VCD_MODULE) == static_cast(VLT_TRACE_SCOPE_MODULE), "VLT_TRACE_SCOPE_MODULE mismatches"); -static_assert((int)FST_ST_VCD_TASK == (int)VLT_TRACE_SCOPE_TASK, +static_assert(static_cast(FST_ST_VCD_TASK) == static_cast(VLT_TRACE_SCOPE_TASK), "VLT_TRACE_SCOPE_TASK mismatches"); -static_assert((int)FST_ST_VCD_FUNCTION == (int)VLT_TRACE_SCOPE_FUNCTION, +static_assert(static_cast(FST_ST_VCD_FUNCTION) == static_cast(VLT_TRACE_SCOPE_FUNCTION), "VLT_TRACE_SCOPE_FUNCTION mismatches"); -static_assert((int)FST_ST_VCD_BEGIN == (int)VLT_TRACE_SCOPE_BEGIN, +static_assert(static_cast(FST_ST_VCD_BEGIN) == static_cast(VLT_TRACE_SCOPE_BEGIN), "VLT_TRACE_SCOPE_BEGIN mismatches"); -static_assert((int)FST_ST_VCD_FORK == (int)VLT_TRACE_SCOPE_FORK, +static_assert(static_cast(FST_ST_VCD_FORK) == static_cast(VLT_TRACE_SCOPE_FORK), "VLT_TRACE_SCOPE_FORK mismatches"); -static_assert((int)FST_ST_VCD_GENERATE == (int)VLT_TRACE_SCOPE_GENERATE, +static_assert(static_cast(FST_ST_VCD_GENERATE) == static_cast(VLT_TRACE_SCOPE_GENERATE), "VLT_TRACE_SCOPE_GENERATE mismatches"); -static_assert((int)FST_ST_VCD_STRUCT == (int)VLT_TRACE_SCOPE_STRUCT, +static_assert(static_cast(FST_ST_VCD_STRUCT) == static_cast(VLT_TRACE_SCOPE_STRUCT), "VLT_TRACE_SCOPE_STRUCT mismatches"); -static_assert((int)FST_ST_VCD_UNION == (int)VLT_TRACE_SCOPE_UNION, +static_assert(static_cast(FST_ST_VCD_UNION) == static_cast(VLT_TRACE_SCOPE_UNION), "VLT_TRACE_SCOPE_UNION mismatches"); -static_assert((int)FST_ST_VCD_CLASS == (int)VLT_TRACE_SCOPE_CLASS, +static_assert(static_cast(FST_ST_VCD_CLASS) == static_cast(VLT_TRACE_SCOPE_CLASS), "VLT_TRACE_SCOPE_CLASS mismatches"); -static_assert((int)FST_ST_VCD_INTERFACE == (int)VLT_TRACE_SCOPE_INTERFACE, +static_assert(static_cast(FST_ST_VCD_INTERFACE) + == static_cast(VLT_TRACE_SCOPE_INTERFACE), "VLT_TRACE_SCOPE_INTERFACE mismatches"); -static_assert((int)FST_ST_VCD_PACKAGE == (int)VLT_TRACE_SCOPE_PACKAGE, +static_assert(static_cast(FST_ST_VCD_PACKAGE) == static_cast(VLT_TRACE_SCOPE_PACKAGE), "VLT_TRACE_SCOPE_PACKAGE mismatches"); -static_assert((int)FST_ST_VCD_PROGRAM == (int)VLT_TRACE_SCOPE_PROGRAM, +static_assert(static_cast(FST_ST_VCD_PROGRAM) == static_cast(VLT_TRACE_SCOPE_PROGRAM), "VLT_TRACE_SCOPE_PROGRAM mismatches"); //============================================================================= @@ -191,8 +193,8 @@ void VerilatedFst::declare(vluint32_t code, const char* name, int dtypenum, fstV tmpModName = *new_it; tmpModName.pop_back(); // If the scope ends with a non-ascii character, it will be 0x80 + fstScopeType - fstWriterSetScope(m_fst, (fstScopeType)(new_it->back() & 0x7f), tmpModName.c_str(), - nullptr); + fstWriterSetScope(m_fst, static_cast(new_it->back() & 0x7f), + tmpModName.c_str(), nullptr); } else fstWriterSetScope(m_fst, FST_ST_VCD_SCOPE, new_it->c_str(), nullptr); diff --git a/include/verilated_imp.h b/include/verilated_imp.h index ed17f86e2..4c30cbafc 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -178,7 +178,7 @@ public: // FILE* list constructed from a file-descriptor class VerilatedFpList final { - FILE* m_fp[31]; + FILE* m_fp[31] = {}; std::size_t m_sz = 0; public: diff --git a/include/verilated_threads.cpp b/include/verilated_threads.cpp index 99e59e444..606985494 100644 --- a/include/verilated_threads.cpp +++ b/include/verilated_threads.cpp @@ -48,7 +48,8 @@ VlMTaskVertex::VlMTaskVertex(vluint32_t upstreamDepCount) // VlWorkerThread VlWorkerThread::VlWorkerThread(VlThreadPool* poolp, VerilatedContext* contextp, bool profiling) - : m_poolp{poolp} + : m_ready_size{0} + , m_poolp{poolp} , m_profiling{profiling} // Must init this last -- after setting up fields that it might read: , m_exiting{false} , m_cthread{startWorker, this} diff --git a/include/verilated_vcd_c.cpp b/include/verilated_vcd_c.cpp index de7433498..2630967f3 100644 --- a/include/verilated_vcd_c.cpp +++ b/include/verilated_vcd_c.cpp @@ -271,8 +271,9 @@ void VerilatedVcd::printStr(const char* str) { } void VerilatedVcd::printQuad(vluint64_t n) { - char buf[100]; - VL_SNPRINTF(buf, 100, "%" VL_PRI64 "u", n); + constexpr size_t LEN_STR_QUAD = 40; + char buf[LEN_STR_QUAD]; + VL_SNPRINTF(buf, LEN_STR_QUAD, "%" VL_PRI64 "u", n); printStr(buf); } @@ -355,9 +356,9 @@ void VerilatedVcd::dumpHeader() { const time_t tick = time(nullptr); tm ticktm; VL_LOCALTIME_R(&tick, &ticktm); - constexpr int bufsize = 50; - char buf[bufsize]; - std::strftime(buf, bufsize, "%c", &ticktm); + constexpr size_t LEN_BUF = 50; + char buf[LEN_BUF]; + std::strftime(buf, LEN_BUF, "%c", &ticktm); printStr(buf); } printStr(" $end\n"); diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index c354d89f1..9c6862158 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -343,8 +343,9 @@ public: virtual const VerilatedRange* rangep() const override { return &(varp()->packed()); } virtual const char* fullname() const override { static VL_THREAD_LOCAL std::string t_out; - char num[25]; - VL_SNPRINTF(num, 25, "%d", m_index); + constexpr size_t LEN_MAX_INDEX = 25; + char num[LEN_MAX_INDEX]; + VL_SNPRINTF(num, LEN_MAX_INDEX, "%d", m_index); t_out = std::string{scopep()->name()} + "." + name() + "[" + num + "]"; return t_out.c_str(); } @@ -484,7 +485,7 @@ public: m_cbData.obj = m_varo.castVpiHandle(); m_varo.createPrevDatap(); } else { - m_cbData.obj = NULL; + m_cbData.obj = nullptr; } } ~VerilatedVpiCbHolder() = default; @@ -631,12 +632,13 @@ public: void* const prevDatap = varop->prevDatap(); // Was malloced when we added the callback VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: value_test %s v[0]=%d/%d %p %p\n", - varop->fullname(), *((CData*)newDatap), - *((CData*)prevDatap), newDatap, prevDatap);); + varop->fullname(), *(static_cast(newDatap)), + *(static_cast(prevDatap)), newDatap, + prevDatap);); if (std::memcmp(prevDatap, newDatap, varop->entSize()) != 0) { - VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: value_callback %" VL_PRI64 - "d %s v[0]=%d\n", - ho.id(), varop->fullname(), *((CData*)newDatap));); + VL_DEBUG_IF_PLI( + VL_DBG_MSGF("- vpi: value_callback %" VL_PRI64 "d %s v[0]=%d\n", ho.id(), + varop->fullname(), *(static_cast(newDatap)));); update.insert(varop); vpi_get_value(ho.cb_datap()->obj, ho.cb_datap()->value); (ho.cb_rtnp())(ho.cb_datap()); @@ -707,7 +709,8 @@ public: va_end(args); m_errorInfo.state = vpiPLI; t_filehold = file; - setError((PLI_BYTE8*)m_buff, nullptr, const_cast(t_filehold.c_str()), line); + setError(static_cast(m_buff), nullptr, + const_cast(t_filehold.c_str()), line); } p_vpi_error_info getError() { if (m_flag) return &m_errorInfo; @@ -1109,7 +1112,7 @@ const char* VerilatedVpiError::strFromVpiProp(PLI_INT32 vpiVal) VL_MT_SAFE { #define SELF_CHECK_RESULT_CSTR(got, exp) \ if (0 != std::strcmp((got), (exp))) { \ std::string msg \ - = std::string{"%Error: "} + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \ + = std::string{"%Error: "} + "GOT = '" + (got) + "'" + " EXP = '" + (exp) + "'"; \ VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \ } diff --git a/src/V3Active.cpp b/src/V3Active.cpp index d00dce620..76adf0e25 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -67,8 +67,8 @@ public: : V3GraphVertex{graphp} , m_name{name} , m_type{type} {} - virtual string name() const { return m_name + " " + typestr(); } - virtual string dotColor() const { return user() ? "green" : "black"; } + virtual string name() const override { return m_name + " " + typestr(); } + virtual string dotColor() const override { return user() ? "green" : "black"; } virtual int type() const { return m_type; } }; @@ -120,7 +120,7 @@ protected: public: LatchDetectGraph() { clear(); } - ~LatchDetectGraph() { clear(); } + virtual ~LatchDetectGraph() override { clear(); } // ACCESSORS LatchDetectGraphVertex* currentp() { return m_curVertexp; } void currentp(LatchDetectGraphVertex* vertex) { m_curVertexp = vertex; } diff --git a/src/V3Ast.h b/src/V3Ast.h index 13e4f5020..e00b6f34f 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1716,7 +1716,7 @@ public: VSigning numeric) const; AstNodeDType* findBitRangeDType(const VNumRange& range, int widthMin, VSigning numeric) const; AstNodeDType* findBasicDType(AstBasicDTypeKwd kwd) const; - AstBasicDType* findInsertSameDType(AstBasicDType* nodep); + static AstBasicDType* findInsertSameDType(AstBasicDType* nodep); // METHODS - dump and error void v3errorEnd(std::ostringstream& str) const; diff --git a/src/V3Branch.cpp b/src/V3Branch.cpp index ff3413815..ae8a6f1d8 100644 --- a/src/V3Branch.cpp +++ b/src/V3Branch.cpp @@ -43,8 +43,8 @@ private: AstUser1InUse m_inuser1; // STATE - int m_likely; // Excuses for branch likely taken - int m_unlikely; // Excuses for branch likely not taken + int m_likely = false; // Excuses for branch likely taken + int m_unlikely = false; // Excuses for branch likely not taken std::vector m_cfuncsp; // List of all tasks // METHODS diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 858a043fa..1a2148fc9 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -164,10 +164,11 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { "bit:" << bit << " newWidth:" << newWidth); m_bitPolarity.setAllBitsX(); for (int i = 0; i < oldPol.width(); ++i) { - if (oldPol.bitIs0(i)) + if (oldPol.bitIs0(i)) { m_bitPolarity.setBit(i, '0'); - else if (oldPol.bitIs1(i)) + } else if (oldPol.bitIs1(i)) { m_bitPolarity.setBit(i, '1'); + } } } UASSERT_OBJ(bit < m_bitPolarity.width(), m_refp, @@ -306,19 +307,20 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { } bool ok = !m_failed; - if (expectConst) + if (expectConst) { ok &= !info.m_refp && info.m_constp; - else + } else { ok &= info.m_refp && !info.m_constp; + } return ok ? info : LeafInfo{}; } AstNode* combineTree(AstNode* lhsp, AstNode* rhsp) { if (!lhsp) return rhsp; - if (isAndTree()) + if (isAndTree()) { return new AstAnd(m_rootp->fileline(), lhsp, rhsp); - else if (isOrTree()) + } else if (isOrTree()) { return new AstOr(m_rootp->fileline(), lhsp, rhsp); - else { + } else { UASSERT_OBJ(isXorTree(), m_rootp, "must be either Xor or RedXor"); return new AstXor(m_rootp->fileline(), lhsp, rhsp); } @@ -836,7 +838,8 @@ private: } else if (AstShiftL* const shiftp = VN_CAST(nodep->rhsp(), ShiftL)) { if (const AstConst* scp = VN_CAST_CONST(shiftp->rhsp(), Const)) { // Check if mask is full over the non-zero bits - V3Number maskLo(nodep, nodep->width()), maskHi(nodep, nodep->width()); + V3Number maskLo(nodep, nodep->width()); + V3Number maskHi(nodep, nodep->width()); maskLo.setMask(nodep->width() - scp->num().toUInt()); maskHi.opShiftL(maskLo, scp->num()); return checkMask(maskHi); diff --git a/src/V3EmitCConstInit.h b/src/V3EmitCConstInit.h index 1cabd9f03..386926b63 100644 --- a/src/V3EmitCConstInit.h +++ b/src/V3EmitCConstInit.h @@ -57,7 +57,7 @@ protected: puts("\n"); for (uint32_t n = 0; n < size; ++n) { m_unpackedWord = n; - if (n) puts(n % tabMod ? ", " : ",\n"); + if (n) puts((n % tabMod) ? ", " : ",\n"); iterate(nodep->getIndexDefaultedValuep(n)); } puts("\n"); @@ -87,7 +87,7 @@ protected: if (m_inUnpacked) puts(" // VlWide " + cvtToStr(m_unpackedWord)); puts("\n"); for (uint32_t n = 0; n < size; ++n) { - if (n) puts(n % 4 ? ", " : ",\n"); + if (n) puts((n % 4) ? ", " : ",\n"); ofp()->printf("0x%08" PRIx32, num.edataWord(n)); } puts("\n"); diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index fddf3e348..03c2b30b7 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -91,7 +91,7 @@ class EmitCLazyDecls final : public AstNVisitor { VL_DEBUG_FUNC; public: - EmitCLazyDecls(EmitCBaseVisitor& emitter) + explicit EmitCLazyDecls(EmitCBaseVisitor& emitter) : m_emitter(emitter) {} void emit(AstNode* nodep) { m_needsBlankLine = false; diff --git a/src/V3EmitCMain.cpp b/src/V3EmitCMain.cpp index e4ace105f..b0475fe40 100644 --- a/src/V3EmitCMain.cpp +++ b/src/V3EmitCMain.cpp @@ -93,6 +93,8 @@ private: puts("topp->final();\n"); puts("return 0;\n"); puts("}\n"); + + m_ofp = nullptr; } }; diff --git a/src/V3LinkInc.cpp b/src/V3LinkInc.cpp index fc949abcd..2317218e7 100644 --- a/src/V3LinkInc.cpp +++ b/src/V3LinkInc.cpp @@ -62,7 +62,6 @@ private: AstNode* m_insStmtp = nullptr; // Where to insert statement bool m_unsupportedHere = false; // Used to detect where it's not supported yet -private: void insertBeforeStmt(AstNode* nodep, AstNode* newp) { // Return node that must be visited, if any // See also AstNode::addBeforeStmt; this predates that function diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 32c7d6da0..62ef02196 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -109,7 +109,7 @@ private: public: // Remove marks from AstVars (clear user1) - void clear() { AstNode::user1ClearTree(); } + static void clear() { AstNode::user1ClearTree(); } // Mark all AstVars referenced by setting user1 void mark(AstNode* node) { iterate(node); } @@ -142,7 +142,7 @@ private: // it is in a supported position, which are: // - RHS is the Cond // - RHS is And(Const, Cond). This And is inserted often by V3Clean. - AstNodeCond* extractCond(AstNode* rhsp) { + static AstNodeCond* extractCond(AstNode* rhsp) { if (AstNodeCond* const condp = VN_CAST(rhsp, NodeCond)) { return condp; } else if (AstAnd* const andp = VN_CAST(rhsp, And)) { @@ -160,7 +160,7 @@ private: // wide, but working that out here is a bit difficult. As this masking is // rarely required (only when trying to merge a "cond & value" with an // earlier ternary), we will just always mask it for safety. - AstNode* maskLsb(AstNode* nodep) { + static AstNode* maskLsb(AstNode* nodep) { AstNode* const maskp = new AstConst(nodep->fileline(), AstConst::BitTrue()); return new AstAnd(nodep->fileline(), nodep, maskp); } diff --git a/src/V3Number.cpp b/src/V3Number.cpp index fe0197718..64d5a8fe2 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -422,22 +422,22 @@ V3Number& V3Number::setSingleBits(char value) { } V3Number& V3Number::setAllBits0() { - for (int i = 0; i < words(); i++) { m_value[i] = {0, 0}; } + for (int i = 0; i < words(); i++) m_value[i] = {0, 0}; return *this; } V3Number& V3Number::setAllBits1() { - for (int i = 0; i < words(); i++) { m_value[i] = {~0u, 0}; } + for (int i = 0; i < words(); i++) m_value[i] = {~0U, 0}; opCleanThis(); return *this; } V3Number& V3Number::setAllBitsX() { // Use setAllBitsXRemoved if calling this based on a non-X/Z input value such as divide by zero - for (int i = 0; i < words(); i++) { m_value[i] = {~0u, ~0u}; } + for (int i = 0; i < words(); i++) m_value[i] = {~0U, ~0U}; opCleanThis(); return *this; } V3Number& V3Number::setAllBitsZ() { - for (int i = 0; i < words(); i++) { m_value[i] = {0, ~0u}; } + for (int i = 0; i < words(); i++) m_value[i] = {0, ~0U}; opCleanThis(); return *this; } diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 733cb33d1..56175a280 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -268,7 +268,7 @@ class ParamProcessor final { // METHODS VL_DEBUG_FUNC; // Declare debug() - void makeSmallNames(AstNodeModule* modp) { + static void makeSmallNames(AstNodeModule* modp) { std::vector usedLetter; usedLetter.resize(256); // Pass 1, assign first letter to each gparam's name diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 4fe3444ab..0ded54fe8 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -991,6 +991,7 @@ private: } } SimStackNode stackNode(nodep, &tconnects); + // cppcheck-suppress danglingLifetime m_callStack.push_back(&stackNode); // Clear output variable if (auto* const basicp = VN_CAST(funcp->fvarp(), Var)->basicp()) { diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index d47b198d6..b06f0ec76 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -1231,9 +1231,10 @@ public: } else { reason = "its type is unknown"; // LCOV_EXCL_LINE } - if (reason) + if (reason) { UINFO(5, "Check " << nodep->prettyNameQ() << " cannot split because" << reason << endl); + } return reason; } VL_DEBUG_FUNC; // Declare debug() diff --git a/src/V3Stats.h b/src/V3Stats.h index 1b6c785c7..b340cf0a9 100644 --- a/src/V3Stats.h +++ b/src/V3Stats.h @@ -24,12 +24,6 @@ class AstNetlist; -#define STAT_ADD_UINFO(level, text, value) \ - do { \ - UINFO((level), "addStat " << text << " " << value << endl); \ - V3Stats::addStat(text, value); \ - } while (0) - //============================================================================ class VDouble0 final { diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index eb5a53a64..4ea0ae3a4 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -499,7 +499,7 @@ public: : m_xpos{xpos} , m_ypos{ypos} , m_serial{++s_serialNext} {} - ~TspTestState() = default; + virtual ~TspTestState() override = default; virtual int cost(const TspStateBase* otherp) const override { return cost(dynamic_cast(otherp)); } diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 3bf94dcb0..7dce81e29 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -689,13 +689,13 @@ private: return dpiproto; } - AstNode* createDpiTemp(AstVar* portp, const string& suffix) { + static AstNode* createDpiTemp(AstVar* portp, const string& suffix) { const string stmt = portp->dpiTmpVarType(portp->name() + suffix) + ";\n"; return new AstCStmt(portp->fileline(), stmt); } - AstNode* createAssignInternalToDpi(AstVar* portp, bool isPtr, const string& frSuffix, - const string& toSuffix) { + static AstNode* createAssignInternalToDpi(AstVar* portp, bool isPtr, const string& frSuffix, + const string& toSuffix) { const string stmt = V3Task::assignInternalToDpi(portp, isPtr, frSuffix, toSuffix); return new AstCStmt(portp->fileline(), stmt); } @@ -948,7 +948,7 @@ private: } } - void makePortList(AstNodeFTask* nodep, AstCFunc* dpip) { + static void makePortList(AstNodeFTask* nodep, AstCFunc* dpip) { // Copy nodep's list of function I/O to the new dpip c function for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) { if (AstVar* portp = VN_CAST(stmtp, Var)) {