Internals: Use emplace instead of insert(make_pair(...)). No functional change intended.

This commit is contained in:
Wilson Snyder 2020-12-18 18:24:47 -05:00
parent d0c4aee7b5
commit c39a8b439a
41 changed files with 86 additions and 96 deletions

View File

@ -2740,7 +2740,7 @@ void VerilatedScope::varInsert(int finalize, const char* namep, void* datap, boo
} }
va_end(ap); va_end(ap);
m_varsp->insert(std::make_pair(namep, var)); m_varsp->emplace(namep, var);
} }
// cppcheck-suppress unusedFunction // Used by applications // cppcheck-suppress unusedFunction // Used by applications

View File

@ -123,8 +123,8 @@ private:
if (iter != m_valueIndexes.end()) return iter->second; if (iter != m_valueIndexes.end()) return iter->second;
m_nextIndex++; m_nextIndex++;
assert(m_nextIndex > 0); // Didn't rollover assert(m_nextIndex > 0); // Didn't rollover
m_valueIndexes.insert(std::make_pair(value, m_nextIndex)); m_valueIndexes.emplace(value, m_nextIndex);
m_indexValues.insert(std::make_pair(m_nextIndex, value)); m_indexValues.emplace(m_nextIndex, value);
return m_nextIndex; return m_nextIndex;
} }
static std::string dequote(const std::string& text) VL_PURE { static std::string dequote(const std::string& text) VL_PURE {
@ -390,7 +390,7 @@ public:
cit->second.second += itemp->count(); cit->second.second += itemp->count();
cit->second.first = combineHier(oldhier, hier); cit->second.first = combineHier(oldhier, hier);
} else { } else {
eventCounts.insert(std::make_pair(name, make_pair(hier, itemp->count()))); eventCounts.emplace(name, make_pair(hier, itemp->count()));
} }
} }

View File

@ -566,8 +566,7 @@ public:
T_Value& at(const T_Key& index) { T_Value& at(const T_Key& index) {
const auto it = m_map.find(index); const auto it = m_map.find(index);
if (it == m_map.end()) { if (it == m_map.end()) {
std::pair<typename Map::iterator, bool> pit std::pair<typename Map::iterator, bool> pit = m_map.emplace(index, m_defaultValue);
= m_map.insert(std::make_pair(index, m_defaultValue));
return pit.first->second; return pit.first->second;
} }
return it->second; return it->second;

View File

@ -331,7 +331,7 @@ public:
if (it != s_s.v.m_userMap.end()) { if (it != s_s.v.m_userMap.end()) {
it->second = userData; it->second = userData;
} else { } else {
s_s.v.m_userMap.insert(it, std::make_pair(std::make_pair(scopep, userKey), userData)); s_s.v.m_userMap.emplace(std::make_pair(scopep, userKey), userData);
} }
} }
static inline void* userFind(const void* scopep, void* userKey) VL_MT_SAFE { static inline void* userFind(const void* scopep, void* userKey) VL_MT_SAFE {
@ -374,9 +374,7 @@ public: // But only for verilated*.cpp
// Slow ok - called once/scope at construction // Slow ok - called once/scope at construction
const VerilatedLockGuard lock(s_s.v.m_nameMutex); const VerilatedLockGuard lock(s_s.v.m_nameMutex);
const auto it = s_s.v.m_nameMap.find(scopep->name()); const auto it = s_s.v.m_nameMap.find(scopep->name());
if (it == s_s.v.m_nameMap.end()) { if (it == s_s.v.m_nameMap.end()) s_s.v.m_nameMap.emplace(scopep->name(), scopep);
s_s.v.m_nameMap.insert(it, std::make_pair(scopep->name(), scopep));
}
} }
static inline const VerilatedScope* scopeFind(const char* namep) VL_MT_SAFE { static inline const VerilatedScope* scopeFind(const char* namep) VL_MT_SAFE {
const VerilatedLockGuard lock(s_s.v.m_nameMutex); const VerilatedLockGuard lock(s_s.v.m_nameMutex);
@ -442,7 +440,7 @@ public: // But only for verilated*.cpp
const VerilatedLockGuard lock(s_s.v.m_exportMutex); const VerilatedLockGuard lock(s_s.v.m_exportMutex);
const auto it = s_s.v.m_exportMap.find(namep); const auto it = s_s.v.m_exportMap.find(namep);
if (it == s_s.v.m_exportMap.end()) { if (it == s_s.v.m_exportMap.end()) {
s_s.v.m_exportMap.insert(it, std::make_pair(namep, s_s.v.m_exportNext++)); s_s.v.m_exportMap.emplace(namep, s_s.v.m_exportNext++);
return s_s.v.m_exportNext++; return s_s.v.m_exportNext++;
} else { } else {
return it->second; return it->second;

View File

@ -44,15 +44,15 @@ protected:
friend class VerilatedVarProps; friend class VerilatedVarProps;
friend class VerilatedScope; friend class VerilatedScope;
VerilatedRange() = default; VerilatedRange() = default;
VerilatedRange(int left, int right)
: m_left{left}
, m_right{right} {}
void init(int left, int right) { void init(int left, int right) {
m_left = left; m_left = left;
m_right = right; m_right = right;
} }
public: public:
VerilatedRange(int left, int right)
: m_left{left}
, m_right{right} {}
~VerilatedRange() = default; ~VerilatedRange() = default;
int left() const { return m_left; } int left() const { return m_left; }
int right() const { return m_right; } int right() const { return m_right; }
@ -83,7 +83,7 @@ class VerilatedVarProps VL_NOT_FINAL {
for (int i = 0; i < m_udims; ++i) { for (int i = 0; i < m_udims; ++i) {
const int left = ulims ? ulims[2 * i + 0] : 0; const int left = ulims ? ulims[2 * i + 0] : 0;
const int right = ulims ? ulims[2 * i + 1] : 0; const int right = ulims ? ulims[2 * i + 1] : 0;
m_unpacked.push_back(VerilatedRange(left, right)); m_unpacked.emplace_back(left, right);
} }
} }
// CONSTRUCTORS // CONSTRUCTORS

View File

@ -198,7 +198,7 @@ void VerilatedVcd::makeNameMap() {
std::string newname = std::string("top"); std::string newname = std::string("top");
if (hiername[0] != '\t') newname += ' '; if (hiername[0] != '\t') newname += ' ';
newname += hiername; newname += hiername;
newmapp->insert(std::make_pair(newname, decl)); newmapp->emplace(newname, decl);
} }
deleteNameMap(); deleteNameMap();
m_namemapp = newmapp; m_namemapp = newmapp;
@ -511,7 +511,7 @@ void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
decl += buf; decl += buf;
} }
decl += " $end\n"; decl += " $end\n";
m_namemapp->insert(std::make_pair(hiername, decl)); m_namemapp->emplace(hiername, decl);
} }
void VerilatedVcd::declBit(vluint32_t code, const char* name, bool array, int arraynum) { void VerilatedVcd::declBit(vluint32_t code, const char* name, bool array, int arraynum) {

View File

@ -461,9 +461,7 @@ public:
} }
s_s.m_cbObjLists[vop->reason()].push_back(vop); s_s.m_cbObjLists[vop->reason()].push_back(vop);
} }
static void cbTimedAdd(VerilatedVpioCb* vop) { static void cbTimedAdd(VerilatedVpioCb* vop) { s_s.m_timedCbs.emplace(vop->time(), vop); }
s_s.m_timedCbs.insert(std::make_pair(vop->time(), vop));
}
static void cbReasonRemove(VerilatedVpioCb* cbp) { static void cbReasonRemove(VerilatedVpioCb* cbp) {
VpioCbList& cbObjList = s_s.m_cbObjLists[cbp->reason()]; VpioCbList& cbObjList = s_s.m_cbObjLists[cbp->reason()];
// We do not remove it now as we may be iterating the list, // We do not remove it now as we may be iterating the list,

View File

@ -68,7 +68,7 @@ void AstNodeUOrStructDType::repairMemberCache() {
if (m_members.find(itemp->name()) != m_members.end()) { if (m_members.find(itemp->name()) != m_members.end()) {
itemp->v3error("Duplicate declaration of member name: " << itemp->prettyNameQ()); itemp->v3error("Duplicate declaration of member name: " << itemp->prettyNameQ());
} else { } else {
m_members.insert(make_pair(itemp->name(), itemp)); m_members.emplace(itemp->name(), itemp);
} }
} }
} }
@ -995,7 +995,7 @@ AstBasicDType* AstTypeTable::findInsertSameDType(AstBasicDType* nodep) {
DetailedMap& mapr = m_detailedMap; DetailedMap& mapr = m_detailedMap;
const auto it = mapr.find(key); const auto it = mapr.find(key);
if (it != mapr.end()) return it->second; if (it != mapr.end()) return it->second;
mapr.insert(make_pair(key, nodep)); mapr.emplace(key, nodep);
nodep->generic(true); nodep->generic(true);
// No addTypesp; the upper function that called new() is responsible for adding // No addTypesp; the upper function that called new() is responsible for adding
return nodep; return nodep;
@ -1168,7 +1168,7 @@ void AstClass::insertCache(AstNode* nodep) {
if (m_members.find(nodep->name()) != m_members.end()) { if (m_members.find(nodep->name()) != m_members.end()) {
nodep->v3error("Duplicate declaration of member name: " << nodep->prettyNameQ()); nodep->v3error("Duplicate declaration of member name: " << nodep->prettyNameQ());
} else { } else {
m_members.insert(make_pair(nodep->name(), nodep)); m_members.emplace(nodep->name(), nodep);
} }
} }
} }

