From bdfdc737a0fb46ac1320c4c9be9899c537527246 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 11 May 2022 00:47:52 -0400 Subject: [PATCH] Internals: Cleanup V3Config. No functional change intended. --- src/V3Config.cpp | 28 +++++++++++----------------- src/V3Config.h | 4 ++-- src/verilog.y | 6 ++++-- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/V3Config.cpp b/src/V3Config.cpp index b8128eaa9..8ffaa21d6 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -44,13 +44,8 @@ public: /// Update into maps from other void update(const V3ConfigWildcardResolver& other) { - typename Map::const_iterator it; - for (it = other.m_mapResolved.begin(); it != other.m_mapResolved.end(); ++it) { - m_mapResolved[it->first].update(it->second); - } - for (it = other.m_mapWildcard.begin(); it != other.m_mapWildcard.end(); ++it) { - m_mapWildcard[it->first].update(it->second); - } + for (const auto& itr : other.m_mapResolved) m_mapResolved[itr.first].update(itr.second); + for (const auto& itr : other.m_mapWildcard) m_mapWildcard[itr.first].update(itr.second); } // Access and create a (wildcard) entity @@ -68,12 +63,12 @@ public: // Cannot be resolved, create if matched // Update this entity with all matches in the wildcards - for (it = m_mapWildcard.begin(); it != m_mapWildcard.end(); ++it) { - if (VString::wildmatch(name, it->first)) { + for (const auto& wildent : m_mapWildcard) { + if (VString::wildmatch(name, wildent.first)) { if (!newp) { newp = &m_mapResolved[name]; // Emplace and get pointer } - newp->update(it->second); + newp->update(wildent.second); } } return newp; @@ -198,8 +193,8 @@ public: AstNode* const nodep = new AstPragma(modp->fileline(), type); modp->addStmtp(nodep); } - for (auto it = m_modPragmas.cbegin(); it != m_modPragmas.cend(); ++it) { - AstNode* const nodep = new AstPragma(modp->fileline(), *it); + for (const auto& itr : m_modPragmas) { + AstNode* const nodep = new AstPragma{modp->fileline(), itr}; modp->addStmtp(nodep); } } @@ -354,13 +349,14 @@ class V3ConfigResolver final { m_profileData; // Access to profile_data records FileLine* m_profileFileLine = nullptr; - static V3ConfigResolver s_singleton; // Singleton (not via local static, as that's slow) V3ConfigResolver() = default; ~V3ConfigResolver() = default; public: - static V3ConfigResolver& s() { return s_singleton; } - + static V3ConfigResolver& s() { + static V3ConfigResolver s_singleton; + return s_singleton; + } V3ConfigModuleResolver& modules() { return m_modules; } V3ConfigFileResolver& files() { return m_files; } @@ -379,8 +375,6 @@ public: FileLine* getProfileDataFileLine() const { return m_profileFileLine; } // Maybe null }; -V3ConfigResolver V3ConfigResolver::s_singleton; - //###################################################################### // V3Config diff --git a/src/V3Config.h b/src/V3Config.h index 750d152fd..add53c11b 100644 --- a/src/V3Config.h +++ b/src/V3Config.h @@ -37,15 +37,15 @@ public: static void addModulePragma(const string& module, VPragmaType pragma); static void addProfileData(FileLine* fl, const string& model, const string& key, uint64_t cost); - static void addWaiver(V3ErrorCode code, const string& filename, const string& message); static void addVarAttr(FileLine* fl, const string& module, const string& ftask, const string& signal, VAttrType type, AstSenTree* nodep); + static void addWaiver(V3ErrorCode code, const string& filename, const string& message); static void applyCase(AstCase* nodep); static void applyCoverageBlock(AstNodeModule* modulep, AstBegin* nodep); + static void applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp); static void applyIgnores(FileLine* filelinep); static void applyModule(AstNodeModule* modulep); - static void applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp); static void applyVarAttr(AstNodeModule* modulep, AstNodeFTask* ftaskp, AstVar* varp); static uint64_t getProfileData(const string& model, const string& key); diff --git a/src/verilog.y b/src/verilog.y index 2d4762799..bca9397e1 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -6450,7 +6450,8 @@ colon: // Generic colon that isn't making a label (e.g. vltItem: - vltOffFront { V3Config::addIgnore($1, false, "*", 0, 0); } + vltOffFront + { V3Config::addIgnore($1, false, "*", 0, 0); } | vltOffFront yVLT_D_FILE yaSTRING { V3Config::addIgnore($1, false, *$3, 0, 0); } | vltOffFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM @@ -6463,7 +6464,8 @@ vltItem: } else { V3Config::addWaiver($1,*$3,*$5); }} - | vltOnFront { V3Config::addIgnore($1, true, "*", 0, 0); } + | vltOnFront + { V3Config::addIgnore($1, true, "*", 0, 0); } | vltOnFront yVLT_D_FILE yaSTRING { V3Config::addIgnore($1, true, *$3, 0, 0); } | vltOnFront yVLT_D_FILE yaSTRING yVLT_D_LINES yaINTNUM