diff --git a/src/V3Case.cpp b/src/V3Case.cpp index a9a0a3511..99f9ba8c6 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -133,7 +133,7 @@ private: int m_caseItems = 0; // Number of caseItem unique values bool m_caseNoOverlapsAllCovered = false; // Proven to be synopsys parallel_case compliant // For each possible value, the case branch we need - AstNode* m_valueItem[1 << CASE_OVERLAP_WIDTH]; + std::array m_valueItem; // METHODS VL_DEBUG_FUNC; // Declare debug() diff --git a/src/V3Error.cpp b/src/V3Error.cpp index e60ce5667..84df9285f 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -36,9 +36,9 @@ std::ostringstream V3Error::s_errorStr; // Error string being formed V3ErrorCode V3Error::s_errorCode = V3ErrorCode::EC_FATAL; bool V3Error::s_errorContexted = false; bool V3Error::s_errorSuppressed = false; -bool V3Error::s_describedEachWarn[V3ErrorCode::_ENUM_MAX]; +std::array V3Error::s_describedEachWarn; +std::array V3Error::s_pretendError; bool V3Error::s_describedWarnings = false; -bool V3Error::s_pretendError[V3ErrorCode::_ENUM_MAX]; V3Error::MessagesSet V3Error::s_messages; V3Error::ErrorExitCb V3Error::s_errorExitCb = nullptr; diff --git a/src/V3Error.h b/src/V3Error.h index a1846e8e4..dc74e55ad 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -224,9 +224,10 @@ class V3Error { private: static bool s_describedWarnings; // Told user how to disable warns - static bool - s_describedEachWarn[V3ErrorCode::_ENUM_MAX]; // Told user specifics about this warning - static bool s_pretendError[V3ErrorCode::_ENUM_MAX]; // Pretend this warning is an error + static std::array + s_describedEachWarn; // Told user specifics about this warning + static std::array + s_pretendError; // Pretend this warning is an error static int s_debugDefault; // Option: --debugi Default debugging level static int s_errorLimit; // Option: --error-limit Number of errors before exit static bool s_warnFatal; // Option: --warnFatal Warnings are fatal diff --git a/src/V3GraphPathChecker.cpp b/src/V3GraphPathChecker.cpp index bc8401c90..05d14a167 100644 --- a/src/V3GraphPathChecker.cpp +++ b/src/V3GraphPathChecker.cpp @@ -32,7 +32,7 @@ struct GraphPCNode { // // Unlike the LogicMTasks's, we have no cost info for the generic graph // accepted by GraphPathChecker, so assume each node has unit cost. - vluint32_t m_cp[GraphWay::NUM_WAYS]; + std::array m_cp; // Detect if we've seen this node before in a given recursive // operation. We'll use this in pathExistsInternal() to avoid checking diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index a7dac78db..850ea63e2 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -153,7 +153,7 @@ private: VSymEnt* m_dunitEntp; // $unit entry NameScopeSymMap m_nameScopeSymMap; // Map of scope referenced by non-pretty textual name ImplicitNameSet m_implicitNameSet; // For [module][signalname] if we can implicitly create it - ScopeAliasMap m_scopeAliasMap[SAMN__MAX]; // Map of aliases + std::array m_scopeAliasMap; // Map of aliases IfaceVarSyms m_ifaceVarSyms; // List of AstIfaceRefDType's to be imported IfaceModSyms m_ifaceModSyms; // List of AstIface+Symbols to be processed bool m_forPrimary; // First link diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 7c555cd7f..862e7d366 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -190,7 +190,7 @@ class OrderUser { // Stored in AstVarScope::user1p, a list of all the various vertices // that can exist for one given variable private: - OrderVarVertex* m_vertexp[WV_MAX]; // Vertex of each type (if non nullptr) + std::array m_vertexp; // Vertex of each type (if non nullptr) public: // METHODS OrderVarVertex* newVarUserVertex(V3Graph* graphp, AstScope* scopep, AstVarScope* varscp, @@ -686,7 +686,7 @@ protected: private: // STATS - VDouble0 m_statCut[OrderVEdgeType::_ENUM_END]; // Count of each edge type cut + std::array m_statCut; // Count of each edge type cut // TYPES enum VarUsage : uint8_t { VU_NONE = 0, VU_CON = 1, VU_GEN = 2 }; diff --git a/src/V3Os.cpp b/src/V3Os.cpp index 299d5c104..b6d7375e5 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -252,12 +252,12 @@ void V3Os::unlinkRegexp(const string& dir, const string& regexp) { //###################################################################### // METHODS (random) -vluint64_t V3Os::rand64(vluint64_t* statep) { +vluint64_t V3Os::rand64(std::array& stater) { // Xoroshiro128+ algorithm - vluint64_t result = statep[0] + statep[1]; - statep[1] ^= statep[0]; - statep[0] = (((statep[0] << 55) | (statep[0] >> 9)) ^ statep[1] ^ (statep[1] << 14)); - statep[1] = (statep[1] << 36) | (statep[1] >> 28); + vluint64_t result = stater[0] + stater[1]; + stater[1] ^= stater[0]; + stater[0] = (((stater[0] << 55) | (stater[0] >> 9)) ^ stater[1] ^ (stater[1] << 14)); + stater[1] = (stater[1] << 36) | (stater[1] >> 28); return result; } diff --git a/src/V3Os.h b/src/V3Os.h index a107f36dc..8c328c89b 100644 --- a/src/V3Os.h +++ b/src/V3Os.h @@ -55,7 +55,7 @@ public: static void unlinkRegexp(const string& dir, const string& regexp); // METHODS (random) - static vluint64_t rand64(vluint64_t* statep); + static vluint64_t rand64(std::array& stater); static string trueRandom(size_t size); // METHODS (time & performance) diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index abfb6ce0d..978587be2 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -306,7 +306,7 @@ private: } void go() { // Generate a pseudo-random graph - vluint64_t rngState[2] = {0x12345678ULL, 0x9abcdef0ULL}; + std::array rngState = {0x12345678ULL, 0x9abcdef0ULL}; // Create 50 vertices for (auto& i : m_vx) i = new V3GraphVertex(&m_graph); // Create 250 edges at random. Edges must go from @@ -425,7 +425,7 @@ private: // Cost of critical paths going FORWARD from graph-start to the start // of this vertex, and also going REVERSE from the end of the graph to // the end of the vertex. Same units as m_cost. - uint32_t m_critPathCost[GraphWay::NUM_WAYS]; + std::array m_critPathCost; uint32_t m_serialId; // Unique MTask ID number @@ -443,7 +443,7 @@ private: // relatives in longest-to-shortest CP order. We rely on this ordering // in more than one place. typedef SortByValueMap EdgeSet; - EdgeSet m_edges[GraphWay::NUM_WAYS]; + std::array m_edges; public: // CONSTRUCTORS @@ -2252,8 +2252,8 @@ void V3Partition::debugMTaskGraphStats(const V3Graph* graphp, const string& stag UINFO(4, " Stats for " << stage << endl); uint32_t mtaskCount = 0; uint32_t totalCost = 0; - uint32_t mtaskCostHist[32]; - memset(mtaskCostHist, 0, sizeof(mtaskCostHist)); + std::array mtaskCostHist; + mtaskCostHist.fill(0); for (const V3GraphVertex* mtaskp = graphp->verticesBeginp(); mtaskp; mtaskp = mtaskp->verticesNextp()) { diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 38ea0da47..9abdbe246 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -1005,7 +1005,8 @@ class SplitPackedVarVisitor : public AstNVisitor, public SplitVarImpl { } UASSERT_OBJ(varp->attrSplitVar(), varp, "split_var attribute must be attached"); - AstConst* consts[2] = {VN_CAST(nodep->lsbp(), Const), VN_CAST(nodep->widthp(), Const)}; + std::array consts + = {VN_CAST(nodep->lsbp(), Const), VN_CAST(nodep->widthp(), Const)}; if (consts[0] && consts[1]) { // OK refit->second.append( PackedVarRefEntry(nodep, consts[0]->toSInt() + refit->second.basicp()->lsb(), diff --git a/src/V3Stats.cpp b/src/V3Stats.cpp index 9562aa8a0..a73df13e4 100644 --- a/src/V3Stats.cpp +++ b/src/V3Stats.cpp @@ -49,7 +49,7 @@ private: std::vector m_statTypeCount; // Nodes of given type VDouble0 m_statAbove[AstType::_ENUM_END][AstType::_ENUM_END]; // Nodes of given type - VDouble0 m_statPred[VBranchPred::_ENUM_END]; // Nodes of given type + std::array m_statPred; // Nodes of given type VDouble0 m_statInstr; // Instruction count VDouble0 m_statInstrFast; // Instruction count, non-slow() eval functions only std::vector m_statVarWidths; // Variables of given width diff --git a/src/V3String.cpp b/src/V3String.cpp index 12db74f7c..5bf79a99a 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -306,7 +306,7 @@ uint64_t VHashSha256::digestUInt64() { } string VHashSha256::digestHex() { - static const char digits[16 + 1] = "0123456789abcdef"; + static const char* digits = "0123456789abcdef"; const string& binhash = digestBinary(); string out; out.reserve(70); @@ -322,8 +322,7 @@ string VHashSha256::digestSymbol() { // has + and / for last two digits, but need C symbol, and we also // avoid conflicts with use of _, so use "AB" at the end. // Thus this function is non-reversible. - static const char digits[64 + 1] - = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AB"; + static const char* digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AB"; const string& binhash = digestBinary(); string out; out.reserve(28); @@ -408,9 +407,9 @@ VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const strin if (sLen >= LENGTH_LIMIT) return sLen; if (tLen >= LENGTH_LIMIT) return tLen; - static EditDistance s_v_two_ago[LENGTH_LIMIT + 1]; - static EditDistance s_v_one_ago[LENGTH_LIMIT + 1]; - static EditDistance s_v_next[LENGTH_LIMIT + 1]; + static std::array s_v_two_ago; + static std::array s_v_one_ago; + static std::array s_v_next; for (size_t i = 0; i < sLen + 1; i++) s_v_one_ago[i] = i; diff --git a/src/V3Task.cpp b/src/V3Task.cpp index f6a0c4a3c..9d210679e 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -1580,7 +1580,7 @@ bool V3Task::dpiToInternalFrStmt(AstVar* portp, const string& frName, string& fr } const char* V3Task::dpiTemporaryVarSuffix() { - static const char suffix[] = "__Vcvt"; + static const char* suffix = "__Vcvt"; return suffix; } diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 2e5dc239d..fdf90654c 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -237,7 +237,7 @@ private: AstUser2InUse m_inuser2; // STATE - std::vector m_entryps[3]; // Nodes to delete when we are finished + std::array, 3> m_entryps; // Nodes to delete when finished bool m_inBBox = false; // In black box; mark as driven+used bool m_inContAssign = false; // In continuous assignment bool m_inProcAssign = false; // In procedural assignment