View File

@ -5020,7 +5020,7 @@ public:
it->second->valuep(newp); it->second->valuep(newp);
} else { } else {
AstInitItem* itemp = new AstInitItem(fileline(), newp); AstInitItem* itemp = new AstInitItem(fileline(), newp);
m_map.insert(it, make_pair(index, itemp)); m_map.emplace(index, itemp);
addOp2p(itemp); addOp2p(itemp);
} }
return oldp; return oldp;

View File

@ -73,7 +73,7 @@ public:
"Newing AstNode object that is already allocated"); "Newing AstNode object that is already allocated");
if (iter == s_nodes.end()) { if (iter == s_nodes.end()) {
int flags = FLAG_ALLOCATED; // This int needed to appease GCC 4.1.2 int flags = FLAG_ALLOCATED; // This int needed to appease GCC 4.1.2
s_nodes.insert(make_pair(nodep, flags)); s_nodes.emplace(nodep, flags);
} }
} }
static void setUnder(const AstNode* nodep, bool flag) { static void setUnder(const AstNode* nodep, bool flag) {
@ -105,7 +105,7 @@ public:
} }
int or_flags = FLAG_IN_TREE | (linkable ? FLAG_LINKABLE : 0); int or_flags = FLAG_IN_TREE | (linkable ? FLAG_LINKABLE : 0);
if (iter == s_nodes.end()) { if (iter == s_nodes.end()) {
s_nodes.insert(make_pair(nodep, or_flags)); s_nodes.emplace(nodep, or_flags);
} else { } else {
iter->second |= or_flags; iter->second |= or_flags;
} }

View File

