From 38a8d7fb2edf0f31604fef0d8dd99d30553732b2 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Fri, 16 Sep 2022 13:17:38 +0100 Subject: [PATCH] Remove redundant 'inline' keywords from definitions Also add checks to t/t_dist_cppstyle --- include/verilated.cpp | 29 ++-- include/verilated.h | 18 +-- include/verilated_dpi.cpp | 2 +- include/verilated_fst_c.h | 16 +-- include/verilated_fst_sc.h | 3 +- include/verilated_funcs.h | 2 +- include/verilated_imp.h | 6 +- include/verilated_profiler.h | 7 +- include/verilated_threads.h | 14 +- include/verilated_trace.h | 34 ++--- include/verilated_vcd_c.cpp | 6 +- include/verilated_vcd_c.h | 18 +-- include/verilated_vcd_sc.h | 3 +- include/verilated_vpi.cpp | 2 +- include/verilatedos.h | 6 +- src/V3Ast.cpp | 3 +- src/V3Ast.h | 214 +++++++++++++++--------------- src/V3AstInlines.h | 63 ++++----- src/V3AstNodeDType.h | 14 +- src/V3AstNodeMath.h | 5 +- src/V3AstNodes.cpp | 7 + src/V3AstUserAllocator.h | 4 +- src/V3Broken.cpp | 4 +- src/V3CCtors.cpp | 2 +- src/V3Config.cpp | 2 +- src/V3Error.h | 6 +- src/V3File.cpp | 8 +- src/V3FileLine.h | 12 +- src/V3Graph.h | 6 +- src/V3GraphAcyc.cpp | 2 +- src/V3GraphAlg.h | 4 +- src/V3Hash.h | 2 +- src/V3LangCode.h | 6 +- src/V3Life.cpp | 6 +- src/V3LinkDot.cpp | 2 +- src/V3Options.h | 16 +-- src/V3Order.cpp | 6 +- src/V3OrderGraph.h | 6 +- src/V3PreLex.h | 4 +- src/V3String.cpp | 12 +- src/V3Subst.cpp | 2 +- src/V3TSP.cpp | 6 +- test_regress/t/TestVpi.h | 2 +- test_regress/t/t_dist_cppstyle.pl | 20 ++- test_regress/t/t_extend_class_c.h | 2 +- 45 files changed, 305 insertions(+), 309 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index ee5090507..1b5dab84b 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1003,22 +1003,22 @@ 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 { +static bool _vl_vsss_eof(FILE* fp, int floc) VL_MT_SAFE { 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 { +static void _vl_vsss_advance(FILE* fp, int& floc) VL_MT_SAFE { if (VL_LIKELY(fp)) { std::fgetc(fp); } else { floc -= 8; } } -static inline int _vl_vsss_peek(FILE* fp, int& floc, const WDataInP fromp, - const std::string& fstr) VL_MT_SAFE { +static int _vl_vsss_peek(FILE* fp, int& floc, const WDataInP fromp, + const std::string& fstr) VL_MT_SAFE { // Get a character without advancing if (VL_LIKELY(fp)) { const int data = std::fgetc(fp); @@ -1035,17 +1035,16 @@ static inline int _vl_vsss_peek(FILE* fp, int& floc, const WDataInP fromp, } } } -static inline void _vl_vsss_skipspace(FILE* fp, int& floc, const WDataInP fromp, - const std::string& fstr) VL_MT_SAFE { +static void _vl_vsss_skipspace(FILE* fp, int& floc, const WDataInP fromp, + const std::string& fstr) VL_MT_SAFE { while (true) { const int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c == EOF || !std::isspace(c)) return; _vl_vsss_advance(fp, floc); } } -static inline void _vl_vsss_read_str(FILE* fp, int& floc, const WDataInP fromp, - const std::string& fstr, char* tmpp, - const char* acceptp) VL_MT_SAFE { +static void _vl_vsss_read_str(FILE* fp, int& floc, const WDataInP fromp, const std::string& fstr, + char* tmpp, const char* acceptp) VL_MT_SAFE { // Read into tmp, consisting of characters from acceptp list char* cp = tmpp; while (true) { @@ -1059,9 +1058,8 @@ static inline void _vl_vsss_read_str(FILE* fp, int& floc, const WDataInP fromp, *cp++ = '\0'; // VL_DBG_MSGF(" _read got='"<>= 1) { VL_ASSIGNBIT_WI(lsb, owp, ld & 1); } } -static inline void _vl_vsss_based(WDataOutP owp, int obits, int baseLog2, const char* strp, - size_t posstart, size_t posend) VL_MT_SAFE { +static void _vl_vsss_based(WDataOutP owp, int obits, int baseLog2, const char* strp, + size_t posstart, size_t posend) VL_MT_SAFE { // Read in base "2^^baseLog2" digits from strp[posstart..posend-1] into owp of size obits. int lsb = 0; for (int i = 0, pos = static_cast(posend) - 1; diff --git a/include/verilated.h b/include/verilated.h index 5700e67be..ed7f7955a 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -274,7 +274,7 @@ protected: public: /// Returns the VerilatedContext this model is instantiated under /// Used to get to e.g. simulation time via contextp()->time() - inline VerilatedContext* contextp() const { return &m_context; } + VerilatedContext* contextp() const { return &m_context; } /// Returns the hierarchical name of this module instance. virtual const char* hierName() const = 0; /// Returns the name of this model (the name of the generated model class). @@ -457,9 +457,9 @@ public: VerilatedCovContext* coveragep() VL_MT_SAFE; /// Set debug level /// Debug is currently global, but for forward compatibility have a per-context method - static void debug(int val) VL_MT_SAFE; + static inline void debug(int val) VL_MT_SAFE; /// Return debug level - static int debug() VL_MT_SAFE; + static inline int debug() VL_MT_SAFE; /// Set current number of errors/assertions void errorCount(int val) VL_MT_SAFE; /// Increment current number of errors/assertions @@ -521,7 +521,7 @@ public: /// /// * Else, time comes from the legacy 'double sc_time_stamp()' which /// must be a function defined by the user's wrapper. - uint64_t time() const VL_MT_SAFE; + inline uint64_t time() const VL_MT_SAFE; /// Set current simulation time. See time() for side effect details void time(uint64_t value) VL_MT_SAFE { m_s.m_time = value; } /// Advance current simulation time. See time() for side effect details @@ -652,13 +652,13 @@ public: // But internals only - called from VerilatedModule's const char* name() const { return m_namep; } const char* identifier() const { return m_identifierp; } int8_t timeunit() const { return m_timeunit; } - inline VerilatedSyms* symsp() const { return m_symsp; } + VerilatedSyms* symsp() const { return m_symsp; } VerilatedVar* varFind(const char* namep) const VL_MT_SAFE_POSTINIT; VerilatedVarNameMap* varsp() const VL_MT_SAFE_POSTINIT { return m_varsp; } void scopeDump() const; void* exportFindError(int funcnum) const; static void* exportFindNullError(int funcnum) VL_MT_SAFE; - static inline void* exportFind(const VerilatedScope* scopep, int funcnum) VL_MT_SAFE { + static void* exportFind(const VerilatedScope* scopep, int funcnum) VL_MT_SAFE { if (VL_UNLIKELY(!scopep)) return exportFindNullError(funcnum); if (VL_LIKELY(funcnum < scopep->m_funcnumMax)) { // m_callbacksp must be declared, as Max'es are > 0 @@ -727,7 +727,7 @@ public: /// Return debug level /// When multithreaded this may not immediately react to another thread /// changing the level (no mutex) - static inline int debug() VL_MT_SAFE { return s_debug; } + static int debug() VL_MT_SAFE { return s_debug; } #else /// Return constant 0 debug level, so C++'s optimizer rips up static constexpr int debug() VL_PURE { return 0; } @@ -933,8 +933,8 @@ private: #endif }; -inline void VerilatedContext::debug(int val) VL_MT_SAFE { Verilated::debug(val); } -inline int VerilatedContext::debug() VL_MT_SAFE { return Verilated::debug(); } +void VerilatedContext::debug(int val) VL_MT_SAFE { Verilated::debug(val); } +int VerilatedContext::debug() VL_MT_SAFE { return Verilated::debug(); } //========================================================================= // Data Types diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index caa72af85..7f68e1bad 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -181,7 +181,7 @@ void svPutPartselLogic(svLogicVecVal* dp, const svLogicVecVal s, int lbit, int w //====================================================================== // Open array internals -static inline const VerilatedDpiOpenVar* _vl_openhandle_varp(const svOpenArrayHandle h) { +static const VerilatedDpiOpenVar* _vl_openhandle_varp(const svOpenArrayHandle h) { if (VL_UNLIKELY(!h)) { VL_FATAL_MT(__FILE__, __LINE__, "", "%%Error: DPI svOpenArrayHandle function called with nullptr handle"); diff --git a/include/verilated_fst_c.h b/include/verilated_fst_c.h index 73c821a60..8b33b4855 100644 --- a/include/verilated_fst_c.h +++ b/include/verilated_fst_c.h @@ -161,13 +161,13 @@ class VerilatedFstBuffer VL_NOT_FINAL { // Implementations of duck-typed methods for VerilatedTraceBuffer. These are // called from only one place (the full* methods), so always inline them. - VL_ATTR_ALWINLINE inline void emitBit(uint32_t code, CData newval); - VL_ATTR_ALWINLINE inline void emitCData(uint32_t code, CData newval, int bits); - VL_ATTR_ALWINLINE inline void emitSData(uint32_t code, SData newval, int bits); - VL_ATTR_ALWINLINE inline void emitIData(uint32_t code, IData newval, int bits); - VL_ATTR_ALWINLINE inline void emitQData(uint32_t code, QData newval, int bits); - VL_ATTR_ALWINLINE inline void emitWData(uint32_t code, const WData* newvalp, int bits); - VL_ATTR_ALWINLINE inline void emitDouble(uint32_t code, double newval); + VL_ATTR_ALWINLINE void emitBit(uint32_t code, CData newval); + VL_ATTR_ALWINLINE void emitCData(uint32_t code, CData newval, int bits); + VL_ATTR_ALWINLINE void emitSData(uint32_t code, SData newval, int bits); + VL_ATTR_ALWINLINE void emitIData(uint32_t code, IData newval, int bits); + VL_ATTR_ALWINLINE void emitQData(uint32_t code, QData newval, int bits); + VL_ATTR_ALWINLINE void emitWData(uint32_t code, const WData* newvalp, int bits); + VL_ATTR_ALWINLINE void emitDouble(uint32_t code, double newval); }; //============================================================================= @@ -232,7 +232,7 @@ public: } // Internal class access - inline VerilatedFst* spTrace() { return &m_sptrace; } + VerilatedFst* spTrace() { return &m_sptrace; } }; #endif // guard diff --git a/include/verilated_fst_sc.h b/include/verilated_fst_sc.h index f6546ce84..f5aaa305c 100644 --- a/include/verilated_fst_sc.h +++ b/include/verilated_fst_sc.h @@ -75,8 +75,7 @@ private: //-------------------------------------------------- // SystemC 2.1.v1 -#define DECL_TRACE_METHOD_A(tp) \ - void trace(const tp& object, const std::string& name) override; +#define DECL_TRACE_METHOD_A(tp) void trace(const tp& object, const std::string& name) override; #define DECL_TRACE_METHOD_B(tp) \ void trace(const tp& object, const std::string& name, int width) override; diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index 8bcef8019..8f5027f96 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -282,7 +282,7 @@ inline uint64_t vl_time_stamp64() { # endif #endif -inline uint64_t VerilatedContext::time() const VL_MT_SAFE { +uint64_t VerilatedContext::time() const VL_MT_SAFE { // When using non-default context, fastest path is return time if (VL_LIKELY(m_s.m_time)) return m_s.m_time; #if defined(SYSTEMC_VERSION) || (!defined(VL_TIME_CONTEXT) && !defined(VL_NO_LEGACY)) diff --git a/include/verilated_imp.h b/include/verilated_imp.h index d55c7b228..cc1971d04 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -356,7 +356,7 @@ public: // But only for verilated*.cpp } } } - inline FILE* fdToFp(IData fdi) VL_MT_SAFE_EXCLUDES(m_fdMutex) { + FILE* fdToFp(IData fdi) VL_MT_SAFE_EXCLUDES(m_fdMutex) { const VerilatedLockGuard lock{m_fdMutex}; const VerilatedFpList fdlist = fdToFpList(fdi); if (VL_UNLIKELY(fdlist.size() != 1)) return nullptr; @@ -466,7 +466,7 @@ public: // There's often many more scopes than userdata's and thus having a ~48byte // per map overhead * N scopes would take much more space and cache thrashing. // As scopep's are pointers, this implicitly handles multiple Context's - static inline void userInsert(const void* scopep, void* userKey, void* userData) VL_MT_SAFE { + static void userInsert(const void* scopep, void* userKey, void* userData) VL_MT_SAFE { const VerilatedLockGuard lock{s().m_userMapMutex}; const auto it = s().m_userMap.find(std::make_pair(scopep, userKey)); if (it != s().m_userMap.end()) { @@ -475,7 +475,7 @@ public: s().m_userMap.emplace(std::make_pair(scopep, userKey), userData); } } - static inline void* userFind(const void* scopep, void* userKey) VL_MT_SAFE { + static void* userFind(const void* scopep, void* userKey) VL_MT_SAFE { const VerilatedLockGuard lock{s().m_userMapMutex}; const auto& it = vlstd::as_const(s().m_userMap).find(std::make_pair(scopep, userKey)); if (VL_UNLIKELY(it == s().m_userMap.end())) return nullptr; diff --git a/include/verilated_profiler.h b/include/verilated_profiler.h index a237ee5cf..5ddf3b0d9 100644 --- a/include/verilated_profiler.h +++ b/include/verilated_profiler.h @@ -45,8 +45,7 @@ class VlThreadPool; //============================================================================= // Return high-precision counter for profiling, or 0x0 if not available -VL_ATTR_ALWINLINE -inline QData VL_CPU_TICK() { +VL_ATTR_ALWINLINE QData VL_CPU_TICK() { uint64_t val; VL_GET_CPU_TICK(val); return val; @@ -171,9 +170,9 @@ public: // METHODS // Is profiling enabled - inline bool enabled() const { return m_enabled; } + bool enabled() const { return m_enabled; } // Append a trace record to the trace buffer of the current thread - static inline VlExecutionRecord& addRecord() { + static VlExecutionRecord& addRecord() { t_trace.emplace_back(); return t_trace.back(); } diff --git a/include/verilated_threads.h b/include/verilated_threads.h index 59658bf20..b595c1bca 100644 --- a/include/verilated_threads.h +++ b/include/verilated_threads.h @@ -103,7 +103,7 @@ public: // Upstream mtasks must call this when they complete. // Returns true when the current MTaskVertex becomes ready to execute, // false while it's still waiting on more dependencies. - inline bool signalUpstreamDone(bool evenCycle) { + bool signalUpstreamDone(bool evenCycle) { if (evenCycle) { const uint32_t upstreamDepsDone = 1 + m_upstreamDepsDone.fetch_add(1, std::memory_order_release); @@ -116,11 +116,11 @@ public: return (upstreamDepsDone_prev == 1); } } - inline bool areUpstreamDepsDone(bool evenCycle) const { + bool areUpstreamDepsDone(bool evenCycle) const { const uint32_t target = evenCycle ? m_upstreamDepCount : 0; return m_upstreamDepsDone.load(std::memory_order_acquire) == target; } - inline void waitUntilUpstreamDone(bool evenCycle) const { + void waitUntilUpstreamDone(bool evenCycle) const { unsigned ct = 0; while (VL_UNLIKELY(!areUpstreamDepsDone(evenCycle))) { VL_CPU_RELAX(); @@ -171,7 +171,7 @@ public: // METHODS template - inline void dequeWork(ExecRec* workp) VL_MT_SAFE_EXCLUDES(m_mutex) { + void dequeWork(ExecRec* workp) VL_MT_SAFE_EXCLUDES(m_mutex) { // Spin for a while, waiting for new data if VL_CONSTEXPR_CXX17 (SpinWait) { for (unsigned i = 0; i < VL_LOCK_SPINS; ++i) { @@ -191,7 +191,7 @@ public: m_ready.erase(m_ready.begin()); m_ready_size.fetch_sub(1, std::memory_order_relaxed); } - inline void addTask(VlExecFnp fnp, VlSelfP selfp, bool evenCycle = false) + void addTask(VlExecFnp fnp, VlSelfP selfp, bool evenCycle = false) VL_MT_SAFE_EXCLUDES(m_mutex) { bool notify; { @@ -223,8 +223,8 @@ public: ~VlThreadPool() override; // METHODS - inline int numThreads() const { return m_workers.size(); } - inline VlWorkerThread* workerp(int index) { + int numThreads() const { return m_workers.size(); } + VlWorkerThread* workerp(int index) { assert(index >= 0); assert(index < m_workers.size()); return m_workers[index]; diff --git a/include/verilated_trace.h b/include/verilated_trace.h index 03ca2ba2c..151d2c9f2 100644 --- a/include/verilated_trace.h +++ b/include/verilated_trace.h @@ -318,8 +318,8 @@ protected: void flushBase(); #ifdef VL_THREADED - inline bool offload() const { return m_offload; } - inline bool parallel() const { return m_parallel; } + bool offload() const { return m_offload; } + bool parallel() const { return m_parallel; } #else static constexpr bool offload() { return false; } static constexpr bool parallel() { return false; } @@ -425,7 +425,7 @@ public: // duck-typed void emitWData(uint32_t code, const WData* newvalp, int bits) = 0; // duck-typed void emitDouble(uint32_t code, double newval) = 0; - VL_ATTR_ALWINLINE inline uint32_t* oldp(uint32_t code) { return m_sigs_oldvalp + code; } + VL_ATTR_ALWINLINE uint32_t* oldp(uint32_t code) { return m_sigs_oldvalp + code; } // Write to previous value buffer value and emit trace entry. void fullBit(uint32_t* oldp, CData newval); @@ -441,27 +441,27 @@ public: // thread and are called chg*Impl // Check previous dumped value of signal. If changed, then emit trace entry - VL_ATTR_ALWINLINE inline void chgBit(uint32_t* oldp, CData newval) { + VL_ATTR_ALWINLINE void chgBit(uint32_t* oldp, CData newval) { const uint32_t diff = *oldp ^ newval; if (VL_UNLIKELY(diff)) fullBit(oldp, newval); } - VL_ATTR_ALWINLINE inline void chgCData(uint32_t* oldp, CData newval, int bits) { + VL_ATTR_ALWINLINE void chgCData(uint32_t* oldp, CData newval, int bits) { const uint32_t diff = *oldp ^ newval; if (VL_UNLIKELY(diff)) fullCData(oldp, newval, bits); } - VL_ATTR_ALWINLINE inline void chgSData(uint32_t* oldp, SData newval, int bits) { + VL_ATTR_ALWINLINE void chgSData(uint32_t* oldp, SData newval, int bits) { const uint32_t diff = *oldp ^ newval; if (VL_UNLIKELY(diff)) fullSData(oldp, newval, bits); } - VL_ATTR_ALWINLINE inline void chgIData(uint32_t* oldp, IData newval, int bits) { + VL_ATTR_ALWINLINE void chgIData(uint32_t* oldp, IData newval, int bits) { const uint32_t diff = *oldp ^ newval; if (VL_UNLIKELY(diff)) fullIData(oldp, newval, bits); } - VL_ATTR_ALWINLINE inline void chgQData(uint32_t* oldp, QData newval, int bits) { + VL_ATTR_ALWINLINE void chgQData(uint32_t* oldp, QData newval, int bits) { const uint64_t diff = *reinterpret_cast(oldp) ^ newval; if (VL_UNLIKELY(diff)) fullQData(oldp, newval, bits); } - VL_ATTR_ALWINLINE inline void chgWData(uint32_t* oldp, const WData* newvalp, int bits) { + VL_ATTR_ALWINLINE void chgWData(uint32_t* oldp, const WData* newvalp, int bits) { for (int i = 0; i < (bits + 31) / 32; ++i) { if (VL_UNLIKELY(oldp[i] ^ newvalp[i])) { fullWData(oldp, newvalp, bits); @@ -469,7 +469,7 @@ public: } } } - VL_ATTR_ALWINLINE inline void chgDouble(uint32_t* oldp, double newval) { + VL_ATTR_ALWINLINE void chgDouble(uint32_t* oldp, double newval) { // cppcheck-suppress invalidPointerCast if (VL_UNLIKELY(*reinterpret_cast(oldp) != newval)) fullDouble(oldp, newval); } @@ -498,48 +498,48 @@ public: // Hot path internal interface to Verilator generated code // Offloaded tracing. Just dump everything in the offload buffer - inline void chgBit(uint32_t code, CData newval) { + void chgBit(uint32_t code, CData newval) { m_offloadBufferWritep[0] = VerilatedTraceOffloadCommand::CHG_BIT_0 | newval; m_offloadBufferWritep[1] = code; m_offloadBufferWritep += 2; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgCData(uint32_t code, CData newval, int bits) { + void chgCData(uint32_t code, CData newval, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_CDATA; m_offloadBufferWritep[1] = code; m_offloadBufferWritep[2] = newval; m_offloadBufferWritep += 3; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgSData(uint32_t code, SData newval, int bits) { + void chgSData(uint32_t code, SData newval, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_SDATA; m_offloadBufferWritep[1] = code; m_offloadBufferWritep[2] = newval; m_offloadBufferWritep += 3; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgIData(uint32_t code, IData newval, int bits) { + void chgIData(uint32_t code, IData newval, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_IDATA; m_offloadBufferWritep[1] = code; m_offloadBufferWritep[2] = newval; m_offloadBufferWritep += 3; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgQData(uint32_t code, QData newval, int bits) { + void chgQData(uint32_t code, QData newval, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_QDATA; m_offloadBufferWritep[1] = code; *reinterpret_cast(m_offloadBufferWritep + 2) = newval; m_offloadBufferWritep += 4; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgWData(uint32_t code, const WData* newvalp, int bits) { + void chgWData(uint32_t code, const WData* newvalp, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_WDATA; m_offloadBufferWritep[1] = code; m_offloadBufferWritep += 2; for (int i = 0; i < (bits + 31) / 32; ++i) { *m_offloadBufferWritep++ = newvalp[i]; } VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgDouble(uint32_t code, double newval) { + void chgDouble(uint32_t code, double newval) { m_offloadBufferWritep[0] = VerilatedTraceOffloadCommand::CHG_DOUBLE; m_offloadBufferWritep[1] = code; // cppcheck-suppress invalidPointerCast diff --git a/include/verilated_vcd_c.cpp b/include/verilated_vcd_c.cpp index ed36e6583..2d0cc57f0 100644 --- a/include/verilated_vcd_c.cpp +++ b/include/verilated_vcd_c.cpp @@ -632,10 +632,10 @@ void VerilatedVcd::commitTraceBuffer(VerilatedVcd::Buffer* bufp) { //============================================================================= // Trace rendering primitives -static inline void -VerilatedVcdCCopyAndAppendNewLine(char* writep, const char* suffixp) VL_ATTR_NO_SANITIZE_ALIGN; +static void VerilatedVcdCCopyAndAppendNewLine(char* writep, + const char* suffixp) VL_ATTR_NO_SANITIZE_ALIGN; -static inline void VerilatedVcdCCopyAndAppendNewLine(char* writep, const char* suffixp) { +static void VerilatedVcdCCopyAndAppendNewLine(char* writep, const char* suffixp) { // Copy the whole suffix (this avoid having hard to predict branches which // helps a lot). Note: The maximum length of the suffix is // VL_TRACE_MAX_VCD_CODE_SIZE + 2 == 7, but we unroll this here for speed. diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index 9079ef926..2967225b1 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -73,7 +73,7 @@ private: void bufferResize(size_t minsize); void bufferFlush() VL_MT_UNSAFE_ONE; - inline void bufferCheck() { + void bufferCheck() { // Flush the write buffer if there's not enough space left for new information // We only call this once per vector, so we need enough slop for a very wide "b###" line if (VL_UNLIKELY(m_writep > m_wrFlushp)) bufferFlush(); @@ -210,13 +210,13 @@ class VerilatedVcdBuffer VL_NOT_FINAL { // Implementation of VerilatedTraceBuffer interface // Implementations of duck-typed methods for VerilatedTraceBuffer. These are // called from only one place (the full* methods), so always inline them. - VL_ATTR_ALWINLINE inline void emitBit(uint32_t code, CData newval); - VL_ATTR_ALWINLINE inline void emitCData(uint32_t code, CData newval, int bits); - VL_ATTR_ALWINLINE inline void emitSData(uint32_t code, SData newval, int bits); - VL_ATTR_ALWINLINE inline void emitIData(uint32_t code, IData newval, int bits); - VL_ATTR_ALWINLINE inline void emitQData(uint32_t code, QData newval, int bits); - VL_ATTR_ALWINLINE inline void emitWData(uint32_t code, const WData* newvalp, int bits); - VL_ATTR_ALWINLINE inline void emitDouble(uint32_t code, double newval); + VL_ATTR_ALWINLINE void emitBit(uint32_t code, CData newval); + VL_ATTR_ALWINLINE void emitCData(uint32_t code, CData newval, int bits); + VL_ATTR_ALWINLINE void emitSData(uint32_t code, SData newval, int bits); + VL_ATTR_ALWINLINE void emitIData(uint32_t code, IData newval, int bits); + VL_ATTR_ALWINLINE void emitQData(uint32_t code, QData newval, int bits); + VL_ATTR_ALWINLINE void emitWData(uint32_t code, const WData* newvalp, int bits); + VL_ATTR_ALWINLINE void emitDouble(uint32_t code, double newval); }; //============================================================================= @@ -313,7 +313,7 @@ public: } // Internal class access - inline VerilatedVcd* spTrace() { return &m_sptrace; } + VerilatedVcd* spTrace() { return &m_sptrace; } }; #endif // guard diff --git a/include/verilated_vcd_sc.h b/include/verilated_vcd_sc.h index 133f70407..c0ba6e528 100644 --- a/include/verilated_vcd_sc.h +++ b/include/verilated_vcd_sc.h @@ -77,8 +77,7 @@ private: //-------------------------------------------------- // SystemC 2.1.v1 -#define DECL_TRACE_METHOD_A(tp) \ - void trace(const tp& object, const std::string& name) override; +#define DECL_TRACE_METHOD_A(tp) void trace(const tp& object, const std::string& name) override; #define DECL_TRACE_METHOD_B(tp) \ void trace(const tp& object, const std::string& name, int width) override; diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index ff2d25c27..be58390ed 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -114,7 +114,7 @@ public: static VerilatedVpio* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - inline vpiHandle castVpiHandle() { return reinterpret_cast(this); } + vpiHandle castVpiHandle() { return reinterpret_cast(this); } // ACCESSORS virtual const char* name() const { return ""; } virtual const char* fullname() const { return ""; } diff --git a/include/verilatedos.h b/include/verilatedos.h index 12763f815..c84e13ef0 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -39,7 +39,7 @@ #ifdef __GNUC__ # define VL_ATTR_ALIGNED(alignment) __attribute__((aligned(alignment))) -# define VL_ATTR_ALWINLINE __attribute__((always_inline)) +# define VL_ATTR_ALWINLINE __attribute__((always_inline)) inline # define VL_ATTR_NOINLINE __attribute__((noinline)) # define VL_ATTR_COLD __attribute__((cold)) # define VL_ATTR_HOT __attribute__((hot)) @@ -548,8 +548,8 @@ struct reverse_wrapper { explicit reverse_wrapper(const T& a_v) : m_v(a_v) {} - inline auto begin() -> decltype(m_v.rbegin()) { return m_v.rbegin(); } - inline auto end() -> decltype(m_v.rend()) { return m_v.rend(); } + auto begin() -> decltype(m_v.rbegin()) { return m_v.rbegin(); } + auto end() -> decltype(m_v.rend()) { return m_v.rend(); } }; // C++20's std::ranges::reverse_view diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 3bc1325bc..4a516e6be 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -212,8 +212,7 @@ string AstNode::prettyTypeName() const { //###################################################################### // Insertion -inline void AstNode::debugTreeChange(const AstNode* nodep, const char* prefix, int lineno, - bool next) { +void AstNode::debugTreeChange(const AstNode* nodep, const char* prefix, int lineno, bool next) { #ifdef VL_DEBUG // Called on all major tree changers. // Only for use for those really nasty bugs relating to internals diff --git a/src/V3Ast.h b/src/V3Ast.h index ff3cce31b..90a203042 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -93,11 +93,11 @@ public: // const char* ascii() const {...}; enum en m_e; // cppcheck-suppress uninitVar // responsibility of each subclass - inline VNType() = default; + VNType() = default; // cppcheck-suppress noExplicitConstructor - inline VNType(en _e) + VNType(en _e) : m_e{_e} {} - explicit inline VNType(int _e) + explicit VNType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -116,12 +116,12 @@ public: static const char* const names[] = {"NONE", "VAUTOM", "VSTATIC"}; return names[m_e]; } - inline VLifetime() + VLifetime() : m_e{NONE} {} // cppcheck-suppress noExplicitConstructor - inline VLifetime(en _e) + VLifetime(en _e) : m_e{_e} {} - explicit inline VLifetime(int _e) + explicit VLifetime(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool isNone() const { return m_e == NONE; } @@ -157,12 +157,12 @@ public: static const char* const names[] = {"[RV] <-", "[LV] =>", "[LV] <=>", "--"}; return names[m_e]; } - inline VAccess() + VAccess() : m_e{READ} {} // cppcheck-suppress noExplicitConstructor - inline VAccess(en _e) + VAccess(en _e) : m_e{_e} {} - explicit inline VAccess(int _e) + explicit VAccess(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } VAccess invert() const { @@ -194,19 +194,19 @@ public: static const char* const names[] = {"UNSIGNED", "SIGNED", "NOSIGN"}; return names[m_e]; } - inline VSigning() + VSigning() : m_e{UNSIGNED} {} // cppcheck-suppress noExplicitConstructor - inline VSigning(en _e) + VSigning(en _e) : m_e{_e} {} - static inline VSigning fromBool(bool isSigned) { // Factory method + static VSigning fromBool(bool isSigned) { // Factory method return isSigned ? VSigning{SIGNED} : VSigning{UNSIGNED}; } - explicit inline VSigning(int _e) + explicit VSigning(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } - inline bool isSigned() const { return m_e == SIGNED; } - inline bool isNosign() const { return m_e == NOSIGN; } + bool isSigned() const { return m_e == SIGNED; } + bool isNosign() const { return m_e == NOSIGN; } // No isUnsigned() as it's ambiguous if NOSIGN should be included or not. }; inline bool operator==(const VSigning& lhs, const VSigning& rhs) { return lhs.m_e == rhs.m_e; } @@ -234,12 +234,12 @@ public: ENUM_SIZE }; enum en m_e; - inline VPragmaType() + VPragmaType() : m_e{ILLEGAL} {} // cppcheck-suppress noExplicitConstructor - inline VPragmaType(en _e) + VPragmaType(en _e) : m_e{_e} {} - explicit inline VPragmaType(int _e) + explicit VPragmaType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -322,12 +322,12 @@ public: } return false; } - inline VEdgeType() + VEdgeType() : m_e{ET_ILLEGAL} {} // cppcheck-suppress noExplicitConstructor - inline VEdgeType(en _e) + VEdgeType(en _e) : m_e{_e} {} - explicit inline VEdgeType(int _e) + explicit VEdgeType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -403,12 +403,12 @@ public: // clang-format on return names[m_e]; } - inline VAttrType() + VAttrType() : m_e{ILLEGAL} {} // cppcheck-suppress noExplicitConstructor - inline VAttrType(en _e) + VAttrType(en _e) : m_e{_e} {} - explicit inline VAttrType(int _e) + explicit VAttrType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -470,12 +470,12 @@ public: UASSERT(0 == std::strcmp(VBasicDTypeKwd{_ENUM_MAX}.dpiType(), " MAX"), "SelfTest: Enum mismatch"); } - inline VBasicDTypeKwd() + VBasicDTypeKwd() : m_e{UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VBasicDTypeKwd(en _e) + VBasicDTypeKwd(en _e) : m_e{_e} {} - explicit inline VBasicDTypeKwd(int _e) + explicit VBasicDTypeKwd(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } int width() const { @@ -574,12 +574,12 @@ class VDirection final { public: enum en : uint8_t { NONE, INPUT, OUTPUT, INOUT, REF, CONSTREF }; enum en m_e; - inline VDirection() + VDirection() : m_e{NONE} {} // cppcheck-suppress noExplicitConstructor - inline VDirection(en _e) + VDirection(en _e) : m_e{_e} {} - explicit inline VDirection(int _e) + explicit VDirection(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -620,12 +620,12 @@ public: enum en : uint8_t { BU_FALSE = 0, BU_TRUE = 1, BU_UNKNOWN = 2, _ENUM_END }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline VBoolOrUnknown() + VBoolOrUnknown() : m_e{BU_UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VBoolOrUnknown(en _e) + VBoolOrUnknown(en _e) : m_e{_e} {} - explicit inline VBoolOrUnknown(int _e) + explicit VBoolOrUnknown(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning const char* ascii() const { static const char* const names[] = {"FALSE", "TRUE", "UNK"}; @@ -659,12 +659,12 @@ public: enum en : uint8_t { JOIN = 0, JOIN_ANY = 1, JOIN_NONE = 2 }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline VJoinType() + VJoinType() : m_e{JOIN} {} // cppcheck-suppress noExplicitConstructor - inline VJoinType(en _e) + VJoinType(en _e) : m_e{_e} {} - explicit inline VJoinType(int _e) + explicit VJoinType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning const char* ascii() const { static const char* const names[] = {"JOIN", "JOIN_ANY", "JOIN_NONE"}; @@ -712,12 +712,12 @@ public: MEMBER }; enum en m_e; - inline VVarType() + VVarType() : m_e{UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VVarType(en _e) + VVarType(en _e) : m_e{_e} {} - explicit inline VVarType(int _e) + explicit VVarType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -764,12 +764,12 @@ public: enum en : uint8_t { BP_UNKNOWN = 0, BP_LIKELY, BP_UNLIKELY, _ENUM_END }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline VBranchPred() + VBranchPred() : m_e{BP_UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VBranchPred(en _e) + VBranchPred(en _e) : m_e{_e} {} - explicit inline VBranchPred(int _e) + explicit VBranchPred(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool unknown() const { return m_e == BP_UNKNOWN; } @@ -805,12 +805,12 @@ public: enum en : uint8_t { CLOCKER_UNKNOWN = 0, CLOCKER_YES, CLOCKER_NO, _ENUM_END }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline VVarAttrClocker() + VVarAttrClocker() : m_e{CLOCKER_UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VVarAttrClocker(en _e) + VVarAttrClocker(en _e) : m_e{_e} {} - explicit inline VVarAttrClocker(int _e) + explicit VVarAttrClocker(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool unknown() const { return m_e == CLOCKER_UNKNOWN; } @@ -847,12 +847,12 @@ class VAlwaysKwd final { public: enum en : uint8_t { ALWAYS, ALWAYS_FF, ALWAYS_LATCH, ALWAYS_COMB }; enum en m_e; - inline VAlwaysKwd() + VAlwaysKwd() : m_e{ALWAYS} {} // cppcheck-suppress noExplicitConstructor - inline VAlwaysKwd(en _e) + VAlwaysKwd(en _e) : m_e{_e} {} - explicit inline VAlwaysKwd(int _e) + explicit VAlwaysKwd(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -870,12 +870,12 @@ class VCaseType final { public: enum en : uint8_t { CT_CASE, CT_CASEX, CT_CASEZ, CT_CASEINSIDE }; enum en m_e; - inline VCaseType() + VCaseType() : m_e{CT_CASE} {} // cppcheck-suppress noExplicitConstructor - inline VCaseType(en _e) + VCaseType(en _e) : m_e{_e} {} - explicit inline VCaseType(int _e) + explicit VCaseType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -903,7 +903,7 @@ public: // cppcheck-suppress noExplicitConstructor VDisplayType(en _e) : m_e{_e} {} - explicit inline VDisplayType(int _e) + explicit VDisplayType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool addNewline() const { return m_e != DT_WRITE; } @@ -926,12 +926,12 @@ class VDumpCtlType final { public: enum en : uint8_t { FILE, VARS, ALL, FLUSH, LIMIT, OFF, ON }; enum en m_e; - inline VDumpCtlType() + VDumpCtlType() : m_e{ON} {} // cppcheck-suppress noExplicitConstructor - inline VDumpCtlType(en _e) + VDumpCtlType(en _e) : m_e{_e} {} - explicit inline VDumpCtlType(int _e) + explicit VDumpCtlType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -956,12 +956,12 @@ public: PX_TEXT // Unknown ID component }; enum en m_e; - inline VParseRefExp() + VParseRefExp() : m_e{PX_NONE} {} // cppcheck-suppress noExplicitConstructor - inline VParseRefExp(en _e) + VParseRefExp(en _e) : m_e{_e} {} - explicit inline VParseRefExp(int _e) + explicit VParseRefExp(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -986,9 +986,9 @@ public: enum en m_e; // cppcheck-suppress noExplicitConstructor - inline VStrength(en strengthLevel) + VStrength(en strengthLevel) : m_e(strengthLevel) {} - explicit inline VStrength(int _e) + explicit VStrength(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } @@ -1080,12 +1080,12 @@ public: INT_FWD_CLASS, // Interface (.h) needs a forward class declaration }; enum en m_e; - inline VUseType() + VUseType() : m_e{IMP_FWD_CLASS} {} // cppcheck-suppress noExplicitConstructor - inline VUseType(en _e) + VUseType(en _e) : m_e{_e} {} - explicit inline VUseType(int _e) + explicit VUseType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning bool isInclude() const { return m_e == IMP_INCLUDE || m_e == INT_INCLUDE; } bool isFwdClass() const { return m_e == IMP_FWD_CLASS || m_e == INT_FWD_CLASS; } @@ -1309,23 +1309,23 @@ class VNVisitor VL_NOT_FINAL : public VNDeleter { public: /// Call visit()s on nodep - void iterate(AstNode* nodep); + inline void iterate(AstNode* nodep); /// Call visit()s on nodep - void iterateNull(AstNode* nodep); + inline void iterateNull(AstNode* nodep); /// Call visit()s on nodep's children - void iterateChildren(AstNode* nodep); + inline void iterateChildren(AstNode* nodep); /// Call visit()s on nodep's children in backp() order - void iterateChildrenBackwards(AstNode* nodep); + inline void iterateChildrenBackwards(AstNode* nodep); /// Call visit()s on const nodep's children - void iterateChildrenConst(AstNode* nodep); + inline void iterateChildrenConst(AstNode* nodep); /// Call visit()s on nodep (maybe nullptr) and nodep's nextp() list - void iterateAndNextNull(AstNode* nodep); + inline void iterateAndNextNull(AstNode* nodep); /// Call visit()s on const nodep (maybe nullptr) and nodep's nextp() list - void iterateAndNextConstNull(AstNode* nodep); + inline void iterateAndNextConstNull(AstNode* nodep); /// Call visit()s on const nodep (maybe nullptr) and nodep's nextp() list, in reverse order - void iterateAndNextConstNullBackwards(AstNode* nodep); + inline void iterateAndNextConstNullBackwards(AstNode* nodep); /// Return edited nodep; see comments in V3Ast.cpp - AstNode* iterateSubtreeReturnEdits(AstNode* nodep); + inline AstNode* iterateSubtreeReturnEdits(AstNode* nodep); virtual void visit(AstNode* nodep) = 0; #include "V3Ast__gen_visitor_decls.h" // From ./astgen @@ -1353,7 +1353,7 @@ protected: public: VNRelinker() = default; - void relink(AstNode* newp); + inline void relink(AstNode* newp); AstNode* oldp() const { return m_oldp; } void dump(std::ostream& str = std::cout) const; }; @@ -1525,7 +1525,7 @@ protected: public: // ACCESSORS - inline VNType type() const { return m_type; } + VNType type() const { return m_type; } const char* typeName() const { return type().ascii(); } // See also prettyTypeName AstNode* nextp() const { return m_nextp; } AstNode* backp() const { return m_backp; } @@ -1607,8 +1607,8 @@ public: virtual string prettyOperatorName() const { return "operator " + prettyTypeName(); } FileLine* fileline() const { return m_fileline; } void fileline(FileLine* fl) { m_fileline = fl; } - bool width1() const; - int widthInstrs() const; + inline bool width1() const; + inline int widthInstrs() const; void didWidth(bool flag) { m_flags.didWidth = flag; } bool didWidth() const { return m_flags.didWidth; } bool didWidthAndSet() { @@ -1622,17 +1622,17 @@ public: void protect(bool flag) { m_flags.protect = flag; } // TODO stomp these width functions out, and call via dtypep() instead - int width() const; - int widthMin() const; + inline int width() const; + inline int widthMin() const; int widthMinV() const { return v3Global.widthMinUsage() == VWidthMinUsage::VERILOG_WIDTH ? widthMin() : width(); } int widthWords() const { return VL_WORDS_I(width()); } bool isQuad() const { return (width() > VL_IDATASIZE && width() <= VL_QUADSIZE); } bool isWide() const { return (width() > VL_QUADSIZE); } - bool isDouble() const; - bool isSigned() const; - bool isString() const; + inline bool isDouble() const; + inline bool isSigned() const; + inline bool isString() const; // clang-format off VNUser user1u() const { @@ -1716,11 +1716,11 @@ public: // ACCESSORS for specific types // Alas these can't be virtual or they break when passed a nullptr - bool isZero() const; - bool isOne() const; - bool isNeqZero() const; - bool isAllOnes() const; - bool isAllOnesV() const; // Verilog width rules apply + inline bool isZero() const; + inline bool isOne() const; + inline bool isNeqZero() const; + inline bool isAllOnes() const; + inline bool isAllOnesV() const; // Verilog width rules apply // METHODS - data type changes especially for initial creation void dtypep(AstNodeDType* nodep) { @@ -1832,9 +1832,9 @@ public: } AstNode* cloneTree(bool cloneNextLink); // Not const, as sets clonep() on original nodep bool gateTree() { return gateTreeIter(); } // Is tree isGateOptimizable? - bool sameTree(const AstNode* node2p) const; // Does tree of this == node2p? + inline bool sameTree(const AstNode* node2p) const; // Does tree of this == node2p? // Does tree of this == node2p?, not allowing non-isGateOptimizable - bool sameGateTree(const AstNode* node2p) const; + inline bool sameGateTree(const AstNode* node2p) const; void deleteTree(); // Always deletes the next link void checkTree(); // User Interface version void checkIter() const; @@ -1932,7 +1932,7 @@ private: public: // For use via the VN_IS macro only template - inline static bool privateIs(const AstNode* nodep) { + static bool privateIs(const AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_IS, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_IS, node cannot be this type."); return nodep && privateTypeTest(nodep); @@ -1940,14 +1940,14 @@ public: // For use via the VN_CAST macro only template - inline static T* privateCast(AstNode* nodep) { + static T* privateCast(AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_CAST, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_CAST, node cannot be this type."); return nodep && privateTypeTest(nodep) ? reinterpret_cast(nodep) : nullptr; } template - inline static const T* privateCast(const AstNode* nodep) { + static const T* privateCast(const AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_CAST, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_CAST, node cannot be this type."); @@ -1956,7 +1956,7 @@ public: // For use via the VN_AS macro only template - inline static T* privateAs(AstNode* nodep) { + static T* privateAs(AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_AS, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_AS, node cannot be this type."); UASSERT_OBJ(!nodep || privateTypeTest(nodep), nodep, @@ -1965,7 +1965,7 @@ public: return reinterpret_cast(nodep); } template - inline static const T* privateAs(const AstNode* nodep) { + static const T* privateAs(const AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_AS, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_AS, node cannot be this type."); UASSERT_OBJ(!nodep || privateTypeTest(nodep), nodep, @@ -2172,7 +2172,7 @@ void AstNode::foreachImpl(ConstCorrectAstNode* nodep, const std::function constexpr int prefetchDistance = 2; // Grow stack to given size - const auto grow = [&](size_t size) VL_ATTR_ALWINLINE { + const auto grow = [&](size_t size) { const ptrdiff_t occupancy = topp - basep; stack.resize(size); basep = stack.data() + prefetchDistance; @@ -2188,7 +2188,7 @@ void AstNode::foreachImpl(ConstCorrectAstNode* nodep, const std::function for (int i = -prefetchDistance; i; ++i) basep[i] = nodep; // Visit given node, enqueue children for traversal - const auto visit = [&](Node* currp) VL_ATTR_ALWINLINE { + const auto visit = [&](Node* currp) { // Type test this node if (AstNode::privateTypeTest(currp)) { // Call the client function @@ -2253,7 +2253,7 @@ bool AstNode::predicateImpl(ConstCorrectAstNode* nodep, constexpr int prefetchDistance = 2; // Grow stack to given size - const auto grow = [&](size_t size) VL_ATTR_ALWINLINE { + const auto grow = [&](size_t size) { const ptrdiff_t occupancy = topp - basep; stack.resize(size); basep = stack.data() + prefetchDistance; @@ -2269,7 +2269,7 @@ bool AstNode::predicateImpl(ConstCorrectAstNode* nodep, for (int i = -prefetchDistance; i; ++i) basep[i] = nodep; // Visit given node, enqueue children for traversal, return true if result determined. - const auto visit = [&](Node* currp) VL_ATTR_ALWINLINE { + const auto visit = [&](Node* currp) { // Type test this node if (AstNode::privateTypeTest(currp)) { // Call the client function @@ -2322,7 +2322,7 @@ inline std::ostream& operator<<(std::ostream& os, const AstNode* rhs) { } return os; } -inline void VNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); } +void VNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); } //###################################################################### @@ -2369,25 +2369,25 @@ struct std::equal_to> final { //###################################################################### // Inline VNVisitor METHODS -inline void VNVisitor::iterate(AstNode* nodep) { nodep->accept(*this); } -inline void VNVisitor::iterateNull(AstNode* nodep) { +void VNVisitor::iterate(AstNode* nodep) { nodep->accept(*this); } +void VNVisitor::iterateNull(AstNode* nodep) { if (VL_LIKELY(nodep)) nodep->accept(*this); } -inline void VNVisitor::iterateChildren(AstNode* nodep) { nodep->iterateChildren(*this); } -inline void VNVisitor::iterateChildrenBackwards(AstNode* nodep) { +void VNVisitor::iterateChildren(AstNode* nodep) { nodep->iterateChildren(*this); } +void VNVisitor::iterateChildrenBackwards(AstNode* nodep) { nodep->iterateChildrenBackwards(*this); } -inline void VNVisitor::iterateChildrenConst(AstNode* nodep) { nodep->iterateChildrenConst(*this); } -inline void VNVisitor::iterateAndNextNull(AstNode* nodep) { +void VNVisitor::iterateChildrenConst(AstNode* nodep) { nodep->iterateChildrenConst(*this); } +void VNVisitor::iterateAndNextNull(AstNode* nodep) { if (VL_LIKELY(nodep)) nodep->iterateAndNext(*this); } -inline void VNVisitor::iterateAndNextConstNullBackwards(AstNode* nodep) { +void VNVisitor::iterateAndNextConstNullBackwards(AstNode* nodep) { if (VL_LIKELY(nodep)) nodep->iterateListBackwards(*this); } -inline void VNVisitor::iterateAndNextConstNull(AstNode* nodep) { +void VNVisitor::iterateAndNextConstNull(AstNode* nodep) { if (VL_LIKELY(nodep)) nodep->iterateAndNextConst(*this); } -inline AstNode* VNVisitor::iterateSubtreeReturnEdits(AstNode* nodep) { +AstNode* VNVisitor::iterateSubtreeReturnEdits(AstNode* nodep) { return nodep->iterateSubtreeReturnEdits(*this); } diff --git a/src/V3AstInlines.h b/src/V3AstInlines.h index d532feb01..9ffb7fa5c 100644 --- a/src/V3AstInlines.h +++ b/src/V3AstInlines.h @@ -25,71 +25,56 @@ //###################################################################### // Inline METHODS -inline AstNode* AstNode::addNext(AstNode* newp) { return addNext(this, newp); } -inline AstNode* AstNode::addNextNull(AstNode* newp) { return addNextNull(this, newp); } -inline void AstNode::addPrev(AstNode* newp) { +AstNode* AstNode::addNext(AstNode* newp) { return addNext(this, newp); } +AstNode* AstNode::addNextNull(AstNode* newp) { return addNextNull(this, newp); } +void AstNode::addPrev(AstNode* newp) { replaceWith(newp); newp->addNext(this); } -inline int AstNode::width() const { return dtypep() ? dtypep()->width() : 0; } -inline int AstNode::widthMin() const { return dtypep() ? dtypep()->widthMin() : 0; } -inline bool AstNode::width1() const { // V3Const uses to know it can optimize +int AstNode::width() const { return dtypep() ? dtypep()->width() : 0; } +int AstNode::widthMin() const { return dtypep() ? dtypep()->widthMin() : 0; } +bool AstNode::width1() const { // V3Const uses to know it can optimize return dtypep() && dtypep()->width() == 1; } -inline int AstNode::widthInstrs() const { +int AstNode::widthInstrs() const { return (!dtypep() ? 1 : (dtypep()->isWide() ? dtypep()->widthWords() : 1)); } -inline bool AstNode::isDouble() const { +bool AstNode::isDouble() const { return dtypep() && VN_IS(dtypep(), BasicDType) && VN_AS(dtypep(), BasicDType)->isDouble(); } -inline bool AstNode::isString() const { +bool AstNode::isString() const { return dtypep() && dtypep()->basicp() && dtypep()->basicp()->isString(); } -inline bool AstNode::isSigned() const { return dtypep() && dtypep()->isSigned(); } +bool AstNode::isSigned() const { return dtypep() && dtypep()->isSigned(); } -inline bool AstNode::isZero() const { +bool AstNode::isZero() const { return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqZero()); } -inline bool AstNode::isNeqZero() const { +bool AstNode::isNeqZero() const { return (VN_IS(this, Const) && VN_AS(this, Const)->num().isNeqZero()); } -inline bool AstNode::isOne() const { - return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqOne()); -} -inline bool AstNode::isAllOnes() const { +bool AstNode::isOne() const { return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqOne()); } +bool AstNode::isAllOnes() const { return (VN_IS(this, Const) && VN_AS(this, Const)->isEqAllOnes()); } -inline bool AstNode::isAllOnesV() const { +bool AstNode::isAllOnesV() const { return (VN_IS(this, Const) && VN_AS(this, Const)->isEqAllOnesV()); } -inline bool AstNode::sameTree(const AstNode* node2p) const { +bool AstNode::sameTree(const AstNode* node2p) const { return sameTreeIter(this, node2p, true, false); } -inline bool AstNode::sameGateTree(const AstNode* node2p) const { +bool AstNode::sameGateTree(const AstNode* node2p) const { return sameTreeIter(this, node2p, true, true); } -inline void AstNodeVarRef::varp(AstVar* varp) { - m_varp = varp; - dtypeFrom(varp); -} - -inline bool AstNodeDType::isFourstate() const { return basicp()->isFourstate(); } - -inline void AstNodeArrayDType::rangep(AstRange* nodep) { setOp2p(nodep); } -inline int AstNodeArrayDType::left() const { return rangep()->leftConst(); } -inline int AstNodeArrayDType::right() const { return rangep()->rightConst(); } -inline int AstNodeArrayDType::hi() const { return rangep()->hiConst(); } -inline int AstNodeArrayDType::lo() const { return rangep()->loConst(); } -inline int AstNodeArrayDType::elementsConst() const { return rangep()->elementsConst(); } -inline VNumRange AstNodeArrayDType::declRange() const { return VNumRange{left(), right()}; } - -inline void AstIfaceRefDType::cloneRelink() { - if (m_cellp && m_cellp->clonep()) m_cellp = m_cellp->clonep(); - if (m_ifacep && m_ifacep->clonep()) m_ifacep = m_ifacep->clonep(); - if (m_modportp && m_modportp->clonep()) m_modportp = m_modportp->clonep(); -} +void AstNodeArrayDType::rangep(AstRange* nodep) { setOp2p(nodep); } +int AstNodeArrayDType::left() const { return rangep()->leftConst(); } +int AstNodeArrayDType::right() const { return rangep()->rightConst(); } +int AstNodeArrayDType::hi() const { return rangep()->hiConst(); } +int AstNodeArrayDType::lo() const { return rangep()->loConst(); } +int AstNodeArrayDType::elementsConst() const { return rangep()->elementsConst(); } +VNumRange AstNodeArrayDType::declRange() const { return VNumRange{left(), right()}; } AstRange::AstRange(FileLine* fl, int left, int right) : ASTGEN_SUPER_Range(fl) { diff --git a/src/V3AstNodeDType.h b/src/V3AstNodeDType.h index 8df86afab..02d45f31e 100644 --- a/src/V3AstNodeDType.h +++ b/src/V3AstNodeDType.h @@ -172,7 +172,7 @@ public: AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } AstRange* rangep() const { return VN_AS(op2p(), Range); } // op2 = Array(s) of variable - void rangep(AstRange* nodep); + inline void rangep(AstRange* nodep); // METHODS AstBasicDType* basicp() const override { return subDTypep()->basicp(); @@ -184,12 +184,12 @@ public: int widthTotalBytes() const override { return elementsConst() * subDTypep()->widthTotalBytes(); } - int left() const; - int right() const; - int hi() const; - int lo() const; - int elementsConst() const; - VNumRange declRange() const; + inline int left() const; + inline int right() const; + inline int hi() const; + inline int lo() const; + inline int elementsConst() const; + inline VNumRange declRange() const; }; class AstNodeUOrStructDType VL_NOT_FINAL : public AstNodeDType { // A struct or union; common handling diff --git a/src/V3AstNodeMath.h b/src/V3AstNodeMath.h index 498fbce3b..14e9bd2ab 100644 --- a/src/V3AstNodeMath.h +++ b/src/V3AstNodeMath.h @@ -341,7 +341,10 @@ public: VAccess access() const { return m_access; } void access(const VAccess& flag) { m_access = flag; } // Avoid using this; Set in constructor AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable - void varp(AstVar* varp); + void varp(AstVar* varp) { + m_varp = varp; + dtypeFrom((AstNode*)varp); + } AstVarScope* varScopep() const { return m_varScopep; } void varScopep(AstVarScope* varscp) { m_varScopep = varscp; } string selfPointer() const { return m_selfPointer; } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index d891a46c4..5bbc6bf42 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -683,6 +683,8 @@ AstVar* AstVar::scVarRecurse(AstNode* nodep) { return nullptr; } +bool AstNodeDType::isFourstate() const { return basicp()->isFourstate(); } + class AstNodeDType::CTypeRecursed final { public: string m_type; // The base type, e.g.: "Foo_t"s @@ -1490,6 +1492,11 @@ void AstIfaceRefDType::dumpSmall(std::ostream& str) const { this->AstNodeDType::dumpSmall(str); str << "iface"; } +void AstIfaceRefDType::cloneRelink() { + if (m_cellp && m_cellp->clonep()) m_cellp = m_cellp->clonep(); + if (m_ifacep && m_ifacep->clonep()) m_ifacep = m_ifacep->clonep(); + if (m_modportp && m_modportp->clonep()) m_modportp = m_modportp->clonep(); +} void AstInitArray::dump(std::ostream& str) const { this->AstNode::dump(str); int n = 0; diff --git a/src/V3AstUserAllocator.h b/src/V3AstUserAllocator.h index 478c31dfa..1a7f55a46 100644 --- a/src/V3AstUserAllocator.h +++ b/src/V3AstUserAllocator.h @@ -35,7 +35,7 @@ class AstUserAllocatorBase VL_NOT_FINAL { private: std::vector m_allocated; - inline T_Data* getUserp(const T_Node* nodep) const { + T_Data* getUserp(const T_Node* nodep) const { if VL_CONSTEXPR_CXX17 (T_UserN == 1) { const VNUser user = nodep->user1u(); return user.to(); @@ -54,7 +54,7 @@ private: } } - inline void setUserp(T_Node* nodep, T_Data* userp) const { + void setUserp(T_Node* nodep, T_Data* userp) const { if VL_CONSTEXPR_CXX17 (T_UserN == 1) { nodep->user1u(VNUser{userp}); } else if VL_CONSTEXPR_CXX17 (T_UserN == 2) { diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index 75fb8c356..dd4978eca 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -132,8 +132,8 @@ private: public: // METHODS void clear() { m_linkable.clear(); } - inline void addLinkable(const AstNode* nodep) { m_linkable.emplace(nodep); } - inline bool isLinkable(const AstNode* nodep) const { return m_linkable.count(nodep) != 0; } + void addLinkable(const AstNode* nodep) { m_linkable.emplace(nodep); } + bool isLinkable(const AstNode* nodep) const { return m_linkable.count(nodep) != 0; } } s_linkableTable; bool V3Broken::isLinkable(const AstNode* nodep) { return s_linkableTable.isLinkable(nodep); } diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index f28e959fc..090009c24 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -44,7 +44,7 @@ private: public: // cppcheck-suppress noExplicitConstructor - inline VCtorType(en _e) + VCtorType(en _e) : m_e{_e} {} bool isClass() const { return m_e == CLASS; } bool isCoverage() const { return m_e == COVERAGE; } diff --git a/src/V3Config.cpp b/src/V3Config.cpp index 5961bf7d0..f716bba2b 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -309,7 +309,7 @@ public: if (lineMatch(lineno, VPragmaType::FULL_CASE)) nodep->fullPragma(true); if (lineMatch(lineno, VPragmaType::PARALLEL_CASE)) nodep->parallelPragma(true); } - inline void applyIgnores(FileLine* filelinep) { + void applyIgnores(FileLine* filelinep) { // HOT routine, called each parsed token line of this filename if (m_lastIgnore.lineno != filelinep->lineno()) { // UINFO(9, " ApplyIgnores for " << filelinep->ascii() << endl); diff --git a/src/V3Error.h b/src/V3Error.h index 077260995..e977a5feb 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -142,13 +142,13 @@ public: }; // clang-format on enum en m_e; - inline V3ErrorCode() + V3ErrorCode() : m_e{EC_MIN} {} // cppcheck-suppress noExplicitConstructor - inline V3ErrorCode(en _e) + V3ErrorCode(en _e) : m_e{_e} {} explicit V3ErrorCode(const char* msgp); // Matching code or ERROR - explicit inline V3ErrorCode(int _e) + explicit V3ErrorCode(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { diff --git a/src/V3File.cpp b/src/V3File.cpp index c4adf58bc..b8c8e6ad6 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -146,7 +146,7 @@ V3FileDependImp dependImp; // Depend implementation class //###################################################################### // V3FileDependImp -inline void V3FileDependImp::writeDepend(const string& filename) { +void V3FileDependImp::writeDepend(const string& filename) { const std::unique_ptr ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); @@ -171,7 +171,7 @@ inline void V3FileDependImp::writeDepend(const string& filename) { } } -inline std::vector V3FileDependImp::getAllDeps() const { +std::vector V3FileDependImp::getAllDeps() const { std::vector r; for (const auto& itr : m_filenameList) { if (!itr.target() && itr.exists()) r.push_back(itr.filename()); @@ -179,7 +179,7 @@ inline std::vector V3FileDependImp::getAllDeps() const { return r; } -inline void V3FileDependImp::writeTimes(const string& filename, const string& cmdlineIn) { +void V3FileDependImp::writeTimes(const string& filename, const string& cmdlineIn) { const std::unique_ptr ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); @@ -214,7 +214,7 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm } } -inline bool V3FileDependImp::checkTimes(const string& filename, const string& cmdlineIn) { +bool V3FileDependImp::checkTimes(const string& filename, const string& cmdlineIn) { const std::unique_ptr ifp{V3File::new_ifstream_nodepend(filename)}; if (ifp->fail()) { UINFO(2, " --check-times failed: no input " << filename << endl); diff --git a/src/V3FileLine.h b/src/V3FileLine.h index f16bc5bca..892fb97bd 100644 --- a/src/V3FileLine.h +++ b/src/V3FileLine.h @@ -247,7 +247,11 @@ public: // OPERATORS void v3errorEnd(std::ostringstream& str, const string& extra = ""); - void v3errorEndFatal(std::ostringstream& str) VL_ATTR_NORETURN; + void v3errorEndFatal(std::ostringstream& str) VL_ATTR_NORETURN { + v3errorEnd(str); + assert(0); // LCOV_EXCL_LINE + VL_UNREACHABLE + } /// When building an error, prefix for printing continuation lines /// e.g. information referring to the same FileLine as before string warnMore() const; @@ -286,10 +290,4 @@ private: }; std::ostream& operator<<(std::ostream& os, FileLine* fileline); -inline void FileLine::v3errorEndFatal(std::ostringstream& str) { - v3errorEnd(str); - assert(0); // LCOV_EXCL_LINE - VL_UNREACHABLE -} - #endif // Guard diff --git a/src/V3Graph.h b/src/V3Graph.h index a18fb5dfc..9d6b9ea06 100644 --- a/src/V3Graph.h +++ b/src/V3Graph.h @@ -54,12 +54,12 @@ public: // // an array dimension or loop bound. }; enum en m_e; - inline GraphWay() + GraphWay() : m_e{FORWARD} {} // cppcheck-suppress noExplicitConstructor - inline constexpr GraphWay(en _e) + constexpr GraphWay(en _e) : m_e{_e} {} - explicit inline constexpr GraphWay(int _e) + explicit constexpr GraphWay(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index 00ab8564f..8860a5479 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -121,7 +121,7 @@ private: void placeTryEdge(V3GraphEdge* edgep); bool placeIterate(GraphAcycVertex* vertexp, uint32_t currentRank); - inline bool origFollowEdge(V3GraphEdge* edgep) { + bool origFollowEdge(V3GraphEdge* edgep) { return (edgep->weight() && (m_origEdgeFuncp)(edgep)); } V3GraphEdge* edgeFromEdge(V3GraphEdge* oldedgep, V3GraphVertex* fromp, V3GraphVertex* top) { diff --git a/src/V3GraphAlg.h b/src/V3GraphAlg.h index 2cc4ce9b5..6441b2cca 100644 --- a/src/V3GraphAlg.h +++ b/src/V3GraphAlg.h @@ -38,9 +38,7 @@ protected: , m_edgeFuncp{edgeFuncp} {} ~GraphAlg() = default; // METHODS - inline bool followEdge(V3GraphEdge* edgep) { - return (edgep->weight() && (m_edgeFuncp)(edgep)); - } + bool followEdge(V3GraphEdge* edgep) { return (edgep->weight() && (m_edgeFuncp)(edgep)); } }; //============================================================================ diff --git a/src/V3Hash.h b/src/V3Hash.h index 13f86dd6d..c5dd1b631 100644 --- a/src/V3Hash.h +++ b/src/V3Hash.h @@ -26,7 +26,7 @@ class V3Hash final { uint32_t m_value; // The 32-bit hash value. - inline static uint32_t combine(uint32_t a, uint32_t b) { + static uint32_t combine(uint32_t a, uint32_t b) { return a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2)); } diff --git a/src/V3LangCode.h b/src/V3LangCode.h index 0565a948d..1d2d70326 100644 --- a/src/V3LangCode.h +++ b/src/V3LangCode.h @@ -55,13 +55,13 @@ public: bool legal() const { return m_e != L_ERROR; } // enum en m_e; - inline V3LangCode() + V3LangCode() : m_e{L_ERROR} {} // cppcheck-suppress noExplicitConstructor - inline V3LangCode(en _e) + V3LangCode(en _e) : m_e{_e} {} explicit V3LangCode(const char* textp); - explicit inline V3LangCode(int _e) + explicit V3LangCode(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; diff --git a/src/V3Life.cpp b/src/V3Life.cpp index d33a47291..5ae48ebd4 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -94,18 +94,18 @@ public: consumed(); } ~LifeVarEntry() = default; - inline void simpleAssign(AstNodeAssign* assp) { // New simple A=.... assignment + void simpleAssign(AstNodeAssign* assp) { // New simple A=.... assignment m_assignp = assp; m_constp = nullptr; m_everSet = true; if (VN_IS(assp->rhsp(), Const)) m_constp = VN_AS(assp->rhsp(), Const); } - inline void complexAssign() { // A[x]=... or some complicated assignment + void complexAssign() { // A[x]=... or some complicated assignment m_assignp = nullptr; m_constp = nullptr; m_everSet = true; } - inline void consumed() { // Rvalue read of A + void consumed() { // Rvalue read of A m_assignp = nullptr; } AstNodeAssign* assignp() const { return m_assignp; } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 4168a0b83..2825daaf7 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -1966,7 +1966,7 @@ private: nodep->v3error("Illegal call of a task as a function: " << nodep->prettyNameQ()); } } - inline void checkNoDot(AstNode* nodep) { + void checkNoDot(AstNode* nodep) { if (VL_UNLIKELY(m_ds.m_dotPos != DP_NONE)) { // UINFO(9, "ds=" << m_ds.ascii() << endl); nodep->v3error("Syntax Error: Not expecting " << nodep->type() << " under a " diff --git a/src/V3Options.h b/src/V3Options.h index 028171c5a..6c0eea7fe 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -39,12 +39,12 @@ class VOptionBool final { public: enum en : uint8_t { OPT_DEFAULT_FALSE = 0, OPT_DEFAULT_TRUE, OPT_TRUE, OPT_FALSE }; enum en m_e; - inline VOptionBool() + VOptionBool() : m_e{OPT_DEFAULT_FALSE} {} // cppcheck-suppress noExplicitConstructor - inline VOptionBool(en _e) + VOptionBool(en _e) : m_e{_e} {} - explicit inline VOptionBool(int _e) + explicit VOptionBool(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool isDefault() const { return m_e == OPT_DEFAULT_FALSE || m_e == OPT_DEFAULT_TRUE; } @@ -78,12 +78,12 @@ public: enum : uint8_t { TS_DEFAULT = TS_1PS }; enum en m_e; // CONSTRUCTOR - inline VTimescale() + VTimescale() : m_e{NONE} {} // cppcheck-suppress noExplicitConstructor - inline VTimescale(en _e) + VTimescale(en _e) : m_e{_e} {} - explicit inline VTimescale(int _e) + explicit VTimescale(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning // Construct from string VTimescale(const string& value, bool& badr); @@ -131,9 +131,9 @@ class TraceFormat final { public: enum en : uint8_t { VCD = 0, FST } m_e; // cppcheck-suppress noExplicitConstructor - inline TraceFormat(en _e = VCD) + TraceFormat(en _e = VCD) : m_e{_e} {} - explicit inline TraceFormat(int _e) + explicit TraceFormat(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool fst() const { return m_e == FST; } diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 3c0aee447..539d6b6fa 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -816,7 +816,7 @@ public: OrderMoveDomScope::DomScopeMap OrderMoveDomScope::s_dsMap; -inline std::ostream& operator<<(std::ostream& lhs, const OrderMoveDomScope& rhs) { +std::ostream& operator<<(std::ostream& lhs, const OrderMoveDomScope& rhs) { lhs << rhs.name(); return lhs; } @@ -1349,7 +1349,7 @@ public: // OrderMoveDomScope methods // Check the domScope is on ready list, add if not -inline void OrderMoveDomScope::ready(OrderProcess* opp) { +void OrderMoveDomScope::ready(OrderProcess* opp) { if (!m_onReadyList) { m_onReadyList = true; m_readyDomScopeE.pushBack(opp->m_pomReadyDomScope, this); @@ -1357,7 +1357,7 @@ inline void OrderMoveDomScope::ready(OrderProcess* opp) { } // Mark one vertex as finished, remove from ready list if done -inline void OrderMoveDomScope::movedVertex(OrderProcess* opp, OrderMoveVertex* vertexp) { +void OrderMoveDomScope::movedVertex(OrderProcess* opp, OrderMoveVertex* vertexp) { UASSERT_OBJ(m_onReadyList, vertexp, "Moving vertex from ready when nothing was on que as ready."); if (m_readyVertices.empty()) { // Else more work to get to later diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index 08c0a54e8..127253002 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -87,12 +87,12 @@ struct OrderVEdgeType { return names[m_e]; } enum en m_e; - inline OrderVEdgeType() + OrderVEdgeType() : m_e{VERTEX_UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline OrderVEdgeType(en _e) + OrderVEdgeType(en _e) : m_e{_e} {} - explicit inline OrderVEdgeType(int _e) + explicit OrderVEdgeType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; diff --git a/src/V3PreLex.h b/src/V3PreLex.h index 804b29e86..8ce783957 100644 --- a/src/V3PreLex.h +++ b/src/V3PreLex.h @@ -143,7 +143,7 @@ public: ~VPreStream() { lexStreamDepthAdd(-1); } private: - void lexStreamDepthAdd(int delta); + inline void lexStreamDepthAdd(int delta); }; //====================================================================== @@ -237,6 +237,6 @@ private: void scanSwitchStream(VPreStream* streamp); }; -inline void VPreStream::lexStreamDepthAdd(int delta) { m_lexp->streamDepthAdd(delta); } +void VPreStream::lexStreamDepthAdd(int delta) { m_lexp->streamDepthAdd(delta); } #endif // Guard diff --git a/src/V3String.cpp b/src/V3String.cpp index 1a42ee2e7..54fcfac07 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -31,7 +31,7 @@ std::map VName::s_dehashMap; // Wildcard // Double procedures, inlined, unrolls loop much better -inline bool VString::wildmatchi(const char* s, const char* p) { +bool VString::wildmatchi(const char* s, const char* p) { for (; *p; s++, p++) { if (*p != '*') { if (((*s) != (*p)) && *p != '?') return false; @@ -193,13 +193,11 @@ static const uint32_t sha256K[] 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}; -static inline uint32_t shaRotr32(uint32_t lhs, uint32_t rhs) VL_ATTR_ALWINLINE; -static inline uint32_t shaRotr32(uint32_t lhs, uint32_t rhs) { - return lhs >> rhs | lhs << (32 - rhs); -} +VL_ATTR_ALWINLINE +static uint32_t shaRotr32(uint32_t lhs, uint32_t rhs) { return lhs >> rhs | lhs << (32 - rhs); } -static inline void sha256Block(uint32_t* h, const uint32_t* chunk) VL_ATTR_ALWINLINE; -static inline void sha256Block(uint32_t* h, const uint32_t* chunk) { +VL_ATTR_ALWINLINE +static void sha256Block(uint32_t* h, const uint32_t* chunk) { uint32_t ah[8]; const uint32_t* p = chunk; diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index eda173f78..d671e23f3 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -255,7 +255,7 @@ private: return entryp; } } - inline bool isSubstVar(AstVar* nodep) { return nodep->isStatementTemp() && !nodep->noSubst(); } + bool isSubstVar(AstVar* nodep) { return nodep->isStatementTemp() && !nodep->noSubst(); } // VISITORS void visit(AstNodeAssign* nodep) override { diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index c89e1f3b9..26055725d 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -122,7 +122,7 @@ public: (new V3GraphEdge(this, tp, fp, cost))->user(userValue); } - inline static uint32_t getEdgeId(const V3GraphEdge* edgep) { + static uint32_t getEdgeId(const V3GraphEdge* edgep) { return static_cast(edgep->user()); } @@ -138,7 +138,7 @@ private: // We will keep sorted lists of edges as vectors using EdgeList = std::vector; - inline static bool edgeCmp(const V3GraphEdge* ap, const V3GraphEdge* bp) { + static bool edgeCmp(const V3GraphEdge* ap, const V3GraphEdge* bp) { // We pre-computed these when adding the edge to sort first by cost, then by identity return ap->user() > bp->user(); } @@ -150,7 +150,7 @@ private: } }; - inline static Vertex* castVertexp(V3GraphVertex* vxp) { return static_cast(vxp); } + static Vertex* castVertexp(V3GraphVertex* vxp) { return static_cast(vxp); } public: // From *this, populate *mstp with the minimum spanning tree. diff --git a/test_regress/t/TestVpi.h b/test_regress/t/TestVpi.h index 389707823..40734b7c6 100644 --- a/test_regress/t/TestVpi.h +++ b/test_regress/t/TestVpi.h @@ -29,7 +29,7 @@ public: , m_freeit(true) {} ~TestVpiHandle() { release(); } operator vpiHandle() const { return m_handle; } - inline TestVpiHandle& operator=(vpiHandle h) { + TestVpiHandle& operator=(vpiHandle h) { release(); m_handle = h; return *this; diff --git a/test_regress/t/t_dist_cppstyle.pl b/test_regress/t/t_dist_cppstyle.pl index a54fef2dd..7a8f23e5d 100755 --- a/test_regress/t/t_dist_cppstyle.pl +++ b/test_regress/t/t_dist_cppstyle.pl @@ -24,8 +24,22 @@ foreach my $file (sort keys %files) { my $contents = file_contents($filename); checkPattern($filename, $contents, - qr/virtual[^{};]+override/, + qr/[^\/]*virtual[^{};]+override/, "'virtual' keyword is redundant on 'override' method"); + + checkPattern($filename, $contents, + qr/ \s*(\w+ )*\s*(inline) [^;]+?\([^;]*?\)[^;]+?(?:{|:|=\s*default)/, + "'inline' keyword is redundant on method definitions inside classes"); + + checkPattern($filename, $contents, + qr/(?\n)inline \S+ [^;:(]+::[^;:(]+\([^;]*\)[^;]+{/, + "Use 'inline' only on declaration inside classes (except for template specializatoins)"); + + if ($file =~ /\.(c|cpp)/) { + checkPattern($filename, $contents, + qr/(\w+\s+)*(inline)/, + "'inline' keyword is on functions defined in .cpp files"); + } } ok(1); @@ -51,8 +65,8 @@ sub checkPattern { my $offset = 0; my $buffer = $contents; - while ($buffer =~ s/.*?^[^\/]*($pattern)//sm) { - my $lineno = offset_to_lineno($contents, $offset + $-[1]); + while ($buffer =~ s/.*?^($pattern)//sm) { + my $lineno = offset_to_lineno($contents, $offset + $-[-1]); $offset += $+[1]; error("$filename:$lineno: $message"); } diff --git a/test_regress/t/t_extend_class_c.h b/test_regress/t/t_extend_class_c.h index c5e98001b..a1cdd58dc 100644 --- a/test_regress/t/t_extend_class_c.h +++ b/test_regress/t/t_extend_class_c.h @@ -13,5 +13,5 @@ public: ~t_extend_class_c() = default; // METHODS // This function will be called from a instance created in Verilog - inline uint32_t my_math(uint32_t in) { return in + 1; } + uint32_t my_math(uint32_t in) { return in + 1; } };