diff --git a/Makefile.in b/Makefile.in index 231fbf75b..dc14bddfd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -326,6 +326,8 @@ CLANGTIDY_FLAGS = -config='' -checks='-fuchsia-*,-cppcoreguidelines-avoid-c-arra 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 49ef170dc..be9740700 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -679,7 +679,10 @@ std::string _vl_vsformat_time(char* tmp, T ld, int timeunit, bool left, size_t w if (std::numeric_limits::is_integer) { constexpr int b = 128; constexpr int w = VL_WORDS_I(b); - VlWide tmp0, tmp1, tmp2, tmp3; + VlWide tmp0; + VlWide tmp1; + VlWide tmp2; + VlWide tmp3; WDataInP shifted = VL_EXTEND_WQ(b, 0, tmp0, static_cast(ld)); if (shift < 0) { diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index fb0609be5..d6f03a7f8 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -76,15 +76,15 @@ private: public: // METHODS // cppcheck-suppress truncLongCastReturn - virtual uint64_t count() const override { return *m_countp; } - virtual void zero() const override { *m_countp = 0; } + uint64_t count() const override { return *m_countp; } + void zero() const override { *m_countp = 0; } // CONSTRUCTORS // cppcheck-suppress noExplicitConstructor explicit VerilatedCoverItemSpec(T* countp) : m_countp{countp} { *m_countp = 0; } - virtual ~VerilatedCoverItemSpec() override = default; + ~VerilatedCoverItemSpec() override = default; }; //============================================================================= @@ -122,7 +122,7 @@ public: protected: friend class VerilatedCovContext; - virtual ~VerilatedCovImp() override { clearGuts(); } + ~VerilatedCovImp() override { clearGuts(); } private: // PRIVATE METHODS @@ -511,8 +511,10 @@ VerilatedCovContext* VerilatedCov::threadCovp() VL_MT_SAFE { VerilatedCovContext* VerilatedContext::coveragep() VL_MT_SAFE { static VerilatedMutex s_mutex; + // cppcheck-suppress identicalInnerCondition if (VL_UNLIKELY(!m_coveragep)) { const VerilatedLockGuard lock{s_mutex}; + // cppcheck-suppress identicalInnerCondition if (VL_LIKELY(!m_coveragep)) { // Not redundant, prevents race m_coveragep.reset(new VerilatedCovImp); } diff --git a/include/verilated_fst_c.h b/include/verilated_fst_c.h index c87b9763b..1d9b07db7 100644 --- a/include/verilated_fst_c.h +++ b/include/verilated_fst_c.h @@ -67,18 +67,18 @@ protected: // Implementation of VerilatedTrace interface // Called when the trace moves forward to a new time point - virtual void emitTimeChange(uint64_t timeui) override; + void emitTimeChange(uint64_t timeui) override; // Hooks called from VerilatedTrace - virtual bool preFullDump() override { return isOpen(); } - virtual bool preChangeDump() override { return isOpen(); } + bool preFullDump() override { return isOpen(); } + bool preChangeDump() override { return isOpen(); } // Trace buffer management - virtual Buffer* getTraceBuffer() override; - virtual void commitTraceBuffer(Buffer*) override; + Buffer* getTraceBuffer() override; + void commitTraceBuffer(Buffer*) override; // Configure sub-class - virtual void configure(const VerilatedTraceConfig&) override; + void configure(const VerilatedTraceConfig&) override; public: //========================================================================= diff --git a/include/verilated_fst_sc.h b/include/verilated_fst_sc.h index 5ae6b7631..878d0b867 100644 --- a/include/verilated_fst_sc.h +++ b/include/verilated_fst_sc.h @@ -60,6 +60,7 @@ public: } // Override VerilatedFstC. Must be called after starting simulation. + // cppcheck-suppress missingOverride // GCC won't accept override virtual void open(const char* filename) /*override*/ VL_MT_SAFE; private: diff --git a/include/verilated_save.h b/include/verilated_save.h index c7230e74e..292bf39dd 100644 --- a/include/verilated_save.h +++ b/include/verilated_save.h @@ -194,16 +194,16 @@ public: /// Construct new object VerilatedSave() = default; /// Flush, close and destruct - virtual ~VerilatedSave() override { close(); } + ~VerilatedSave() override { close(); } // METHODS /// Open the file; call isOpen() to see if errors void open(const char* filenamep) VL_MT_UNSAFE_ONE; /// Open the file; call isOpen() to see if errors void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); } /// Flush and close the file - virtual void close() override VL_MT_UNSAFE_ONE; + void close() override VL_MT_UNSAFE_ONE; /// Flush data to file - virtual void flush() override VL_MT_UNSAFE_ONE; + void flush() override VL_MT_UNSAFE_ONE; }; //============================================================================= @@ -221,7 +221,7 @@ public: /// Construct new object VerilatedRestore() = default; /// Flush, close and destruct - virtual ~VerilatedRestore() override { close(); } + ~VerilatedRestore() override { close(); } // METHODS /// Open the file; call isOpen() to see if errors @@ -229,9 +229,9 @@ public: /// Open the file; call isOpen() to see if errors void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); } /// Close the file - virtual void close() override VL_MT_UNSAFE_ONE; - virtual void flush() override VL_MT_UNSAFE_ONE {} - virtual void fill() override VL_MT_UNSAFE_ONE; + void close() override VL_MT_UNSAFE_ONE; + void flush() override VL_MT_UNSAFE_ONE {} + void fill() override VL_MT_UNSAFE_ONE; }; //============================================================================= diff --git a/include/verilated_types.h b/include/verilated_types.h index d45477d00..93906b1d3 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -91,9 +91,9 @@ class VlReadMem final { const int m_bits; // Bit width of values const std::string& m_filename; // Filename const QData m_end; // End address (as specified by user) - FILE* m_fp; // File handle for filename - QData m_addr; // Next address to read - int m_linenum; // Line number last read from file + FILE* m_fp = nullptr; // File handle for filename + QData m_addr = 0; // Next address to read + int m_linenum = 0; // Line number last read from file bool m_anyAddr = false; // Had address directive in the file public: VlReadMem(bool hex, int bits, const std::string& filename, QData start, QData end); @@ -107,8 +107,8 @@ public: class VlWriteMem final { const bool m_hex; // Hex format const int m_bits; // Bit width of values - FILE* m_fp; // File handle for filename - QData m_addr; // Next address to write + FILE* m_fp = nullptr; // File handle for filename + QData m_addr = 0; // Next address to write public: VlWriteMem(bool hex, int bits, const std::string& filename, QData start, QData end); ~VlWriteMem(); diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index 20c5440f5..99b8ad48b 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -102,18 +102,18 @@ protected: // Implementation of VerilatedTrace interface // Called when the trace moves forward to a new time point - virtual void emitTimeChange(uint64_t timeui) override; + void emitTimeChange(uint64_t timeui) override; // Hooks called from VerilatedTrace - virtual bool preFullDump() override { return isOpen(); } - virtual bool preChangeDump() override; + bool preFullDump() override { return isOpen(); } + bool preChangeDump() override; // Trace buffer management - virtual Buffer* getTraceBuffer() override; - virtual void commitTraceBuffer(Buffer*) override; + Buffer* getTraceBuffer() override; + void commitTraceBuffer(Buffer*) override; // Configure sub-class - virtual void configure(const VerilatedTraceConfig&) override { return; }; + void configure(const VerilatedTraceConfig&) override { return; }; public: //========================================================================= diff --git a/include/verilated_vcd_sc.h b/include/verilated_vcd_sc.h index 5e71811c0..60504cf1e 100644 --- a/include/verilated_vcd_sc.h +++ b/include/verilated_vcd_sc.h @@ -63,6 +63,7 @@ public: } // Override VerilatedVcdC. Must be called after starting simulation. + // cppcheck-suppress missingOverride // GCC won't accept override virtual void open(const char* filename) /*override*/ VL_MT_SAFE; private: diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 277230720..77c79412b 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -135,12 +135,12 @@ public: VerilatedVpioTimedCb(uint64_t id, QData time) : m_id{id} , m_time{time} {} - virtual ~VerilatedVpioTimedCb() override = default; + ~VerilatedVpioTimedCb() override = default; static VerilatedVpioTimedCb* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiCallback; } - virtual PLI_INT32 dovpi_remove_cb() override; + uint32_t type() const override { return vpiCallback; } + PLI_INT32 dovpi_remove_cb() override; }; class VerilatedVpioReasonCb final : public VerilatedVpio { @@ -154,12 +154,12 @@ public: VerilatedVpioReasonCb(uint64_t id, PLI_INT32 reason) : m_id{id} , m_reason{reason} {} - virtual ~VerilatedVpioReasonCb() override = default; + ~VerilatedVpioReasonCb() override = default; static VerilatedVpioReasonCb* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiCallback; } - virtual PLI_INT32 dovpi_remove_cb() override; + uint32_t type() const override { return vpiCallback; } + PLI_INT32 dovpi_remove_cb() override; }; class VerilatedVpioConst final : public VerilatedVpio { @@ -168,11 +168,11 @@ class VerilatedVpioConst final : public VerilatedVpio { public: explicit VerilatedVpioConst(int32_t num) : m_num{num} {} - virtual ~VerilatedVpioConst() override = default; + ~VerilatedVpioConst() override = default; static VerilatedVpioConst* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiConstant; } + uint32_t type() const override { return vpiConstant; } int32_t num() const { return m_num; } }; @@ -200,10 +200,10 @@ public: } const VerilatedVar* varp() const { return m_varp; } const VerilatedScope* scopep() const { return m_scopep; } - virtual uint32_t size() const override { return get_range().elements(); } - virtual const VerilatedRange* rangep() const override { return &get_range(); } - virtual const char* name() const override { return m_varp->name(); } - virtual const char* fullname() const override { + uint32_t size() const override { return get_range().elements(); } + const VerilatedRange* rangep() const override { return &get_range(); } + const char* name() const override { return m_varp->name(); } + const char* fullname() const override { static VL_THREAD_LOCAL std::string t_out; t_out = std::string{m_scopep->name()} + "." + name(); return t_out.c_str(); @@ -214,12 +214,12 @@ class VerilatedVpioParam final : public VerilatedVpioVarBase { public: VerilatedVpioParam(const VerilatedVar* varp, const VerilatedScope* scopep) : VerilatedVpioVarBase{varp, scopep} {} - virtual ~VerilatedVpioParam() override = default; + ~VerilatedVpioParam() override = default; static VerilatedVpioParam* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiParameter; } + uint32_t type() const override { return vpiParameter; } void* varDatap() const { return m_varp->datap(); } }; @@ -229,13 +229,13 @@ class VerilatedVpioRange final : public VerilatedVpio { public: explicit VerilatedVpioRange(const VerilatedRange* range) : m_range{range} {} - virtual ~VerilatedVpioRange() override = default; + ~VerilatedVpioRange() override = default; static VerilatedVpioRange* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiRange; } - virtual uint32_t size() const override { return m_range->elements(); } - virtual const VerilatedRange* rangep() const override { return m_range; } + uint32_t type() const override { return vpiRange; } + uint32_t size() const override { return m_range->elements(); } + const VerilatedRange* rangep() const override { return m_range; } }; class VerilatedVpioRangeIter final : public VerilatedVpio { @@ -246,12 +246,12 @@ class VerilatedVpioRangeIter final : public VerilatedVpio { public: explicit VerilatedVpioRangeIter(const VerilatedRange* range) : m_range{range} {} - virtual ~VerilatedVpioRangeIter() override = default; + ~VerilatedVpioRangeIter() override = default; static VerilatedVpioRangeIter* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiIterator; } - virtual vpiHandle dovpi_scan() override { + uint32_t type() const override { return vpiIterator; } + vpiHandle dovpi_scan() override { if (VL_UNLIKELY(m_done)) { delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle return nullptr; @@ -268,14 +268,14 @@ protected: public: explicit VerilatedVpioScope(const VerilatedScope* scopep) : m_scopep{scopep} {} - virtual ~VerilatedVpioScope() override = default; + ~VerilatedVpioScope() override = default; static VerilatedVpioScope* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiScope; } + uint32_t type() const override { return vpiScope; } const VerilatedScope* scopep() const { return m_scopep; } - virtual const char* name() const override { return m_scopep->name(); } - virtual const char* fullname() const override { return m_scopep->name(); } + const char* name() const override { return m_scopep->name(); } + const char* fullname() const override { return m_scopep->name(); } }; class VerilatedVpioVar VL_NOT_FINAL : public VerilatedVpioVarBase { @@ -308,7 +308,7 @@ public: m_mask.u32 = 0; } } - virtual ~VerilatedVpioVar() override { + ~VerilatedVpioVar() override { if (m_prevDatap) VL_DO_CLEAR(delete[] m_prevDatap, m_prevDatap = nullptr); } static VerilatedVpioVar* castp(vpiHandle h) { @@ -318,7 +318,7 @@ public: uint8_t mask_byte(int idx) const { return m_mask.u8[idx & 3]; } uint32_t entSize() const { return m_entSize; } uint32_t index() const { return m_index; } - virtual uint32_t type() const override { + uint32_t type() const override { return (varp()->dims() > 1) ? vpiMemory : vpiReg; // but might be wire, logic } void* prevDatap() const { return m_prevDatap; } @@ -339,14 +339,14 @@ public: m_index = index; m_varDatap = (static_cast(varp->datap())) + entSize() * offset; } - virtual ~VerilatedVpioMemoryWord() override = default; + ~VerilatedVpioMemoryWord() override = default; static VerilatedVpioMemoryWord* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiMemoryWord; } - virtual uint32_t size() const override { return varp()->packed().elements(); } - virtual const VerilatedRange* rangep() const override { return &(varp()->packed()); } - virtual const char* fullname() const override { + uint32_t type() const override { return vpiMemoryWord; } + uint32_t size() const override { return varp()->packed().elements(); } + const VerilatedRange* rangep() const override { return &(varp()->packed()); } + const char* fullname() const override { static VL_THREAD_LOCAL std::string t_out; constexpr size_t LEN_MAX_INDEX = 25; char num[LEN_MAX_INDEX]; @@ -364,12 +364,12 @@ class VerilatedVpioVarIter final : public VerilatedVpio { public: explicit VerilatedVpioVarIter(const VerilatedScope* scopep) : m_scopep{scopep} {} - virtual ~VerilatedVpioVarIter() override = default; + ~VerilatedVpioVarIter() override = default; static VerilatedVpioVarIter* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiIterator; } - virtual vpiHandle dovpi_scan() override { + uint32_t type() const override { return vpiIterator; } + vpiHandle dovpi_scan() override { if (VL_LIKELY(m_scopep->varsp())) { const VerilatedVarNameMap* const varsp = m_scopep->varsp(); if (VL_UNLIKELY(!m_started)) { @@ -405,15 +405,15 @@ public: , m_varp{varp} , m_iteration{varp->unpacked().right()} , m_direction{VL_LIKELY(varp->unpacked().left() > varp->unpacked().right()) ? 1 : -1} {} - virtual ~VerilatedVpioMemoryWordIter() override = default; + ~VerilatedVpioMemoryWordIter() override = default; static VerilatedVpioMemoryWordIter* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiIterator; } + uint32_t type() const override { return vpiIterator; } void iterationInc() { if (!(m_done = (m_iteration == m_varp->unpacked().left()))) m_iteration += m_direction; } - virtual vpiHandle dovpi_scan() override { + vpiHandle dovpi_scan() override { if (VL_UNLIKELY(m_done)) { delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle return nullptr; @@ -438,9 +438,9 @@ public: static VerilatedVpioModule* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiModule; } - virtual const char* name() const override { return m_name; } - virtual const char* fullname() const override { return m_fullname; } + uint32_t type() const override { return vpiModule; } + const char* name() const override { return m_name; } + const char* fullname() const override { return m_fullname; } }; class VerilatedVpioModuleIter final : public VerilatedVpio { @@ -452,12 +452,12 @@ public: : m_vec{&vec} { m_it = m_vec->begin(); } - virtual ~VerilatedVpioModuleIter() override = default; + ~VerilatedVpioModuleIter() override = default; static VerilatedVpioModuleIter* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - virtual uint32_t type() const override { return vpiIterator; } - virtual vpiHandle dovpi_scan() override { + uint32_t type() const override { return vpiIterator; } + vpiHandle dovpi_scan() override { if (m_it == m_vec->end()) { delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle return nullptr; diff --git a/include/verilatedos.h b/include/verilatedos.h index 2b0cdd8ce..b01eac65c 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -456,7 +456,8 @@ using ssize_t = uint32_t; ///< signed size_t; returned from read() // or 0x0 if not implemented on this platform #define VL_GET_CPU_TICK(val) \ { \ - uint32_t hi, lo; \ + uint32_t hi; \ + uint32_t lo; \ asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); \ (val) = ((uint64_t)lo) | (((uint64_t)hi) << 32); \ } diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 1b9e9534c..ba69b1b27 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -75,7 +75,7 @@ public: class LatchDetectGraph final : public V3Graph { protected: - LatchDetectGraphVertex* m_curVertexp; // Current latch detection graph vertex + LatchDetectGraphVertex* m_curVertexp = nullptr; // Current latch detection graph vertex std::vector m_outputs; // Vector of lvalues encountered on this pass VL_DEBUG_FUNC; // Declare debug() @@ -290,13 +290,13 @@ private: // STATE LatchDetectGraph m_graph; // Graph used to detect latches in combo always // VISITORS - virtual void visit(AstVarRef* nodep) { + virtual void visit(AstVarRef* nodep) override { const AstVar* const varp = nodep->varp(); if (nodep->access().isWriteOrRW() && varp->isSignal() && !varp->isUsedLoopIdx()) { m_graph.addAssignment(nodep); } } - virtual void visit(AstNodeIf* nodep) { + virtual void visit(AstNodeIf* nodep) override { if (!nodep->isBoundsCheck()) { LatchDetectGraphVertex* const parentp = m_graph.currentp(); LatchDetectGraphVertex* const branchp = m_graph.addPathVertex(parentp, "BRANCH", true); @@ -308,7 +308,7 @@ private: } } //-------------------- - virtual void visit(AstNode* nodep) { iterateChildren(nodep); } + virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -317,7 +317,7 @@ public: iterate(nodep); m_graph.latchCheck(nodep, kwd == VAlwaysKwd::ALWAYS_LATCH); } - virtual ~ActiveLatchCheckVisitor() = default; + ~ActiveLatchCheckVisitor() override = default; }; //###################################################################### @@ -387,7 +387,7 @@ public: : m_check{check} { iterate(nodep); } - virtual ~ActiveDlyVisitor() override = default; + ~ActiveDlyVisitor() override = default; }; //###################################################################### @@ -530,7 +530,7 @@ private: // Warn and/or convert any delayed assignments if (combo && !sequent) { - ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_COMB}; + { ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_COMB}; } const ActiveLatchCheckVisitor latchvisitor{nodep, kwd}; } else if (!combo && sequent) { ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_SEQ}; @@ -598,7 +598,7 @@ private: public: // CONSTRUCTORS explicit ActiveVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ActiveVisitor() override = default; + ~ActiveVisitor() override = default; }; //###################################################################### diff --git a/src/V3Ast.h b/src/V3Ast.h index 58e940480..eb1a61705 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -2605,7 +2605,7 @@ protected: : AstNodeMath{t, fl} , m_access{access} , m_name{name} { - this->varp(nullptr); + varp(nullptr); } AstNodeVarRef(VNType t, FileLine* fl, const string& name, AstVar* varp, const VAccess& access) : AstNodeMath{t, fl} diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 95ce8ba24..cf226075d 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -489,7 +489,7 @@ string AstVar::cPubArgType(bool named, bool forReturn) const { class dpiTypesToStringConverter VL_NOT_FINAL { public: virtual string openArray(const AstVar*) const { return "const svOpenArrayHandle"; } - virtual string bitLogicVector(const AstVar* varp, bool isBit) const { + virtual string bitLogicVector(const AstVar* /*varp*/, bool isBit) const { return isBit ? "svBitVecVal" : "svLogicVecVal"; } virtual string primitive(const AstVar* varp) const { @@ -659,7 +659,7 @@ public: } }; -string AstNodeDType::cType(const string& name, bool forFunc, bool isRef) const { +string AstNodeDType::cType(const string& name, bool /*forFunc*/, bool isRef) const { const CTypeRecursed info = cTypeRecurse(false); return info.render(name, isRef); } @@ -1326,8 +1326,9 @@ void AstClass::repairCache() { clearCache(); for (auto* itemp = membersp(); itemp; itemp = itemp->nextp()) { if (const auto* const scopep = VN_CAST(itemp, Scope)) { - for (auto* itemp = scopep->blocksp(); itemp; itemp = itemp->nextp()) - insertCache(itemp); + for (auto* blockp = scopep->blocksp(); blockp; blockp = blockp->nextp()) { + insertCache(blockp); + } } else { insertCache(itemp); } @@ -1354,7 +1355,7 @@ AstClass* AstClassExtends::classp() const { return refp->classp(); } void AstClassRefDType::dump(std::ostream& str) const { - this->AstNode::dump(str); + this->AstNodeDType::dump(str); if (classOrPackagep()) str << " cpkg=" << nodeAddr(classOrPackagep()); if (classp()) { str << " -> "; @@ -1385,7 +1386,7 @@ void AstEnumItemRef::dump(std::ostream& str) const { } } void AstIfaceRefDType::dump(std::ostream& str) const { - this->AstNode::dump(str); + this->AstNodeDType::dump(str); if (cellName() != "") str << " cell=" << cellName(); if (ifaceName() != "") str << " if=" << ifaceName(); if (modportName() != "") str << " mp=" << modportName(); @@ -1434,7 +1435,7 @@ void AstJumpLabel::dump(std::ostream& str) const { } } void AstLogOr::dump(std::ostream& str) const { - this->AstNode::dump(str); + this->AstNodeMath::dump(str); if (sideEffect()) str << " [SIDE]"; } void AstMemberSel::dump(std::ostream& str) const { @@ -1447,7 +1448,7 @@ void AstMemberSel::dump(std::ostream& str) const { } } void AstMethodCall::dump(std::ostream& str) const { - this->AstNodeStmt::dump(str); + this->AstNodeFTaskRef::dump(str); if (isStatement()) str << " [STMT]"; str << " -> "; if (taskp()) { @@ -1533,7 +1534,7 @@ void AstRefDType::dump(std::ostream& str) const { } } void AstNodeUOrStructDType::dump(std::ostream& str) const { - this->AstNode::dump(str); + this->AstNodeDType::dump(str); if (packed()) str << " [PACKED]"; if (isFourstate()) str << " [4STATE]"; } @@ -1624,7 +1625,7 @@ void AstPackageImport::dump(std::ostream& str) const { str << " -> " << packagep(); } void AstPatMember::dump(std::ostream& str) const { - this->AstNode::dump(str); + this->AstNodeMath::dump(str); if (isDefault()) str << " [DEFAULT]"; } void AstNodeTriop::dump(std::ostream& str) const { this->AstNodeMath::dump(str); } @@ -1773,7 +1774,7 @@ void AstScope::dump(std::ostream& str) const { str << " [modp=" << reinterpret_cast(modp()) << "]"; } void AstScopeName::dump(std::ostream& str) const { - this->AstNode::dump(str); + this->AstNodeMath::dump(str); if (dpiExport()) str << " [DPIEX]"; if (forFormat()) str << " [FMT]"; } @@ -1840,7 +1841,7 @@ void AstNodeBlock::dump(std::ostream& str) const { if (unnamed()) str << " [UNNAMED]"; } void AstBegin::dump(std::ostream& str) const { - this->AstNode::dump(str); + this->AstNodeBlock::dump(str); if (generate()) str << " [GEN]"; if (genforp()) str << " [GENFOR]"; if (implied()) str << " [IMPLIED]"; @@ -1866,7 +1867,7 @@ void AstCoverInc::dump(std::ostream& str) const { } } void AstFork::dump(std::ostream& str) const { - this->AstNode::dump(str); + this->AstNodeBlock::dump(str); if (!joinType().join()) str << " [" << joinType() << "]"; } void AstTraceDecl::dump(std::ostream& str) const { diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index f86f8e350..4c2a468d9 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -186,7 +186,7 @@ public: class AstEmpty final : public AstNode { // Represents something missing, e.g. a missing argument in FOREACH public: - AstEmpty(FileLine* fl) + explicit AstEmpty(FileLine* fl) : ASTGEN_SUPER_Empty(fl) {} ASTNODE_NODE_FUNCS(Empty) virtual bool same(const AstNode* samep) const override { return true; } @@ -194,7 +194,7 @@ public: class AstEmptyQueue final : public AstNodeMath { public: - AstEmptyQueue(FileLine* fl) + explicit AstEmptyQueue(FileLine* fl) : ASTGEN_SUPER_EmptyQueue(fl) {} ASTNODE_NODE_FUNCS(EmptyQueue) virtual string emitC() override { V3ERROR_NA_RETURN(""); } diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index 42f57e4e8..2eb5de33b 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -48,7 +48,7 @@ static class BrokenCntGlobal { uint8_t m_count = MIN_VALUE; public: - uint8_t get() { + uint8_t get() const { UASSERT(MIN_VALUE <= m_count && m_count <= MAX_VALUE, "Invalid generation number"); return m_count; } diff --git a/src/V3Class.cpp b/src/V3Class.cpp index 5b29eccd6..f65fbfbf6 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -115,13 +115,13 @@ private: // Move later, or we wouldn't keep interating the class // We're really moving the VarScope but we might not // have a pointer to it yet - m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); + m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep)); } if (!m_ftaskp && nodep->lifetime().isStatic()) { - m_toPackageMoves.push_back(std::make_pair(nodep, m_classPackagep)); + m_toPackageMoves.emplace_back(std::make_pair(nodep, m_classPackagep)); // We're really moving the VarScope but we might not // have a pointer to it yet - m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); + m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep)); } } } @@ -137,7 +137,7 @@ private: m_ftaskp = nodep; iterateChildren(nodep); if (m_packageScopep && nodep->lifetime().isStatic()) { - m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); + m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep)); } } } @@ -152,12 +152,16 @@ private: virtual void visit(AstInitial* nodep) override { // But not AstInitialAutomatic, which remains under the class iterateChildren(nodep); - if (m_packageScopep) { m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); } + if (m_packageScopep) { + m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep)); + } } virtual void visit(AstInitialStatic* nodep) override { // But not AstInitialAutomatic, which remains under the class iterateChildren(nodep); - if (m_packageScopep) { m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); } + if (m_packageScopep) { + m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep)); + } } virtual void visit(AstNodeMath* nodep) override {} // Short circuit diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index eaf5e3708..b1db26b9b 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -220,7 +220,9 @@ class CombineVisitor final : VNVisitor { // CONSTRUCTORS explicit CombineVisitor(AstNetlist* nodep) { iterate(nodep); } - ~CombineVisitor() { V3Stats::addStat("Optimizations, Combined CFuncs", m_cfuncsCombined); } + ~CombineVisitor() override { + V3Stats::addStat("Optimizations, Combined CFuncs", m_cfuncsCombined); + } public: static void apply(AstNetlist* netlistp) { CombineVisitor{netlistp}; } diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 372757419..c9250a3f6 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -325,7 +325,6 @@ class ConstBitOpTreeVisitor final : public VNVisitor { return ResultTerm{resultp, ops, clean}; } - public: // CONSTRUCTORS VarInfo(ConstBitOpTreeVisitor* parent, AstVarRef* refp, int width) : m_parentp{parent} @@ -754,10 +753,11 @@ public: if (debug() >= 9) { // LCOV_EXCL_START cout << "Bitop tree considered: " << endl; for (AstNode* const termp : termps) termp->dumpTree("Reduced term: "); - for (const std::pair& termp : visitor.m_frozenNodes) + for (const std::pair& termp : visitor.m_frozenNodes) { termp.first->dumpTree("Frozen term with lsb " + std::to_string(termp.second.m_lsb) + " polarity " + std::to_string(termp.second.m_polarity) + ": "); + } cout << "Needs flipping: " << needsFlip << endl; cout << "Needs cleaning: " << needsCleaning << endl; cout << "Size: " << resultOps << " input size: " << visitor.m_ops << endl; diff --git a/src/V3DupFinder.h b/src/V3DupFinder.h index 4cf4b485a..ed8d13097 100644 --- a/src/V3DupFinder.h +++ b/src/V3DupFinder.h @@ -52,7 +52,7 @@ public: V3DupFinder() : m_hasherp{new V3Hasher} , m_hasher{*m_hasherp} {} - V3DupFinder(const V3Hasher& hasher) + explicit V3DupFinder(const V3Hasher& hasher) : m_hasherp{nullptr} , m_hasher{hasher} {} ~V3DupFinder() { diff --git a/src/V3EmitCFunc.cpp b/src/V3EmitCFunc.cpp index 7117fee7e..b3a224c5c 100644 --- a/src/V3EmitCFunc.cpp +++ b/src/V3EmitCFunc.cpp @@ -600,7 +600,7 @@ void EmitCFunc::emitVarReset(AstVar* varp) { // If an ARRAYINIT we initialize it using an initial block similar to a signal // puts("// parameter "+varp->nameProtect()+" = "+varp->valuep()->name()+"\n"); } else if (const AstInitArray* const initarp = VN_CAST(varp->valuep(), InitArray)) { - if (AstAssocArrayDType* const adtypep = VN_CAST(dtypep, AssocArrayDType)) { + if (VN_IS(dtypep, AssocArrayDType)) { if (initarp->defaultp()) { emitSetVarConstant(varNameProtected + ".atDefault()", VN_AS(initarp->defaultp(), Const)); @@ -611,7 +611,7 @@ void EmitCFunc::emitVarReset(AstVar* varp) { emitSetVarConstant(varNameProtected + ".at(" + cvtToStr(itr.first) + ")", VN_AS(valuep, Const)); } - } else if (AstWildcardArrayDType* const adtypep = VN_CAST(dtypep, WildcardArrayDType)) { + } else if (VN_IS(dtypep, WildcardArrayDType)) { if (initarp->defaultp()) { emitSetVarConstant(varNameProtected + ".atDefault()", VN_AS(initarp->defaultp(), Const)); diff --git a/src/V3EmitCHeaders.cpp b/src/V3EmitCHeaders.cpp index 77835212b..f0734f670 100644 --- a/src/V3EmitCHeaders.cpp +++ b/src/V3EmitCHeaders.cpp @@ -236,10 +236,11 @@ class EmitCHeader final : public EmitCConstInit { void emitAll(const AstNodeModule* modp) { // Include files required by this AstNodeModule if (const AstClass* const classp = VN_CAST(modp, Class)) { - if (classp->extendsp()) + if (classp->extendsp()) { puts("#include \"" + prefixNameProtect(classp->extendsp()->classp()->classOrPackagep()) + ".h\"\n"); + } } emitModCUse(modp, VUseType::INT_INCLUDE); diff --git a/src/V3EmitCMake.cpp b/src/V3EmitCMake.cpp index 1e8f1700e..db74dcce9 100644 --- a/src/V3EmitCMake.cpp +++ b/src/V3EmitCMake.cpp @@ -208,19 +208,15 @@ class CMakeEmitter final { *of << "target_link_libraries(${TOP_TARGET_NAME} PRIVATE " << prefix << ")\n"; if (!children.empty()) { *of << "target_link_libraries(" << prefix << " INTERFACE"; - for (V3HierBlock::HierBlockSet::const_iterator child = children.begin(); - child != children.end(); ++child) { - *of << " " << (*child)->hierPrefix(); - } + for (const auto& childr : children) { *of << " " << (childr)->hierPrefix(); } *of << ")\n"; } *of << "verilate(" << prefix << " PREFIX " << prefix << " TOP_MODULE " << hblockp->modp()->name() << " DIRECTORY " << deslash(v3Global.opt.makeDir() + "/" + prefix) << " SOURCES "; - for (V3HierBlock::HierBlockSet::const_iterator child = children.begin(); - child != children.end(); ++child) { + for (const auto& childr : children) { *of << " " - << deslash(v3Global.opt.makeDir() + "/" + (*child)->hierWrapper(true)); + << deslash(v3Global.opt.makeDir() + "/" + childr->hierWrapper(true)); } *of << " "; const string vFile = hblockp->vFileIfNecessary(); diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index c0a8e452c..5ec26221f 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -689,5 +689,5 @@ public: void V3EmitC::emitcModel() { UINFO(2, __FUNCTION__ << ": " << endl); - { EmitCModel emit(v3Global.rootp()); } + { EmitCModel{v3Global.rootp()}; } } diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index e325aa79e..aaa920664 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -774,7 +774,7 @@ void EmitCSyms::emitSymImp() { puts(protectIf(aboveScopep->nameDotless(), aboveScopep->protect())); } puts("."); - puts(protName.substr(protName.rfind(".") + 1)); + puts(protName.substr(protName.rfind('.') + 1)); puts(" = &"); puts(protectIf(scopep->nameDotless(), scopep->protect()) + ";\n"); ++m_numStmts; diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index 90e3c85e7..028ee77d1 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -72,10 +72,10 @@ int FileLineSingleton::nameToNumber(const string& filename) { //! Experimental. Updated to also put out the language. void FileLineSingleton::fileNameNumMapDumpXml(std::ostream& os) { os << "\n"; - for (auto it = m_namemap.cbegin(); it != m_namemap.cend(); ++it) { - os << "second) << "\" filename=\"" - << V3OutFormatter::quoteNameControls(it->first, V3OutFormatter::LA_XML) - << "\" language=\"" << numberToLang(it->second).ascii() << "\"/>\n"; + for (const auto& itr : m_namemap) { + os << "\n"; } os << "\n"; } diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index cf3485121..e5cecd07a 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -81,16 +81,16 @@ public: AstScope* scopep() const { return m_scopep; } bool reducible() const { return m_reducible; } bool dedupable() const { return m_dedupable; } - void setConsumed(const char* consumedReason) { + void setConsumed(const char* /*consumedReason*/) { m_consumed = true; // UINFO(0, "\t\tSetConsumed "<user4(0); - HasherVisitor{nodep}; + { HasherVisitor{nodep}; } return V3Hash(nodep->user4()); } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 63a4eb301..7c0d5269b 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -1902,7 +1902,7 @@ private: static int debug() { return LinkDotState::debug(); } // METHODS - Variables - void createImplicitVar(VSymEnt* lookupSymp, AstVarRef* nodep, AstNodeModule* modp, + void createImplicitVar(VSymEnt* /*lookupSymp*/, AstVarRef* nodep, AstNodeModule* modp, VSymEnt* moduleSymp, bool noWarn) { // Create implicit after warning if (!nodep->varp()) { diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 79be8fd05..67d82b7fb 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -445,7 +445,7 @@ private: selp->rhsp()->unlinkFrBackWithNext()}; selp->replaceWith(newp); VL_DO_DANGLING(selp->deleteTree(), selp); - } else if (AstSelLoopVars* const selp = VN_CAST(bracketp, SelLoopVars)) { + } else if (VN_IS(bracketp, SelLoopVars)) { // Ok } else { nodep->v3error( diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 45ce55922..a20100a80 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -404,7 +404,7 @@ private: return newFormat; } - static void expectDescriptor(AstNode* nodep, AstNodeVarRef* filep) { + static void expectDescriptor(AstNode* /*nodep*/, AstNodeVarRef* filep) { // This might fail on complex expressions like arrays // We use attrFileDescr() only for lint suppression, so that's ok if (filep && filep->varp()) filep->varp()->attrFileDescr(true); diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index 618b010ab..c121d5387 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -69,7 +69,7 @@ private: && m_accessors(nodep).size() == 1); // .. a block temp used in a single CFunc } - bool existsNonLeaf(const std::unordered_set& funcps) { + static bool existsNonLeaf(const std::unordered_set& funcps) { for (const AstCFunc* const funcp : funcps) { if (funcp->user1()) return true; } diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index bb4251cbb..74dfaecb1 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -414,7 +414,7 @@ public: // Given an AstNode list (held via AstNode::nextp()), move conditional statements as close // together as possible static AstNode* optimize(AstNode* nodep, const StmtPropertiesAllocator& stmtProperties) { - CodeMotionOptimizeVisitor{nodep, stmtProperties}; + { CodeMotionOptimizeVisitor{nodep, stmtProperties}; } // It is possible for the head of the list to be moved later such that it is no longer // in head position. If so, rewind the list and return the new head. while (nodep->backp()->nextp() == nodep) nodep = nodep->backp(); diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 032f8ef3f..311b4a381 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -737,7 +737,7 @@ class OrderBuildVisitor final : public VNVisitor { virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } // CONSTRUCTOR - OrderBuildVisitor(AstNetlist* nodep) { + explicit OrderBuildVisitor(AstNetlist* nodep) { // Enable debugging (3 is default if global debug; we want acyc debugging) if (debug()) m_graphp->debug(5); @@ -753,7 +753,7 @@ class OrderBuildVisitor final : public VNVisitor { // Build the rest of the graph iterate(nodep); } - virtual ~OrderBuildVisitor() = default; + ~OrderBuildVisitor() override = default; public: // Process the netlist and return the constructed ordering graph. It's 'process' because @@ -1331,7 +1331,7 @@ class OrderProcess final : VNDeleter { pushDeletep(m_deleteDomainp); } - ~OrderProcess() { + ~OrderProcess() override { // Stats for (int type = 0; type < OrderVEdgeType::_ENUM_END; type++) { const double count = double(m_statCut[type]); @@ -2103,9 +2103,9 @@ void V3Order::orderAll(AstNetlist* netlistp) { // Build ordering graph std::unique_ptr orderGraph = OrderBuildVisitor::process(netlistp); // Order the netlist - OrderProcess::main(netlistp, *orderGraph.get()); + OrderProcess::main(netlistp, *orderGraph); // Reset debug level - orderGraph.get()->debug(V3Error::debugDefault()); + orderGraph->debug(V3Error::debugDefault()); // Dump tree V3Global::dumpCheckGlobalTree("order", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Order.h b/src/V3Order.h index 13b82ad69..fa9724473 100644 --- a/src/V3Order.h +++ b/src/V3Order.h @@ -26,7 +26,7 @@ class AstNetlist; class V3Order final { public: - static void orderAll(AstNetlist* nodep); + static void orderAll(AstNetlist* netlistp); }; #endif // Guard diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 607639ed9..610bdba9a 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -289,7 +289,7 @@ class ParamProcessor final { } } } - string paramSmallName(AstNodeModule* modp, AstNode* varp) { + static string paramSmallName(AstNodeModule* modp, AstNode* varp) { if (varp->user4() <= 1) makeSmallNames(modp); int index = varp->user4() / 256; const char ch = varp->user4() & 255; diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index de03355ef..6eb40cf7c 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -468,13 +468,13 @@ void V3ParseImp::tokenPipeline() { if (nexttok == yP_COLONCOLON) { token = yaID__CC; } else if (nexttok == '#') { - const V3ParseBisonYYSType curValue + const V3ParseBisonYYSType curValueHold = yylval; // Remember value, as about to read ahead { const size_t depth = tokenPipeScanParam(0); if (tokenPeekp(depth)->token == yP_COLONCOLON) token = yaID__CC; } - yylval = curValue; + yylval = curValueHold; } } // If add to above "else if", also add to "if (token" further above diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 6b6aea6d7..4b37f53df 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -261,7 +261,7 @@ private: // METHODS protected: friend class PartPropagateCp; - void notifyEdgeCp(V3GraphVertex* vxp, GraphWay way, V3GraphVertex* throughp, + void notifyEdgeCp(V3GraphVertex* /*vxp*/, GraphWay way, V3GraphVertex* throughp, uint32_t cp) const { const uint32_t throughCost = critPathCost(throughp, way); UASSERT_SELFTEST(uint32_t, cp, (1 + throughCost)); @@ -272,7 +272,7 @@ private: // Don't need to check this in the self test; it supports an assert // that runs in production code. } - void setCritPathCost(V3GraphVertex* vxp, GraphWay way, uint32_t cost) { + void setCritPathCost(V3GraphVertex* vxp, GraphWay /*way*/, uint32_t cost) { m_cp[vxp] = cost; // Confirm that we only set each node's CP once. That's an // important property of PartPropagateCp which allows it to be far @@ -281,7 +281,7 @@ private: UASSERT_OBJ(it == m_seen.end(), vxp, "Set CP on node twice"); m_seen[vxp] = cost; } - uint32_t critPathCost(V3GraphVertex* vxp, GraphWay way) const { + uint32_t critPathCost(V3GraphVertex* vxp, GraphWay /*way*/) const { const auto it = m_cp.find(vxp); if (it != m_cp.end()) return it->second; return 0; @@ -743,7 +743,7 @@ public: bool mergeWouldCreateCycle() const; // Instead of virtual method bool removedFromSb() const { return (m_id & REMOVED_MASK) != 0; } - void removedFromSb(bool removed) { m_id |= REMOVED_MASK; } + void removedFromSb(bool /*removed*/) { m_id |= REMOVED_MASK; } bool operator<(const MergeCandidate& other) const { return m_id < other.m_id; } }; diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 50254b1ca..936395f9d 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -378,7 +378,7 @@ public: : m_tempNames{"__Vtemp"} { iterate(nodep); } - virtual ~PremitVisitor() { + ~PremitVisitor() override { V3Stats::addStat("Optimizations, Prelim extracted value to ConstPool", m_extractedToConstPool); } diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 88aa10198..dbcdbd9ed 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -75,7 +75,7 @@ private: } } void markAllDerived() { - for (auto p : m_baseToDerivedMap) { + for (const auto& p : m_baseToDerivedMap) { if (p.first->user1()) markDerived(p.first); } } diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 360f38769..3186b182a 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -67,11 +67,11 @@ private: // METHODS VL_DEBUG_FUNC; // Declare debug() - AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) { + static AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) { AstVar* varp = VN_AS(cfuncp->user1p(), Var); if (!varp) { const string newvarname = string("__Vilp"); - varp = new AstVar(fl, VVarType::STMTTEMP, newvarname, VFlagLogicPacked(), 32); + varp = new AstVar{fl, VVarType::STMTTEMP, newvarname, VFlagLogicPacked{}, 32}; UASSERT_OBJ(cfuncp, fl, "Assignment not under a function"); cfuncp->addInitsp(varp); cfuncp->user1p(varp); diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 549d6ecbc..193b0e061 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -610,7 +610,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { } AstVarRef* createTempVar(AstNode* context, AstNode* nodep, AstUnpackArrayDType* dtypep, const std::string& name_prefix, std::vector& vars, - int start_idx, bool lvalue, bool ftask) { + int start_idx, bool lvalue, bool /*ftask*/) { FileLine* const fl = nodep->fileline(); const std::string name = m_tempNames.get(nodep) + "__" + name_prefix; AstNodeAssign* const assignp = VN_CAST(context, NodeAssign); @@ -773,8 +773,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { public: explicit SplitUnpackedVarVisitor(AstNetlist* nodep) - : m_refs{} - , m_tempNames{"__VsplitVar"} { + : m_tempNames{"__VsplitVar"} { iterate(nodep); } ~SplitUnpackedVarVisitor() override { @@ -1114,10 +1113,10 @@ class SplitPackedVarVisitor final : public VNVisitor, public SplitVarImpl { << " is added for " << varp->prettyNameQ() << '\n'); } } - static void updateReferences(AstVar* varp, PackedVarRef& ref, + static void updateReferences(AstVar* varp, PackedVarRef& pref, const std::vector& vars) { for (const bool lvalue : {false, true}) { // Refer the new split variables - std::vector& refs = lvalue ? ref.lhs() : ref.rhs(); + std::vector& refs = lvalue ? pref.lhs() : pref.rhs(); for (PackedVarRefEntry& ref : refs) { auto varit = std::upper_bound(vars.begin(), vars.end(), ref.lsb(), SplitNewVar::Match()); diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index a3f0643e0..791034307 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -112,7 +112,7 @@ private: AstVarScope* m_vscp; // AstVarScope being traced (non const to allow copy during sorting) std::string m_path; // Path to enclosing module in hierarchy std::string m_name; // Name of signal - Signal(AstVarScope* vscp) + explicit Signal(AstVarScope* vscp) : m_vscp{vscp} { // Compute path in hierarchy and signal name const string& vcdName = AstNode::vcdName(vscp->varp()->name()); @@ -312,13 +312,13 @@ private: const string intfScopeName = irpName.substr(0, scopeLen); if (scopeName != intfScopeName) continue; - string scopeName = AstNode::vcdName(irp->name()); - if (scopeName.substr(0, 4) == "TOP ") scopeName.erase(0, 4); + string iscopeName = AstNode::vcdName(irp->name()); + if (iscopeName.substr(0, 4) == "TOP ") iscopeName.erase(0, 4); // Note this insert doesn't know what above is interfaces. // Perhaps all scopes should be changed to include the VLT_TRACE_SCOPE characters. // Instead we fix up when printing m_scopeSubFuncps - scopeName += getScopeChar(VLT_TRACE_SCOPE_INTERFACE) + ' '; - m_scopeSubFuncps.emplace(scopeName, m_subFuncps); + iscopeName += getScopeChar(VLT_TRACE_SCOPE_INTERFACE) + ' '; + m_scopeSubFuncps.emplace(iscopeName, m_subFuncps); VL_DO_DANGLING(irp->unlinkFrBack(), irp); } diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index d09acd272..6a9d7f4a8 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -607,7 +607,6 @@ class TristateVisitor final : public TristateBaseVisitor { if (!outvarp) { // This is the final pre-forced resolution of the tristate, so we apply // the pull direction to any undriven pins. - V3Number pull(invarp, lhsp->width()); const AstPull* const pullp = static_cast(lhsp->user3p()); bool pull1 = pullp && pullp->direction() == 1; // Else default is down undrivenp @@ -989,12 +988,13 @@ class TristateVisitor final : public TristateBaseVisitor { if (!dropop[2]) iterateAndNextNull(nodep->fhsp()); } else { AstNode* nonXp = nullptr; - if (!dropop[0]) + if (!dropop[0]) { nonXp = nodep->rhsp(); - else if (!dropop[1]) + } else if (!dropop[1]) { nonXp = nodep->thsp(); - else if (!dropop[2]) + } else if (!dropop[2]) { nonXp = nodep->fhsp(); + } // Replace 'z with non-Z if (dropop[0] || dropop[1] || dropop[2]) { // Unsupported: A $countones('0) should compare with the enables, but we don't diff --git a/src/V3VariableOrder.cpp b/src/V3VariableOrder.cpp index 8c6d91edd..6628cb7ed 100644 --- a/src/V3VariableOrder.cpp +++ b/src/V3VariableOrder.cpp @@ -48,7 +48,7 @@ public: : m_mtaskIds(mtaskIds) { // Cannot be {} or GCC 4.8 false warning m_serial = ++s_serialNext; // Cannot be ()/{} or GCC 4.8 false warning } - virtual ~VarTspSorter() = default; + ~VarTspSorter() override = default; // METHODS virtual bool operator<(const TspStateBase& other) const override { return operator<(dynamic_cast(other)); diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 237675b4a..f24380c2c 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -674,10 +674,11 @@ private: AstNodeDType* const vdtypep = m_vup->dtypeNullSkipRefp(); if (VN_IS(vdtypep, QueueDType) || VN_IS(vdtypep, DynArrayDType) || VN_IS(vdtypep, UnpackArrayDType)) { - if (times != 1) + if (times != 1) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Non-1 replication to form " << vdtypep->prettyDTypeNameQ() << " data type"); + } // Don't iterate lhsp as SELF, the potential Concat below needs // the adtypep passed down to recognize the QueueDType userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, BOTH).p()); @@ -1125,9 +1126,10 @@ private: } virtual void visit(AstEmptyQueue* nodep) override { nodep->dtypeSetEmptyQueue(); - if (!VN_IS(nodep->backp(), Assign)) + if (!VN_IS(nodep->backp(), Assign)) { nodep->v3warn(E_UNSUPPORTED, "Unsupported/Illegal: empty queue ('{}') in this context"); + } } virtual void visit(AstFell* nodep) override { if (m_vup->prelim()) { @@ -4040,6 +4042,7 @@ private: argsp->v3error("Illegal to foreach loop on basic '" + fromDtp->prettyTypeName() + "'"); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); + VL_DO_DANGLING(bodyPointp->deleteTree(), bodyPointp); return; } if (varp) { @@ -4592,9 +4595,11 @@ private: // TOP LEVEL NODE if (nodep->modVarp() && nodep->modVarp()->isGParam()) { // Widthing handled as special init() case - if (auto* const patternp = VN_CAST(nodep->exprp(), Pattern)) - if (const auto* modVarp = nodep->modVarp()) + if (auto* const patternp = VN_CAST(nodep->exprp(), Pattern)) { + if (const auto* modVarp = nodep->modVarp()) { patternp->childDTypep(modVarp->childDTypep()->cloneTree(false)); + } + } userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } else if (!m_paramsOnly) { if (!nodep->modVarp()->didWidth()) { diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 4d6b7de01..b4afe191a 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -70,7 +70,7 @@ private: , m_fromRange{fromRange} {} ~FromData() = default; }; - FromData fromDataForArray(AstNode* nodep, AstNode* basefromp) { + static FromData fromDataForArray(AstNode* nodep, AstNode* basefromp) { // What is the data type and information for this SEL-ish's from()? UINFO(9, " fromData start ddtypep = " << basefromp << endl); VNumRange fromRange; // constructs to isRanged(false) diff --git a/src/Verilator.cpp b/src/Verilator.cpp index f503ee6b9..f28faabf6 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -703,7 +703,7 @@ static void execHierVerilation() { //###################################################################### -int main(int argc, char** argv, char** env) { +int main(int argc, char** argv, char** /*env*/) { // General initialization std::ios::sync_with_stdio();