@ -106,7 +106,7 @@ public:
} }
} }
// METHODS // METHODS
void addCall(AstCCall* nodep) { m_callMmap.insert(make_pair(nodep->funcp(), nodep)); } void addCall(AstCCall* nodep) { m_callMmap.emplace(nodep->funcp(), nodep); }
void deleteCall(AstCCall* nodep) { void deleteCall(AstCCall* nodep) {
std::pair<CallMmap::iterator, CallMmap::iterator> eqrange std::pair<CallMmap::iterator, CallMmap::iterator> eqrange
= m_callMmap.equal_range(nodep->funcp()); = m_callMmap.equal_range(nodep->funcp());

View File

@ -142,7 +142,7 @@ private:
+ cvtToStr(nodep->fileline()->lineno()) + "_" + type; + cvtToStr(nodep->fileline()->lineno()) + "_" + type;
const auto it = m_varnames.find(name); const auto it = m_varnames.find(name);
if (it == m_varnames.end()) { if (it == m_varnames.end()) {
m_varnames.insert(make_pair(name, 1)); m_varnames.emplace(name, 1);
} else { } else {
int suffix = (it->second)++; int suffix = (it->second)++;
name += "_" + cvtToStr(suffix); name += "_" + cvtToStr(suffix);

View File

@ -285,7 +285,7 @@ private:
AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef);
if (varrefp && !m_sideEffect if (varrefp && !m_sideEffect
&& varrefp->varScopep()) { // For simplicity, we only remove post-scoping && varrefp->varScopep()) { // For simplicity, we only remove post-scoping
m_assignMap.insert(make_pair(varrefp->varScopep(), nodep)); m_assignMap.emplace(varrefp->varScopep(), nodep);
checkAll(varrefp); // Must track reference to dtype() checkAll(varrefp); // Must track reference to dtype()
checkVarRef(varrefp); checkVarRef(varrefp);
} else { // Track like any other statement } else { // Track like any other statement

View File

@ -150,7 +150,7 @@ private:
VFlagBitPacked(), width); VFlagBitPacked(), width);
} }
addmodp->addStmtp(varp); addmodp->addStmtp(varp);
m_modVarMap.insert(make_pair(make_pair(addmodp, name), varp)); m_modVarMap.emplace(make_pair(addmodp, name), varp);
} }
AstVarScope* varscp = new AstVarScope(oldvarscp->fileline(), oldvarscp->scopep(), varp); AstVarScope* varscp = new AstVarScope(oldvarscp->fileline(), oldvarscp->scopep(), varp);

View File

@ -296,7 +296,7 @@ private:
if (nodep->funcPublic()) { if (nodep->funcPublic()) {
// There may be multiple public functions by the same name; // There may be multiple public functions by the same name;
// record for later correction or making of shells // record for later correction or making of shells
m_modFuncs.insert(make_pair(nodep->name(), nodep)); m_modFuncs.emplace(nodep->name(), nodep);
nodep->name(m_scopep->nameDotless() + "__" + nodep->name()); nodep->name(m_scopep->nameDotless() + "__" + nodep->name());
} }
} }

View File

@ -172,7 +172,7 @@ class EmitCSyms final : EmitCBaseVisitor {
const auto scpit = m_vpiScopeCandidates.find(scp); const auto scpit = m_vpiScopeCandidates.find(scp);
if ((scpit != m_vpiScopeCandidates.end()) if ((scpit != m_vpiScopeCandidates.end())
&& (m_scopeNames.find(scp) == m_scopeNames.end())) { && (m_scopeNames.find(scp) == m_scopeNames.end())) {
m_scopeNames.insert(make_pair(scpit->second.m_symName, scpit->second)); m_scopeNames.emplace(scpit->second.m_symName, scpit->second);
} }
string::size_type pos = scp.rfind("__DOT__"); string::size_type pos = scp.rfind("__DOT__");
if (pos == string::npos) { if (pos == string::npos) {
@ -313,8 +313,8 @@ class EmitCSyms final : EmitCBaseVisitor {
// <<" ss"<<name<<endl); // <<" ss"<<name<<endl);
int timeunit = m_modp ? m_modp->timeunit().powerOfTen() : 0; int timeunit = m_modp ? m_modp->timeunit().powerOfTen() : 0;
if (m_scopeNames.find(name) == m_scopeNames.end()) { if (m_scopeNames.find(name) == m_scopeNames.end()) {
m_scopeNames.insert(make_pair( m_scopeNames.emplace(
name, ScopeData(name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER"))); name, ScopeData(name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER"));
} }
if (nodep->dpiExport()) { if (nodep->dpiExport()) {
UASSERT_OBJ(m_cfuncp, nodep, "ScopeName not under DPI function"); UASSERT_OBJ(m_cfuncp, nodep, "ScopeName not under DPI function");

View File

@ -580,7 +580,7 @@ protected:
// Cache small files (only to save space) // Cache small files (only to save space)
// It's quite common to `include "timescale" thousands of times // It's quite common to `include "timescale" thousands of times
// This isn't so important if it's just an open(), but filtering can be slow // This isn't so important if it's just an open(), but filtering can be slow
m_contentsMap.insert(make_pair(filename, listString(outl))); m_contentsMap.emplace(filename, listString(outl));
} }
return true; return true;
} }
@ -980,7 +980,7 @@ public:
UASSERT(old == it->second, UASSERT(old == it->second,
"Passthru request for '" + old + "' after already --protect-ids of it."); "Passthru request for '" + old + "' after already --protect-ids of it.");
} else { } else {
m_nameMap.insert(make_pair(old, old)); m_nameMap.emplace(old, old);
m_newIdSet.insert(old); m_newIdSet.insert(old);
} }
return old; return old;
@ -1011,7 +1011,7 @@ public:
} }
} }
} }
m_nameMap.insert(make_pair(old, out)); m_nameMap.emplace(old, out);
m_newIdSet.insert(out); m_newIdSet.insert(out);
return out; return out;
} }

View File

@ -63,7 +63,7 @@ int FileLineSingleton::nameToNumber(const string& filename) {
int num = m_names.size(); int num = m_names.size();
m_names.push_back(filename); m_names.push_back(filename);
m_languages.push_back(V3LangCode::mostRecent()); m_languages.push_back(V3LangCode::mostRecent());
m_namemap.insert(make_pair(filename, num)); m_namemap.emplace(filename, num);
return num; return num;
} }

View File

