From a2d26b45bbfa736a5a8845a6a06a9bce229a89ee Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 30 Jul 2022 11:52:35 -0400 Subject: [PATCH] Internals: Fix some clang-tidy issues. No functional change intended. --- Makefile.in | 7 +- include/verilated.cpp | 11 ++- include/verilated.h | 4 +- include/verilated_cov.cpp | 2 +- include/verilated_cov.h | 5 +- include/verilated_fst_c.cpp | 3 +- include/verilated_fst_c.h | 2 +- include/verilated_fst_sc.h | 2 +- include/verilated_imp.h | 37 ++++----- include/verilated_profiler.h | 4 +- include/verilated_save.h | 5 +- include/verilated_sym_props.h | 1 - include/verilated_threads.h | 13 ++-- include/verilated_trace.h | 4 +- include/verilated_vcd_c.h | 3 +- include/verilated_vcd_sc.h | 2 +- include/verilated_vpi.h | 2 +- src/V3Ast.h | 12 +-- src/V3AstNodes.h | 142 +++++++++++++++++----------------- src/V3Dead.cpp | 4 +- src/V3DupFinder.h | 5 +- src/V3FileLine.cpp | 2 +- src/V3FileLine.h | 4 +- src/V3HierBlock.cpp | 2 +- src/V3Options.cpp | 8 +- src/V3ParseGrammar.cpp | 3 +- src/V3ParseImp.h | 5 +- src/V3PartitionGraph.h | 4 +- src/V3PreProc.cpp | 2 +- src/V3Simulate.h | 7 +- src/V3TraceDecl.cpp | 4 +- src/V3Tristate.cpp | 2 +- src/V3Unroll.cpp | 2 +- src/VlcBucket.h | 10 +-- 34 files changed, 160 insertions(+), 165 deletions(-) diff --git a/Makefile.in b/Makefile.in index dc14bddfd..b805f4886 100644 --- a/Makefile.in +++ b/Makefile.in @@ -322,12 +322,13 @@ cppcheck: $(CPPCHECK_DEP) $(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 -DVL_THREADED=1 $(CPPCHECK_INC) $< CLANGTIDY = clang-tidy -CLANGTIDY_FLAGS = -config='' -checks='-fuchsia-*,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables' +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 .h,.h.tidy,$(CPPCHECK_H)) \ $(subst .cpp,.cpp.tidy,$(CPPCHECK_CPP)) CLANGTIDY_DEFS = -DVL_DEBUG=1 -DVL_THREADED=1 -DVL_CPPCHECK=1 -# cppcoreguidelines-avoid-goto modernize-avoid-c-arrays readability-magic-numbers readability-simplify-boolean-expr -# cppcoreguidelines-macro-usage clang-tidy: $(CLANGTIDY_DEP) %.cpp.tidy: %.cpp diff --git a/include/verilated.cpp b/include/verilated.cpp index 6dfc844e1..90b5f46c9 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -700,7 +700,8 @@ std::string _vl_vsformat_time(char* tmp, T ld, int timeunit, bool left, size_t w = VL_EXTEND_WQ(b, 0, tmp2, std::numeric_limits::max()); // breaks shifted if (VL_GT_W(w, integer, max64Bit)) { WDataOutP v = VL_ASSIGN_W(b, tmp3, integer); // breaks fracDigitsPow10 - VlWide zero, ten; + VlWide zero; + VlWide ten; VL_ZERO_W(b, zero); VL_EXTEND_WI(b, 0, ten, 10); char buf[128]; // 128B is obviously long enough to represent 128bit integer in decimal @@ -1850,8 +1851,7 @@ VlReadMem::VlReadMem(bool hex, int bits, const std::string& filename, QData star , m_bits{bits} , m_filename(filename) // Need () or GCC 4.8 false warning , m_end{end} - , m_addr{start} - , m_linenum{0} { + , m_addr{start} { m_fp = std::fopen(filename.c_str(), "r"); if (VL_UNLIKELY(!m_fp)) { // We don't report the Verilog source filename as it slow to have to pass it down @@ -1985,8 +1985,7 @@ void VlReadMem::setData(void* valuep, const std::string& rhs) { VlWriteMem::VlWriteMem(bool hex, int bits, const std::string& filename, QData start, QData end) : m_hex{hex} - , m_bits{bits} - , m_addr{0} { + , m_bits{bits} { if (VL_UNLIKELY(start > end)) { VL_FATAL_MT(filename.c_str(), 0, "", "$writemem invalid address range"); return; @@ -2311,7 +2310,7 @@ std::string VerilatedContext::dumpfile() const VL_MT_SAFE_EXCLUDES(m_timeDumpMut return m_dumpfile; } std::string VerilatedContext::dumpfileCheck() const VL_MT_SAFE_EXCLUDES(m_timeDumpMutex) { - const std::string out = dumpfile(); + std::string out = dumpfile(); if (VL_UNLIKELY(out.empty())) { VL_PRINTF_MT("%%Warning: $dumpvar ignored as not proceeded by $dumpfile\n"); return ""; diff --git a/include/verilated.h b/include/verilated.h index 8943fc523..bed666c7d 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -558,7 +558,8 @@ public: /// releases - contact the authors before production use. void scopesDump() const VL_MT_SAFE; -public: // But for internal use only + // METHODS - public but for internal use only + // Internal: access to implementation class VerilatedContextImp* impp() { return reinterpret_cast(this); } const VerilatedContextImp* impp() const { @@ -884,7 +885,6 @@ public: } #endif -public: // METHODS - INTERNAL USE ONLY (but public due to what uses it) // Internal: Create a new module name by concatenating two strings // Returns pointer to thread-local static data (overwritten on next call) diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index d6f03a7f8..6c0f72340 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -205,7 +205,7 @@ private: // Forward to . so we have a whole word const std::string suffix = *bpost ? std::string{bpost + 1} : ""; - const std::string out = prefix + "*" + suffix; + std::string out = prefix + "*" + suffix; // cout << "\nch pre="<seedp() && reset() == samep->reset() && urandom() == samep->urandom(); @@ -5772,7 +5772,7 @@ public: virtual bool isGateOptimizable() const override { return false; } virtual bool isPredictOptimizable() const override { return false; } virtual int instrCount() const override { return INSTR_COUNT_TIME; } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } virtual void dump(std::ostream& str = std::cout) const override; void timeunit(const VTimescale& flag) { m_timeunit = flag; } VTimescale timeunit() const { return m_timeunit; } @@ -5793,7 +5793,7 @@ public: virtual bool isGateOptimizable() const override { return false; } virtual bool isPredictOptimizable() const override { return false; } virtual int instrCount() const override { return INSTR_COUNT_TIME; } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } virtual void dump(std::ostream& str = std::cout) const override; void timeunit(const VTimescale& flag) { m_timeunit = flag; } VTimescale timeunit() const { return m_timeunit; } @@ -5818,7 +5818,7 @@ public: virtual bool isSubstOptimizable() const override { return false; } virtual bool isPredictOptimizable() const override { return false; } virtual int instrCount() const override { return INSTR_COUNT_PLI; } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; //====================================================================== @@ -6406,7 +6406,7 @@ public: virtual bool cleanOut() const override { return true; } virtual bool cleanLhs() const override { return true; } virtual bool sizeMattersLhs() const override { return false; } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; class AstFEof final : public AstNodeUniop { @@ -6448,7 +6448,7 @@ public: AstNode* filep() const { return op1p(); } void strp(AstNode* nodep) { setOp2p(nodep); } AstNode* strp() const { return op2p(); } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; class AstFGetC final : public AstNodeUniop { @@ -8573,7 +8573,7 @@ public: AstNode* exprp() const { return op1p(); } // op1 = expression AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; class AstPast final : public AstNodeMath { @@ -8596,7 +8596,7 @@ public: AstNode* ticksp() const { return op2p(); } // op2 = ticks or nullptr means 1 AstSenTree* sentreep() const { return VN_AS(op4p(), SenTree); } // op4 = clock domain void sentreep(AstSenTree* sentreep) { addOp4p(sentreep); } // op4 = clock domain - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; class AstRose final : public AstNodeMath { @@ -8617,7 +8617,7 @@ public: AstNode* exprp() const { return op1p(); } // op1 = expression AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; class AstSampled final : public AstNodeMath { @@ -8636,7 +8636,7 @@ public: virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } virtual int instrCount() const override { return 0; } AstNode* exprp() const { return op1p(); } // op1 = expression - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; class AstStable final : public AstNodeMath { @@ -8657,7 +8657,7 @@ public: AstNode* exprp() const { return op1p(); } // op1 = expression AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; class AstPattern final : public AstNodeMath { @@ -8732,7 +8732,7 @@ public: void rhsp(AstNode* nodep) { return setOp2p(nodep); } AstSenTree* sentreep() const { return VN_AS(op4p(), SenTree); } // op4 = clock domain void sentreep(AstSenTree* sentreep) { addOp4p(sentreep); } // op4 = clock domain - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; //====================================================================== @@ -8953,7 +8953,7 @@ public: virtual bool isPredictOptimizable() const override { return false; } virtual bool isPure() const override { return false; } virtual bool isOutputter() const override { return true; } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } }; //====================================================================== @@ -8973,7 +8973,7 @@ public: ASTNODE_BASE_FUNCS(NodeFile) virtual void dump(std::ostream& str) const override; virtual string name() const override { return m_name; } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } void tblockp(AstTextBlock* tblockp) { setOp1p(tblockp); } AstTextBlock* tblockp() { return VN_AS(op1p(), TextBlock); } }; @@ -9241,7 +9241,7 @@ public: } ASTNODE_NODE_FUNCS(CReturn) virtual int instrCount() const override { return widthInstrs(); } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } // AstNode* lhsp() const { return op1p(); } }; @@ -9272,7 +9272,7 @@ public: virtual bool cleanOut() const override { return m_cleanOut; } virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } void addBodysp(AstNode* nodep) { addNOp1p(nodep); } AstNode* bodysp() const { return op1p(); } // op1 = expressions to print bool pure() const { return m_pure; } @@ -9289,7 +9289,7 @@ public: ASTNODE_NODE_FUNCS(CReset) virtual bool isGateOptimizable() const override { return false; } virtual bool isPredictOptimizable() const override { return false; } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } AstVarRef* varrefp() const { return VN_AS(op1p(), VarRef); } // op1 = varref to reset }; @@ -9307,7 +9307,7 @@ public: ASTNODE_NODE_FUNCS(CStmt) virtual bool isGateOptimizable() const override { return false; } virtual bool isPredictOptimizable() const override { return false; } - virtual bool same(const AstNode* samep) const override { return true; } + virtual bool same(const AstNode* /*samep*/) const override { return true; } void addBodysp(AstNode* nodep) { addNOp1p(nodep); } AstNode* bodysp() const { return op1p(); } // op1 = expressions to print }; @@ -9403,7 +9403,7 @@ class AstTypeTable final : public AstNode { AstEmptyQueueDType* m_emptyQueuep = nullptr; AstQueueDType* m_queueIndexp = nullptr; AstVoidDType* m_voidp = nullptr; - AstBasicDType* m_basicps[VBasicDTypeKwd::_ENUM_MAX]; + AstBasicDType* m_basicps[VBasicDTypeKwd::_ENUM_MAX]{}; // using DetailedMap = std::map; DetailedMap m_detailedMap; diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 6347fc098..8018e94e9 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -85,7 +85,7 @@ private: } if (AstNode* const subnodep = nodep->getChildDTypep()) subnodep->user1Inc(); } - void checkVarRef(AstNodeVarRef* nodep) { + void checkVarRef(AstNodeVarRef* nodep) const { if (nodep->classOrPackagep() && m_elimCells) nodep->classOrPackagep(nullptr); } void checkDType(AstNodeDType* nodep) { @@ -316,7 +316,7 @@ private: } } } - bool mightElimVar(AstVar* nodep) { + bool mightElimVar(AstVar* nodep) const { if (nodep->isSigPublic()) return false; // Can't elim publics! if (nodep->isIO() || nodep->isClassMember()) return false; if (nodep->isTemp() && !nodep->isTrace()) return true; diff --git a/src/V3DupFinder.h b/src/V3DupFinder.h index ed8d13097..1ee51a992 100644 --- a/src/V3DupFinder.h +++ b/src/V3DupFinder.h @@ -44,7 +44,7 @@ class V3DupFinder final : private std::multimap { using Super = std::multimap; // MEMBERS - const V3Hasher* const m_hasherp; // Pointer to owned hasher + const V3Hasher* const m_hasherp = nullptr; // Pointer to owned hasher const V3Hasher& m_hasher; // Reference to hasher public: @@ -53,8 +53,7 @@ public: : m_hasherp{new V3Hasher} , m_hasher{*m_hasherp} {} explicit V3DupFinder(const V3Hasher& hasher) - : m_hasherp{nullptr} - , m_hasher{hasher} {} + : m_hasher{hasher} {} ~V3DupFinder() { if (m_hasherp) delete m_hasherp; } diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index 028ee77d1..2e5a5fbef 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -126,7 +126,7 @@ string VFileContent::getLine(int lineno) const { return ""; } } - const string text = m_lines[lineno]; + string text = m_lines[lineno]; UINFO(9, "Get Stream[ct" << m_id << "+" << lineno << "]: " << text); return text; } diff --git a/src/V3FileLine.h b/src/V3FileLine.h index 328b682cd..d49d5e44a 100644 --- a/src/V3FileLine.h +++ b/src/V3FileLine.h @@ -162,7 +162,7 @@ public: m_firstColumn = firstColumn; m_lastColumn = lastColumn; } - void language(V3LangCode lang) { singleton().numberToLang(filenameno(), lang); } + void language(V3LangCode lang) const { singleton().numberToLang(filenameno(), lang); } void filename(const string& name) { m_filenameno = singleton().nameToNumber(name); } void parent(FileLine* fileline) { m_parent = fileline; } void lineDirective(const char* textp, int& enterExitRef); @@ -213,7 +213,7 @@ public: void warnStyleOff(bool flag); void warnStateFrom(const FileLine& from) { m_warnOn = from.m_warnOn; } void warnResetDefault() { warnStateFrom(defaultFileLine()); } - bool lastWarnWaived() { return m_waive; } + bool lastWarnWaived() const { return m_waive; } // Specific flag ACCESSORS/METHODS bool celldefineOn() const { return m_warnOn.test(V3ErrorCode::I_CELLDEFINE); } diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index 22006fa23..2430e19db 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -201,7 +201,7 @@ string V3HierBlock::hierGenerated(bool withDir) const { } string V3HierBlock::vFileIfNecessary() const { - const string filename = V3Os::filenameRealPath(m_modp->fileline()->filename()); + string filename = V3Os::filenameRealPath(m_modp->fileline()->filename()); for (const string& v : v3Global.opt.vFiles()) { // Already listed in vFiles, so no need to add the file. if (filename == V3Os::filenameRealPath(v)) return ""; diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 29c4a4ca3..d54b96c11 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -339,7 +339,7 @@ bool V3Options::hasParameter(const string& name) { } string V3Options::parameter(const string& name) { - const string value = m_parameters.find(name)->second; + string value = m_parameters.find(name)->second; m_parameters.erase(m_parameters.find(name)); return value; } @@ -477,7 +477,7 @@ string V3Options::fileExists(const string& filename) { return ""; // Not found } // Check if it is a directory, ignore if so - const string filenameOut = V3Os::filenameFromDirBase(dir, basename); + string filenameOut = V3Os::filenameFromDirBase(dir, basename); if (!fileStatNormal(filenameOut)) return ""; // Directory return filenameOut; } @@ -518,11 +518,11 @@ string V3Options::filePath(FileLine* fl, const string& modname, const string& la // using the incdir and libext's. // Return "" if not found. for (const string& dir : m_impp->m_incDirUsers) { - const string exists = filePathCheckOneDir(modname, dir); + string exists = filePathCheckOneDir(modname, dir); if (exists != "") return exists; } for (const string& dir : m_impp->m_incDirFallbacks) { - const string exists = filePathCheckOneDir(modname, dir); + string exists = filePathCheckOneDir(modname, dir); if (exists != "") return exists; } diff --git a/src/V3ParseGrammar.cpp b/src/V3ParseGrammar.cpp index f2d57f289..38bae0374 100644 --- a/src/V3ParseGrammar.cpp +++ b/src/V3ParseGrammar.cpp @@ -270,7 +270,8 @@ string V3ParseGrammar::deQuote(FileLine* fileline, string text) { } else if (*cp == 'x' && isxdigit(cp[1]) && isxdigit(cp[2])) { // SystemVerilog 3.1 #define vl_decodexdigit(c) ((isdigit(c) ? ((c) - '0') : (tolower((c)) - 'a' + 10))) - newtext += (char)(16 * vl_decodexdigit(cp[1]) + vl_decodexdigit(cp[2])); + newtext + += static_cast(16 * vl_decodexdigit(cp[1]) + vl_decodexdigit(cp[2])); cp += 2; } else if (isalnum(*cp)) { fileline->v3error("Unknown escape sequence: \\" << *cp); diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index 777e205cc..cc1918865 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -173,9 +173,10 @@ public: } static int debug() { static int level = -1; - if (VL_UNLIKELY(level < 0)) + if (VL_UNLIKELY(level < 0)) { level = std::max(std::max(debugBison(), debugFlex()), v3Global.opt.debugSrcLevel("V3ParseImp")); + } return level; } @@ -273,7 +274,7 @@ public: //==== Symbol tables V3ParseSym* symp() { return m_symp; } - AstPackage* unitPackage(FileLine* fl) { + AstPackage* unitPackage(FileLine* /*fl*/) { // Find one made earlier? const VSymEnt* const rootSymp = symp()->symRootp()->findIdFlat(AstPackage::dollarUnitName()); diff --git a/src/V3PartitionGraph.h b/src/V3PartitionGraph.h index 2fba23172..262a2b286 100644 --- a/src/V3PartitionGraph.h +++ b/src/V3PartitionGraph.h @@ -30,7 +30,7 @@ class AbstractMTask VL_NOT_FINAL : public V3GraphVertex { public: - AbstractMTask(V3Graph* graphp) + explicit AbstractMTask(V3Graph* graphp) : V3GraphVertex{graphp} {} virtual ~AbstractMTask() override = default; virtual uint32_t id() const = 0; @@ -42,7 +42,7 @@ public: // TYPES using VxList = std::list; // CONSTRUCTORS - AbstractLogicMTask(V3Graph* graphp) + explicit AbstractLogicMTask(V3Graph* graphp) : AbstractMTask{graphp} {} virtual ~AbstractLogicMTask() override = default; // METHODS diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 7301d6b1e..7dfeb9c12 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -1612,7 +1612,7 @@ string V3PreProcImp::getline() { // Make new string with data up to the newline. const int len = rtnp - m_lineChars.c_str() + 1; - const string theLine(m_lineChars, 0, len); + string theLine(m_lineChars, 0, len); m_lineChars = m_lineChars.erase(0, len); // Remove returned characters if (debug() >= 4) { const string lncln = V3PreLex::cleanDbgStrg(theLine); diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 195139cd2..378cdd0e4 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -183,7 +183,7 @@ public: } m_whyNotOptimizable = why; std::ostringstream stack; - for (auto& callstack : vlstd::reverse_view(m_callStack)) { + for (const auto& callstack : vlstd::reverse_view(m_callStack)) { AstFuncRef* const funcp = callstack->m_funcp; stack << "\n " << funcp->fileline() << "... Called from " << funcp->prettyName() << "() with parameters:"; @@ -193,9 +193,10 @@ public: AstVar* const portp = conIt->first; AstNode* const pinp = conIt->second->exprp(); AstNodeDType* const dtypep = pinp->dtypep(); - if (AstConst* const valp = fetchConstNull(pinp)) + if (AstConst* const valp = fetchConstNull(pinp)) { stack << "\n " << portp->prettyName() << " = " << prettyNumber(&valp->num(), dtypep); + } } } m_whyNotOptimizable += stack.str(); @@ -380,7 +381,7 @@ private: UASSERT_OBJ(vscp, nodep, "Not linked"); return vscp; } - int unrollCount() { + int unrollCount() const { return m_params ? v3Global.opt.unrollCount() * 16 : v3Global.opt.unrollCount(); } bool jumpingOver(AstNode* nodep) { diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 791034307..09c2ac8f5 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -192,7 +192,9 @@ private: m_subFuncSize += stmtp->nodeCount(); } - std::string getScopeChar(VltTraceScope sct) { return std::string(1, (char)(0x80 + sct)); } + std::string getScopeChar(VltTraceScope sct) { + return std::string(1, static_cast(0x80 + sct)); + } std::string addAboveInterface(const std::string& scopeName) { std::string out; diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 6a9d7f4a8..da76ddb17 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -360,7 +360,7 @@ class TristateVisitor final : public TristateBaseVisitor { VDouble0 m_statTriSigs; // stat tracking // METHODS - string dbgState() { + string dbgState() const { string o = (m_graphing ? " gr " : " ng "); if (m_alhs) o += "alhs "; return o; diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index 429708301..769faf369 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -58,7 +58,7 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - bool cantUnroll(AstNode* nodep, const char* reason) { + bool cantUnroll(AstNode* nodep, const char* reason) const { if (m_generate) nodep->v3warn(E_UNSUPPORTED, "Unsupported: Can't unroll generate for; " << reason); UINFO(3, " Can't Unroll: " << reason << " :" << nodep << endl); diff --git a/src/VlcBucket.h b/src/VlcBucket.h index ef5fdcdc7..0160ae1b2 100644 --- a/src/VlcBucket.h +++ b/src/VlcBucket.h @@ -96,20 +96,20 @@ public: } uint64_t popCount() const { uint64_t pop = 0; - for (uint64_t i = 0; i < m_dataSize; i++) { - if (hits(i)) pop++; + for (uint64_t i = 0; i < m_dataSize; ++i) { + if (hits(i)) ++pop; } return pop; } uint64_t dataPopCount(const VlcBuckets& remaining) { uint64_t pop = 0; - for (uint64_t i = 0; i < m_dataSize; i++) { - if (hits(i) && remaining.hits(i)) pop++; + for (uint64_t i = 0; i < m_dataSize; ++i) { + if (hits(i) && remaining.hits(i)) ++pop; } return pop; } void orData(const VlcBuckets& ordata) { - for (uint64_t i = 0; i < m_dataSize; i++) { + for (uint64_t i = 0; i < m_dataSize; ++i) { if (hits(i) && ordata.hits(i)) clearHits(i); } }