From 990ccd67638da2f327c0aade3246b47014a5c58f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 29 Nov 2024 18:01:50 -0500 Subject: [PATCH] Internals: Standardize on `template +template class VerilatedTrace; class VerilatedTraceBaseC; class VerilatedTraceConfig; @@ -300,7 +300,7 @@ public: private: // The following are for use by Verilator internals only - template + template friend class VerilatedTrace; // Run-time trace configuration requested by this model virtual std::unique_ptr traceConfig() const; diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index 3491aa376..412102476 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -71,7 +71,7 @@ public: // But only local to this file // This isn't in the header file for auto-magic conversion because it // inlines to too much code and makes compilation too slow. -template +template class VerilatedCoverItemSpec final : public VerilatedCovImpItem { private: // MEMBERS diff --git a/include/verilated_save.h b/include/verilated_save.h index 4ff97a154..724fe8298 100644 --- a/include/verilated_save.h +++ b/include/verilated_save.h @@ -300,7 +300,7 @@ inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, std::string& r VerilatedSerialize& operator<<(VerilatedSerialize& os, VerilatedContext* rhsp); VerilatedDeserialize& operator>>(VerilatedDeserialize& os, VerilatedContext* rhsp); -template +template VerilatedSerialize& operator<<(VerilatedSerialize& os, VlAssocArray& rhs) { os << rhs.atDefault(); const uint32_t len = rhs.size(); @@ -312,7 +312,7 @@ VerilatedSerialize& operator<<(VerilatedSerialize& os, VlAssocArray +template VerilatedDeserialize& operator>>(VerilatedDeserialize& os, VlAssocArray& rhs) { os >> rhs.atDefault(); uint32_t len = 0; diff --git a/include/verilated_trace.h b/include/verilated_trace.h index 87d5025b4..d5b8f76bb 100644 --- a/include/verilated_trace.h +++ b/include/verilated_trace.h @@ -41,9 +41,9 @@ // clang-format on class VlThreadPool; -template +template class VerilatedTraceBuffer; -template +template class VerilatedTraceOffloadBuffer; //============================================================================= @@ -100,7 +100,7 @@ enum class VerilatedTraceSigType : uint8_t { // Offloaded tracing // A simple synchronized first in first out queue -template +template class VerilatedThreadQueue final { // LCOV_EXCL_LINE // lcov bug private: mutable VerilatedMutex m_mutex; // Protects m_queue @@ -202,7 +202,7 @@ public: // T_Trace is the format-specific subclass of VerilatedTrace. // T_Buffer is the format-specific base class of VerilatedTraceBuffer. -template +template class VerilatedTrace VL_NOT_FINAL { public: using Buffer = VerilatedTraceBuffer; @@ -442,7 +442,7 @@ public: // T_Buffer is the format-specific base class of VerilatedTraceBuffer. // The format-specific hot-path methods use duck-typing via T_Buffer for performance. -template +template class VerilatedTraceBuffer VL_NOT_FINAL : public T_Buffer { protected: // Type of the owner trace file @@ -543,7 +543,7 @@ public: // T_Buffer is the format-specific base class of VerilatedTraceBuffer. // The format-specific hot-path methods use duck-typing via T_Buffer for performance. -template +template class VerilatedTraceOffloadBuffer final : public VerilatedTraceBuffer { using typename VerilatedTraceBuffer::Trace; diff --git a/include/verilated_types.h b/include/verilated_types.h index 2e8af51ee..fe6db1774 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -309,7 +309,7 @@ public: size_t operator()() { return VL_MASK_I(31) & vl_rand64(); } }; -template +template class VlRandC final { T_Value m_remaining = 0; // Number of values to pull before re-randomize T_Value m_lfsr = 1; // LFSR state @@ -477,7 +477,7 @@ std::string VL_TO_STRING(const VlWide& obj) { // // Bound here is the maximum size() allowed, e.g. 1 + SystemVerilog bound // For dynamic arrays it is always zero -template +template class VlQueue final { private: // TYPES @@ -485,7 +485,7 @@ private: public: using const_iterator = typename Deque::const_iterator; - template + template using WithFuncReturnType = decltype(std::declval()(0, std::declval())); private: @@ -909,7 +909,7 @@ public: } }; -template +template std::string VL_TO_STRING(const VlQueue& obj) { return obj.to_string(); } @@ -919,7 +919,7 @@ std::string VL_TO_STRING(const VlQueue& obj) { // There are no multithreaded locks on this; the base variable must // be protected by other means // -template +template class VlAssocArray final { private: // TYPES @@ -927,7 +927,7 @@ private: public: using const_iterator = typename Map::const_iterator; - template + template using WithFuncReturnType = decltype(std::declval()(std::declval(), std::declval())); @@ -1244,12 +1244,12 @@ public: } }; -template +template std::string VL_TO_STRING(const VlAssocArray& obj) { return obj.to_string(); } -template +template void VL_READMEM_N(bool hex, int bits, const std::string& filename, VlAssocArray& obj, QData start, QData end) VL_MT_SAFE { VlReadMem rmem{hex, bits, filename, start, end}; @@ -1265,7 +1265,7 @@ void VL_READMEM_N(bool hex, int bits, const std::string& filename, } } -template +template void VL_WRITEMEM_N(bool hex, int bits, const std::string& filename, const VlAssocArray& obj, QData start, QData end) VL_MT_SAFE { VlWriteMem wmem{hex, bits, filename, start, end}; @@ -1287,9 +1287,8 @@ void VL_WRITEMEM_N(bool hex, int bits, const std::string& filename, /// This class may get exposed to a Verilated Model's top I/O, if the top /// IO has an unpacked array. -template -struct VlUnpacked final { -private: +template +class VlUnpacked final { // TYPES using T_Key = IData; // Index type, for uniformity with other containers using Unpacked = T_Value[T_Depth]; @@ -1569,7 +1568,7 @@ private: } }; -template +template std::string VL_TO_STRING(const VlUnpacked& obj) { return obj.to_string(); } @@ -2027,7 +2026,7 @@ public: #define VL_KEEP_THIS \ VlClassRef::type> __Vthisref { this } -template // T typically of type VlClassRef +template // T typically of type VlClassRef inline T VL_NULL_CHECK(T t, const char* filename, int linenum) { if (VL_UNLIKELY(!t)) Verilated::nullPointerError(filename, linenum); return t; diff --git a/include/verilatedos.h b/include/verilatedos.h index f633a0f32..c96f1b022 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -701,7 +701,7 @@ reverse_wrapper reverse_view(const T& v) { // Object that is returned by this function is not considered // as MT_SAFE and any function call on this object still // needs to be `VL_MT_SAFE`. -template +template T const& as_const(T& v) VL_MT_SAFE { return v; } diff --git a/src/V3Ast.h b/src/V3Ast.h index 4169c7dc2..c298829fc 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1745,7 +1745,7 @@ public: explicit VNUser(void* p) { m_u.up = p; } ~VNUser() = default; // Casters - template + template typename std::enable_if::value, T>::type to() const VL_MT_SAFE { return reinterpret_cast(m_u.up); } diff --git a/src/V3AstUserAllocator.h b/src/V3AstUserAllocator.h index e18aea1b1..974be6b0b 100644 --- a/src/V3AstUserAllocator.h +++ b/src/V3AstUserAllocator.h @@ -27,7 +27,7 @@ #include #include -template +template class AstUserAllocatorBase VL_NOT_FINAL { static_assert(1 <= T_UserN && T_UserN <= 4, "Wrong user pointer number"); static_assert(std::is_base_of::value, "T_Node must be an AstNode type"); @@ -107,13 +107,13 @@ public: // User pointer allocator classes. T_Node is the type of node the allocator should be applied to // and is there for a bit of extra type safety. T_Data is the type of the data structure // managed by the allocator. -template +template class AstUser1Allocator final : public AstUserAllocatorBase {}; -template +template class AstUser2Allocator final : public AstUserAllocatorBase {}; -template +template class AstUser3Allocator final : public AstUserAllocatorBase {}; -template +template class AstUser4Allocator final : public AstUserAllocatorBase {}; #endif // Guard diff --git a/src/V3Const.cpp b/src/V3Const.cpp index f25116282..da37703aa 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -57,7 +57,7 @@ static bool isConst(const AstNode* nodep, uint64_t v) { return constp && constp->toUQuad() == v; } -template +template static typename std::enable_if::value, bool>::type isPow2(T val) { return (val & (val - 1)) == 0; } diff --git a/src/V3GraphAlg.h b/src/V3GraphAlg.h index 63fec5691..4a5478237 100644 --- a/src/V3GraphAlg.h +++ b/src/V3GraphAlg.h @@ -27,7 +27,7 @@ // Algorithms - common class // For internal use, most graph algorithms use this as a base class -template // Or sometimes const V3Graph +template // Or sometimes const V3Graph class GraphAlg VL_NOT_FINAL { protected: T_Graph* const m_graphp; // Graph we're operating upon diff --git a/src/V3GraphStream.h b/src/V3GraphStream.h index 7741938b0..948c762d4 100644 --- a/src/V3GraphStream.h +++ b/src/V3GraphStream.h @@ -40,7 +40,7 @@ // not generally safe. If you want a raw pointer compare, see // GraphStreamUnordered below. -template +template class GraphStream final { // TYPES class VxHolder final { diff --git a/src/V3Hash.h b/src/V3Hash.h index 1aa39b292..7ca847697 100644 --- a/src/V3Hash.h +++ b/src/V3Hash.h @@ -57,13 +57,13 @@ public: bool operator<(const V3Hash& rh) const { return m_value < rh.m_value; } // '+' combines hashes - template + template V3Hash operator+(T that) const { return V3Hash{combine(m_value, V3Hash{that}.m_value)}; } // '+=' combines in place - template + template V3Hash& operator+=(T that) { return *this = *this + that; } diff --git a/src/V3OptionParser.cpp b/src/V3OptionParser.cpp index c71a4590e..49e27fe30 100644 --- a/src/V3OptionParser.cpp +++ b/src/V3OptionParser.cpp @@ -59,7 +59,7 @@ struct V3OptionParser::Impl final { class ActionCbCall; // Callback without argument for "-opt" class ActionCbFOnOff; // Callback for "-fopt" and "-fno-opt" class ActionCbOnOff; // Callback for "-opt" and "-no-opt" - template + template class ActionCbVal; // Callback for "-opt val" class ActionCbPartialMatch; // Callback "-O3" for "-O" class ActionCbPartialMatchVal; // Callback "-debugi-V3Options 3" for "-debugi-" @@ -171,7 +171,7 @@ V3OptionParser::ActionIfs* V3OptionParser::find(const char* optp) { return nullptr; } -template +template V3OptionParser::ActionIfs& V3OptionParser::add(const std::string& opt, ARG arg) { UASSERT(!m_pimpl->m_isFinalized, "Cannot add after finalize() is called"); std::unique_ptr act{new ACT{std::move(arg)}}; diff --git a/src/V3OptionParser.h b/src/V3OptionParser.h index 9b35b9e48..8b4870168 100644 --- a/src/V3OptionParser.h +++ b/src/V3OptionParser.h @@ -65,7 +65,7 @@ private: // METHODS ActionIfs* find(const char* optp) VL_MT_DISABLED; - template + template ActionIfs& add(const string& opt, ARG arg) VL_MT_DISABLED; // Returns true if strp starts with "-fno" static bool hasPrefixFNo(const char* strp) VL_MT_DISABLED; diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index b09a7a95b..ad1be879b 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -186,7 +186,7 @@ struct SplitVarImpl VL_NOT_FINAL { static const char* cannotSplitPackedVarReason(const AstVar* varp); - template + template void insertBeginCore(T_ALWAYSLIKE* ap, AstNodeStmt* stmtp, AstNodeModule* modp) { if (ap->isJustOneBodyStmt() && ap->stmtsp() == stmtp) { stmtp->unlinkFrBack(); diff --git a/src/V3StdFuture.h b/src/V3StdFuture.h index 2e4d2f31b..0ab865b06 100644 --- a/src/V3StdFuture.h +++ b/src/V3StdFuture.h @@ -22,7 +22,7 @@ namespace vlstd { // constexpr std::max with arguments passed by value (required by constexpr before C++14) -template +template constexpr T max(T a, T b) { return a > b ? a : b; } diff --git a/src/V3String.h b/src/V3String.h index 83db7eed9..84b89a422 100644 --- a/src/V3String.h +++ b/src/V3String.h @@ -33,20 +33,20 @@ //###################################################################### // Global string-related functions -template +template std::string cvtToStr(const T& t) VL_PURE { std::ostringstream os; os << t; return os.str(); } -template +template typename std::enable_if::value, std::string>::type cvtToHex(const T tp) VL_PURE { std::ostringstream os; os << static_cast(tp); return os.str(); } -template +template typename std::enable_if::value, std::string>::type cvtToHex(const T t) { std::ostringstream os; os << std::hex << std::setw(sizeof(T) * 8 / 4) << std::setfill('0') << t;