@ -330,7 +330,7 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) const {
for (V3GraphVertex* vertexp = verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { for (V3GraphVertex* vertexp = verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) {
string vertexSubgraph string vertexSubgraph
= (colorAsSubgraph && vertexp->color()) ? cvtToStr(vertexp->color()) : ""; = (colorAsSubgraph && vertexp->color()) ? cvtToStr(vertexp->color()) : "";
subgraphs.insert(make_pair(vertexSubgraph, vertexp)); subgraphs.emplace(vertexSubgraph, vertexp);
} }
// We use a map here, as we don't want to corrupt anything (userp) in the graph, // We use a map here, as we don't want to corrupt anything (userp) in the graph,

View File

@ -167,7 +167,7 @@ private:
void insertDfaOrigins(DfaVertex* dfaStatep) { void insertDfaOrigins(DfaVertex* dfaStatep) {
// Record the NFA states this dfa came from // Record the NFA states this dfa came from
uint32_t hash = hashDfaOrigins(dfaStatep); uint32_t hash = hashDfaOrigins(dfaStatep);
m_hashMap.insert(make_pair(hash, dfaStatep)); m_hashMap.emplace(hash, dfaStatep);
} }
DfaVertex* findDfaOrigins(const DfaStates& nfasWithInput) { DfaVertex* findDfaOrigins(const DfaStates& nfasWithInput) {

View File

@ -115,7 +115,7 @@ public:
depCount++; depCount++;
} }
VxHolder newVx(vxp, pos++, depCount); VxHolder newVx(vxp, pos++, depCount);
m_waitingVertices.insert(make_pair(vxp, newVx)); m_waitingVertices.emplace(vxp, newVx);
} }
} else { // REVERSE } else { // REVERSE
if (vxp->outEmpty()) { if (vxp->outEmpty()) {
@ -127,7 +127,7 @@ public:
depCount++; depCount++;
} }
VxHolder newVx(vxp, pos++, depCount); VxHolder newVx(vxp, pos++, depCount);
m_waitingVertices.insert(make_pair(vxp, newVx)); m_waitingVertices.emplace(vxp, newVx);
} }
} }
} }

View File

