diff --git a/include/verilated_unordered_set_map.h b/include/verilated_unordered_set_map.h index ce5ee4357..7384e6aab 100644 --- a/include/verilated_unordered_set_map.h +++ b/include/verilated_unordered_set_map.h @@ -50,7 +50,7 @@ inline size_t vl_hash_bytes(const void* vbufp, size_t nbytes) { const vluint8_t* bufp = static_cast(vbufp); size_t hash = 0; for (size_t i = 0; i < nbytes; i++) { - hash = bufp[i] + 31u * hash; // the K&R classic! + hash = bufp[i] + 31U * hash; // the K&R classic! } return hash; } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 86fa52c26..7c7c28e00 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -110,10 +110,11 @@ string AstNodeCCall::hiernameProtect() const { void AstNodeCond::numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, const V3Number& ths) { - if (lhs.isNeqZero()) + if (lhs.isNeqZero()) { out.opAssign(rhs); - else + } else { out.opAssign(ths); + } } int AstBasicDType::widthAlignBytes() const { diff --git a/src/V3Config.cpp b/src/V3Config.cpp index 7b89b4df7..757c8126f 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -250,7 +250,7 @@ public: return (m_on > rh.m_on); } }; -std::ostream& operator<<(std::ostream& os, V3ConfigIgnoresLine rhs) { +std::ostream& operator<<(std::ostream& os, const V3ConfigIgnoresLine& rhs) { return os << rhs.m_lineno << ", " << rhs.m_code << ", " << rhs.m_on; } @@ -456,8 +456,8 @@ void V3Config::addVarAttr(FileLine* fl, const string& module, const string& ftas } } -void V3Config::addWaiver(V3ErrorCode code, const string& filename, const string& match) { - V3ConfigResolver::s().files().at(filename).addWaiver(code, match); +void V3Config::addWaiver(V3ErrorCode code, const string& filename, const string& message) { + V3ConfigResolver::s().files().at(filename).addWaiver(code, message); } void V3Config::applyCase(AstCase* nodep) { diff --git a/src/V3Config.h b/src/V3Config.h index fbf8b6413..96346c4f1 100644 --- a/src/V3Config.h +++ b/src/V3Config.h @@ -33,14 +33,14 @@ public: static void addCoverageBlockOff(const string& file, int lineno); static void addCoverageBlockOff(const string& module, const string& blockname); static void addIgnore(V3ErrorCode code, bool on, const string& filename, int min, int max); - static void addWaiver(V3ErrorCode code, const string& filename, const string& msg); + static void addWaiver(V3ErrorCode code, const string& filename, const string& message); static void addInline(FileLine* fl, const string& module, const string& ftask, bool on); static void addVarAttr(FileLine* fl, const string& module, const string& ftask, const string& signal, AstAttrType type, AstSenTree* nodep); static void applyCase(AstCase* nodep); static void applyCoverageBlock(AstNodeModule* modulep, AstBegin* nodep); static void applyIgnores(FileLine* filelinep); - static void applyModule(AstNodeModule* nodep); + static void applyModule(AstNodeModule* modulep); static void applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp); static void applyVarAttr(AstNodeModule* modulep, AstNodeFTask* ftaskp, AstVar* varp); static bool waive(FileLine* filelinep, V3ErrorCode code, const string& match); diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 056f77d52..c39c8ecd6 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -2924,9 +2924,10 @@ void EmitCImp::emitInt(AstNodeModule* modp) { string section; section = "\n// PORTS\n"; - if (modp->isTop()) + if (modp->isTop()) { section += ("// The application code writes and reads these signals to\n" "// propagate new values into/out from the Verilated model.\n"); + } emitVarList(modp->stmtsp(), EVL_CLASS_IO, "", section /*ref*/); section = "\n// LOCAL SIGNALS\n"; @@ -3452,24 +3453,24 @@ class EmitCTrace : EmitCStmts { } } // clang-format off - else if (vartype == AstVarType::GPARAM) fstvt = "FST_VT_VCD_PARAMETER"; - else if (vartype == AstVarType::LPARAM) fstvt = "FST_VT_VCD_PARAMETER"; - else if (vartype == AstVarType::SUPPLY0) fstvt = "FST_VT_VCD_SUPPLY0"; - else if (vartype == AstVarType::SUPPLY1) fstvt = "FST_VT_VCD_SUPPLY1"; - else if (vartype == AstVarType::TRI0) fstvt = "FST_VT_VCD_TRI0"; - else if (vartype == AstVarType::TRI1) fstvt = "FST_VT_VCD_TRI1"; - else if (vartype == AstVarType::TRIWIRE) fstvt = "FST_VT_VCD_TRI"; - else if (vartype == AstVarType::WIRE) fstvt = "FST_VT_VCD_WIRE"; - else if (vartype == AstVarType::PORT) fstvt = "FST_VT_VCD_WIRE"; + else if (vartype == AstVarType::GPARAM) { fstvt = "FST_VT_VCD_PARAMETER"; } + else if (vartype == AstVarType::LPARAM) { fstvt = "FST_VT_VCD_PARAMETER"; } + else if (vartype == AstVarType::SUPPLY0) { fstvt = "FST_VT_VCD_SUPPLY0"; } + else if (vartype == AstVarType::SUPPLY1) { fstvt = "FST_VT_VCD_SUPPLY1"; } + else if (vartype == AstVarType::TRI0) { fstvt = "FST_VT_VCD_TRI0"; } + else if (vartype == AstVarType::TRI1) { fstvt = "FST_VT_VCD_TRI1"; } + else if (vartype == AstVarType::TRIWIRE) { fstvt = "FST_VT_VCD_TRI"; } + else if (vartype == AstVarType::WIRE) { fstvt = "FST_VT_VCD_WIRE"; } + else if (vartype == AstVarType::PORT) { fstvt = "FST_VT_VCD_WIRE"; } // - else if (kwd == AstBasicDTypeKwd::INTEGER) fstvt = "FST_VT_VCD_INTEGER"; - else if (kwd == AstBasicDTypeKwd::BIT) fstvt = "FST_VT_SV_BIT"; - else if (kwd == AstBasicDTypeKwd::LOGIC) fstvt = "FST_VT_SV_LOGIC"; - else if (kwd == AstBasicDTypeKwd::INT) fstvt = "FST_VT_SV_INT"; - else if (kwd == AstBasicDTypeKwd::SHORTINT) fstvt = "FST_VT_SV_SHORTINT"; - else if (kwd == AstBasicDTypeKwd::LONGINT) fstvt = "FST_VT_SV_LONGINT"; - else if (kwd == AstBasicDTypeKwd::BYTE) fstvt = "FST_VT_SV_BYTE"; - else fstvt = "FST_VT_SV_BIT"; + else if (kwd == AstBasicDTypeKwd::INTEGER) { fstvt = "FST_VT_VCD_INTEGER"; } + else if (kwd == AstBasicDTypeKwd::BIT) { fstvt = "FST_VT_SV_BIT"; } + else if (kwd == AstBasicDTypeKwd::LOGIC) { fstvt = "FST_VT_SV_LOGIC"; } + else if (kwd == AstBasicDTypeKwd::INT) { fstvt = "FST_VT_SV_INT"; } + else if (kwd == AstBasicDTypeKwd::SHORTINT) { fstvt = "FST_VT_SV_SHORTINT"; } + else if (kwd == AstBasicDTypeKwd::LONGINT) { fstvt = "FST_VT_SV_LONGINT"; } + else if (kwd == AstBasicDTypeKwd::BYTE) { fstvt = "FST_VT_SV_BYTE"; } + else { fstvt = "FST_VT_SV_BIT"; } // clang-format on // // Not currently supported diff --git a/src/V3File.cpp b/src/V3File.cpp index 45527897e..a01457afd 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -496,7 +496,8 @@ private: void startFilter(const string& command) { if (command == "") {} // Prevent Unused #ifdef INFILTER_PIPE - int fd_stdin[2], fd_stdout[2]; + int fd_stdin[2]; + int fd_stdout[2]; static const int P_RD = 0; static const int P_WR = 1; diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 6f9128d94..1ff49ea4c 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -58,7 +58,7 @@ class GateVarVertex; class GateGraphBaseVisitor { public: V3Graph* m_graphp; // Graph this class is visiting - GateGraphBaseVisitor(V3Graph* graphp) + explicit GateGraphBaseVisitor(V3Graph* graphp) : m_graphp(graphp) {} virtual ~GateGraphBaseVisitor() {} virtual VNUser visit(GateLogicVertex* vertexp, VNUser vu = VNUser(0)) = 0; diff --git a/src/V3Os.cpp b/src/V3Os.cpp index 86e5b266d..6fb2b9088 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -283,12 +283,12 @@ string V3Os::trueRandom(size_t size) { uint64_t V3Os::timeUsecs() { #if defined(_WIN32) || defined(__MINGW32__) // Microseconds between 1601-01-01 00:00:00 UTC and 1970-01-01 00:00:00 UTC - static const uint64_t EPOCH_DIFFERENCE_USECS = 11644473600000000ull; + static const uint64_t EPOCH_DIFFERENCE_USECS = 11644473600000000ULL; FILETIME ft; // contains number of 0.1us intervals since the beginning of 1601 UTC. GetSystemTimeAsFileTime(&ft); uint64_t us - = ((static_cast(ft.dwHighDateTime) << 32) + ft.dwLowDateTime + 5ull) / 10ull; + = ((static_cast(ft.dwHighDateTime) << 32) + ft.dwLowDateTime + 5ULL) / 10ULL; return us - EPOCH_DIFFERENCE_USECS; #else // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index 390eff981..be019ff31 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -143,7 +143,7 @@ void V3ParseImp::verilatorCmtLint(const char* textp, bool warnOff) { while (*sp && isspace(*sp)) sp++; string msg = sp; string::size_type pos; - if ((pos = msg.find('*')) != string::npos) { msg.erase(pos); } + if ((pos = msg.find('*')) != string::npos) msg.erase(pos); if (!(parsep()->fileline()->warnOff(msg, warnOff))) { if (!parsep()->optFuture(msg)) { yyerrorf("Unknown verilator lint message code: %s, in %s", msg.c_str(), textp); diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index 05ceeb87d..e22688919 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -146,7 +146,7 @@ public: void ppline(const char* textp); void linenoInc() { fileline()->linenoInc(); } - void verilatorCmtLint(const char* textp, bool on); + void verilatorCmtLint(const char* textp, bool warnOff); void verilatorCmtLintSave(); void verilatorCmtLintRestore(); void verilatorCmtBad(const char* textp); diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index fda0bf411..e062e6e13 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -2356,7 +2356,7 @@ void V3Partition::hashGraphDebug(const V3Graph* graphp, const char* debugName) { for (const V3GraphVertex* vxp = graphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { for (const V3GraphEdge* edgep = vxp->outBeginp(); edgep; edgep = edgep->outNextp()) { const V3GraphVertex* top = edgep->top(); - hash = vx2Id[top] + 31u * hash; // The K&R hash function + hash = vx2Id[top] + 31U * hash; // The K&R hash function } } UINFO(0, "Hash of shape (not contents) of " << debugName << " = " << cvtToStr(hash) << endl); diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index d965f3ff6..466d3b209 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -1215,10 +1215,13 @@ int V3PreProcImp::getStateToken() { UINFO(5, "``-end-defarg Out:" << out << endl); statePop(); } - if (!m_off) unputDefrefString(out); + if (!m_off) { + unputDefrefString(out); + } // Prevent problem when EMPTY="" in `ifdef NEVER `define `EMPTY - else if (stateIsDefname()) + else if (stateIsDefname()) { unputDefrefString("__IF_OFF_IGNORED_DEFINE"); + } m_lexp->m_parenLevel = 0; } else { // Finished a defref inside a upper defref // Can't subst now, or @@ -1433,10 +1436,13 @@ int V3PreProcImp::getStateToken() { UINFO(5, "``-end-defref Out:" << out << endl); statePop(); } - if (!m_off) unputDefrefString(out); + if (!m_off) { + unputDefrefString(out); + } // Prevent problem when EMPTY="" in `ifdef NEVER `define `EMPTY - else if (stateIsDefname()) + else if (stateIsDefname()) { unputDefrefString("__IF_OFF_IGNORED_DEFINE"); + } } else { // Inside another define. // Can't subst now, or diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 51d96d6cf..f051ed1c8 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -949,7 +949,8 @@ public: points.push_back(std::make_pair(it->msb() + 1, true)); // End of a region } if (skipUnused && !m_rhs.empty()) { // Range to be read must be kept, so add points here - int lsb = m_basicp->msb() + 1, msb = m_basicp->lsb() - 1; + int lsb = m_basicp->msb() + 1; + int msb = m_basicp->lsb() - 1; for (size_t i = 0; i < m_rhs.size(); ++i) { lsb = std::min(lsb, m_rhs[i].lsb()); msb = std::max(msb, m_rhs[i].msb()); diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index 7ac74a154..57f22c16e 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -523,7 +523,8 @@ public: // For test purposes, each TspTestState is merely a point // on the Cartesian plane; cost is the linear distance // between two points. - unsigned xabs, yabs; + unsigned xabs; + unsigned yabs; xabs = diff(otherp->m_xpos, m_xpos); yabs = diff(otherp->m_ypos, m_ypos); return lround(sqrt(xabs * xabs + yabs * yabs)); diff --git a/src/V3Width.cpp b/src/V3Width.cpp index a21e85daf..a9b34a301 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -2842,9 +2842,9 @@ private: patp->dtypep(vdtypep); AstNode* valuep = patternMemberValueIterate(patp); { // Packed. Convert to concat for now. - if (!newp) + if (!newp) { newp = valuep; - else { + } else { AstConcat* concatp = new AstConcat(patp->fileline(), newp, valuep); newp = concatp; newp->dtypeSetLogicSized(concatp->lhsp()->width() diff --git a/src/VlcOptions.h b/src/VlcOptions.h index e2af6e5e6..6d76dd99d 100644 --- a/src/VlcOptions.h +++ b/src/VlcOptions.h @@ -46,8 +46,8 @@ class VlcOptions { private: // METHODS - void showVersion(bool verbose); - bool onoff(const char* sw, const char* arg, bool& flag); + static void showVersion(bool verbose); + static bool onoff(const char* sw, const char* arg, bool& flag); public: // CONSTRUCTORS