@ -115,7 +115,7 @@ V3Hash V3Hashed::uncachedHash(const AstNode* nodep) {
V3Hashed::iterator V3Hashed::hashAndInsert(AstNode* nodep) { V3Hashed::iterator V3Hashed::hashAndInsert(AstNode* nodep) {
hash(nodep); hash(nodep);
return m_hashMmap.insert(make_pair(nodeHash(nodep), nodep)); return m_hashMmap.emplace(nodeHash(nodep), nodep);
} }
void V3Hashed::hash(AstNode* nodep) { void V3Hashed::hash(AstNode* nodep) {
@ -162,7 +162,7 @@ void V3Hashed::dumpFile(const string& filename, bool tree) {
if (it != end()) lasthash = it->first; if (it != end()) lasthash = it->first;
if (num_in_bucket) { if (num_in_bucket) {
if (dist.find(num_in_bucket) == dist.end()) { if (dist.find(num_in_bucket) == dist.end()) {
dist.insert(make_pair(num_in_bucket, 1)); dist.emplace(num_in_bucket, 1);
} else { } else {
++dist[num_in_bucket]; ++dist[num_in_bucket];
} }

View File

@ -314,7 +314,7 @@ void V3HierBlockPlan::add(const AstNodeModule* modp, const std::vector<AstVar*>&
V3HierBlock* hblockp = new V3HierBlock(modp, gparams); V3HierBlock* hblockp = new V3HierBlock(modp, gparams);
UINFO(3, "Add " << modp->prettyNameQ() << " with " << gparams.size() << " parameters" UINFO(3, "Add " << modp->prettyNameQ() << " with " << gparams.size() << " parameters"
<< std::endl); << std::endl);
m_blocks.insert(std::make_pair(modp, hblockp)); m_blocks.emplace(modp, hblockp);
} }
} }

View File

@ -161,7 +161,7 @@ public:
// METHODS // METHODS
void insert(AstVar* nodep) { void insert(AstVar* nodep) {
UINFO(8, " dmINSERT " << nodep << endl); UINFO(8, " dmINSERT " << nodep << endl);
m_modVarNameMap.insert(make_pair(nodep->name(), nodep)); m_modVarNameMap.emplace(nodep->name(), nodep);
} }
AstVar* find(const string& name) { AstVar* find(const string& name) {
const auto it = m_modVarNameMap.find(name); const auto it = m_modVarNameMap.find(name);

View File

@ -31,7 +31,7 @@ private:
struct Singleton { struct Singleton {
KeywordMap s_kwdMap; // List of keywords, and what language applies KeywordMap s_kwdMap; // List of keywords, and what language applies
Singleton() { init(); } Singleton() { init(); }
void addKwd(const string& kwd, const string& why) { s_kwdMap.insert(make_pair(kwd, why)); } void addKwd(const string& kwd, const string& why) { s_kwdMap.emplace(kwd, why); }
void init(); void init();
}; };

View File

@ -165,7 +165,7 @@ public:
checkRemoveAssign(it); checkRemoveAssign(it);
it->second.simpleAssign(assp); it->second.simpleAssign(assp);
} else { } else {
m_map.insert(make_pair(nodep, LifeVarEntry(LifeVarEntry::SIMPLEASSIGN(), assp))); m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::SIMPLEASSIGN(), assp));
} }
// lifeDump(); // lifeDump();
} }
@ -175,7 +175,7 @@ public:
if (it != m_map.end()) { if (it != m_map.end()) {
it->second.complexAssign(); it->second.complexAssign();
} else { } else {
m_map.insert(make_pair(nodep, LifeVarEntry(LifeVarEntry::COMPLEXASSIGN()))); m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::COMPLEXASSIGN()));
} }
} }
void varUsageReplace(AstVarScope* nodep, AstVarRef* varrefp) { void varUsageReplace(AstVarScope* nodep, AstVarRef* varrefp) {
@ -196,7 +196,7 @@ public:
UINFO(4, " usage: " << nodep << endl); UINFO(4, " usage: " << nodep << endl);
it->second.consumed(); it->second.consumed();
} else { } else {
m_map.insert(make_pair(nodep, LifeVarEntry(LifeVarEntry::CONSUMED()))); m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::CONSUMED()));
} }
} }
void complexAssignFind(AstVarScope* nodep) { void complexAssignFind(AstVarScope* nodep) {
@ -205,7 +205,7 @@ public:
UINFO(4, " casfind: " << it->first << endl); UINFO(4, " casfind: " << it->first << endl);
it->second.complexAssign(); it->second.complexAssign();
} else { } else {
m_map.insert(make_pair(nodep, LifeVarEntry(LifeVarEntry::COMPLEXASSIGN()))); m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::COMPLEXASSIGN()));
} }
} }
void consumedFind(AstVarScope* nodep) { void consumedFind(AstVarScope* nodep) {
@ -213,7 +213,7 @@ public:
if (it != m_map.end()) { if (it != m_map.end()) {
it->second.consumed(); it->second.consumed();
} else { } else {
m_map.insert(make_pair(nodep, LifeVarEntry(LifeVarEntry::CONSUMED()))); m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::CONSUMED()));
} }
} }
void lifeToAbove() { void lifeToAbove() {

View File

@ -304,7 +304,7 @@ public:
nodep->user1p(symp); nodep->user1p(symp);
checkDuplicate(rootEntp(), nodep, nodep->origName()); checkDuplicate(rootEntp(), nodep, nodep->origName());
rootEntp()->insert(nodep->origName(), symp); rootEntp()->insert(nodep->origName(), symp);
if (forScopeCreation()) m_nameScopeSymMap.insert(make_pair(scopename, symp)); if (forScopeCreation()) m_nameScopeSymMap.emplace(scopename, symp);
return symp; return symp;
} }
VSymEnt* insertCell(VSymEnt* abovep, VSymEnt* modSymp, AstCell* nodep, VSymEnt* insertCell(VSymEnt* abovep, VSymEnt* modSymp, AstCell* nodep,
@ -326,11 +326,11 @@ public:
// have 2 same cells under an if // have 2 same cells under an if
modSymp->reinsert(nodep->name(), symp); modSymp->reinsert(nodep->name(), symp);
} }
if (forScopeCreation()) m_nameScopeSymMap.insert(make_pair(scopename, symp)); if (forScopeCreation()) m_nameScopeSymMap.emplace(scopename, symp);
return symp; return symp;
} }
void insertMap(VSymEnt* symp, const string& scopename) { void insertMap(VSymEnt* symp, const string& scopename) {
if (forScopeCreation()) m_nameScopeSymMap.insert(make_pair(scopename, symp)); if (forScopeCreation()) m_nameScopeSymMap.emplace(scopename, symp);
} }
VSymEnt* insertInline(VSymEnt* abovep, VSymEnt* modSymp, AstCellInline* nodep, VSymEnt* insertInline(VSymEnt* abovep, VSymEnt* modSymp, AstCellInline* nodep,
@ -409,9 +409,7 @@ public:
// Mark the given variable name as being allowed to be implicitly declared // Mark the given variable name as being allowed to be implicitly declared
if (nodep) { if (nodep) {
const auto it = m_implicitNameSet.find(make_pair(nodep, varname)); const auto it = m_implicitNameSet.find(make_pair(nodep, varname));
if (it == m_implicitNameSet.end()) { if (it == m_implicitNameSet.end()) { m_implicitNameSet.emplace(nodep, varname); }
m_implicitNameSet.insert(make_pair(nodep, varname));
}
} }
} }
bool implicitOk(AstNodeModule* nodep, const string& varname) { bool implicitOk(AstNodeModule* nodep, const string& varname) {
@ -501,7 +499,7 @@ public:
UASSERT_OBJ( UASSERT_OBJ(
!(VN_IS(rhsp->nodep(), Cell) && !VN_IS(VN_CAST(rhsp->nodep(), Cell)->modp(), Iface)), !(VN_IS(rhsp->nodep(), Cell) && !VN_IS(VN_CAST(rhsp->nodep(), Cell)->modp(), Iface)),
rhsp->nodep(), "Got a non-IFACE alias RHS"); rhsp->nodep(), "Got a non-IFACE alias RHS");
m_scopeAliasMap[samn].insert(make_pair(lhsp, rhsp)); m_scopeAliasMap[samn].emplace(lhsp, rhsp);
} }
void computeScopeAliases() { void computeScopeAliases() {
UINFO(9, "computeIfaceAliases\n"); UINFO(9, "computeIfaceAliases\n");

View File

@ -458,7 +458,7 @@ string V3Options::fileExists(const string& filename) {
auto diriter = m_impp->m_dirMap.find(dir); auto diriter = m_impp->m_dirMap.find(dir);
if (diriter == m_impp->m_dirMap.end()) { if (diriter == m_impp->m_dirMap.end()) {
// Read the listing // Read the listing
m_impp->m_dirMap.insert(std::make_pair(dir, std::set<string>())); m_impp->m_dirMap.emplace(dir, std::set<string>());
diriter = m_impp->m_dirMap.find(dir); diriter = m_impp->m_dirMap.find(dir);
std::set<string>* setp = &(diriter->second); std::set<string>* setp = &(diriter->second);
@ -1229,7 +1229,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
} else if (!strcmp(sw, "-hierarchical-block") && (i + 1) < argc) { } else if (!strcmp(sw, "-hierarchical-block") && (i + 1) < argc) {
shift; shift;
V3HierarchicalBlockOption opt(argv[i]); V3HierarchicalBlockOption opt(argv[i]);
m_hierBlocks.insert(std::make_pair(opt.mangledName(), opt)); m_hierBlocks.emplace(opt.mangledName(), opt);
} else if (!strncmp(sw, "-I", 2)) { } else if (!strncmp(sw, "-I", 2)) {
addIncDirUser(parseFileArg(optdir, string(sw + strlen("-I")))); addIncDirUser(parseFileArg(optdir, string(sw + strlen("-I"))));
} else if (!strcmp(sw, "-if-depth") && (i + 1) < argc) { } else if (!strcmp(sw, "-if-depth") && (i + 1) < argc) {
@ -1814,7 +1814,7 @@ void V3Options::setDebugSrcLevel(const string& srcfile, int level) {
if (iter != m_debugSrcs.end()) { if (iter != m_debugSrcs.end()) {
iter->second = level; iter->second = level;
} else { } else {
m_debugSrcs.insert(make_pair(srcfile, level)); m_debugSrcs.emplace(srcfile, level);
} }
} }
@ -1835,7 +1835,7 @@ void V3Options::setDumpTreeLevel(const string& srcfile, int level) {
if (iter != m_dumpTrees.end()) { if (iter != m_dumpTrees.end()) {
iter->second = level; iter->second = level;
} else { } else {
m_dumpTrees.insert(make_pair(srcfile, level)); m_dumpTrees.emplace(srcfile, level);
} }
} }

View File

@ -164,7 +164,7 @@ public:
return iter->second; return iter->second;
} else { } else {
OrderMoveDomScope* domScopep = new OrderMoveDomScope(domainp, scopep); OrderMoveDomScope* domScopep = new OrderMoveDomScope(domainp, scopep);
s_dsMap.insert(make_pair(key, domScopep)); s_dsMap.emplace(key, domScopep);
return domScopep; return domScopep;
} }
} }

View File

@ -137,7 +137,7 @@ public:
for (AstNodeModule* modp = nodep->modulesp(); modp; for (AstNodeModule* modp = nodep->modulesp(); modp;
modp = VN_CAST(modp->nextp(), NodeModule)) { modp = VN_CAST(modp->nextp(), NodeModule)) {
if (hierOpts.find(modp->prettyName()) != hierOpts.end()) { if (hierOpts.find(modp->prettyName()) != hierOpts.end()) {
m_hierBlockMod.insert(std::make_pair(modp->name(), modp)); m_hierBlockMod.emplace(modp->name(), modp);
} }
} }
} }
@ -321,7 +321,7 @@ class ParamProcessor final {
// We use all upper case above, so lower here can't conflict // We use all upper case above, so lower here can't conflict
newname += "__pi" + cvtToStr(++m_longId); newname += "__pi" + cvtToStr(++m_longId);
} }
m_longMap.insert(make_pair(longname, newname)); m_longMap.emplace(longname, newname);
} }
} }
UINFO(4, "Name: " << srcModp->name() << "->" << longname << "->" << newname << endl); UINFO(4, "Name: " << srcModp->name() << "->" << longname << "->" << newname << endl);
@ -349,12 +349,12 @@ class ParamProcessor final {
AstVar* oldvarp = varp->clonep(); AstVar* oldvarp = varp->clonep();
// UINFO(8,"Clone list 0x"<<hex<<(uint32_t)oldvarp // UINFO(8,"Clone list 0x"<<hex<<(uint32_t)oldvarp
// <<" -> 0x"<<(uint32_t)varp<<endl); // <<" -> 0x"<<(uint32_t)varp<<endl);
clonemapp->insert(make_pair(oldvarp, varp)); clonemapp->emplace(oldvarp, varp);
} }
} else if (AstParamTypeDType* ptp = VN_CAST(stmtp, ParamTypeDType)) { } else if (AstParamTypeDType* ptp = VN_CAST(stmtp, ParamTypeDType)) {
if (ptp->isGParam()) { if (ptp->isGParam()) {
AstParamTypeDType* oldptp = ptp->clonep(); AstParamTypeDType* oldptp = ptp->clonep();
clonemapp->insert(make_pair(oldptp, ptp)); clonemapp->emplace(oldptp, ptp);
} }
} }
} }
@ -383,7 +383,7 @@ class ParamProcessor final {
for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) { for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (AstVar* varp = VN_CAST(stmtp, Var)) { if (AstVar* varp = VN_CAST(stmtp, Var)) {
if (varp->isIO() || varp->isGParam() || varp->isIfaceRef()) { if (varp->isIO() || varp->isGParam() || varp->isIfaceRef()) {
nameToPin.insert(make_pair(varp->name(), varp)); nameToPin.emplace(varp->name(), varp);
} }
} }
} }
@ -474,7 +474,7 @@ class ParamProcessor final {
} }
insertp->addNextHere(newmodp); insertp->addNextHere(newmodp);
m_modNameMap.insert(make_pair(newmodp->name(), ModInfo(newmodp))); m_modNameMap.emplace(newmodp->name(), ModInfo(newmodp));
auto iter = m_modNameMap.find(newname); auto iter = m_modNameMap.find(newname);
CloneMap* clonemapp = &(iter->second.m_cloneMap); CloneMap* clonemapp = &(iter->second.m_cloneMap);
UINFO(4, " De-parameterize to new: " << newmodp << endl); UINFO(4, " De-parameterize to new: " << newmodp << endl);
@ -758,7 +758,7 @@ class ParamVisitor final : public AstNVisitor {
UASSERT_OBJ(nodep->modp(), nodep, "Not linked?"); UASSERT_OBJ(nodep->modp(), nodep, "Not linked?");
m_processor.cellDeparam(nodep, m_modp, hierName); m_processor.cellDeparam(nodep, m_modp, hierName);
// Remember to process the child module at the end of the module // Remember to process the child module at the end of the module
m_todoModps.insert(make_pair(nodep->modp()->level(), nodep->modp())); m_todoModps.emplace(nodep->modp()->level(), nodep->modp());
} }
void visitModules() { void visitModules() {
// Loop on all modules left to process // Loop on all modules left to process
@ -827,7 +827,7 @@ class ParamVisitor final : public AstNVisitor {
|| VN_IS(nodep, Class) // Nor moved classes || VN_IS(nodep, Class) // Nor moved classes
|| VN_IS(nodep, Package)) { // Likewise haven't done wrapTopPackages yet || VN_IS(nodep, Package)) { // Likewise haven't done wrapTopPackages yet
// Add request to END of modules left to process // Add request to END of modules left to process
m_todoModps.insert(make_pair(nodep->level(), nodep)); m_todoModps.emplace(nodep->level(), nodep);
m_generateHierName = ""; m_generateHierName = "";
visitModules(); visitModules();
} else if (nodep->user5()) { } else if (nodep->user5()) {

View File

@ -344,7 +344,7 @@ void V3PreProcImp::define(FileLine* fl, const string& name, const string& value,
} }
undef(name); undef(name);
} }
m_defines.insert(make_pair(name, VDefine(fl, value, params, cmdline))); m_defines.emplace(name, VDefine(fl, value, params, cmdline));
} }
} }

View File

@ -109,7 +109,7 @@ private:
(m_aboveCellp ? static_cast<AstNode*>(m_aboveCellp) : static_cast<AstNode*>(nodep)) (m_aboveCellp ? static_cast<AstNode*>(m_aboveCellp) : static_cast<AstNode*>(nodep))
->fileline(), ->fileline(),
nodep, scopename, m_aboveScopep, m_aboveCellp); nodep, scopename, m_aboveScopep, m_aboveCellp);
if (VN_IS(nodep, Package)) m_packageScopes.insert(make_pair(nodep, m_scopep)); if (VN_IS(nodep, Package)) m_packageScopes.emplace(nodep, m_scopep);
// Now for each child cell, iterate the module this cell points to // Now for each child cell, iterate the module this cell points to
for (AstNode* cellnextp = nodep->stmtsp(); cellnextp; cellnextp = cellnextp->nextp()) { for (AstNode* cellnextp = nodep->stmtsp(); cellnextp; cellnextp = cellnextp->nextp()) {
@ -169,7 +169,7 @@ private:
: static_cast<AstNode*>(nodep)); : static_cast<AstNode*>(nodep));
m_scopep m_scopep
= new AstScope(abovep->fileline(), m_modp, scopename, m_aboveScopep, m_aboveCellp); = new AstScope(abovep->fileline(), m_modp, scopename, m_aboveScopep, m_aboveCellp);
m_packageScopes.insert(make_pair(nodep, m_scopep)); m_packageScopes.emplace(nodep, m_scopep);
// Create scope for the current usage of this cell // Create scope for the current usage of this cell
AstNode::user1ClearTree(); AstNode::user1ClearTree();
@ -272,7 +272,7 @@ private:
nodep->attrClocker(VVarAttrClocker::CLOCKER_NO); nodep->attrClocker(VVarAttrClocker::CLOCKER_NO);
} }
UASSERT_OBJ(m_scopep, nodep, "No scope for var"); UASSERT_OBJ(m_scopep, nodep, "No scope for var");
m_varScopes.insert(make_pair(make_pair(nodep, m_scopep), varscp)); m_varScopes.emplace(make_pair(nodep, m_scopep), varscp);
m_scopep->addVarp(varscp); m_scopep->addVarp(varscp);
} }
} }
@ -287,7 +287,7 @@ private:
// the var's referenced package etc might not be created yet. // the var's referenced package etc might not be created yet.
// So push to a list and post-correct. // So push to a list and post-correct.
// No check here for nodep->classOrPackagep(), will check when walk list. // No check here for nodep->classOrPackagep(), will check when walk list.
m_varRefScopes.insert(make_pair(nodep, m_scopep)); m_varRefScopes.emplace(nodep, m_scopep);
} }
} }
virtual void visit(AstScopeName* nodep) override { virtual void visit(AstScopeName* nodep) override {

View File

@ -528,7 +528,7 @@ protected:
int currOrder = 0; // Existing sequence number of assignment int currOrder = 0; // Existing sequence number of assignment
for (AstNode* nextp = nodep; nextp; nextp = nextp->nextp()) { for (AstNode* nextp = nodep; nextp; nextp = nextp->nextp()) {
SplitLogicVertex* vvertexp = reinterpret_cast<SplitLogicVertex*>(nextp->user3p()); SplitLogicVertex* vvertexp = reinterpret_cast<SplitLogicVertex*>(nextp->user3p());
rankMap.insert(make_pair(vvertexp->rank(), nextp)); rankMap.emplace(vvertexp->rank(), nextp);
nextp->user4(++currOrder); // Record current ordering nextp->user4(++currOrder); // Record current ordering
} }

View File

@ -873,9 +873,7 @@ class PackedVarRef final {
// Use raw pointer to dedup // Use raw pointer to dedup
typedef std::map<AstNode*, size_t, AstNodeComparator> NodeIndices; typedef std::map<AstNode*, size_t, AstNodeComparator> NodeIndices;
NodeIndices nodes; NodeIndices nodes;
for (size_t i = 0; i < refs.size(); ++i) { for (size_t i = 0; i < refs.size(); ++i) { nodes.emplace(refs[i].nodep(), i); }
nodes.insert(std::make_pair(refs[i].nodep(), i));
}
std::vector<PackedVarRefEntry> vect; std::vector<PackedVarRefEntry> vect;
vect.reserve(nodes.size()); vect.reserve(nodes.size());
for (NodeIndices::const_iterator it = nodes.begin(), it_end = nodes.end(); it != it_end; for (NodeIndices::const_iterator it = nodes.begin(), it_end = nodes.end(); it != it_end;

View File

@ -54,7 +54,7 @@ class StatsReport final {
// * is always first // * is always first
for (auto& itr : s_allStats) { for (auto& itr : s_allStats) {
V3Statistic* repp = &itr; V3Statistic* repp = &itr;
byName.insert(make_pair(repp->name(), repp)); byName.emplace(repp->name(), repp);
} }
// Process duplicates // Process duplicates
@ -79,7 +79,7 @@ class StatsReport final {
const V3Statistic* repp = &itr; const V3Statistic* repp = &itr;
if (repp->stage() == "*" && repp->printit()) { if (repp->stage() == "*" && repp->printit()) {
if (maxWidth < repp->name().length()) maxWidth = repp->name().length(); if (maxWidth < repp->name().length()) maxWidth = repp->name().length();
byName.insert(make_pair(repp->name(), repp)); byName.emplace(repp->name(), repp);
} }
} }
@ -123,10 +123,10 @@ class StatsReport final {
if (repp->stage() != "*" && repp->printit()) { if (repp->stage() != "*" && repp->printit()) {
if (maxWidth < repp->name().length()) maxWidth = repp->name().length(); if (maxWidth < repp->name().length()) maxWidth = repp->name().length();
if (stageInt.find(repp->stage()) == stageInt.end()) { if (stageInt.find(repp->stage()) == stageInt.end()) {
stageInt.insert(make_pair(repp->stage(), stage++)); stageInt.emplace(repp->stage(), stage++);
stages.push_back(repp->stage()); stages.push_back(repp->stage());
} }
byName.insert(make_pair(repp->name(), repp)); byName.emplace(repp->name(), repp);
} }
} }

View File

@ -129,7 +129,7 @@ public:
entp->nodep()->v3fatalSrc("Inserting two symbols with same name: " << name); entp->nodep()->v3fatalSrc("Inserting two symbols with same name: " << name);
} }
} else { } else {
m_idNameMap.insert(make_pair(name, entp)); m_idNameMap.emplace(name, entp);
} }
} }
void reinsert(const string& name, VSymEnt* entp) { void reinsert(const string& name, VSymEnt* entp) {

View File

@ -912,7 +912,7 @@ private:
// as it's legal for the user to attach multiple tasks to one dpi cname // as it's legal for the user to attach multiple tasks to one dpi cname
const auto iter = m_dpiNames.find(nodep->cname()); const auto iter = m_dpiNames.find(nodep->cname());
if (iter == m_dpiNames.end()) { if (iter == m_dpiNames.end()) {
m_dpiNames.insert(make_pair(nodep->cname(), make_pair(nodep, dpiproto))); m_dpiNames.emplace(nodep->cname(), make_pair(nodep, dpiproto));
return false; return false;
} else if (iter->second.second != dpiproto) { } else if (iter->second.second != dpiproto) {
nodep->v3error( nodep->v3error(

View File

@ -363,7 +363,7 @@ private:
// make slow routines set all activity flags. // make slow routines set all activity flags.
actSet.erase(TraceActivityVertex::ACTIVITY_SLOW); actSet.erase(TraceActivityVertex::ACTIVITY_SLOW);
} }
traces.insert(make_pair(actSet, vtxp)); traces.emplace(actSet, vtxp);
} }
} }
} }

View File

@ -427,7 +427,7 @@ class TristateVisitor final : public TristateBaseVisitor {
if (it == m_lhsmap.end()) { // Not found if (it == m_lhsmap.end()) { // Not found
RefVec* refsp = new RefVec(); RefVec* refsp = new RefVec();
refsp->push_back(nodep); refsp->push_back(nodep);
m_lhsmap.insert(make_pair(key, refsp)); m_lhsmap.emplace(key, refsp);
} else { } else {
it->second->push_back(nodep); it->second->push_back(nodep);
} }

View File

@ -2060,7 +2060,7 @@ private:
<< otherp->warnOther() << "... Location of original declaration\n" << otherp->warnOther() << "... Location of original declaration\n"
<< otherp->warnContextSecondary()); << otherp->warnContextSecondary());
} else { } else {
inits.insert(make_pair(num, itemp)); inits.emplace(num, itemp);
} }
num.opAdd(one, constp->num()); num.opAdd(one, constp->num());
} }
@ -3371,8 +3371,7 @@ private:
patp = nullptr; patp = nullptr;
break; break;
} else { } else {
std::pair<PatMap::iterator, bool> ret std::pair<PatMap::iterator, bool> ret = patmap.emplace(memp, patp);
= patmap.insert(make_pair(memp, patp));
if (!ret.second) { if (!ret.second) {
patp->v3error("Assignment pattern contains duplicate entry: " patp->v3error("Assignment pattern contains duplicate entry: "
<< VN_CAST(patp->keyp(), Text)->text()); << VN_CAST(patp->keyp(), Text)->text());
@ -5836,7 +5835,7 @@ private:
initp->addValuep(dimensionValue(nodep->fileline(), nodep, attrType, i)); initp->addValuep(dimensionValue(nodep->fileline(), nodep, attrType, i));
} }
userIterate(varp, nullptr); // May have already done $unit so must do this var userIterate(varp, nullptr); // May have already done $unit so must do this var
m_tableMap.insert(make_pair(make_pair(nodep, attrType), varp)); m_tableMap.emplace(make_pair(nodep, attrType), varp);
return varp; return varp;
} }
uint64_t enumMaxValue(const AstNode* errNodep, const AstEnumDType* adtypep) { uint64_t enumMaxValue(const AstNode* errNodep, const AstEnumDType* adtypep) {
@ -5936,7 +5935,7 @@ private:
if (values[i]) initp->addIndexValuep(i, values[i]); if (values[i]) initp->addIndexValuep(i, values[i]);
} }
userIterate(varp, nullptr); // May have already done $unit so must do this var userIterate(varp, nullptr); // May have already done $unit so must do this var
m_tableMap.insert(make_pair(make_pair(nodep, attrType), varp)); m_tableMap.emplace(make_pair(nodep, attrType), varp);
return varp; return varp;
} }
@ -5956,7 +5955,7 @@ private:
if (patmap.find(element) != patmap.end()) { if (patmap.find(element) != patmap.end()) {
patp->v3error("Assignment pattern key used multiple times: " << element); patp->v3error("Assignment pattern key used multiple times: " << element);
} else { } else {
patmap.insert(make_pair(element, patp)); patmap.emplace(element, patp);
} }
element += range.leftToRightInc(); element += range.leftToRightInc();
} }

View File

@ -130,7 +130,7 @@ public:
VlcPoint point(name, pointnum); VlcPoint point(name, pointnum);
point.countInc(count); point.countInc(count);
m_points.push_back(point); m_points.push_back(point);
m_nameMap.insert(make_pair(point.name(), point.pointNum())); m_nameMap.emplace(point.name(), point.pointNum());
} }
return pointnum; return pointnum;
} }