Internals: Add const. No functional change.

This commit is contained in:
Wilson Snyder 2021-06-20 18:32:57 -04:00
parent ec4eb18846
commit 512fe0a2d1
87 changed files with 690 additions and 669 deletions

View File

@ -163,7 +163,7 @@ private:
} else { } else {
++m_statAsNotImm; ++m_statAsNotImm;
} }
bool force = VN_IS(nodep, AssertIntrinsic); const bool force = VN_IS(nodep, AssertIntrinsic);
if (passsp) passsp = newIfAssertOn(passsp, force); if (passsp) passsp = newIfAssertOn(passsp, force);
if (failsp) failsp = newIfAssertOn(failsp, force); if (failsp) failsp = newIfAssertOn(failsp, force);
if (!failsp) failsp = newFireAssertUnchecked(nodep, "'assert' failed."); if (!failsp) failsp = newFireAssertUnchecked(nodep, "'assert' failed.");
@ -231,7 +231,7 @@ private:
} while (ifp); } while (ifp);
AstNode* newifp = nodep->cloneTree(false); AstNode* newifp = nodep->cloneTree(false);
bool allow_none = nodep->unique0Pragma(); const bool allow_none = nodep->unique0Pragma();
// Empty case means no property // Empty case means no property
if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse()); if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse());
@ -305,7 +305,7 @@ private:
// Empty case means no property // Empty case means no property
if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse()); if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse());
bool allow_none = has_default || nodep->unique0Pragma(); const bool allow_none = has_default || nodep->unique0Pragma();
AstNode* ohot AstNode* ohot
= (allow_none = (allow_none
? static_cast<AstNode*>(new AstOneHot0(nodep->fileline(), propp)) ? static_cast<AstNode*>(new AstOneHot0(nodep->fileline(), propp))

View File

@ -119,7 +119,7 @@ string AstNode::encodeName(const string& namein) {
// a user identifier nor a temp we create in Verilator. // a user identifier nor a temp we create in Verilator.
// We also do *NOT* use __DOT__ etc, as we search for those // We also do *NOT* use __DOT__ etc, as we search for those
// in some replacements, and don't want to mangle the user's names. // in some replacements, and don't want to mangle the user's names.
unsigned val = pos[0] & 0xff; // Mask to avoid sign extension const unsigned val = pos[0] & 0xff; // Mask to avoid sign extension
std::stringstream hex; std::stringstream hex;
hex << std::setfill('0') << std::setw(2) << std::hex << val; hex << std::setfill('0') << std::setw(2) << std::hex << val;
out += "__0" + hex.str(); out += "__0" + hex.str();
@ -1045,7 +1045,7 @@ void AstNode::dumpTreeFileGdb(const AstNode* nodep, // LCOV_EXCL_START
cout << "<nullptr>" << endl; cout << "<nullptr>" << endl;
return; return;
} }
string filename = filenamep ? filenamep : v3Global.debugFilename("debug.tree", 98); const string filename = filenamep ? filenamep : v3Global.debugFilename("debug.tree", 98);
v3Global.rootp()->dumpTreeFile(filename); v3Global.rootp()->dumpTreeFile(filename);
} // LCOV_EXCL_STOP } // LCOV_EXCL_STOP
@ -1178,7 +1178,7 @@ string AstNode::locationStr() const {
str += modp->hierName(); str += modp->hierName();
return str; return str;
} else if ((nvrp = VN_CAST_CONST(backp, NodeVarRef))) { } else if ((nvrp = VN_CAST_CONST(backp, NodeVarRef))) {
string prettyName = nvrp->prettyName(); const string prettyName = nvrp->prettyName();
// VarRefs have not been flattened yet and do not contain location information // VarRefs have not been flattened yet and do not contain location information
if (prettyName != nvrp->name()) { if (prettyName != nvrp->name()) {
str += prettyName; str += prettyName;

View File

@ -284,7 +284,7 @@ AstNetlist::AstNetlist()
} }
void AstNetlist::timeprecisionMerge(FileLine*, const VTimescale& value) { void AstNetlist::timeprecisionMerge(FileLine*, const VTimescale& value) {
VTimescale prec = v3Global.opt.timeComputePrec(value); const VTimescale prec = v3Global.opt.timeComputePrec(value);
if (prec.isNone() || prec == m_timeprecision) { if (prec.isNone() || prec == m_timeprecision) {
} else if (m_timeprecision.isNone()) { } else if (m_timeprecision.isNone()) {
m_timeprecision = prec; m_timeprecision = prec;
@ -343,7 +343,8 @@ string AstVar::vlArgType(bool named, bool forReturn, bool forFunc, const string&
string ostatic; string ostatic;
if (isStatic() && namespc.empty()) ostatic = "static "; if (isStatic() && namespc.empty()) ostatic = "static ";
bool isRef = isDpiOpenArray() || (forFunc && (isWritable() || direction().isRefOrConstRef())); const bool isRef
= isDpiOpenArray() || (forFunc && (isWritable() || direction().isRefOrConstRef()));
if (forFunc && isReadOnly() && isRef) ostatic = ostatic + "const "; if (forFunc && isReadOnly() && isRef) ostatic = ostatic + "const ";
@ -358,7 +359,7 @@ string AstVar::vlArgType(bool named, bool forReturn, bool forFunc, const string&
string AstVar::vlEnumType() const { string AstVar::vlEnumType() const {
string arg; string arg;
AstBasicDType* bdtypep = basicp(); AstBasicDType* bdtypep = basicp();
bool strtype = bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::STRING; const bool strtype = bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::STRING;
if (bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::CHARPTR) { if (bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::CHARPTR) {
return "VLVT_PTR"; return "VLVT_PTR";
} else if (bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::SCOPEPTR) { } else if (bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::SCOPEPTR) {
@ -648,7 +649,7 @@ public:
}; };
string AstNodeDType::cType(const string& name, bool forFunc, bool isRef) const { string AstNodeDType::cType(const string& name, bool forFunc, bool isRef) const {
CTypeRecursed info = cTypeRecurse(false); const CTypeRecursed info = cTypeRecurse(false);
return info.render(name, isRef); return info.render(name, isRef);
} }
@ -1251,7 +1252,8 @@ const char* AstClassPackage::broken() const {
return nullptr; return nullptr;
} }
void AstClass::insertCache(AstNode* nodep) { void AstClass::insertCache(AstNode* nodep) {
bool doit = (VN_IS(nodep, Var) || VN_IS(nodep, EnumItemRef) const bool doit
= (VN_IS(nodep, Var) || VN_IS(nodep, EnumItemRef)
|| (VN_IS(nodep, NodeFTask) && !VN_CAST(nodep, NodeFTask)->isExternProto())); || (VN_IS(nodep, NodeFTask) && !VN_CAST(nodep, NodeFTask)->isExternProto()));
if (doit) { if (doit) {
if (m_members.find(nodep->name()) != m_members.end()) { if (m_members.find(nodep->name()) != m_members.end()) {

View File

@ -685,7 +685,7 @@ public:
refDTypep(nullptr); refDTypep(nullptr);
setOp2p(rangep); setOp2p(rangep);
dtypep(nullptr); // V3Width will resolve dtypep(nullptr); // V3Width will resolve
int width = subDTypep()->width() * rangep->elementsConst(); const int width = subDTypep()->width() * rangep->elementsConst();
widthForce(width, width); widthForce(width, width);
} }
AstPackArrayDType(FileLine* fl, AstNodeDType* dtp, AstRange* rangep) AstPackArrayDType(FileLine* fl, AstNodeDType* dtp, AstRange* rangep)
@ -693,7 +693,7 @@ public:
refDTypep(dtp); refDTypep(dtp);
setOp2p(rangep); setOp2p(rangep);
dtypep(this); dtypep(this);
int width = subDTypep()->width() * rangep->elementsConst(); const int width = subDTypep()->width() * rangep->elementsConst();
widthForce(width, width); widthForce(width, width);
} }
ASTNODE_NODE_FUNCS(PackArrayDType) ASTNODE_NODE_FUNCS(PackArrayDType)
@ -848,7 +848,7 @@ private:
numeric(numer); numeric(numer);
if (!rangep && (wantwidth || wantwidthmin >= 0)) { // Constant width if (!rangep && (wantwidth || wantwidthmin >= 0)) { // Constant width
if (wantwidth > 1) m.m_nrange.init(wantwidth - 1, 0, false); if (wantwidth > 1) m.m_nrange.init(wantwidth - 1, 0, false);
int wmin = wantwidthmin >= 0 ? wantwidthmin : wantwidth; const int wmin = wantwidthmin >= 0 ? wantwidthmin : wantwidth;
widthForce(wantwidth, wmin); widthForce(wantwidth, wmin);
} else if (!rangep) { // Set based on keyword properties } else if (!rangep) { // Set based on keyword properties
// V3Width will pull from this width // V3Width will pull from this width

View File

@ -36,19 +36,19 @@ private:
inline T_Data* getUserp(T_Node* nodep) const { inline T_Data* getUserp(T_Node* nodep) const {
// This simplifies statically as T_UserN is constant. In C++17, use 'if constexpr'. // This simplifies statically as T_UserN is constant. In C++17, use 'if constexpr'.
if (T_UserN == 1) { if (T_UserN == 1) {
VNUser user = nodep->user1u(); const VNUser user = nodep->user1u();
return user.to<T_Data*>(); return user.to<T_Data*>();
} else if (T_UserN == 2) { } else if (T_UserN == 2) {
VNUser user = nodep->user2u(); const VNUser user = nodep->user2u();
return user.to<T_Data*>(); return user.to<T_Data*>();
} else if (T_UserN == 3) { } else if (T_UserN == 3) {
VNUser user = nodep->user3u(); const VNUser user = nodep->user3u();
return user.to<T_Data*>(); return user.to<T_Data*>();
} else if (T_UserN == 4) { } else if (T_UserN == 4) {
VNUser user = nodep->user4u(); const VNUser user = nodep->user4u();
return user.to<T_Data*>(); return user.to<T_Data*>();
} else { } else {
VNUser user = nodep->user5u(); const VNUser user = nodep->user5u();
return user.to<T_Data*>(); return user.to<T_Data*>();
} }
} }

View File

@ -117,7 +117,7 @@ private:
string dottedname = nodep->name() + "__DOT__"; // So always found string dottedname = nodep->name() + "__DOT__"; // So always found
string::size_type pos; string::size_type pos;
while ((pos = dottedname.find("__DOT__")) != string::npos) { while ((pos = dottedname.find("__DOT__")) != string::npos) {
string ident = dottedname.substr(0, pos); const string ident = dottedname.substr(0, pos);
dottedname = dottedname.substr(pos + strlen("__DOT__")); dottedname = dottedname.substr(pos + strlen("__DOT__"));
if (nodep->name() != "") m_namedScope = dot(m_namedScope, ident); if (nodep->name() != "") m_namedScope = dot(m_namedScope, ident);
m_unnamedScope = dot(m_unnamedScope, ident); m_unnamedScope = dot(m_unnamedScope, ident);

View File

@ -70,15 +70,15 @@ private:
// Do if // Do if
reset(); reset();
iterateAndNextNull(nodep->ifsp()); iterateAndNextNull(nodep->ifsp());
int ifLikely = m_likely; const int ifLikely = m_likely;
int ifUnlikely = m_unlikely; const int ifUnlikely = m_unlikely;
// Do else // Do else
reset(); reset();
iterateAndNextNull(nodep->elsesp()); iterateAndNextNull(nodep->elsesp());
int elseLikely = m_likely; const int elseLikely = m_likely;
int elseUnlikely = m_unlikely; const int elseUnlikely = m_unlikely;
// Compute // Compute
int likeness = ifLikely - ifUnlikely - (elseLikely - elseUnlikely); const int likeness = ifLikely - ifUnlikely - (elseLikely - elseUnlikely);
if (likeness > 0) { if (likeness > 0) {
nodep->branchPred(VBranchPred::BP_LIKELY); nodep->branchPred(VBranchPred::BP_LIKELY);
} else if (likeness < 0) { } else if (likeness < 0) {

View File

@ -72,7 +72,7 @@ public:
UASSERT_OBJ(!(iter != s_nodes.end() && (iter->second & FLAG_ALLOCATED)), nodep, UASSERT_OBJ(!(iter != s_nodes.end() && (iter->second & FLAG_ALLOCATED)), nodep,
"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 const int flags = FLAG_ALLOCATED; // This int needed to appease GCC 4.1.2
s_nodes.emplace(nodep, flags); s_nodes.emplace(nodep, flags);
} }
} }
@ -103,7 +103,7 @@ public:
UASSERT_OBJ(!(iter->second & FLAG_IN_TREE), nodep, UASSERT_OBJ(!(iter->second & FLAG_IN_TREE), nodep,
"AstNode is already in tree at another location"); "AstNode is already in tree at another location");
} }
int or_flags = FLAG_IN_TREE | (linkable ? FLAG_LINKABLE : 0); const int or_flags = FLAG_IN_TREE | (linkable ? FLAG_LINKABLE : 0);
if (iter == s_nodes.end()) { if (iter == s_nodes.end()) {
s_nodes.emplace(nodep, or_flags); s_nodes.emplace(nodep, or_flags);
} else { } else {

View File

@ -139,8 +139,8 @@ void V3CCtors::evalAsserts() {
if (AstVar* varp = VN_CAST(np, Var)) { if (AstVar* varp = VN_CAST(np, Var)) {
if (varp->isPrimaryInish() && !varp->isSc()) { if (varp->isPrimaryInish() && !varp->isSc()) {
if (AstBasicDType* basicp = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) { if (AstBasicDType* basicp = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) {
int storedWidth = basicp->widthAlignBytes() * 8; const int storedWidth = basicp->widthAlignBytes() * 8;
int lastWordWidth = varp->width() % storedWidth; const int lastWordWidth = varp->width() % storedWidth;
if (lastWordWidth != 0) { if (lastWordWidth != 0) {
// if (signal & CONST(upper_non_clean_mask)) { fail; } // if (signal & CONST(upper_non_clean_mask)) { fail; }
AstVarRef* const vrefp AstVarRef* const vrefp

View File

@ -151,7 +151,7 @@ private:
*m_ofp << " "; *m_ofp << " ";
} }
*m_ofp << nodep->prettyTypeName() << "\n"; *m_ofp << nodep->prettyTypeName() << "\n";
string lastPrefix = m_prefix; const string lastPrefix = m_prefix;
m_prefix = lastPrefix + "1:"; m_prefix = lastPrefix + "1:";
iterateAndNextNull(nodep->op1p()); iterateAndNextNull(nodep->op1p());
m_prefix = lastPrefix + "2:"; m_prefix = lastPrefix + "2:";
@ -449,7 +449,7 @@ private:
if (!vertexp->asyncPath() && level != 0) return false; // Not part of path if (!vertexp->asyncPath() && level != 0) return false; // Not part of path
// Other logic in the path // Other logic in the path
string cont = prefix + sep; const string cont = prefix + sep;
string nextsep = " "; string nextsep = " ";
for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) {
CdcEitherVertex* eFromVertexp = static_cast<CdcEitherVertex*>(edgep->fromp()); CdcEitherVertex* eFromVertexp = static_cast<CdcEitherVertex*>(edgep->fromp());
@ -506,7 +506,8 @@ private:
} }
} }
string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc_edges.txt"; const string filename
= v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc_edges.txt";
const std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename)); const std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename));
if (ofp->fail()) v3fatal("Can't write " << filename); if (ofp->fail()) v3fatal("Can't write " << filename);
*ofp << "Edge Report for " << v3Global.opt.prefix() << '\n'; *ofp << "Edge Report for " << v3Global.opt.prefix() << '\n';
@ -523,7 +524,7 @@ private:
os.setf(std::ios::left); os.setf(std::ios::left);
// Module name - doesn't work due to flattening having lost the original // Module name - doesn't work due to flattening having lost the original
// so we assume the modulename matches the filebasename // so we assume the modulename matches the filebasename
string fname = vvertexp->varScp()->fileline()->filebasename() + ":"; const string fname = vvertexp->varScp()->fileline()->filebasename() + ":";
os << " " << std::setw(20) << fname; os << " " << std::setw(20) << fname;
os << " " << std::setw(8) << what; os << " " << std::setw(8) << what;
os << " " << std::setw(40) << vvertexp->varScp()->prettyName(); os << " " << std::setw(40) << vvertexp->varScp()->prettyName();
@ -727,7 +728,7 @@ public:
// CONSTRUCTORS // CONSTRUCTORS
explicit CdcVisitor(AstNode* nodep) { explicit CdcVisitor(AstNode* nodep) {
// Make report of all signal names and what clock edges they have // Make report of all signal names and what clock edges they have
string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc.txt"; const string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc.txt";
m_ofp = V3File::new_ofstream(filename); m_ofp = V3File::new_ofstream(filename);
if (m_ofp->fail()) v3fatal("Can't write " << filename); if (m_ofp->fail()) v3fatal("Can't write " << filename);
m_ofFilename = filename; m_ofFilename = filename;

View File

@ -68,7 +68,7 @@ private:
void setCppWidth(AstNode* nodep) { void setCppWidth(AstNode* nodep) {
nodep->user2(true); // Don't resize it again nodep->user2(true); // Don't resize it again
AstNodeDType* old_dtypep = nodep->dtypep(); AstNodeDType* old_dtypep = nodep->dtypep();
int width = cppWidth(nodep); // widthMin is unchanged const int width = cppWidth(nodep); // widthMin is unchanged
if (old_dtypep->width() != width) { if (old_dtypep->width() != width) {
// Since any given dtype's cppWidth() is the same, we can just // Since any given dtype's cppWidth() is the same, we can just
// remember one conversion for each, and reuse it // remember one conversion for each, and reuse it
@ -103,7 +103,7 @@ private:
void setCleanState(AstNode* nodep, CleanState clean) { nodep->user1(clean); } void setCleanState(AstNode* nodep, CleanState clean) { nodep->user1(clean); }
CleanState getCleanState(AstNode* nodep) { return static_cast<CleanState>(nodep->user1()); } CleanState getCleanState(AstNode* nodep) { return static_cast<CleanState>(nodep->user1()); }
bool isClean(AstNode* nodep) { bool isClean(AstNode* nodep) {
CleanState clstate = getCleanState(nodep); const CleanState clstate = getCleanState(nodep);
if (clstate == CS_CLEAN) return true; if (clstate == CS_CLEAN) return true;
if (clstate == CS_DIRTY) return false; if (clstate == CS_DIRTY) return false;
nodep->v3fatalSrc("Unknown clean state on node: " + nodep->prettyTypeName()); nodep->v3fatalSrc("Unknown clean state on node: " + nodep->prettyTypeName());
@ -111,7 +111,8 @@ private:
} }
void setClean(AstNode* nodep, bool isClean) { void setClean(AstNode* nodep, bool isClean) {
computeCppWidth(nodep); // Just to be sure it's in widthMin computeCppWidth(nodep); // Just to be sure it's in widthMin
bool wholeUint = (nodep->widthMin() == VL_IDATASIZE || nodep->widthMin() == VL_QUADSIZE const bool wholeUint
= (nodep->widthMin() == VL_IDATASIZE || nodep->widthMin() == VL_QUADSIZE
|| (nodep->widthMin() % VL_EDATASIZE) == 0); || (nodep->widthMin() % VL_EDATASIZE) == 0);
setCleanState(nodep, ((isClean || wholeUint) ? CS_CLEAN : CS_DIRTY)); setCleanState(nodep, ((isClean || wholeUint) ? CS_CLEAN : CS_DIRTY));
} }

View File

@ -219,7 +219,7 @@ private:
if (ofuncp->finalsp()) tempp->addStmtsp(ofuncp->finalsp()->unlinkFrBackWithNext()); if (ofuncp->finalsp()) tempp->addStmtsp(ofuncp->finalsp()->unlinkFrBackWithNext());
while (tempp->stmtsp()) { while (tempp->stmtsp()) {
AstNode* itemp = tempp->stmtsp()->unlinkFrBack(); AstNode* itemp = tempp->stmtsp()->unlinkFrBack();
int stmts = EmitCBaseCounterVisitor(itemp).count(); const int stmts = EmitCBaseCounterVisitor(itemp).count();
if (!funcp || (func_stmts + stmts) > v3Global.opt.outputSplitCFuncs()) { if (!funcp || (func_stmts + stmts) > v3Global.opt.outputSplitCFuncs()) {
// Make a new function // Make a new function
funcp = new AstCFunc{ofuncp->fileline(), ofuncp->name() + cvtToStr(++funcnum), funcp = new AstCFunc{ofuncp->fileline(), ofuncp->name() + cvtToStr(++funcnum),

View File

@ -201,7 +201,7 @@ public:
} }
void applyBlock(AstNodeBlock* nodep) { void applyBlock(AstNodeBlock* nodep) {
AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF; const AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF;
if (!nodep->unnamed()) { if (!nodep->unnamed()) {
for (const string& i : m_coverageOffBlocks) { for (const string& i : m_coverageOffBlocks) {
if (VString::wildmatch(nodep->name(), i)) { if (VString::wildmatch(nodep->name(), i)) {
@ -297,14 +297,14 @@ public:
void applyBlock(AstNodeBlock* nodep) { void applyBlock(AstNodeBlock* nodep) {
// Apply to block at this line // Apply to block at this line
AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF; const AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF;
if (lineMatch(nodep->fileline()->lineno(), pragma)) { if (lineMatch(nodep->fileline()->lineno(), pragma)) {
nodep->addStmtsp(new AstPragma(nodep->fileline(), pragma)); nodep->addStmtsp(new AstPragma(nodep->fileline(), pragma));
} }
} }
void applyCase(AstCase* nodep) { void applyCase(AstCase* nodep) {
// Apply to this case at this line // Apply to this case at this line
int lineno = nodep->fileline()->lineno(); const int lineno = nodep->fileline()->lineno();
if (lineMatch(lineno, AstPragmaType::FULL_CASE)) nodep->fullPragma(true); if (lineMatch(lineno, AstPragmaType::FULL_CASE)) nodep->fullPragma(true);
if (lineMatch(lineno, AstPragmaType::PARALLEL_CASE)) nodep->parallelPragma(true); if (lineMatch(lineno, AstPragmaType::PARALLEL_CASE)) nodep->parallelPragma(true);
} }
@ -313,7 +313,7 @@ public:
if (m_lastIgnore.lineno != filelinep->lineno()) { if (m_lastIgnore.lineno != filelinep->lineno()) {
// UINFO(9, " ApplyIgnores for " << filelinep->ascii() << endl); // UINFO(9, " ApplyIgnores for " << filelinep->ascii() << endl);
// Process all on/offs for lines up to and including the current line // Process all on/offs for lines up to and including the current line
int curlineno = filelinep->lastLineno(); const int curlineno = filelinep->lastLineno();
for (; m_lastIgnore.it != m_ignLines.end(); ++m_lastIgnore.it) { for (; m_lastIgnore.it != m_ignLines.end(); ++m_lastIgnore.it) {
if (m_lastIgnore.it->m_lineno > curlineno) break; if (m_lastIgnore.it->m_lineno > curlineno) break;
// UINFO(9, " Hit " << *m_lastIt << endl); // UINFO(9, " Hit " << *m_lastIt << endl);

View File

@ -376,10 +376,10 @@ class ConstBitOpTreeVisitor final : public AstNVisitor {
AstAnd* andp = VN_CAST(nodep->lhsp(), And); AstAnd* andp = VN_CAST(nodep->lhsp(), And);
CONST_BITOP_RETURN_IF(!andp, nodep->lhsp()); CONST_BITOP_RETURN_IF(!andp, nodep->lhsp());
auto mask = findLeaf(andp->lhsp(), true); const auto mask = findLeaf(andp->lhsp(), true);
CONST_BITOP_RETURN_IF(!mask.m_constp || mask.m_lsb != 0, andp->lhsp()); CONST_BITOP_RETURN_IF(!mask.m_constp || mask.m_lsb != 0, andp->lhsp());
LeafInfo leaf = findLeaf(andp->rhsp(), false); const LeafInfo leaf = findLeaf(andp->rhsp(), false);
CONST_BITOP_RETURN_IF(!leaf.m_refp, andp->rhsp()); CONST_BITOP_RETURN_IF(!leaf.m_refp, andp->rhsp());
restorer.disableRestore(); // Now all subtree succeeded restorer.disableRestore(); // Now all subtree succeeded
@ -394,7 +394,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor {
} }
virtual void visit(AstNodeBiop* nodep) override { virtual void visit(AstNodeBiop* nodep) override {
auto isConst = [](AstNode* nodep, vluint64_t v) -> bool { const auto isConst = [](AstNode* nodep, vluint64_t v) -> bool {
AstConst* constp = VN_CAST(nodep, Const); AstConst* constp = VN_CAST(nodep, Const);
return constp && constp->toUQuad() == v; return constp && constp->toUQuad() == v;
}; };
@ -452,16 +452,16 @@ class ConstBitOpTreeVisitor final : public AstNVisitor {
Restorer restorer{*this}; Restorer restorer{*this};
CONST_BITOP_RETURN_IF(!m_polarity, nodep); CONST_BITOP_RETURN_IF(!m_polarity, nodep);
const bool maskFlip = isOrTree(); const bool maskFlip = isOrTree();
LeafInfo comp = findLeaf(nodep->lhsp(), true); const LeafInfo comp = findLeaf(nodep->lhsp(), true);
CONST_BITOP_RETURN_IF(!comp.m_constp || comp.m_lsb != 0, nodep->lhsp()); CONST_BITOP_RETURN_IF(!comp.m_constp || comp.m_lsb != 0, nodep->lhsp());
AstAnd* andp = VN_CAST(nodep->rhsp(), And); // comp == (mask & v) AstAnd* andp = VN_CAST(nodep->rhsp(), And); // comp == (mask & v)
CONST_BITOP_RETURN_IF(!andp, nodep->rhsp()); CONST_BITOP_RETURN_IF(!andp, nodep->rhsp());
LeafInfo mask = findLeaf(andp->lhsp(), true); const LeafInfo mask = findLeaf(andp->lhsp(), true);
CONST_BITOP_RETURN_IF(!mask.m_constp || mask.m_lsb != 0, andp->lhsp()); CONST_BITOP_RETURN_IF(!mask.m_constp || mask.m_lsb != 0, andp->lhsp());
LeafInfo ref = findLeaf(andp->rhsp(), false); const LeafInfo ref = findLeaf(andp->rhsp(), false);
CONST_BITOP_RETURN_IF(!ref.m_refp, andp->rhsp()); CONST_BITOP_RETURN_IF(!ref.m_refp, andp->rhsp());
restorer.disableRestore(); // Now all checks passed restorer.disableRestore(); // Now all checks passed
@ -1002,7 +1002,7 @@ private:
|| lp->num().isFourState() || lp->num().isNegative()) { || lp->num().isFourState() || lp->num().isNegative()) {
return false; return false;
} }
int newLsb = lp->toSInt() + bp->toSInt(); const int newLsb = lp->toSInt() + bp->toSInt();
if (newLsb + nodep->widthConst() > ap->width()) return false; if (newLsb + nodep->widthConst() > ap->width()) return false;
// //
UINFO(9, "SEL(SHIFTR(a,b),l,w) -> SEL(a,l+b,w)\n"); UINFO(9, "SEL(SHIFTR(a,b),l,w) -> SEL(a,l+b,w)\n");
@ -1023,7 +1023,7 @@ private:
AstExtend* extendp = VN_CAST(nodep->rhsp(), Extend); AstExtend* extendp = VN_CAST(nodep->rhsp(), Extend);
if (!extendp) return false; if (!extendp) return false;
AstNode* smallerp = extendp->lhsp(); AstNode* smallerp = extendp->lhsp();
int subsize = smallerp->width(); const int subsize = smallerp->width();
AstConst* constp = VN_CAST(nodep->lhsp(), Const); AstConst* constp = VN_CAST(nodep->lhsp(), Const);
if (!constp) return false; if (!constp) return false;
if (!constp->num().isBitsZero(constp->width() - 1, subsize)) return false; if (!constp->num().isBitsZero(constp->width() - 1, subsize)) return false;
@ -1048,7 +1048,7 @@ private:
const AstExtend* extendp = VN_CAST_CONST(nodep->rhsp(), Extend); const AstExtend* extendp = VN_CAST_CONST(nodep->rhsp(), Extend);
if (!extendp) return false; if (!extendp) return false;
AstNode* smallerp = extendp->lhsp(); AstNode* smallerp = extendp->lhsp();
int subsize = smallerp->width(); const int subsize = smallerp->width();
const AstConst* constp = VN_CAST_CONST(nodep->lhsp(), Const); const AstConst* constp = VN_CAST_CONST(nodep->lhsp(), Const);
if (!constp) return false; if (!constp) return false;
if (constp->num().isBitsZero(constp->width() - 1, subsize)) return false; if (constp->num().isBitsZero(constp->width() - 1, subsize)) return false;
@ -1079,9 +1079,9 @@ private:
} }
// Find range of dtype we are selecting from // Find range of dtype we are selecting from
// Similar code in V3Unknown::AstSel // Similar code in V3Unknown::AstSel
bool doit = true; const bool doit = true;
if (m_warn && VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const) && doit) { if (m_warn && VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const) && doit) {
int maxDeclBit = nodep->declRange().hiMaxSelect() * nodep->declElWidth() const int maxDeclBit = nodep->declRange().hiMaxSelect() * nodep->declElWidth()
+ (nodep->declElWidth() - 1); + (nodep->declElWidth() - 1);
if (VN_CAST(nodep->lsbp(), Const)->num().isFourState() if (VN_CAST(nodep->lsbp(), Const)->num().isFourState()
|| VN_CAST(nodep->widthp(), Const)->num().isFourState()) { || VN_CAST(nodep->widthp(), Const)->num().isFourState()) {
@ -1157,7 +1157,7 @@ private:
const AstConst* lwidth = VN_CAST_CONST(lhsp->widthp(), Const); const AstConst* lwidth = VN_CAST_CONST(lhsp->widthp(), Const);
const AstConst* rwidth = VN_CAST_CONST(rhsp->widthp(), Const); const AstConst* rwidth = VN_CAST_CONST(rhsp->widthp(), Const);
if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated
int rend = (rstart->toSInt() + rwidth->toSInt()); const int rend = (rstart->toSInt() + rwidth->toSInt());
return (rend == lstart->toSInt()); return (rend == lstart->toSInt());
} }
bool ifMergeAdjacent(AstNode* lhsp, AstNode* rhsp) { bool ifMergeAdjacent(AstNode* lhsp, AstNode* rhsp) {
@ -1190,7 +1190,7 @@ private:
AstConst* lwidth = VN_CAST(lselp->widthp(), Const); AstConst* lwidth = VN_CAST(lselp->widthp(), Const);
AstConst* rwidth = VN_CAST(rselp->widthp(), Const); AstConst* rwidth = VN_CAST(rselp->widthp(), Const);
if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated
int rend = (rstart->toSInt() + rwidth->toSInt()); const int rend = (rstart->toSInt() + rwidth->toSInt());
// a[i:j] a[j-1:k] // a[i:j] a[j-1:k]
if (rend == lstart->toSInt()) return true; if (rend == lstart->toSInt()) return true;
// a[i:0] a[msb:j] // a[i:0] a[msb:j]
@ -1207,8 +1207,8 @@ private:
const AstNodeBiop* rp = VN_CAST_CONST(rhsp, NodeBiop); const AstNodeBiop* rp = VN_CAST_CONST(rhsp, NodeBiop);
if (!lp || !rp) return false; if (!lp || !rp) return false;
// {a[]&b[], a[]&b[]} // {a[]&b[], a[]&b[]}
bool lad = ifMergeAdjacent(lp->lhsp(), rp->lhsp()); const bool lad = ifMergeAdjacent(lp->lhsp(), rp->lhsp());
bool rad = ifMergeAdjacent(lp->rhsp(), rp->rhsp()); const bool rad = ifMergeAdjacent(lp->rhsp(), rp->rhsp());
if (lad && rad) return true; if (lad && rad) return true;
// {a[] & b[]&c[], a[] & b[]&c[]} // {a[] & b[]&c[], a[] & b[]&c[]}
if (lad && concatMergeable(lp->rhsp(), rp->rhsp())) return true; if (lad && concatMergeable(lp->rhsp(), rp->rhsp())) return true;
@ -1449,10 +1449,10 @@ private:
// {a[1], a[0]} -> a[1:0] // {a[1], a[0]} -> a[1:0]
AstSel* lselp = VN_CAST(nodep->lhsp()->unlinkFrBack(), Sel); AstSel* lselp = VN_CAST(nodep->lhsp()->unlinkFrBack(), Sel);
AstSel* rselp = VN_CAST(nodep->rhsp()->unlinkFrBack(), Sel); AstSel* rselp = VN_CAST(nodep->rhsp()->unlinkFrBack(), Sel);
int lstart = lselp->lsbConst(); const int lstart = lselp->lsbConst();
int lwidth = lselp->widthConst(); const int lwidth = lselp->widthConst();
int rstart = rselp->lsbConst(); const int rstart = rselp->lsbConst();
int rwidth = rselp->widthConst(); const int rwidth = rselp->widthConst();
UASSERT_OBJ((rstart + rwidth) == lstart, nodep, UASSERT_OBJ((rstart + rwidth) == lstart, nodep,
"tried to merge two selects which are not adjacent"); "tried to merge two selects which are not adjacent");
@ -1513,7 +1513,7 @@ private:
} }
void replaceMulShift(AstMul* nodep) { // Mul, but not MulS as not simple shift void replaceMulShift(AstMul* nodep) { // Mul, but not MulS as not simple shift
UINFO(5, "MUL(2^n,b)->SHIFTL(b,n) " << nodep << endl); UINFO(5, "MUL(2^n,b)->SHIFTL(b,n) " << nodep << endl);
int amount = VN_CAST(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 const int amount = VN_CAST(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
AstNode* opp = nodep->rhsp()->unlinkFrBack(); AstNode* opp = nodep->rhsp()->unlinkFrBack();
AstShiftL* newp AstShiftL* newp
= new AstShiftL(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount)); = new AstShiftL(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount));
@ -1523,7 +1523,7 @@ private:
} }
void replaceDivShift(AstDiv* nodep) { // Mul, but not MulS as not simple shift void replaceDivShift(AstDiv* nodep) { // Mul, but not MulS as not simple shift
UINFO(5, "DIV(b,2^n)->SHIFTR(b,n) " << nodep << endl); UINFO(5, "DIV(b,2^n)->SHIFTR(b,n) " << nodep << endl);
int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 const int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
AstNode* opp = nodep->lhsp()->unlinkFrBack(); AstNode* opp = nodep->lhsp()->unlinkFrBack();
AstShiftR* newp AstShiftR* newp
= new AstShiftR(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount)); = new AstShiftR(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount));
@ -1533,7 +1533,7 @@ private:
} }
void replaceModAnd(AstModDiv* nodep) { // Mod, but not ModS as not simple shift void replaceModAnd(AstModDiv* nodep) { // Mod, but not ModS as not simple shift
UINFO(5, "MOD(b,2^n)->AND(b,2^n-1) " << nodep << endl); UINFO(5, "MOD(b,2^n)->AND(b,2^n-1) " << nodep << endl);
int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 const int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
V3Number mask(nodep, nodep->width()); V3Number mask(nodep, nodep->width());
mask.setMask(amount); mask.setMask(amount);
AstNode* opp = nodep->lhsp()->unlinkFrBack(); AstNode* opp = nodep->lhsp()->unlinkFrBack();
@ -1576,7 +1576,7 @@ private:
if (nodep->type() == lhsp->type()) { if (nodep->type() == lhsp->type()) {
int shift1 = VN_CAST(shift1p, Const)->toUInt(); int shift1 = VN_CAST(shift1p, Const)->toUInt();
int shift2 = VN_CAST(shift2p, Const)->toUInt(); int shift2 = VN_CAST(shift2p, Const)->toUInt();
int newshift = shift1 + shift2; const int newshift = shift1 + shift2;
VL_DO_DANGLING(shift1p->deleteTree(), shift1p); VL_DO_DANGLING(shift1p->deleteTree(), shift1p);
VL_DO_DANGLING(shift2p->deleteTree(), shift2p); VL_DO_DANGLING(shift2p->deleteTree(), shift2p);
nodep->lhsp(ap); nodep->lhsp(ap);
@ -1588,7 +1588,7 @@ private:
if (VN_IS(lhsp, ShiftR)) shift1 = -shift1; if (VN_IS(lhsp, ShiftR)) shift1 = -shift1;
int shift2 = VN_CAST(shift2p, Const)->toUInt(); int shift2 = VN_CAST(shift2p, Const)->toUInt();
if (VN_IS(nodep, ShiftR)) shift2 = -shift2; if (VN_IS(nodep, ShiftR)) shift2 = -shift2;
int newshift = shift1 + shift2; const int newshift = shift1 + shift2;
VL_DO_DANGLING(shift1p->deleteTree(), shift1p); VL_DO_DANGLING(shift1p->deleteTree(), shift1p);
VL_DO_DANGLING(shift2p->deleteTree(), shift2p); VL_DO_DANGLING(shift2p->deleteTree(), shift2p);
AstNode* newp; AstNode* newp;
@ -1656,7 +1656,7 @@ private:
&& (con2p->toSInt() != con1p->toSInt() + sel1p->width())) { && (con2p->toSInt() != con1p->toSInt() + sel1p->width())) {
return false; return false;
} }
bool lsbFirstAssign = (con1p->toUInt() < con2p->toUInt()); const bool lsbFirstAssign = (con1p->toUInt() < con2p->toUInt());
UINFO(4, "replaceAssignMultiSel " << nodep << endl); UINFO(4, "replaceAssignMultiSel " << nodep << endl);
UINFO(4, " && " << nextp << endl); UINFO(4, " && " << nextp << endl);
// nodep->dumpTree(cout, "comb1: "); // nodep->dumpTree(cout, "comb1: ");
@ -1815,8 +1815,8 @@ private:
return true; return true;
} else if (m_doV && VN_IS(nodep->lhsp(), StreamL)) { } else if (m_doV && VN_IS(nodep->lhsp(), StreamL)) {
// Push the stream operator to the rhs of the assignment statement // Push the stream operator to the rhs of the assignment statement
int dWidth = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->width(); const int dWidth = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->width();
int sWidth = nodep->rhsp()->width(); const int sWidth = nodep->rhsp()->width();
// Unlink the stuff // Unlink the stuff
AstNode* dstp = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack(); AstNode* dstp = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack();
AstNode* streamp = VN_CAST(nodep->lhsp(), StreamL)->unlinkFrBack(); AstNode* streamp = VN_CAST(nodep->lhsp(), StreamL)->unlinkFrBack();
@ -1836,8 +1836,8 @@ private:
// The right stream operator on lhs of assignment statement does // The right stream operator on lhs of assignment statement does
// not reorder bits. However, if the rhs is wider than the lhs, // not reorder bits. However, if the rhs is wider than the lhs,
// then we select bits from the left-most, not the right-most. // then we select bits from the left-most, not the right-most.
int dWidth = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->width(); const int dWidth = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->width();
int sWidth = nodep->rhsp()->width(); const int sWidth = nodep->rhsp()->width();
// Unlink the stuff // Unlink the stuff
AstNode* dstp = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack(); AstNode* dstp = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack();
AstNode* sizep = VN_CAST(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack(); AstNode* sizep = VN_CAST(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack();
@ -2666,7 +2666,7 @@ private:
string fmt; string fmt;
bool inPct = false; bool inPct = false;
AstNode* argp = nodep->exprsp(); AstNode* argp = nodep->exprsp();
string text = nodep->text(); const string text = nodep->text();
for (const char ch : text) { for (const char ch : text) {
if (!inPct && ch == '%') { if (!inPct && ch == '%') {
inPct = true; inPct = true;
@ -2688,7 +2688,8 @@ private:
if (argp) { if (argp) {
AstNode* nextp = argp->nextp(); AstNode* nextp = argp->nextp();
if (VN_IS(argp, Const)) { // Convert it if (VN_IS(argp, Const)) { // Convert it
string out = VN_CAST(argp, Const)->num().displayed(nodep, fmt); const string out
= VN_CAST(argp, Const)->num().displayed(nodep, fmt);
UINFO(9, " DispConst: " << fmt << " -> " << out << " for " UINFO(9, " DispConst: " << fmt << " -> " << out << " for "
<< argp << endl); << argp << endl);
// fmt = out w/ replace % with %% as it must be literal. // fmt = out w/ replace % with %% as it must be literal.
@ -2726,10 +2727,10 @@ private:
iterateChildren(nodep); iterateChildren(nodep);
} }
virtual void visit(AstWhile* nodep) override { virtual void visit(AstWhile* nodep) override {
bool oldHasJumpDelay = m_hasJumpDelay; const bool oldHasJumpDelay = m_hasJumpDelay;
m_hasJumpDelay = false; m_hasJumpDelay = false;
{ iterateChildren(nodep); } { iterateChildren(nodep); }
bool thisWhileHasJumpDelay = m_hasJumpDelay; const bool thisWhileHasJumpDelay = m_hasJumpDelay;
m_hasJumpDelay = thisWhileHasJumpDelay || oldHasJumpDelay; m_hasJumpDelay = thisWhileHasJumpDelay || oldHasJumpDelay;
if (m_doNConst) { if (m_doNConst) {
if (nodep->condp()->isZero()) { if (nodep->condp()->isZero()) {

View File

@ -92,7 +92,7 @@ private:
// See also similar rule in V3TraceDecl::varIgnoreTrace // See also similar rule in V3TraceDecl::varIgnoreTrace
if (!nodep->isToggleCoverable()) return "Not relevant signal type"; if (!nodep->isToggleCoverable()) return "Not relevant signal type";
if (!v3Global.opt.coverageUnderscore()) { if (!v3Global.opt.coverageUnderscore()) {
string prettyName = nodep->prettyName(); const string prettyName = nodep->prettyName();
if (prettyName[0] == '_') return "Leading underscore"; if (prettyName[0] == '_') return "Leading underscore";
if (prettyName.find("._") != string::npos) return "Inlined leading underscore"; if (prettyName.find("._") != string::npos) return "Inlined leading underscore";
} }
@ -114,7 +114,7 @@ private:
// Note the module name could have parameters appended, we'll consider this // Note the module name could have parameters appended, we'll consider this
// a feature as it allows for each parameterized block to be counted separately. // a feature as it allows for each parameterized block to be counted separately.
// Someday the user might be allowed to specify a different page suffix // Someday the user might be allowed to specify a different page suffix
string page = page_prefix + "/" + m_modp->prettyName(); const string page = page_prefix + "/" + m_modp->prettyName();
AstCoverDecl* declp = new AstCoverDecl(fl, page, comment, linescov, offset); AstCoverDecl* declp = new AstCoverDecl(fl, page, comment, linescov, offset);
declp->hier(hier); declp->hier(hier);
@ -144,7 +144,7 @@ private:
if (it == m_varnames.end()) { if (it == m_varnames.end()) {
m_varnames.emplace(name, 1); m_varnames.emplace(name, 1);
} else { } else {
int suffix = (it->second)++; const int suffix = (it->second)++;
name += "_" + cvtToStr(suffix); name += "_" + cvtToStr(suffix);
} }
return name; return name;
@ -278,7 +278,7 @@ private:
// We'll do this, and make the if(...) coverinc later. // We'll do this, and make the if(...) coverinc later.
// Add signal to hold the old value // Add signal to hold the old value
string newvarname = string("__Vtogcov__") + nodep->shortName(); const string newvarname = string("__Vtogcov__") + nodep->shortName();
AstVar* chgVarp AstVar* chgVarp
= new AstVar(nodep->fileline(), AstVarType::MODULETEMP, newvarname, nodep); = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, newvarname, nodep);
chgVarp->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true); chgVarp->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true);
@ -312,7 +312,7 @@ private:
if (bdtypep->isRanged()) { if (bdtypep->isRanged()) {
for (int index_docs = bdtypep->lo(); index_docs < bdtypep->hi() + 1; for (int index_docs = bdtypep->lo(); index_docs < bdtypep->hi() + 1;
++index_docs) { ++index_docs) {
int index_code = index_docs - bdtypep->lo(); const int index_code = index_docs - bdtypep->lo();
ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]", ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]",
new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true), new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true),
index_code, 1), index_code, 1),
@ -326,7 +326,7 @@ private:
} }
} else if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { } else if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) {
for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) { for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) {
int index_code = index_docs - adtypep->lo(); const int index_code = index_docs - adtypep->lo();
ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]", ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]",
new AstArraySel(varp->fileline(), new AstArraySel(varp->fileline(),
above.m_varRefp->cloneTree(true), index_code), above.m_varRefp->cloneTree(true), index_code),
@ -339,7 +339,7 @@ private:
} else if (AstPackArrayDType* adtypep = VN_CAST(dtypep, PackArrayDType)) { } else if (AstPackArrayDType* adtypep = VN_CAST(dtypep, PackArrayDType)) {
for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) { for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) {
AstNodeDType* subtypep = adtypep->subDTypep()->skipRefp(); AstNodeDType* subtypep = adtypep->subDTypep()->skipRefp();
int index_code = index_docs - adtypep->lo(); const int index_code = index_docs - adtypep->lo();
ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]", ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]",
new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true), new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true),
index_code * subtypep->width(), subtypep->width()), index_code * subtypep->width(), subtypep->width()),
@ -354,7 +354,7 @@ private:
for (AstMemberDType* itemp = adtypep->membersp(); itemp; for (AstMemberDType* itemp = adtypep->membersp(); itemp;
itemp = VN_CAST(itemp->nextp(), MemberDType)) { itemp = VN_CAST(itemp->nextp(), MemberDType)) {
AstNodeDType* subtypep = itemp->subDTypep()->skipRefp(); AstNodeDType* subtypep = itemp->subDTypep()->skipRefp();
int index_code = itemp->lsb(); const int index_code = itemp->lsb();
ToggleEnt newent(above.m_comment + string(".") + itemp->name(), ToggleEnt newent(above.m_comment + string(".") + itemp->name(),
new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true), new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true),
index_code, subtypep->width()), index_code, subtypep->width()),
@ -385,17 +385,18 @@ private:
UINFO(4, " IF: " << nodep << endl); UINFO(4, " IF: " << nodep << endl);
if (m_state.m_on) { if (m_state.m_on) {
// An else-if. When we iterate the if, use "elsif" marking // An else-if. When we iterate the if, use "elsif" marking
bool elsif = nodep->ifsp() && VN_IS(nodep->elsesp(), If) && !nodep->elsesp()->nextp(); const bool elsif
= nodep->ifsp() && VN_IS(nodep->elsesp(), If) && !nodep->elsesp()->nextp();
if (elsif) VN_CAST(nodep->elsesp(), If)->user1(true); if (elsif) VN_CAST(nodep->elsesp(), If)->user1(true);
bool first_elsif = !nodep->user1() && elsif; const bool first_elsif = !nodep->user1() && elsif;
bool cont_elsif = nodep->user1() && elsif; const bool cont_elsif = nodep->user1() && elsif;
bool final_elsif = nodep->user1() && !elsif && nodep->elsesp(); const bool final_elsif = nodep->user1() && !elsif && nodep->elsesp();
// //
// Considered: If conditional is on a different line from if/else then we // Considered: If conditional is on a different line from if/else then we
// can show it as part of line coverage of the statement // can show it as part of line coverage of the statement
// above. Otherwise show it based on what is inside. // above. Otherwise show it based on what is inside.
// But: Seemed too complicated, and fragile. // But: Seemed too complicated, and fragile.
CheckState lastState = m_state; const CheckState lastState = m_state;
CheckState ifState; CheckState ifState;
CheckState elseState; CheckState elseState;
{ {

View File

@ -110,7 +110,7 @@ private:
if (!lastrefp) { if (!lastrefp) {
vscp->user5p(nodep); vscp->user5p(nodep);
} else { } else {
bool last_was_blocking = lastrefp->user5(); const bool last_was_blocking = lastrefp->user5();
if (last_was_blocking != blocking) { if (last_was_blocking != blocking) {
AstNode* nonblockingp = blocking ? nodep : lastrefp; AstNode* nonblockingp = blocking ? nodep : lastrefp;
AstNode* blockingp = blocking ? lastrefp : nodep; AstNode* blockingp = blocking ? lastrefp : nodep;
@ -228,7 +228,7 @@ private:
UASSERT_OBJ(varrefp->varScopep(), varrefp, "Var didn't get varscoped in V3Scope.cpp"); UASSERT_OBJ(varrefp->varScopep(), varrefp, "Var didn't get varscoped in V3Scope.cpp");
varrefp->unlinkFrBack(); varrefp->unlinkFrBack();
AstVar* oldvarp = varrefp->varp(); AstVar* oldvarp = varrefp->varp();
int modVecNum = m_scopeVecMap[varrefp->varScopep()]++; const int modVecNum = m_scopeVecMap[varrefp->varScopep()]++;
// //
std::deque<AstNode*> dimreadps; // Read value for each dimension of assignment std::deque<AstNode*> dimreadps; // Read value for each dimension of assignment
for (unsigned dimension = 0; dimension < dimvalp.size(); dimension++) { for (unsigned dimension = 0; dimension < dimvalp.size(); dimension++) {
@ -236,7 +236,7 @@ private:
if (VN_IS(dimp, Const)) { // bit = const, can just use it if (VN_IS(dimp, Const)) { // bit = const, can just use it
dimreadps.push_front(dimp); dimreadps.push_front(dimp);
} else { } else {
string bitvarname = (string("__Vdlyvdim") + cvtToStr(dimension) + "__" const string bitvarname = (string("__Vdlyvdim") + cvtToStr(dimension) + "__"
+ oldvarp->shortName() + "__v" + cvtToStr(modVecNum)); + oldvarp->shortName() + "__v" + cvtToStr(modVecNum));
AstVarScope* bitvscp AstVarScope* bitvscp
= createVarSc(varrefp->varScopep(), bitvarname, dimp->width(), nullptr); = createVarSc(varrefp->varScopep(), bitvarname, dimp->width(), nullptr);
@ -256,7 +256,7 @@ private:
// vlsb = constant, can just push constant into where we use it // vlsb = constant, can just push constant into where we use it
bitreadp = lsbvaluep; bitreadp = lsbvaluep;
} else { } else {
string bitvarname = (string("__Vdlyvlsb__") + oldvarp->shortName() + "__v" const string bitvarname = (string("__Vdlyvlsb__") + oldvarp->shortName() + "__v"
+ cvtToStr(modVecNum)); + cvtToStr(modVecNum));
AstVarScope* bitvscp AstVarScope* bitvscp
= createVarSc(varrefp->varScopep(), bitvarname, lsbvaluep->width(), nullptr); = createVarSc(varrefp->varScopep(), bitvarname, lsbvaluep->width(), nullptr);
@ -440,7 +440,7 @@ private:
checkActivePost(nodep, oldactivep); checkActivePost(nodep, oldactivep);
} }
if (!dlyvscp) { // First use of this delayed variable if (!dlyvscp) { // First use of this delayed variable
string newvarname = (string("__Vdly__") + nodep->varp()->shortName()); const string newvarname = (string("__Vdly__") + nodep->varp()->shortName());
dlyvscp = createVarSc(oldvscp, newvarname, 0, nullptr); dlyvscp = createVarSc(oldvscp, newvarname, 0, nullptr);
AstNodeAssign* prep; AstNodeAssign* prep;
AstBasicDType* basicp = oldvscp->dtypep()->basicp(); AstBasicDType* basicp = oldvscp->dtypep()->basicp();

View File

@ -52,7 +52,7 @@ private:
UINFO(6, " Deep " << nodep << endl); UINFO(6, " Deep " << nodep << endl);
// if (debug() >= 9) nodep->dumpTree(cout, "deep:"); // if (debug() >= 9) nodep->dumpTree(cout, "deep:");
string newvarname = (string("__Vdeeptemp") + cvtToStr(m_modp->varNumGetInc())); const string newvarname = (string("__Vdeeptemp") + cvtToStr(m_modp->varNumGetInc()));
AstVar* varp AstVar* varp
= new AstVar(nodep->fileline(), AstVarType::STMTTEMP, newvarname, nodep->dtypep()); = new AstVar(nodep->fileline(), AstVarType::STMTTEMP, newvarname, nodep->dtypep());
UASSERT_OBJ(m_cfuncp, nodep, "Deep expression not under a function"); UASSERT_OBJ(m_cfuncp, nodep, "Deep expression not under a function");

View File

@ -111,7 +111,7 @@ private:
// If for any given name only one function exists, we can use that function directly. // If for any given name only one function exists, we can use that function directly.
// If multiple functions exist, we need to select the appropriate scope. // If multiple functions exist, we need to select the appropriate scope.
for (FuncMmap::iterator it = m_modFuncs.begin(); it != m_modFuncs.end(); ++it) { for (FuncMmap::iterator it = m_modFuncs.begin(); it != m_modFuncs.end(); ++it) {
string name = it->first; const string name = it->first;
AstCFunc* topFuncp = it->second; AstCFunc* topFuncp = it->second;
auto nextIt1 = it; auto nextIt1 = it;
++nextIt1; ++nextIt1;
@ -133,7 +133,8 @@ private:
AstCFunc* funcp = eachIt->second; AstCFunc* funcp = eachIt->second;
auto nextIt2 = eachIt; auto nextIt2 = eachIt;
++nextIt2; ++nextIt2;
bool moreOfSame = (nextIt2 != m_modFuncs.end() && nextIt2->first == name); const bool moreOfSame
= (nextIt2 != m_modFuncs.end() && nextIt2->first == name);
UASSERT_OBJ(funcp->scopep(), funcp, "Not scoped"); UASSERT_OBJ(funcp->scopep(), funcp, "Not scoped");
UINFO(6, " Wrapping " << name << " " << funcp << endl); UINFO(6, " Wrapping " << name << " " << funcp << endl);

View File

@ -561,7 +561,7 @@ public:
// displays are handled in AstDisplay // displays are handled in AstDisplay
if (!nodep->dpiExport()) { if (!nodep->dpiExport()) {
// this is where the DPI import context scope is set // this is where the DPI import context scope is set
string scope = nodep->scopeDpiName(); const string scope = nodep->scopeDpiName();
putbs("(&(vlSymsp->" + protect("__Vscope_" + scope) + "))"); putbs("(&(vlSymsp->" + protect("__Vscope_" + scope) + "))");
} }
} }
@ -1520,15 +1520,15 @@ class EmitCImp final : EmitCStmts {
if (v3Global.opt.lintOnly()) { if (v3Global.opt.lintOnly()) {
// Unfortunately we have some lint checks here, so we can't just skip processing. // Unfortunately we have some lint checks here, so we can't just skip processing.
// We should move them to a different stage. // We should move them to a different stage.
string filename = VL_DEV_NULL; const string filename = VL_DEV_NULL;
newCFile(filename, slow, source); newCFile(filename, slow, source);
ofp = new V3OutCFile(filename); ofp = new V3OutCFile(filename);
} else if (optSystemC()) { } else if (optSystemC()) {
string filename = filenameNoExt + (source ? ".cpp" : ".h"); const string filename = filenameNoExt + (source ? ".cpp" : ".h");
newCFile(filename, slow, source); newCFile(filename, slow, source);
ofp = new V3OutScFile(filename); ofp = new V3OutScFile(filename);
} else { } else {
string filename = filenameNoExt + (source ? ".cpp" : ".h"); const string filename = filenameNoExt + (source ? ".cpp" : ".h");
newCFile(filename, slow, source); newCFile(filename, slow, source);
ofp = new V3OutCFile(filename); ofp = new V3OutCFile(filename);
} }
@ -1800,30 +1800,30 @@ class EmitCImp final : EmitCStmts {
// Returns string to do resetting, empty to do nothing (which caller should handle) // Returns string to do resetting, empty to do nothing (which caller should handle)
if (AstAssocArrayDType* adtypep = VN_CAST(dtypep, AssocArrayDType)) { if (AstAssocArrayDType* adtypep = VN_CAST(dtypep, AssocArrayDType)) {
// Access std::array as C array // Access std::array as C array
string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : ""); const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1, return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1,
suffix + ".atDefault()" + cvtarray); suffix + ".atDefault()" + cvtarray);
} else if (VN_IS(dtypep, ClassRefDType)) { } else if (VN_IS(dtypep, ClassRefDType)) {
return ""; // Constructor does it return ""; // Constructor does it
} else if (AstDynArrayDType* adtypep = VN_CAST(dtypep, DynArrayDType)) { } else if (AstDynArrayDType* adtypep = VN_CAST(dtypep, DynArrayDType)) {
// Access std::array as C array // Access std::array as C array
string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : ""); const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1, return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1,
suffix + ".atDefault()" + cvtarray); suffix + ".atDefault()" + cvtarray);
} else if (AstQueueDType* adtypep = VN_CAST(dtypep, QueueDType)) { } else if (AstQueueDType* adtypep = VN_CAST(dtypep, QueueDType)) {
// Access std::array as C array // Access std::array as C array
string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : ""); const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1, return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1,
suffix + ".atDefault()" + cvtarray); suffix + ".atDefault()" + cvtarray);
} else if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { } else if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) {
UASSERT_OBJ(adtypep->hi() >= adtypep->lo(), varp, UASSERT_OBJ(adtypep->hi() >= adtypep->lo(), varp,
"Should have swapped msb & lsb earlier."); "Should have swapped msb & lsb earlier.");
string ivar = string("__Vi") + cvtToStr(depth); const string ivar = string("__Vi") + cvtToStr(depth);
string pre = ("for (int " + ivar + "=" + cvtToStr(0) + "; " + ivar + "<" const string pre = ("for (int " + ivar + "=" + cvtToStr(0) + "; " + ivar + "<"
+ cvtToStr(adtypep->elementsConst()) + "; ++" + ivar + ") {\n"); + cvtToStr(adtypep->elementsConst()) + "; ++" + ivar + ") {\n");
string below = emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), const string below = emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(),
depth + 1, suffix + "[" + ivar + "]"); depth + 1, suffix + "[" + ivar + "]");
string post = "}\n"; const string post = "}\n";
return below.empty() ? "" : pre + below + post; return below.empty() ? "" : pre + below + post;
} else if (basicp && basicp->keyword() == AstBasicDTypeKwd::STRING) { } else if (basicp && basicp->keyword() == AstBasicDTypeKwd::STRING) {
// String's constructor deals with it // String's constructor deals with it
@ -2224,9 +2224,9 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
ofp()->putsQuoted(emitDispState.m_format); ofp()->putsQuoted(emitDispState.m_format);
// Arguments // Arguments
for (unsigned i = 0; i < emitDispState.m_argsp.size(); i++) { for (unsigned i = 0; i < emitDispState.m_argsp.size(); i++) {
char fmt = emitDispState.m_argsChar[i]; const char fmt = emitDispState.m_argsChar[i];
AstNode* argp = emitDispState.m_argsp[i]; AstNode* argp = emitDispState.m_argsp[i];
string func = emitDispState.m_argsFunc[i]; const string func = emitDispState.m_argsFunc[i];
if (func != "" || argp) { if (func != "" || argp) {
puts(","); puts(",");
ofp()->indentInc(); ofp()->indentInc();
@ -2234,7 +2234,7 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
if (func != "") { if (func != "") {
puts(func); puts(func);
} else if (argp) { } else if (argp) {
bool addrof = isScan || (fmt == '@'); const bool addrof = isScan || (fmt == '@');
if (addrof) puts("&("); if (addrof) puts("&(");
iterate(argp); iterate(argp);
if (!addrof) emitDatap(argp); if (!addrof) emitDatap(argp);
@ -2287,7 +2287,7 @@ void EmitCStmts::displayArg(AstNode* dispp, AstNode** elistp, bool isScan, const
// + 1.0 rounding bias. // + 1.0 rounding bias.
double dchars = mantissabits / 3.321928094887362 + 1.0; double dchars = mantissabits / 3.321928094887362 + 1.0;
if (fmtLetter == 'd') dchars++; // space for sign if (fmtLetter == 'd') dchars++; // space for sign
int nchars = int(dchars); const int nchars = int(dchars);
pfmt = string("%") + cvtToStr(nchars) + fmtLetter; pfmt = string("%") + cvtToStr(nchars) + fmtLetter;
} else { } else {
pfmt = string("%") + vfmt + fmtLetter; pfmt = string("%") + vfmt + fmtLetter;
@ -2392,7 +2392,7 @@ void EmitCStmts::displayNode(AstNode* nodep, AstScopeName* scopenamep, const str
case 'z': displayArg(nodep, &elistp, isScan, vfmt, ignore, 'z'); break; case 'z': displayArg(nodep, &elistp, isScan, vfmt, ignore, 'z'); break;
case 'm': { case 'm': {
UASSERT_OBJ(scopenamep, nodep, "Display with %m but no AstScopeName"); UASSERT_OBJ(scopenamep, nodep, "Display with %m but no AstScopeName");
string suffix = scopenamep->scopePrettySymName(); const string suffix = scopenamep->scopePrettySymName();
if (suffix == "") { if (suffix == "") {
emitDispState.pushFormat("%S"); emitDispState.pushFormat("%S");
} else { } else {
@ -2613,9 +2613,9 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) {
if (v3Global.opt.savable()) { if (v3Global.opt.savable()) {
puts("\n// Savable\n"); puts("\n// Savable\n");
for (int de = 0; de < 2; ++de) { for (int de = 0; de < 2; ++de) {
string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize"; const string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize";
string funcname = de ? "__Vdeserialize" : "__Vserialize"; const string funcname = de ? "__Vdeserialize" : "__Vserialize";
string op = de ? ">>" : "<<"; const string op = de ? ">>" : "<<";
// NOLINTNEXTLINE(performance-inefficient-string-concatenation) // NOLINTNEXTLINE(performance-inefficient-string-concatenation)
puts("void " + prefixNameProtect(modp) + "::" + protect(funcname) + "(" + classname puts("void " + prefixNameProtect(modp) + "::" + protect(funcname) + "(" + classname
+ "& os) {\n"); + "& os) {\n");
@ -2657,10 +2657,10 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) {
AstNodeDType* elementp = varp->dtypeSkipRefp(); AstNodeDType* elementp = varp->dtypeSkipRefp();
for (AstUnpackArrayDType* arrayp = VN_CAST(elementp, UnpackArrayDType); for (AstUnpackArrayDType* arrayp = VN_CAST(elementp, UnpackArrayDType);
arrayp; arrayp = VN_CAST(elementp, UnpackArrayDType)) { arrayp; arrayp = VN_CAST(elementp, UnpackArrayDType)) {
int vecnum = vects++; const int vecnum = vects++;
UASSERT_OBJ(arrayp->hi() >= arrayp->lo(), varp, UASSERT_OBJ(arrayp->hi() >= arrayp->lo(), varp,
"Should have swapped msb & lsb earlier."); "Should have swapped msb & lsb earlier.");
string ivar = string("__Vi") + cvtToStr(vecnum); const string ivar = string("__Vi") + cvtToStr(vecnum);
puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(0)); puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(0));
puts("; " + ivar + "<" + cvtToStr(arrayp->elementsConst())); puts("; " + ivar + "<" + cvtToStr(arrayp->elementsConst()));
puts("; ++" + ivar + ") {\n"); puts("; ++" + ivar + ") {\n");
@ -2673,8 +2673,8 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) {
// (i.e. packed types of more than 64 bits). // (i.e. packed types of more than 64 bits).
if (elementp->isWide() if (elementp->isWide()
&& !(basicp && basicp->keyword() == AstBasicDTypeKwd::STRING)) { && !(basicp && basicp->keyword() == AstBasicDTypeKwd::STRING)) {
int vecnum = vects++; const int vecnum = vects++;
string ivar = string("__Vi") + cvtToStr(vecnum); const string ivar = string("__Vi") + cvtToStr(vecnum);
puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(0)); puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(0));
puts("; " + ivar + "<" + cvtToStr(elementp->widthWords())); puts("; " + ivar + "<" + cvtToStr(elementp->widthWords()));
puts("; ++" + ivar + ") {\n"); puts("; ++" + ivar + ") {\n");
@ -2731,10 +2731,10 @@ void EmitCImp::emitSensitives() {
= VN_CAST(varp->dtypeSkipRefp(), UnpackArrayDType); = VN_CAST(varp->dtypeSkipRefp(), UnpackArrayDType);
arrayp; arrayp;
arrayp = VN_CAST(arrayp->subDTypep()->skipRefp(), UnpackArrayDType)) { arrayp = VN_CAST(arrayp->subDTypep()->skipRefp(), UnpackArrayDType)) {
int vecnum = vects++; const int vecnum = vects++;
UASSERT_OBJ(arrayp->hi() >= arrayp->lo(), varp, UASSERT_OBJ(arrayp->hi() >= arrayp->lo(), varp,
"Should have swapped msb & lsb earlier."); "Should have swapped msb & lsb earlier.");
string ivar = string("__Vi") + cvtToStr(vecnum); const string ivar = string("__Vi") + cvtToStr(vecnum);
puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(arrayp->lo())); puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(arrayp->lo()));
puts("; " + ivar + "<=" + cvtToStr(arrayp->hi())); puts("; " + ivar + "<=" + cvtToStr(arrayp->hi()));
puts("; ++" + ivar + ") {\n"); puts("; ++" + ivar + ") {\n");
@ -2947,7 +2947,7 @@ void EmitCStmts::emitVarList(AstNode* firstp, EisWhich which, const string& pref
} }
if (varp->isStatic() ? !isstatic : isstatic) doit = false; if (varp->isStatic() ? !isstatic : isstatic) doit = false;
if (doit) { if (doit) {
int sigbytes = varp->dtypeSkipRefp()->widthAlignBytes(); const int sigbytes = varp->dtypeSkipRefp()->widthAlignBytes();
int sortbytes = 9; int sortbytes = 9;
if (varp->isUsedClock() && varp->widthMin() == 1) { if (varp->isUsedClock() && varp->widthMin() == 1) {
sortbytes = 0; sortbytes = 0;
@ -2966,7 +2966,8 @@ void EmitCStmts::emitVarList(AstNode* firstp, EisWhich which, const string& pref
} else if (sigbytes == 1) { } else if (sigbytes == 1) {
sortbytes = 1; sortbytes = 1;
} }
bool anonOk = (v3Global.opt.compLimitMembers() != 0 // Enabled const bool anonOk
= (v3Global.opt.compLimitMembers() != 0 // Enabled
&& !varp->isStatic() && !varp->isIO() // Confusing to user && !varp->isStatic() && !varp->isIO() // Confusing to user
&& !varp->isSc() // Aggregates can't be anon && !varp->isSc() // Aggregates can't be anon
&& (varp->basicp() && (varp->basicp()
@ -3013,7 +3014,7 @@ void EmitCStmts::emitVarSort(const VarSortMap& vmap, VarVec* sortedp) {
using MTaskVarSortMap = std::map<const MTaskIdSet, VarSortMap>; using MTaskVarSortMap = std::map<const MTaskIdSet, VarSortMap>;
MTaskVarSortMap m2v; MTaskVarSortMap m2v;
for (VarSortMap::const_iterator it = vmap.begin(); it != vmap.end(); ++it) { for (VarSortMap::const_iterator it = vmap.begin(); it != vmap.end(); ++it) {
int size_class = it->first; const int size_class = it->first;
const VarVec& vec = it->second; const VarVec& vec = it->second;
for (const AstVar* varp : vec) { m2v[varp->mtaskIds()][size_class].push_back(varp); } for (const AstVar* varp : vec) { m2v[varp->mtaskIds()][size_class].push_back(varp); }
} }
@ -3048,8 +3049,8 @@ void EmitCStmts::emitSortedVarList(const VarVec& anons, const VarVec& nonanons,
string curVarCmt; string curVarCmt;
// Output anons // Output anons
{ {
int anonMembers = anons.size(); const int anonMembers = anons.size();
int lim = v3Global.opt.compLimitMembers(); const int lim = v3Global.opt.compLimitMembers();
int anonL3s = 1; int anonL3s = 1;
int anonL2s = 1; int anonL2s = 1;
int anonL1s = 1; int anonL1s = 1;
@ -3643,8 +3644,8 @@ class EmitCTrace final : EmitCStmts {
} }
// //
// fstVarType // fstVarType
AstVarType vartype = nodep->varType(); const AstVarType vartype = nodep->varType();
AstBasicDTypeKwd kwd = nodep->declKwd(); const AstBasicDTypeKwd kwd = nodep->declKwd();
string fstvt; string fstvt;
// Doubles have special decoding properties, so must indicate if a double // Doubles have special decoding properties, so must indicate if a double
if (nodep->dtypep()->basicp()->isDouble()) { if (nodep->dtypep()->basicp()->isDouble()) {
@ -3902,7 +3903,7 @@ class EmitCTrace final : EmitCStmts {
} }
} }
virtual void visit(AstTraceDecl* nodep) override { virtual void visit(AstTraceDecl* nodep) override {
int enumNum = emitTraceDeclDType(nodep->dtypep()); const int enumNum = emitTraceDeclDType(nodep->dtypep());
if (nodep->arrayRange().ranged()) { if (nodep->arrayRange().ranged()) {
puts("{int i; for (i=0; i<" + cvtToStr(nodep->arrayRange().elements()) + "; i++) {\n"); puts("{int i; for (i=0; i<" + cvtToStr(nodep->arrayRange().elements()) + "; i++) {\n");
emitTraceInitOne(nodep, enumNum); emitTraceInitOne(nodep, enumNum);
@ -3947,7 +3948,7 @@ public:
static void setParentClassPointers() { static void setParentClassPointers() {
// Set user4p in all CFunc and Var to point to the containing AstNodeModule // Set user4p in all CFunc and Var to point to the containing AstNodeModule
auto setAll = [](AstNodeModule* modp) -> void { const auto setAll = [](AstNodeModule* modp) -> void {
for (AstNode* nodep = VN_CAST(modp, NodeModule)->stmtsp(); nodep; nodep = nodep->nextp()) { for (AstNode* nodep = VN_CAST(modp, NodeModule)->stmtsp(); nodep; nodep = nodep->nextp()) {
if (VN_IS(nodep, CFunc) || VN_IS(nodep, Var)) nodep->user4p(modp); if (VN_IS(nodep, CFunc) || VN_IS(nodep, Var)) nodep->user4p(modp);
} }

View File

@ -40,7 +40,7 @@ public:
private: private:
// MAIN METHOD // MAIN METHOD
void emitInt() { void emitInt() {
string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__main.cpp"; const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__main.cpp";
newCFile(filename, false /*slow*/, true /*source*/); newCFile(filename, false /*slow*/, true /*source*/);
V3OutCFile cf(filename); V3OutCFile cf(filename);
m_ofp = &cf; m_ofp = &cf;

View File

@ -64,7 +64,7 @@ class CMakeEmitter final {
static void cmake_set(std::ofstream& of, const string& name, const string& value, static void cmake_set(std::ofstream& of, const string& name, const string& value,
const string& cache_type = "", const string& docstring = "") { const string& cache_type = "", const string& docstring = "") {
string raw_value = "\"" + value + "\""; const string raw_value = "\"" + value + "\"";
cmake_set_raw(of, name, raw_value, cache_type, docstring); cmake_set_raw(of, name, raw_value, cache_type, docstring);
} }
@ -80,7 +80,7 @@ class CMakeEmitter final {
static void emitOverallCMake() { static void emitOverallCMake() {
const std::unique_ptr<std::ofstream> of( const std::unique_ptr<std::ofstream> of(
V3File::new_ofstream(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".cmake")); V3File::new_ofstream(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".cmake"));
string name = v3Global.opt.prefix(); const string name = v3Global.opt.prefix();
*of << "# Verilated -*- CMake -*-\n"; *of << "# Verilated -*- CMake -*-\n";
*of << "# DESCR" *of << "# DESCR"

View File

@ -125,7 +125,7 @@ class EmitCSyms final : EmitCBaseVisitor {
&& !(VN_IS(nodep, CFunc) && !(VN_IS(nodep, CFunc)
&& (VN_CAST(nodep, CFunc)->isConstructor() && (VN_CAST(nodep, CFunc)->isConstructor()
|| VN_CAST(nodep, CFunc)->isDestructor()))) { || VN_CAST(nodep, CFunc)->isDestructor()))) {
string rsvd = V3LanguageWords::isKeyword(nodep->name()); const string rsvd = V3LanguageWords::isKeyword(nodep->name());
if (rsvd != "") { if (rsvd != "") {
// Generally V3Name should find all of these and throw SYMRSVDWORD. // Generally V3Name should find all of these and throw SYMRSVDWORD.
// We'll still check here because the compiler errors // We'll still check here because the compiler errors
@ -170,7 +170,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())) {
auto scopeNameit = m_scopeNames.find(scpit->second.m_symName); const auto scopeNameit = m_scopeNames.find(scpit->second.m_symName);
if (scopeNameit == m_scopeNames.end()) { if (scopeNameit == m_scopeNames.end()) {
m_scopeNames.emplace(scpit->second.m_symName, scpit->second); m_scopeNames.emplace(scpit->second.m_symName, scpit->second);
} else { } else {
@ -216,9 +216,9 @@ class EmitCSyms final : EmitCBaseVisitor {
} }
// UINFO(9,"For "<<scopep->name()<<" - "<<varp->name()<<" Scp "<<scpName<<" // UINFO(9,"For "<<scopep->name()<<" - "<<varp->name()<<" Scp "<<scpName<<"
// Var "<<varBase<<endl); // Var "<<varBase<<endl);
string varBasePretty = AstNode::prettyName(varBase); const string varBasePretty = AstNode::prettyName(varBase);
string scpPretty = AstNode::prettyName(scpName); const string scpPretty = AstNode::prettyName(scpName);
string scpSym = scopeSymString(scpName); const string scpSym = scopeSymString(scpName);
// UINFO(9," scnameins sp "<<scpName<<" sp "<<scpPretty<<" ss "<<scpSym<<endl); // UINFO(9," scnameins sp "<<scpName<<" sp "<<scpPretty<<" ss "<<scpSym<<endl);
if (v3Global.opt.vpi()) varHierarchyScopes(scpName); if (v3Global.opt.vpi()) varHierarchyScopes(scpName);
if (m_scopeNames.find(scpSym) == m_scopeNames.end()) { if (m_scopeNames.find(scpSym) == m_scopeNames.end()) {
@ -238,7 +238,7 @@ class EmitCSyms final : EmitCBaseVisitor {
++it) { ++it) {
if (it->second.m_type != "SCOPE_MODULE") continue; if (it->second.m_type != "SCOPE_MODULE") continue;
string symName = it->second.m_symName; const string symName = it->second.m_symName;
string above = symName; string above = symName;
if (above.substr(0, 4) == "TOP.") above.replace(0, 4, ""); if (above.substr(0, 4) == "TOP.") above.replace(0, 4, "");
@ -289,10 +289,11 @@ class EmitCSyms final : EmitCBaseVisitor {
} }
virtual void visit(AstCellInline* nodep) override { virtual void visit(AstCellInline* nodep) override {
if (v3Global.opt.vpi()) { if (v3Global.opt.vpi()) {
string type = (nodep->origModName() == "__BEGIN__") ? "SCOPE_OTHER" : "SCOPE_MODULE"; const string type
string name = nodep->scopep()->name() + "__DOT__" + nodep->name(); = (nodep->origModName() == "__BEGIN__") ? "SCOPE_OTHER" : "SCOPE_MODULE";
string name_dedot = AstNode::dedotName(name); const string name = nodep->scopep()->name() + "__DOT__" + nodep->name();
int timeunit = m_modp->timeunit().powerOfTen(); const string name_dedot = AstNode::dedotName(name);
const int timeunit = m_modp->timeunit().powerOfTen();
m_vpiScopeCandidates.insert( m_vpiScopeCandidates.insert(
std::make_pair(name, ScopeData(scopeSymString(name), name_dedot, timeunit, type))); std::make_pair(name, ScopeData(scopeSymString(name), name_dedot, timeunit, type)));
} }
@ -304,19 +305,19 @@ class EmitCSyms final : EmitCBaseVisitor {
m_scopes.emplace_back(std::make_pair(nodep, m_modp)); m_scopes.emplace_back(std::make_pair(nodep, m_modp));
if (v3Global.opt.vpi() && !nodep->isTop()) { if (v3Global.opt.vpi() && !nodep->isTop()) {
string type = VN_IS(nodep->modp(), Package) ? "SCOPE_OTHER" : "SCOPE_MODULE"; const string type = VN_IS(nodep->modp(), Package) ? "SCOPE_OTHER" : "SCOPE_MODULE";
string name_dedot = AstNode::dedotName(nodep->shortName()); const string name_dedot = AstNode::dedotName(nodep->shortName());
int timeunit = m_modp->timeunit().powerOfTen(); const int timeunit = m_modp->timeunit().powerOfTen();
m_vpiScopeCandidates.insert( m_vpiScopeCandidates.insert(
std::make_pair(nodep->name(), ScopeData(scopeSymString(nodep->name()), name_dedot, std::make_pair(nodep->name(), ScopeData(scopeSymString(nodep->name()), name_dedot,
timeunit, type))); timeunit, type)));
} }
} }
virtual void visit(AstScopeName* nodep) override { virtual void visit(AstScopeName* nodep) override {
string name = nodep->scopeSymName(); const string name = nodep->scopeSymName();
// UINFO(9,"scnameins sp "<<nodep->name()<<" sp "<<nodep->scopePrettySymName() // UINFO(9,"scnameins sp "<<nodep->name()<<" sp "<<nodep->scopePrettySymName()
// <<" ss"<<name<<endl); // <<" ss"<<name<<endl);
int timeunit = m_modp ? m_modp->timeunit().powerOfTen() : 0; const 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.emplace( m_scopeNames.emplace(
name, ScopeData(name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER")); name, ScopeData(name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER"));
@ -369,7 +370,7 @@ public:
void EmitCSyms::emitSymHdr() { void EmitCSyms::emitSymHdr() {
UINFO(6, __FUNCTION__ << ": " << endl); UINFO(6, __FUNCTION__ << ": " << endl);
string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".h"; const string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".h";
newCFile(filename, true /*slow*/, false /*source*/); newCFile(filename, true /*slow*/, false /*source*/);
if (v3Global.opt.systemC()) { if (v3Global.opt.systemC()) {
@ -408,7 +409,8 @@ void EmitCSyms::emitSymHdr() {
for (const auto& itr : m_scopeFuncs) { for (const auto& itr : m_scopeFuncs) {
AstCFunc* funcp = itr.second.m_cfuncp; AstCFunc* funcp = itr.second.m_cfuncp;
if (funcp->dpiExportImpl()) { if (funcp->dpiExportImpl()) {
string cbtype = protect(v3Global.opt.prefix() + "__Vcb_" + funcp->cname() + "_t"); const string cbtype
= protect(v3Global.opt.prefix() + "__Vcb_" + funcp->cname() + "_t");
types["using " + cbtype + " = void (*) (" + cFuncArgs(funcp) + ");\n"] = 1; types["using " + cbtype + " = void (*) (" + cFuncArgs(funcp) + ");\n"] = 1;
} }
} }
@ -575,12 +577,12 @@ void EmitCSyms::emitSymImpPreamble() {
void EmitCSyms::emitScopeHier(bool destroy) { void EmitCSyms::emitScopeHier(bool destroy) {
if (v3Global.opt.vpi()) { if (v3Global.opt.vpi()) {
string verb = destroy ? "Tear down" : "Set up"; const string verb = destroy ? "Tear down" : "Set up";
string method = destroy ? "remove" : "add"; const string method = destroy ? "remove" : "add";
puts("\n// " + verb + " scope hierarchy\n"); puts("\n// " + verb + " scope hierarchy\n");
for (ScopeNames::const_iterator it = m_scopeNames.begin(); it != m_scopeNames.end(); for (ScopeNames::const_iterator it = m_scopeNames.begin(); it != m_scopeNames.end();
++it) { ++it) {
string name = it->second.m_prettyName; const string name = it->second.m_prettyName;
if (it->first == "TOP") continue; if (it->first == "TOP") continue;
if ((name.find('.') == string::npos) && (it->second.m_type == "SCOPE_MODULE")) { if ((name.find('.') == string::npos) && (it->second.m_type == "SCOPE_MODULE")) {
puts("__Vhier." + method + "(0, &" + protect("__Vscope_" + it->second.m_symName) puts("__Vhier." + method + "(0, &" + protect("__Vscope_" + it->second.m_symName)
@ -591,8 +593,8 @@ void EmitCSyms::emitScopeHier(bool destroy) {
for (auto it = m_vpiScopeHierarchy.cbegin(); it != m_vpiScopeHierarchy.cend(); ++it) { for (auto it = m_vpiScopeHierarchy.cbegin(); it != m_vpiScopeHierarchy.cend(); ++it) {
for (ScopeNameList::const_iterator lit = it->second.begin(); lit != it->second.end(); for (ScopeNameList::const_iterator lit = it->second.begin(); lit != it->second.end();
++lit) { ++lit) {
string fromname = scopeSymString(it->first); const string fromname = scopeSymString(it->first);
string toname = scopeSymString(*lit); const string toname = scopeSymString(*lit);
const auto from = vlstd::as_const(m_scopeNames).find(fromname); const auto from = vlstd::as_const(m_scopeNames).find(fromname);
const auto to = vlstd::as_const(m_scopeNames).find(toname); const auto to = vlstd::as_const(m_scopeNames).find(toname);
UASSERT(from != m_scopeNames.end(), fromname + " not in m_scopeNames"); UASSERT(from != m_scopeNames.end(), fromname + " not in m_scopeNames");
@ -608,7 +610,7 @@ void EmitCSyms::emitScopeHier(bool destroy) {
void EmitCSyms::emitSymImp() { void EmitCSyms::emitSymImp() {
UINFO(6, __FUNCTION__ << ": " << endl); UINFO(6, __FUNCTION__ << ": " << endl);
string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".cpp"; const string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".cpp";
AstCFile* cfilep = newCFile(filename, true /*slow*/, true /*source*/); AstCFile* cfilep = newCFile(filename, true /*slow*/, true /*source*/);
cfilep->support(true); cfilep->support(true);
@ -623,9 +625,9 @@ void EmitCSyms::emitSymImp() {
if (v3Global.opt.savable()) { if (v3Global.opt.savable()) {
for (int de = 0; de < 2; ++de) { for (int de = 0; de < 2; ++de) {
string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize"; const string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize";
string funcname = de ? "__Vdeserialize" : "__Vserialize"; const string funcname = de ? "__Vdeserialize" : "__Vserialize";
string op = de ? ">>" : "<<"; const string op = de ? ">>" : "<<";
// NOLINTNEXTLINE(performance-inefficient-string-concatenation) // NOLINTNEXTLINE(performance-inefficient-string-concatenation)
puts("void " + symClassName() + "::" + protect(funcname) + "(" + classname puts("void " + symClassName() + "::" + protect(funcname) + "(" + classname
+ "& os) {\n"); + "& os) {\n");
@ -724,7 +726,7 @@ void EmitCSyms::emitSymImp() {
if (!modp->isTop()) { if (!modp->isTop()) {
checkSplit(false); checkSplit(false);
// first is used by AstCoverDecl's call to __vlCoverInsert // first is used by AstCoverDecl's call to __vlCoverInsert
bool first = !modp->user1(); const bool first = !modp->user1();
modp->user1(true); modp->user1(true);
puts(protectIf(scopep->nameDotless(), scopep->protect()) + "." puts(protectIf(scopep->nameDotless(), scopep->protect()) + "."
+ protect("__Vconfigure") + "(this, " + (first ? "true" : "false") + ");\n"); + protect("__Vconfigure") + "(this, " + (first ? "true" : "false") + ");\n");
@ -878,7 +880,7 @@ void EmitCSyms::emitSymImp() {
void EmitCSyms::emitDpiHdr() { void EmitCSyms::emitDpiHdr() {
UINFO(6, __FUNCTION__ << ": " << endl); UINFO(6, __FUNCTION__ << ": " << endl);
string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.h"; const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.h";
AstCFile* cfilep = newCFile(filename, false /*slow*/, false /*source*/); AstCFile* cfilep = newCFile(filename, false /*slow*/, false /*source*/);
cfilep->support(true); cfilep->support(true);
V3OutCFile hf(filename); V3OutCFile hf(filename);
@ -927,7 +929,7 @@ void EmitCSyms::emitDpiHdr() {
void EmitCSyms::emitDpiImp() { void EmitCSyms::emitDpiImp() {
UINFO(6, __FUNCTION__ << ": " << endl); UINFO(6, __FUNCTION__ << ": " << endl);
string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.cpp"; const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.cpp";
AstCFile* cfilep = newCFile(filename, false /*slow*/, true /*source*/); AstCFile* cfilep = newCFile(filename, false /*slow*/, true /*source*/);
cfilep->support(true); cfilep->support(true);
V3OutCFile hf(filename); V3OutCFile hf(filename);

View File

@ -203,7 +203,7 @@ public:
const V3StringSet& cppFiles = v3Global.opt.cppFiles(); const V3StringSet& cppFiles = v3Global.opt.cppFiles();
for (const auto& cppfile : cppFiles) { for (const auto& cppfile : cppFiles) {
of.puts("\t" + V3Os::filenameNonExt(cppfile) + " \\\n"); of.puts("\t" + V3Os::filenameNonExt(cppfile) + " \\\n");
string dir = V3Os::filenameDir(cppfile); const string dir = V3Os::filenameDir(cppfile);
dirs.insert(dir); dirs.insert(dir);
} }
of.puts("\n"); of.puts("\n");
@ -228,7 +228,7 @@ public:
of.puts("VPATH += $(VM_USER_DIR)\n"); of.puts("VPATH += $(VM_USER_DIR)\n");
of.puts("\n"); of.puts("\n");
for (const string& cppfile : cppFiles) { for (const string& cppfile : cppFiles) {
string basename = V3Os::filenameNonExt(cppfile); const string basename = V3Os::filenameNonExt(cppfile);
// NOLINTNEXTLINE(performance-inefficient-string-concatenation) // NOLINTNEXTLINE(performance-inefficient-string-concatenation)
of.puts(basename + ".o: " + cppfile + "\n"); of.puts(basename + ".o: " + cppfile + "\n");
of.puts("\t$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<\n"); of.puts("\t$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<\n");

View File

@ -850,7 +850,8 @@ void V3EmitV::emitvFiles() {
void V3EmitV::debugEmitV(const string& stage) { void V3EmitV::debugEmitV(const string& stage) {
UINFO(2, __FUNCTION__ << ": " << endl); UINFO(2, __FUNCTION__ << ": " << endl);
string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__" + stage + ".v"; const string filename
= v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__" + stage + ".v";
V3OutVFile of(filename); V3OutVFile of(filename);
EmitVFileVisitor visitor(v3Global.rootp(), &of, true, true); EmitVFileVisitor visitor(v3Global.rootp(), &of, true, true);
} }

View File

@ -129,9 +129,9 @@ class EmitXmlFileVisitor final : public AstNVisitor {
outputChildrenEnd(nodep, ""); outputChildrenEnd(nodep, "");
} }
virtual void visit(AstVar* nodep) override { virtual void visit(AstVar* nodep) override {
AstVarType typ = nodep->varType(); const AstVarType typ = nodep->varType();
string kw = nodep->verilogKwd(); const string kw = nodep->verilogKwd();
string vt = nodep->dtypep()->name(); const string vt = nodep->dtypep()->name();
outputTag(nodep, ""); outputTag(nodep, "");
if (nodep->isIO()) { if (nodep->isIO()) {
puts(" dir="); puts(" dir=");
@ -183,7 +183,7 @@ class EmitXmlFileVisitor final : public AstNVisitor {
} }
virtual void visit(AstModportVarRef* nodep) override { virtual void visit(AstModportVarRef* nodep) override {
// Dump direction for Modport references // Dump direction for Modport references
string kw = nodep->direction().xmlKwd(); const string kw = nodep->direction().xmlKwd();
outputTag(nodep, ""); outputTag(nodep, "");
puts(" direction="); puts(" direction=");
putsQuoted(kw); putsQuoted(kw);
@ -376,7 +376,7 @@ public:
void V3EmitXml::emitxml() { void V3EmitXml::emitxml() {
UINFO(2, __FUNCTION__ << ": " << endl); UINFO(2, __FUNCTION__ << ": " << endl);
// All-in-one file // All-in-one file
string filename = (v3Global.opt.xmlOutput().empty() const string filename = (v3Global.opt.xmlOutput().empty()
? v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".xml" ? v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".xml"
: v3Global.opt.xmlOutput()); : v3Global.opt.xmlOutput());
V3OutXmlFile of(filename); V3OutXmlFile of(filename);

View File

@ -97,7 +97,7 @@ void V3Error::incErrors() {
} }
void V3Error::abortIfWarnings() { void V3Error::abortIfWarnings() {
bool exwarn = warnFatal() && warnCount(); const bool exwarn = warnFatal() && warnCount();
if (errorCount() && exwarn) { if (errorCount() && exwarn) {
v3fatalExit("Exiting due to " << std::dec << errorCount() << " error(s), " // v3fatalExit("Exiting due to " << std::dec << errorCount() << " error(s), " //
<< warnCount() << " warning(s)\n"); << warnCount() << " warning(s)\n");
@ -132,7 +132,7 @@ bool V3Error::isError(V3ErrorCode code, bool supp) {
string V3Error::msgPrefix() { string V3Error::msgPrefix() {
V3ErrorCode code = s_errorCode; V3ErrorCode code = s_errorCode;
bool supp = s_errorSuppressed; const bool supp = s_errorSuppressed;
if (supp) { if (supp) {
return "-arning-suppressed: "; return "-arning-suppressed: ";
} else if (code == V3ErrorCode::USERINFO) { } else if (code == V3ErrorCode::USERINFO) {
@ -210,8 +210,8 @@ void V3Error::v3errorEnd(std::ostringstream& sstr, const string& locationStr) {
if (s_messages.find(msg) != s_messages.end()) return; if (s_messages.find(msg) != s_messages.end()) return;
s_messages.insert(msg); s_messages.insert(msg);
if (!locationStr.empty()) { if (!locationStr.empty()) {
string locationMsg = warnMore() + locationStr + "\n"; const string locationMsg = warnMore() + locationStr + "\n";
size_t pos = msg.find('\n'); const size_t pos = msg.find('\n');
msg.insert(pos + 1, locationMsg); msg.insert(pos + 1, locationMsg);
} }
// Output // Output

View File

@ -149,11 +149,11 @@ private:
AstNode* newp; AstNode* newp;
// Negative word numbers requested for lhs when it's "before" what we want. // Negative word numbers requested for lhs when it's "before" what we want.
// We get a 0 then. // We get a 0 then.
int othword = word - shift / VL_EDATASIZE; const int othword = word - shift / VL_EDATASIZE;
AstNode* llowp = newAstWordSelClone(lhsp, othword); AstNode* llowp = newAstWordSelClone(lhsp, othword);
if (int loffset = VL_BITBIT_E(shift)) { if (const int loffset = VL_BITBIT_E(shift)) {
AstNode* lhip = newAstWordSelClone(lhsp, othword - 1); AstNode* lhip = newAstWordSelClone(lhsp, othword - 1);
int nbitsonright = VL_EDATASIZE - loffset; // bits that end up in lword const int nbitsonright = VL_EDATASIZE - loffset; // bits that end up in lword
newp = new AstOr( newp = new AstOr(
fl, fl,
new AstAnd(fl, new AstConst(fl, AstConst::SizedEData(), VL_MASK_E(loffset)), new AstAnd(fl, new AstConst(fl, AstConst::SizedEData(), VL_MASK_E(loffset)),
@ -448,7 +448,7 @@ private:
UASSERT_OBJ(nodep->widthMin() == rhsp->widthConst(), nodep, "Width mismatch"); UASSERT_OBJ(nodep->widthMin() == rhsp->widthConst(), nodep, "Width mismatch");
if (!doExpand(nodep)) return false; if (!doExpand(nodep)) return false;
if (VN_IS(rhsp->lsbp(), Const) && VL_BITBIT_E(rhsp->lsbConst()) == 0) { if (VN_IS(rhsp->lsbp(), Const) && VL_BITBIT_E(rhsp->lsbConst()) == 0) {
int lsb = rhsp->lsbConst(); const int lsb = rhsp->lsbConst();
UINFO(8, " Wordize ASSIGN(SEL,align) " << nodep << endl); UINFO(8, " Wordize ASSIGN(SEL,align) " << nodep << endl);
for (int w = 0; w < nodep->widthWords(); w++) { for (int w = 0; w < nodep->widthWords(); w++) {
addWordAssign(nodep, w, newAstWordSelClone(rhsp->fromp(), w + VL_BITWORD_E(lsb))); addWordAssign(nodep, w, newAstWordSelClone(rhsp->fromp(), w + VL_BITWORD_E(lsb)));
@ -491,15 +491,15 @@ private:
// rhsp: may be allones and can remove AND NOT gate // rhsp: may be allones and can remove AND NOT gate
// lsbp: constant or variable // lsbp: constant or variable
// Yuk. // Yuk.
bool destwide = lhsp->fromp()->isWide(); const bool destwide = lhsp->fromp()->isWide();
bool ones = nodep->rhsp()->isAllOnesV(); const bool ones = nodep->rhsp()->isAllOnesV();
if (VN_IS(lhsp->lsbp(), Const)) { if (VN_IS(lhsp->lsbp(), Const)) {
// The code should work without this constant test, but it won't // The code should work without this constant test, but it won't
// constify as nicely as we'd like. // constify as nicely as we'd like.
AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
AstNode* destp = lhsp->fromp()->unlinkFrBack(); AstNode* destp = lhsp->fromp()->unlinkFrBack();
int lsb = lhsp->lsbConst(); const int lsb = lhsp->lsbConst();
int msb = lhsp->msbConst(); const int msb = lhsp->msbConst();
V3Number maskset(nodep, destp->widthMin()); V3Number maskset(nodep, destp->widthMin());
for (int bit = lsb; bit < (msb + 1); bit++) maskset.setBit(bit, 1); for (int bit = lsb; bit < (msb + 1); bit++) maskset.setBit(bit, 1);
V3Number maskold(nodep, destp->widthMin()); V3Number maskold(nodep, destp->widthMin());
@ -659,7 +659,7 @@ private:
UINFO(8, " CONCAT " << nodep << endl); UINFO(8, " CONCAT " << nodep << endl);
AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
int rhsshift = rhsp->widthMin(); const int rhsshift = rhsp->widthMin();
if (nodep->isQuad() && !lhsp->isQuad()) { if (nodep->isQuad() && !lhsp->isQuad()) {
lhsp = new AstCCast(nodep->fileline(), lhsp, nodep); lhsp = new AstCCast(nodep->fileline(), lhsp, nodep);
} }
@ -680,7 +680,7 @@ private:
if (!doExpand(rhsp)) return false; if (!doExpand(rhsp)) return false;
// Lhs or Rhs may be word, long, or quad. // Lhs or Rhs may be word, long, or quad.
// newAstWordSelClone nicely abstracts the difference. // newAstWordSelClone nicely abstracts the difference.
int rhsshift = rhsp->rhsp()->widthMin(); const int rhsshift = rhsp->rhsp()->widthMin();
// Sometimes doing the words backwards is preferable. // Sometimes doing the words backwards is preferable.
// When we have x={x,foo} backwards is better, when x={foo,x} forward is better // When we have x={x,foo} backwards is better, when x={foo,x} forward is better
// However V3Subst tends to rip this up, so not worth optimizing now. // However V3Subst tends to rip this up, so not worth optimizing now.
@ -701,7 +701,7 @@ private:
} else { } else {
AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
AstNode* newp; AstNode* newp;
int lhswidth = lhsp->widthMin(); const int lhswidth = lhsp->widthMin();
if (lhswidth == 1) { if (lhswidth == 1) {
UINFO(8, " REPLICATE(w1) " << nodep << endl); UINFO(8, " REPLICATE(w1) " << nodep << endl);
newp = new AstNegate(nodep->fileline(), lhsp); newp = new AstNegate(nodep->fileline(), lhsp);
@ -716,7 +716,7 @@ private:
} }
newp = lhsp->cloneTree(true); newp = lhsp->cloneTree(true);
for (unsigned repnum = 1; repnum < times; repnum++) { for (unsigned repnum = 1; repnum < times; repnum++) {
int rhsshift = repnum * lhswidth; const int rhsshift = repnum * lhswidth;
newp = new AstOr(nodep->fileline(), newp = new AstOr(nodep->fileline(),
new AstShiftL(nodep->fileline(), lhsp->cloneTree(true), new AstShiftL(nodep->fileline(), lhsp->cloneTree(true),
new AstConst(nodep->fileline(), rhsshift), new AstConst(nodep->fileline(), rhsshift),
@ -734,7 +734,7 @@ private:
UINFO(8, " Wordize ASSIGN(REPLICATE) " << nodep << endl); UINFO(8, " Wordize ASSIGN(REPLICATE) " << nodep << endl);
if (!doExpand(rhsp)) return false; if (!doExpand(rhsp)) return false;
AstNode* lhsp = rhsp->lhsp(); AstNode* lhsp = rhsp->lhsp();
int lhswidth = lhsp->widthMin(); const int lhswidth = lhsp->widthMin();
const AstConst* constp = VN_CAST(rhsp->rhsp(), Const); const AstConst* constp = VN_CAST(rhsp->rhsp(), Const);
UASSERT_OBJ(constp, rhsp, "Replication value isn't a constant. Checked earlier!"); UASSERT_OBJ(constp, rhsp, "Replication value isn't a constant. Checked earlier!");
uint32_t times = constp->toUInt(); uint32_t times = constp->toUInt();

View File

@ -89,8 +89,8 @@ class V3FileDependImp final {
time_t mnstime() const { return VL_STAT_MTIME_NSEC(m_stat); } // Nanoseconds time_t mnstime() const { return VL_STAT_MTIME_NSEC(m_stat); } // Nanoseconds
void loadStats() { void loadStats() {
if (!m_stat.st_mtime) { if (!m_stat.st_mtime) {
string fn = filename(); const string fn = filename();
int err = stat(fn.c_str(), &m_stat); const int err = stat(fn.c_str(), &m_stat);
if (err != 0) { if (err != 0) {
memset(&m_stat, 0, sizeof(m_stat)); memset(&m_stat, 0, sizeof(m_stat));
m_stat.st_mtime = 1; m_stat.st_mtime = 1;
@ -181,7 +181,7 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm
const std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename)); const std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename));
if (ofp->fail()) v3fatal("Can't write " << filename); if (ofp->fail()) v3fatal("Can't write " << filename);
string cmdline = stripQuotes(cmdlineIn); const string cmdline = stripQuotes(cmdlineIn);
*ofp << "# DESCR" *ofp << "# DESCR"
<< "IPTION: Verilator output: Timestamp data for --skip-identical. Delete at will.\n"; << "IPTION: Verilator output: Timestamp data for --skip-identical. Delete at will.\n";
*ofp << "C \"" << cmdline << "\"\n"; *ofp << "C \"" << cmdline << "\"\n";
@ -219,7 +219,7 @@ inline bool V3FileDependImp::checkTimes(const string& filename, const string& cm
return false; return false;
} }
{ {
string ignore = V3Os::getline(*ifp); const string ignore = V3Os::getline(*ifp);
if (ignore.empty()) { /*used*/ if (ignore.empty()) { /*used*/
} }
} }
@ -228,8 +228,8 @@ inline bool V3FileDependImp::checkTimes(const string& filename, const string& cm
*ifp >> chkDir; *ifp >> chkDir;
char quote; char quote;
*ifp >> quote; *ifp >> quote;
string chkCmdline = V3Os::getline(*ifp, '"'); const string chkCmdline = V3Os::getline(*ifp, '"');
string cmdline = stripQuotes(cmdlineIn); const string cmdline = stripQuotes(cmdlineIn);
if (cmdline != chkCmdline) { if (cmdline != chkCmdline) {
UINFO(2, " --check-times failed: different command line\n"); UINFO(2, " --check-times failed: different command line\n");
return false; return false;
@ -254,12 +254,12 @@ inline bool V3FileDependImp::checkTimes(const string& filename, const string& cm
*ifp >> chkMnstime; *ifp >> chkMnstime;
char quote; char quote;
*ifp >> quote; *ifp >> quote;
string chkFilename = V3Os::getline(*ifp, '"'); const string chkFilename = V3Os::getline(*ifp, '"');
V3Options::fileNfsFlush(chkFilename); V3Options::fileNfsFlush(chkFilename);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
struct stat chkStat; struct stat chkStat;
int err = stat(chkFilename.c_str(), &chkStat); const int err = stat(chkFilename.c_str(), &chkStat);
if (err != 0) { if (err != 0) {
UINFO(2, " --check-times failed: missing " << chkFilename << endl); UINFO(2, " --check-times failed: missing " << chkFilename << endl);
return false; return false;
@ -354,7 +354,7 @@ private:
} }
} }
bool readContentsFile(const string& filename, StrList& outl) { bool readContentsFile(const string& filename, StrList& outl) {
int fd = open(filename.c_str(), O_RDONLY); const int fd = open(filename.c_str(), O_RDONLY);
if (fd < 0) return false; if (fd < 0) return false;
m_readEof = false; m_readEof = false;
readBlocks(fd, -1, outl); readBlocks(fd, -1, outl);
@ -365,7 +365,7 @@ private:
if (filename != "" || outl.empty()) {} // Prevent unused if (filename != "" || outl.empty()) {} // Prevent unused
#ifdef INFILTER_PIPE #ifdef INFILTER_PIPE
writeFilter("read \"" + filename + "\"\n"); writeFilter("read \"" + filename + "\"\n");
string line = readFilterLine(); const string line = readFilterLine();
if (line.find("Content-Length") != string::npos) { if (line.find("Content-Length") != string::npos) {
int len = 0; int len = 0;
sscanf(line.c_str(), "Content-Length: %d\n", &len); sscanf(line.c_str(), "Content-Length: %d\n", &len);
@ -402,7 +402,7 @@ private:
ssize_t todo = INFILTER_IPC_BUFSIZ; ssize_t todo = INFILTER_IPC_BUFSIZ;
if (size > 0 && size < todo) todo = size; if (size > 0 && size < todo) todo = size;
errno = 0; errno = 0;
ssize_t got = read(fd, buf, todo); const ssize_t got = read(fd, buf, todo);
// UINFO(9,"RD GOT g "<< got<<" e "<<errno<<" "<<strerror(errno)<<endl); // UINFO(9,"RD GOT g "<< got<<" e "<<errno<<" "<<strerror(errno)<<endl);
// usleep(50*1000); // usleep(50*1000);
if (got > 0) { if (got > 0) {
@ -431,7 +431,7 @@ private:
while (!m_readEof) { while (!m_readEof) {
StrList outl; StrList outl;
readBlocks(m_readFd, 1, outl); readBlocks(m_readFd, 1, outl);
string onechar = listString(outl); const string onechar = listString(outl);
line += onechar; line += onechar;
if (onechar == "\n") { if (onechar == "\n") {
if (line == "\n") { if (line == "\n") {
@ -459,7 +459,7 @@ private:
unsigned offset = 0; unsigned offset = 0;
while (!m_readEof && out.length() > offset) { while (!m_readEof && out.length() > offset) {
errno = 0; errno = 0;
int got = write(m_writeFd, (out.c_str()) + offset, out.length() - offset); const int got = write(m_writeFd, (out.c_str()) + offset, out.length() - offset);
// UINFO(9,"WR GOT g "<< got<<" e "<<errno<<" "<<strerror(errno)<<endl); // UINFO(9,"WR GOT g "<< got<<" e "<<errno<<" "<<strerror(errno)<<endl);
// usleep(50*1000); // usleep(50*1000);
if (got > 0) { if (got > 0) {
@ -506,7 +506,7 @@ private:
UINFO(1, "--pipe-filter: /bin/sh -c " << command << endl); UINFO(1, "--pipe-filter: /bin/sh -c " << command << endl);
pid_t pid = fork(); const pid_t pid = fork();
if (pid < 0) v3fatal("--pipe-filter: fork failed: " << strerror(errno)); if (pid < 0) v3fatal("--pipe-filter: fork failed: " << strerror(errno));
if (pid == 0) { // Child if (pid == 0) { // Child
UINFO(6, "In child\n"); UINFO(6, "In child\n");
@ -827,7 +827,7 @@ void V3OutFormatter::putsQuoted(const string& strg) {
// Quote \ and " for use inside C programs // Quote \ and " for use inside C programs
// Don't use to quote a filename for #include - #include doesn't \ escape. // Don't use to quote a filename for #include - #include doesn't \ escape.
putcNoTracking('"'); putcNoTracking('"');
string quoted = quoteNameControls(strg); const string quoted = quoteNameControls(strg);
for (const char c : quoted) putcNoTracking(c); for (const char c : quoted) putcNoTracking(c);
putcNoTracking('"'); putcNoTracking('"');
} }
@ -894,7 +894,7 @@ string V3OutFormatter::quoteNameControls(const string& namein, V3OutFormatter::L
out += c; out += c;
} else { } else {
// This will also cover \a etc // This will also cover \a etc
string octal = string("\\") + cvtToStr((c >> 6) & 3) + cvtToStr((c >> 3) & 7) const string octal = string("\\") + cvtToStr((c >> 6) & 3) + cvtToStr((c >> 3) & 7)
+ cvtToStr(c & 7); + cvtToStr(c & 7);
out += octal; out += octal;
} }
@ -1003,7 +1003,7 @@ public:
out = "PS" + digest.digestSymbol(); out = "PS" + digest.digestSymbol();
// See if we can shrink the digest symbol to something smaller // See if we can shrink the digest symbol to something smaller
for (size_t len = 6; len < out.size() - 3; len += 3) { for (size_t len = 6; len < out.size() - 3; len += 3) {
string tryout = out.substr(0, len); const string tryout = out.substr(0, len);
if (m_newIdSet.find(tryout) == m_newIdSet.end()) { if (m_newIdSet.find(tryout) == m_newIdSet.end()) {
out = tryout; out = tryout;
break; break;

View File

@ -60,7 +60,7 @@ string FileLineSingleton::filenameLetters(int fileno) {
int FileLineSingleton::nameToNumber(const string& filename) { int FileLineSingleton::nameToNumber(const string& filename) {
const auto it = vlstd::as_const(m_namemap).find(filename); const auto it = vlstd::as_const(m_namemap).find(filename);
if (VL_LIKELY(it != m_namemap.end())) return it->second; if (VL_LIKELY(it != m_namemap.end())) return it->second;
int num = m_names.size(); const 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.emplace(filename, num); m_namemap.emplace(filename, num);
@ -95,7 +95,7 @@ void VFileContent::pushText(const string& text) {
} }
// Any leftover text is stored on largest line (might be "") // Any leftover text is stored on largest line (might be "")
string leftover = m_lines.back() + text; const string leftover = m_lines.back() + text;
m_lines.pop_back(); m_lines.pop_back();
// Insert line-by-line // Insert line-by-line
@ -125,7 +125,7 @@ string VFileContent::getLine(int lineno) const {
return ""; return "";
} }
} }
string text = m_lines[lineno]; const string text = m_lines[lineno];
UINFO(9, "Get Stream[ct" << m_id << "+" << lineno << "]: " << text); UINFO(9, "Get Stream[ct" << m_id << "+" << lineno << "]: " << text);
return text; return text;
} }
@ -399,7 +399,7 @@ string FileLine::warnContext(bool secondary) const {
if (!v3Global.opt.context()) return ""; if (!v3Global.opt.context()) return "";
string out; string out;
if (firstLineno() == lastLineno() && firstColumn()) { if (firstLineno() == lastLineno() && firstColumn()) {
string sourceLine = prettySource(); const string sourceLine = prettySource();
// Don't show super-long lines as can fill screen and unlikely to help user // Don't show super-long lines as can fill screen and unlikely to help user
if (!sourceLine.empty() && sourceLine.length() < SHOW_SOURCE_MAX_LENGTH if (!sourceLine.empty() && sourceLine.length() < SHOW_SOURCE_MAX_LENGTH
&& sourceLine.length() >= static_cast<size_t>(lastColumn() - 1)) { && sourceLine.length() >= static_cast<size_t>(lastColumn() - 1)) {

View File

@ -571,7 +571,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) {
if (logicVertexp->reducible()) { if (logicVertexp->reducible()) {
// Can we eliminate? // Can we eliminate?
GateOkVisitor okVisitor(logicp, vvertexp->isClock(), false); GateOkVisitor okVisitor(logicp, vvertexp->isClock(), false);
bool multiInputs = okVisitor.rhsVarRefs().size() > 1; const bool multiInputs = okVisitor.rhsVarRefs().size() > 1;
// Was it ok? // Was it ok?
bool doit = okVisitor.isSimple(); bool doit = okVisitor.isSimple();
if (doit && multiInputs) { if (doit && multiInputs) {

View File

@ -114,7 +114,7 @@ V3GraphEdge* V3GraphVertex::findConnectingEdgep(GraphWay way, const V3GraphVerte
// O(edges) linear search. Searches search both nodes' edge lists in // O(edges) linear search. Searches search both nodes' edge lists in
// parallel. The lists probably aren't _both_ huge, so this is // parallel. The lists probably aren't _both_ huge, so this is
// unlikely to blow up even on fairly nasty graphs. // unlikely to blow up even on fairly nasty graphs.
GraphWay inv = way.invert(); const GraphWay inv = way.invert();
V3GraphEdge* aedgep = this->beginp(way); V3GraphEdge* aedgep = this->beginp(way);
V3GraphEdge* bedgep = waywardp->beginp(inv); V3GraphEdge* bedgep = waywardp->beginp(inv);
while (aedgep && bedgep) { while (aedgep && bedgep) {
@ -340,7 +340,7 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) const {
int n = 0; int n = 0;
string subgr; string subgr;
for (auto it = subgraphs.cbegin(); it != subgraphs.cend(); ++it) { for (auto it = subgraphs.cbegin(); it != subgraphs.cend(); ++it) {
string vertexSubgraph = it->first; const string vertexSubgraph = it->first;
V3GraphVertex* vertexp = it->second; V3GraphVertex* vertexp = it->second;
numMap[vertexp] = n; numMap[vertexp] = n;
if (subgr != vertexSubgraph) { if (subgr != vertexSubgraph) {
@ -366,8 +366,8 @@ 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()) {
for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) {
if (edgep->weight()) { if (edgep->weight()) {
int fromVnum = numMap[edgep->fromp()]; const int fromVnum = numMap[edgep->fromp()];
int toVnum = numMap[edgep->top()]; const int toVnum = numMap[edgep->top()];
*logp << "\tn" << edgep->fromp()->dotName() << fromVnum << " -> n" *logp << "\tn" << edgep->fromp()->dotName() << fromVnum << " -> n"
<< edgep->top()->dotName() << toVnum << edgep->top()->dotName() << toVnum
<< " [" << " ["

View File

@ -318,7 +318,7 @@ private:
// Foreach input state (NFA inputs of this DFA state) // Foreach input state (NFA inputs of this DFA state)
for (int inIt : inputs) { for (int inIt : inputs) {
DfaInput input = inIt; const DfaInput input = inIt;
UINFO(9, " ===" << ++i << "=======================\n"); UINFO(9, " ===" << ++i << "=======================\n");
UINFO(9, " On input " << cvtToHex(input.toNodep()) << endl); UINFO(9, " On input " << cvtToHex(input.toNodep()) << endl);

View File

@ -73,7 +73,7 @@ GraphPathChecker::~GraphPathChecker() {
void GraphPathChecker::initHalfCriticalPaths(GraphWay way, bool checkOnly) { void GraphPathChecker::initHalfCriticalPaths(GraphWay way, bool checkOnly) {
GraphStreamUnordered order(m_graphp, way); GraphStreamUnordered order(m_graphp, way);
GraphWay rev = way.invert(); const GraphWay rev = way.invert();
while (const V3GraphVertex* vertexp = order.nextp()) { while (const V3GraphVertex* vertexp = order.nextp()) {
unsigned critPathCost = 0; unsigned critPathCost = 0;
for (V3GraphEdge* edgep = vertexp->beginp(rev); edgep; edgep = edgep->nextp(rev)) { for (V3GraphEdge* edgep = vertexp->beginp(rev); edgep; edgep = edgep->nextp(rev)) {

View File

@ -309,7 +309,7 @@ bool V3HierBlockPlan::isHierBlock(const AstNodeModule* modp) const {
} }
void V3HierBlockPlan::add(const AstNodeModule* modp, const std::vector<AstVar*>& gparams) { void V3HierBlockPlan::add(const AstNodeModule* modp, const std::vector<AstVar*>& gparams) {
iterator it = m_blocks.find(modp); const iterator it = m_blocks.find(modp);
if (it == m_blocks.end()) { if (it == m_blocks.end()) {
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"
@ -319,9 +319,9 @@ void V3HierBlockPlan::add(const AstNodeModule* modp, const std::vector<AstVar*>&
} }
void V3HierBlockPlan::registerUsage(const AstNodeModule* parentp, const AstNodeModule* childp) { void V3HierBlockPlan::registerUsage(const AstNodeModule* parentp, const AstNodeModule* childp) {
iterator parent = m_blocks.find(parentp); const iterator parent = m_blocks.find(parentp);
UASSERT_OBJ(parent != m_blocks.end(), parentp, "must be added"); UASSERT_OBJ(parent != m_blocks.end(), parentp, "must be added");
iterator child = m_blocks.find(childp); const iterator child = m_blocks.find(childp);
if (child != m_blocks.end()) { if (child != m_blocks.end()) {
UINFO(3, "Found usage relation " << parentp->prettyNameQ() << " uses " UINFO(3, "Found usage relation " << parentp->prettyNameQ() << " uses "
<< childp->prettyNameQ() << std::endl); << childp->prettyNameQ() << std::endl);

View File

@ -165,7 +165,7 @@ private:
virtual void visit(AstNodeAssign* nodep) override { virtual void visit(AstNodeAssign* nodep) override {
// Don't count assignments, as they'll likely flatten out // Don't count assignments, as they'll likely flatten out
// Still need to iterate though to nullify VarXRefs // Still need to iterate though to nullify VarXRefs
int oldcnt = m_modp->user4(); const int oldcnt = m_modp->user4();
iterateChildren(nodep); iterateChildren(nodep);
m_modp->user4(oldcnt); m_modp->user4(oldcnt);
} }
@ -191,8 +191,8 @@ private:
} }
modp->user4(statements); modp->user4(statements);
int allowed = modp->user2(); const int allowed = modp->user2();
int refs = modp->user3(); const int refs = modp->user3();
// Should we automatically inline this module? // Should we automatically inline this module?
// If --flatten is specified, then force everything to be inlined that can be. // If --flatten is specified, then force everything to be inlined that can be.
@ -282,7 +282,7 @@ private:
nodep->unlinkFrBack(); nodep->unlinkFrBack();
m_modp->addInlinesp(nodep); m_modp->addInlinesp(nodep);
// Rename // Rename
string name = m_cellp->name() + "__DOT__" + nodep->name(); const string name = m_cellp->name() + "__DOT__" + nodep->name();
nodep->name(name); nodep->name(name);
UINFO(6, " Inline " << nodep << endl); UINFO(6, " Inline " << nodep << endl);
// Do CellInlines under this, but don't move them // Do CellInlines under this, but don't move them
@ -290,12 +290,12 @@ private:
} }
virtual void visit(AstCell* nodep) override { virtual void visit(AstCell* nodep) override {
// Cell under the inline cell, need to rename to avoid conflicts // Cell under the inline cell, need to rename to avoid conflicts
string name = m_cellp->name() + "__DOT__" + nodep->name(); const string name = m_cellp->name() + "__DOT__" + nodep->name();
nodep->name(name); nodep->name(name);
iterateChildren(nodep); iterateChildren(nodep);
} }
virtual void visit(AstClass* nodep) override { virtual void visit(AstClass* nodep) override {
string name = m_cellp->name() + "__DOT__" + nodep->name(); const string name = m_cellp->name() + "__DOT__" + nodep->name();
nodep->name(name); nodep->name(name);
iterateChildren(nodep); iterateChildren(nodep);
} }
@ -376,7 +376,7 @@ private:
} }
// Variable under the inline cell, need to rename to avoid conflicts // Variable under the inline cell, need to rename to avoid conflicts
// Also clear I/O bits, as it is now local. // Also clear I/O bits, as it is now local.
string name = m_cellp->name() + "__DOT__" + nodep->name(); const string name = m_cellp->name() + "__DOT__" + nodep->name();
if (!nodep->isFuncLocal() && !nodep->isClassMember()) nodep->inlineAttrReset(name); if (!nodep->isFuncLocal() && !nodep->isClassMember()) nodep->inlineAttrReset(name);
if (!m_cellp->isTrace()) nodep->trace(false); if (!m_cellp->isTrace()) nodep->trace(false);
if (debug() >= 9) nodep->dumpTree(cout, "varchanged:"); if (debug() >= 9) nodep->dumpTree(cout, "varchanged:");
@ -415,7 +415,7 @@ private:
} }
virtual void visit(AstVarXRef* nodep) override { virtual void visit(AstVarXRef* nodep) override {
// Track what scope it was originally under so V3LinkDot can resolve it // Track what scope it was originally under so V3LinkDot can resolve it
string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots()); const string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots());
nodep->inlinedDots(newdots); nodep->inlinedDots(newdots);
for (string tryname = nodep->dotted(); true;) { for (string tryname = nodep->dotted(); true;) {
if (m_renamedInterfaces.count(tryname)) { if (m_renamedInterfaces.count(tryname)) {
@ -434,7 +434,7 @@ private:
} }
virtual void visit(AstNodeFTaskRef* nodep) override { virtual void visit(AstNodeFTaskRef* nodep) override {
// Track what scope it was originally under so V3LinkDot can resolve it // Track what scope it was originally under so V3LinkDot can resolve it
string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots()); const string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots());
nodep->inlinedDots(newdots); nodep->inlinedDots(newdots);
if (m_renamedInterfaces.count(nodep->dotted())) { if (m_renamedInterfaces.count(nodep->dotted())) {
nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted()); nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted());
@ -659,7 +659,7 @@ private:
AstCell* cellp; AstCell* cellp;
if ((cellp = VN_CAST(fromVarp->user1p(), Cell)) || (cellp = irdtp->cellp())) { if ((cellp = VN_CAST(fromVarp->user1p(), Cell)) || (cellp = irdtp->cellp())) {
varp->user1p(cellp); varp->user1p(cellp);
string alias = m_scope + "__DOT__" + pinp->name(); const string alias = m_scope + "__DOT__" + pinp->name();
cellp->addIntfRefp(new AstIntfRef(pinp->fileline(), alias)); cellp->addIntfRefp(new AstIntfRef(pinp->fileline(), alias));
} }
} }

View File

@ -207,7 +207,7 @@ private:
AstUnpackArrayDType* arrdtype = VN_CAST(nodep->dtypep(), UnpackArrayDType); AstUnpackArrayDType* arrdtype = VN_CAST(nodep->dtypep(), UnpackArrayDType);
AstNode* prevp = nullptr; AstNode* prevp = nullptr;
for (int i = arrdtype->lo(); i <= arrdtype->hi(); ++i) { for (int i = arrdtype->lo(); i <= arrdtype->hi(); ++i) {
string varNewName = nodep->name() + "__BRA__" + cvtToStr(i) + "__KET__"; const string varNewName = nodep->name() + "__BRA__" + cvtToStr(i) + "__KET__";
UINFO(8, "VAR name insert " << varNewName << " " << nodep << endl); UINFO(8, "VAR name insert " << varNewName << " " << nodep << endl);
if (!m_deModVars.find(varNewName)) { if (!m_deModVars.find(varNewName)) {
AstIfaceRefDType* ifaceRefp AstIfaceRefDType* ifaceRefp
@ -246,7 +246,8 @@ private:
m_cellRangep = nodep->rangep(); m_cellRangep = nodep->rangep();
AstVar* ifaceVarp = VN_CAST(nodep->nextp(), Var); AstVar* ifaceVarp = VN_CAST(nodep->nextp(), Var);
bool isIface = ifaceVarp && VN_IS(ifaceVarp->dtypep(), UnpackArrayDType) const bool isIface
= ifaceVarp && VN_IS(ifaceVarp->dtypep(), UnpackArrayDType)
&& VN_IS(VN_CAST(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(), && VN_IS(VN_CAST(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(),
IfaceRefDType); IfaceRefDType);
@ -254,7 +255,7 @@ private:
for (int i = 0; i < m_cellRangep->elementsConst(); i++) { for (int i = 0; i < m_cellRangep->elementsConst(); i++) {
m_instSelNum m_instSelNum
= m_cellRangep->littleEndian() ? (m_cellRangep->elementsConst() - 1 - i) : i; = m_cellRangep->littleEndian() ? (m_cellRangep->elementsConst() - 1 - i) : i;
int instNum = m_cellRangep->loConst() + i; const int instNum = m_cellRangep->loConst() + i;
AstCell* newp = nodep->cloneTree(false); AstCell* newp = nodep->cloneTree(false);
nodep->addNextHere(newp); nodep->addNextHere(newp);
@ -316,8 +317,8 @@ private:
if (!nodep->exprp()) return; // No-connect if (!nodep->exprp()) return; // No-connect
if (m_cellRangep) { if (m_cellRangep) {
UINFO(4, " PIN " << nodep << endl); UINFO(4, " PIN " << nodep << endl);
int pinwidth = nodep->modVarp()->width(); const int pinwidth = nodep->modVarp()->width();
int expwidth = nodep->exprp()->width(); const int expwidth = nodep->exprp()->width();
std::pair<uint32_t, uint32_t> pinDim = nodep->modVarp()->dtypep()->dimensions(false); std::pair<uint32_t, uint32_t> pinDim = nodep->modVarp()->dtypep()->dimensions(false);
std::pair<uint32_t, uint32_t> expDim = nodep->exprp()->dtypep()->dimensions(false); std::pair<uint32_t, uint32_t> expDim = nodep->exprp()->dtypep()->dimensions(false);
UINFO(4, " PINVAR " << nodep->modVarp() << endl); UINFO(4, " PINVAR " << nodep->modVarp() << endl);
@ -328,7 +329,7 @@ private:
if (expDim.first == pinDim.first && expDim.second == pinDim.second + 1) { if (expDim.first == pinDim.first && expDim.second == pinDim.second + 1) {
// Connection to array, where array dimensions match the instant dimension // Connection to array, where array dimensions match the instant dimension
AstRange* rangep = VN_CAST(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep(); AstRange* rangep = VN_CAST(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep();
int arraySelNum = rangep->littleEndian() const int arraySelNum = rangep->littleEndian()
? (rangep->elementsConst() - 1 - m_instSelNum) ? (rangep->elementsConst() - 1 - m_instSelNum)
: m_instSelNum; : m_instSelNum;
AstNode* exprp = nodep->exprp()->unlinkFrBack(); AstNode* exprp = nodep->exprp()->unlinkFrBack();
@ -346,7 +347,7 @@ private:
<< m_cellRangep->rightConst() << "]"); << m_cellRangep->rightConst() << "]");
} }
AstNode* exprp = nodep->exprp()->unlinkFrBack(); AstNode* exprp = nodep->exprp()->unlinkFrBack();
bool inputPin = nodep->modVarp()->isNonOutput(); const bool inputPin = nodep->modVarp()->isNonOutput();
if (!inputPin if (!inputPin
&& !VN_IS(exprp, VarRef) && !VN_IS(exprp, VarRef)
// V3Const will collapse the SEL with the one we're about to make // V3Const will collapse the SEL with the one we're about to make
@ -373,7 +374,7 @@ private:
"Unsupported: Non-constant index when passing interface to module"); "Unsupported: Non-constant index when passing interface to module");
return; return;
} }
string index = AstNode::encodeNumber(constp->toSInt()); const string index = AstNode::encodeNumber(constp->toSInt());
if (VN_IS(arrselp->lhsp(), SliceSel)) if (VN_IS(arrselp->lhsp(), SliceSel))
arrselp->lhsp()->v3error("Unsupported: interface slices"); arrselp->lhsp()->v3error("Unsupported: interface slices");
AstVarRef* varrefp = VN_CAST(arrselp->lhsp(), VarRef); AstVarRef* varrefp = VN_CAST(arrselp->lhsp(), VarRef);
@ -397,7 +398,7 @@ private:
// Clone pin varp: // Clone pin varp:
for (int in = 0; in < pinArrp->elementsConst(); ++in) { // 0 = leftmost for (int in = 0; in < pinArrp->elementsConst(); ++in) { // 0 = leftmost
int i = pinArrp->left() + in * pinArrp->declRange().leftToRightInc(); int i = pinArrp->left() + in * pinArrp->declRange().leftToRightInc();
string varNewName = pinVarp->name() + "__BRA__" + cvtToStr(i) + "__KET__"; const string varNewName = pinVarp->name() + "__BRA__" + cvtToStr(i) + "__KET__";
AstVar* varNewp = nullptr; AstVar* varNewp = nullptr;
// Only clone the var once for all usages of a given child module // Only clone the var once for all usages of a given child module
@ -445,7 +446,7 @@ private:
expr_i = exprArrp->left() + in * exprArrp->declRange().leftToRightInc(); expr_i = exprArrp->left() + in * exprArrp->declRange().leftToRightInc();
} }
string newname = varrefp->name() + "__BRA__" + cvtToStr(expr_i) + "__KET__"; const string newname = varrefp->name() + "__BRA__" + cvtToStr(expr_i) + "__KET__";
AstVarXRef* newVarXRefp AstVarXRef* newVarXRefp
= new AstVarXRef(nodep->fileline(), newname, "", VAccess::WRITE); = new AstVarXRef(nodep->fileline(), newname, "", VAccess::WRITE);
newVarXRefp->varp(newp->modVarp()); newVarXRefp->varp(newp->modVarp());

View File

@ -387,7 +387,7 @@ private:
// Just don't optimize blocks with labels; they're rare - so far. // Just don't optimize blocks with labels; they're rare - so far.
LifeBlock* prevLifep = m_lifep; LifeBlock* prevLifep = m_lifep;
LifeBlock* bodyLifep = new LifeBlock(prevLifep, m_statep); LifeBlock* bodyLifep = new LifeBlock(prevLifep, m_statep);
bool prev_noopt = m_noopt; const bool prev_noopt = m_noopt;
{ {
m_lifep = bodyLifep; m_lifep = bodyLifep;
m_noopt = true; m_noopt = true;

View File

@ -108,8 +108,8 @@ public:
: mtaskp{mtaskp_} : mtaskp{mtaskp_}
, sequence{sequence_} {} , sequence{sequence_} {}
bool operator<(const LifeLocation& b) const { bool operator<(const LifeLocation& b) const {
unsigned a_id = mtaskp ? mtaskp->id() : 0; const unsigned a_id = mtaskp ? mtaskp->id() : 0;
unsigned b_id = b.mtaskp ? b.mtaskp->id() : 0; const unsigned b_id = b.mtaskp ? b.mtaskp->id() : 0;
if (a_id < b_id) return true; if (a_id < b_id) return true;
if (b_id < a_id) return false; if (b_id < a_id) return false;
return sequence < b.sequence; return sequence < b.sequence;

View File

@ -141,7 +141,7 @@ private:
// Read-subfile // Read-subfile
// If file not found, make AstNotFoundModule, rather than error out. // If file not found, make AstNotFoundModule, rather than error out.
// We'll throw the error when we know the module will really be needed. // We'll throw the error when we know the module will really be needed.
string prettyName = AstNode::prettyName(modName); const string prettyName = AstNode::prettyName(modName);
V3Parse parser(v3Global.rootp(), m_filterp, m_parseSymp); V3Parse parser(v3Global.rootp(), m_filterp, m_parseSymp);
// true below -> other simulators treat modules in link-found files as library cells // true below -> other simulators treat modules in link-found files as library cells
parser.parseFile(nodep->fileline(), prettyName, true, ""); parser.parseFile(nodep->fileline(), prettyName, true, "");
@ -217,7 +217,7 @@ private:
if (VN_IS(nodep, Iface) || VN_IS(nodep, Package)) { if (VN_IS(nodep, Iface) || VN_IS(nodep, Package)) {
nodep->inLibrary(true); // Interfaces can't be at top, unless asked nodep->inLibrary(true); // Interfaces can't be at top, unless asked
} }
bool topMatch = (v3Global.opt.topModule() == nodep->prettyName()); const bool topMatch = (v3Global.opt.topModule() == nodep->prettyName());
if (topMatch) { if (topMatch) {
m_topVertexp = vertex(nodep); m_topVertexp = vertex(nodep);
UINFO(2, "Link --top-module: " << nodep << endl); UINFO(2, "Link --top-module: " << nodep << endl);
@ -289,7 +289,7 @@ private:
// Execute only once. Complication is that cloning may result in // Execute only once. Complication is that cloning may result in
// user1 being set (for pre-clone) so check if user1() matches the // user1 being set (for pre-clone) so check if user1() matches the
// m_mod, if 0 never did it, if !=, it is an unprocessed clone // m_mod, if 0 never did it, if !=, it is an unprocessed clone
bool cloned = (nodep->user1p() && nodep->user1p() != m_modp); const bool cloned = (nodep->user1p() && nodep->user1p() != m_modp);
if (nodep->user1p() == m_modp) return; // AstBind and AstNodeModule may call a cell twice if (nodep->user1p() == m_modp) return; // AstBind and AstNodeModule may call a cell twice
if (v3Global.opt.hierChild() && nodep->modName() == m_origTopModuleName) { if (v3Global.opt.hierChild() && nodep->modName() == m_origTopModuleName) {
if (nodep->modName() == m_modp->origName()) { if (nodep->modName() == m_modp->origName()) {
@ -432,7 +432,8 @@ private:
// classes are better supported may remap interfaces to be more // classes are better supported may remap interfaces to be more
// like a class. // like a class.
if (!nodep->hasIfaceVar()) { if (!nodep->hasIfaceVar()) {
string varName = nodep->name() + "__Viftop"; // V3LinkDot looks for this naming const string varName
= nodep->name() + "__Viftop"; // V3LinkDot looks for this naming
AstIfaceRefDType* idtypep = new AstIfaceRefDType(nodep->fileline(), nodep->name(), AstIfaceRefDType* idtypep = new AstIfaceRefDType(nodep->fileline(), nodep->name(),
nodep->modp()->name()); nodep->modp()->name());
idtypep->ifacep(nullptr); // cellp overrides idtypep->ifacep(nullptr); // cellp overrides

View File

@ -164,7 +164,7 @@ public:
VL_DEBUG_FUNC; // Declare debug() VL_DEBUG_FUNC; // Declare debug()
void dump(const string& nameComment = "linkdot", bool force = false) { void dump(const string& nameComment = "linkdot", bool force = false) {
if (debug() >= 6 || force) { if (debug() >= 6 || force) {
string filename = v3Global.debugFilename(nameComment) + ".txt"; const string filename = v3Global.debugFilename(nameComment) + ".txt";
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename)); const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
if (logp->fail()) v3fatal("Can't write " << filename); if (logp->fail()) v3fatal("Can't write " << filename);
std::ostream& os = *logp; std::ostream& os = *logp;
@ -476,7 +476,7 @@ public:
} }
} }
if (!ok) { if (!ok) {
string suggest = suggestSymFallback(ifaceSymp, ifacerefp->modportName(), const string suggest = suggestSymFallback(ifaceSymp, ifacerefp->modportName(),
LinkNodeMatcherModport()); LinkNodeMatcherModport());
ifacerefp->modportFileline()->v3error( ifacerefp->modportFileline()->v3error(
"Modport not found under interface " "Modport not found under interface "
@ -658,8 +658,8 @@ public:
static string removeLastInlineScope(const string& name) { static string removeLastInlineScope(const string& name) {
string out = name; string out = name;
string dot = "__DOT__"; const string dot = "__DOT__";
size_t dotPos = out.rfind(dot, out.size() - dot.length() - 2); const size_t dotPos = out.rfind(dot, out.size() - dot.length() - 2);
if (dotPos == string::npos) { if (dotPos == string::npos) {
return ""; return "";
} else { } else {
@ -676,12 +676,12 @@ public:
<< ((lookupSymp->symPrefix() == "") ? "" : " as ") << ((lookupSymp->symPrefix() == "") ? "" : " as ")
<< ((lookupSymp->symPrefix() == "") ? "" : lookupSymp->symPrefix() + dotname) << ((lookupSymp->symPrefix() == "") ? "" : lookupSymp->symPrefix() + dotname)
<< " at se" << lookupSymp << endl); << " at se" << lookupSymp << endl);
string prefix = lookupSymp->symPrefix(); const string prefix = lookupSymp->symPrefix();
VSymEnt* foundp = nullptr; VSymEnt* foundp = nullptr;
while (!foundp) { while (!foundp) {
foundp = lookupSymp->findIdFallback(prefix + dotname); // Might be nullptr foundp = lookupSymp->findIdFallback(prefix + dotname); // Might be nullptr
if (prefix.empty()) break; if (prefix.empty()) break;
string nextPrefix = removeLastInlineScope(prefix); const string nextPrefix = removeLastInlineScope(prefix);
if (prefix == nextPrefix) break; if (prefix == nextPrefix) break;
} }
if (!foundp) baddot = dotname; if (!foundp) baddot = dotname;
@ -778,8 +778,9 @@ class LinkDotFindVisitor final : public AstNVisitor {
// m_curSymp/m_modSymp maybe nullptr for packages and non-top modules // m_curSymp/m_modSymp maybe nullptr for packages and non-top modules
// Packages will be under top after the initial phases, but until then // Packages will be under top after the initial phases, but until then
// need separate handling // need separate handling
bool standalonePkg = !m_modSymp && (m_statep->forPrearray() && VN_IS(nodep, Package)); const bool standalonePkg
bool doit = (m_modSymp || standalonePkg); = !m_modSymp && (m_statep->forPrearray() && VN_IS(nodep, Package));
const bool doit = (m_modSymp || standalonePkg);
VL_RESTORER(m_scope); VL_RESTORER(m_scope);
VL_RESTORER(m_classOrPackagep); VL_RESTORER(m_classOrPackagep);
VL_RESTORER(m_modSymp); VL_RESTORER(m_modSymp);
@ -888,11 +889,11 @@ class LinkDotFindVisitor final : public AstNVisitor {
VL_RESTORER(m_inRecursion); VL_RESTORER(m_inRecursion);
// Where do we add it? // Where do we add it?
VSymEnt* aboveSymp = m_curSymp; VSymEnt* aboveSymp = m_curSymp;
string origname = AstNode::dedotName(nodep->name()); const string origname = AstNode::dedotName(nodep->name());
string::size_type pos; string::size_type pos;
if ((pos = origname.rfind('.')) != string::npos) { if ((pos = origname.rfind('.')) != string::npos) {
// Flattened, find what CellInline it should live under // Flattened, find what CellInline it should live under
string scope = origname.substr(0, pos); const string scope = origname.substr(0, pos);
string baddot; string baddot;
VSymEnt* okSymp; VSymEnt* okSymp;
aboveSymp = m_statep->findDotted(nodep->fileline(), aboveSymp, scope, baddot, okSymp); aboveSymp = m_statep->findDotted(nodep->fileline(), aboveSymp, scope, baddot, okSymp);
@ -913,11 +914,11 @@ class LinkDotFindVisitor final : public AstNVisitor {
UINFO(5, " CELLINLINE under " << m_scope << " is " << nodep << endl); UINFO(5, " CELLINLINE under " << m_scope << " is " << nodep << endl);
VSymEnt* aboveSymp = m_curSymp; VSymEnt* aboveSymp = m_curSymp;
// If baz__DOT__foo__DOT__bar, we need to find baz__DOT__foo and add bar to it. // If baz__DOT__foo__DOT__bar, we need to find baz__DOT__foo and add bar to it.
string dottedname = nodep->name(); const string dottedname = nodep->name();
string::size_type pos; string::size_type pos;
if ((pos = dottedname.rfind("__DOT__")) != string::npos) { if ((pos = dottedname.rfind("__DOT__")) != string::npos) {
string dotted = dottedname.substr(0, pos); const string dotted = dottedname.substr(0, pos);
string ident = dottedname.substr(pos + strlen("__DOT__")); const string ident = dottedname.substr(pos + strlen("__DOT__"));
string baddot; string baddot;
VSymEnt* okSymp; VSymEnt* okSymp;
aboveSymp = m_statep->findDotted(nodep->fileline(), aboveSymp, dotted, baddot, okSymp); aboveSymp = m_statep->findDotted(nodep->fileline(), aboveSymp, dotted, baddot, okSymp);
@ -1004,7 +1005,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
m_classOrPackagep = VN_CAST(m_curSymp->nodep(), Class); m_classOrPackagep = VN_CAST(m_curSymp->nodep(), Class);
} }
// Create symbol table for the task's vars // Create symbol table for the task's vars
string name = string{nodep->isExternProto() ? "extern " : ""} + nodep->name(); const string name = string{nodep->isExternProto() ? "extern " : ""} + nodep->name();
m_curSymp = m_statep->insertBlock(m_curSymp, name, nodep, m_classOrPackagep); m_curSymp = m_statep->insertBlock(m_curSymp, name, nodep, m_classOrPackagep);
m_curSymp->fallbackp(upSymp); m_curSymp->fallbackp(upSymp);
// Convert the func's range to the output variable // Convert the func's range to the output variable
@ -1068,7 +1069,8 @@ class LinkDotFindVisitor final : public AstNVisitor {
bool nansiBad bool nansiBad
= ((findvarp->isDeclTyped() && nodep->isDeclTyped()) = ((findvarp->isDeclTyped() && nodep->isDeclTyped())
|| (findvarp->isIO() && nodep->isIO())); // e.g. !(output && output) || (findvarp->isIO() && nodep->isIO())); // e.g. !(output && output)
bool ansiBad = findvarp->isAnsi() || nodep->isAnsi(); // dup illegal with ANSI const bool ansiBad
= findvarp->isAnsi() || nodep->isAnsi(); // dup illegal with ANSI
if (ansiBad || nansiBad) { if (ansiBad || nansiBad) {
bool ansiWarn = ansiBad && !nansiBad; bool ansiWarn = ansiBad && !nansiBad;
if (ansiWarn) { if (ansiWarn) {
@ -1134,7 +1136,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
= new AstVar(nodep->fileline(), AstVarType(AstVarType::GPARAM), = new AstVar(nodep->fileline(), AstVarType(AstVarType::GPARAM),
nodep->name(), nodep); nodep->name(), nodep);
newp->combineType(nodep); newp->combineType(nodep);
string svalue = v3Global.opt.parameter(nodep->name()); const string svalue = v3Global.opt.parameter(nodep->name());
if (AstNode* valuep if (AstNode* valuep
= AstConst::parseParamLiteral(nodep->fileline(), svalue)) { = AstConst::parseParamLiteral(nodep->fileline(), svalue)) {
newp->valuep(valuep); newp->valuep(valuep);
@ -1268,12 +1270,12 @@ class LinkDotFindVisitor final : public AstNVisitor {
} }
virtual void visit(AstWithParse* nodep) override { virtual void visit(AstWithParse* nodep) override {
// Change WITHPARSE(FUNCREF, equation) to FUNCREF(WITH(equation)) // Change WITHPARSE(FUNCREF, equation) to FUNCREF(WITH(equation))
auto funcrefp = VN_CAST(nodep->funcrefp(), NodeFTaskRef); const auto funcrefp = VN_CAST(nodep->funcrefp(), NodeFTaskRef);
UASSERT_OBJ(funcrefp, nodep, "'with' only can operate on a function/task"); UASSERT_OBJ(funcrefp, nodep, "'with' only can operate on a function/task");
string name = "item"; string name = "item";
FileLine* argFl = nodep->fileline(); FileLine* argFl = nodep->fileline();
if (auto argp = VN_CAST(funcrefp->pinsp(), Arg)) { if (const auto argp = VN_CAST(funcrefp->pinsp(), Arg)) {
if (auto parserefp = VN_CAST(argp->exprp(), ParseRef)) { if (const auto parserefp = VN_CAST(argp->exprp(), ParseRef)) {
name = parserefp->name(); name = parserefp->name();
argFl = parserefp->fileline(); argFl = parserefp->fileline();
} else { } else {
@ -1557,7 +1559,7 @@ class LinkDotScopeVisitor final : public AstNVisitor {
= LinkDotState::ifaceRefFromArray(nodep->varp()->dtypep()); = LinkDotState::ifaceRefFromArray(nodep->varp()->dtypep());
UASSERT_OBJ(dtypep, nodep, "Non AstIfaceRefDType on isIfaceRef() var"); UASSERT_OBJ(dtypep, nodep, "Non AstIfaceRefDType on isIfaceRef() var");
UINFO(9, "Iface parent dtype " << dtypep << endl); UINFO(9, "Iface parent dtype " << dtypep << endl);
string ifcellname = dtypep->cellName(); const string ifcellname = dtypep->cellName();
string baddot; string baddot;
VSymEnt* okSymp; VSymEnt* okSymp;
VSymEnt* cellSymp = m_statep->findDotted(nodep->fileline(), m_modSymp, ifcellname, VSymEnt* cellSymp = m_statep->findDotted(nodep->fileline(), m_modSymp, ifcellname,
@ -1644,7 +1646,8 @@ class LinkDotScopeVisitor final : public AstNVisitor {
UASSERT_OBJ(refp || xrefp, nodep, UASSERT_OBJ(refp || xrefp, nodep,
"Unsupported: Non Var(X)Ref attached to interface pin"); "Unsupported: Non Var(X)Ref attached to interface pin");
string scopename = refp ? refp->varp()->name() : xrefp->dotted() + "." + xrefp->name(); const string scopename
= refp ? refp->varp()->name() : xrefp->dotted() + "." + xrefp->name();
string baddot; string baddot;
VSymEnt* okSymp; VSymEnt* okSymp;
VSymEnt* symp = m_statep->findDotted(nodep->lhsp()->fileline(), m_modSymp, scopename, VSymEnt* symp = m_statep->findDotted(nodep->lhsp()->fileline(), m_modSymp, scopename,
@ -1844,7 +1847,7 @@ private:
if (!nodep->varp()) { if (!nodep->varp()) {
if (!noWarn) { if (!noWarn) {
if (nodep->fileline()->warnIsOff(V3ErrorCode::I_DEF_NETTYPE_WIRE)) { if (nodep->fileline()->warnIsOff(V3ErrorCode::I_DEF_NETTYPE_WIRE)) {
string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(), const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
LinkNodeMatcherVar()); LinkNodeMatcherVar());
nodep->v3error("Signal definition not found, and implicit disabled with " nodep->v3error("Signal definition not found, and implicit disabled with "
"`default_nettype: " "`default_nettype: "
@ -1855,7 +1858,7 @@ private:
// Bypass looking for suggestions if IMPLICIT is turned off // Bypass looking for suggestions if IMPLICIT is turned off
// as there could be thousands of these suppressed in large netlists // as there could be thousands of these suppressed in large netlists
else if (!nodep->fileline()->warnIsOff(V3ErrorCode::IMPLICIT)) { else if (!nodep->fileline()->warnIsOff(V3ErrorCode::IMPLICIT)) {
string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(), const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
LinkNodeMatcherVar()); LinkNodeMatcherVar());
nodep->v3warn(IMPLICIT, nodep->v3warn(IMPLICIT,
"Signal definition not found, creating implicitly: " "Signal definition not found, creating implicitly: "
@ -1905,7 +1908,7 @@ private:
} }
} }
AstVar* findIfaceTopVarp(AstNode* nodep, VSymEnt* parentEntp, const string& name) { AstVar* findIfaceTopVarp(AstNode* nodep, VSymEnt* parentEntp, const string& name) {
string findName = name + "__Viftop"; const string findName = name + "__Viftop";
VSymEnt* ifaceSymp = parentEntp->findIdFallback(findName); VSymEnt* ifaceSymp = parentEntp->findIdFallback(findName);
AstVar* ifaceTopVarp = ifaceSymp ? VN_CAST(ifaceSymp->nodep(), Var) : nullptr; AstVar* ifaceTopVarp = ifaceSymp ? VN_CAST(ifaceSymp->nodep(), Var) : nullptr;
UASSERT_OBJ(ifaceTopVarp, nodep, "Can't find interface var ref: " << findName); UASSERT_OBJ(ifaceTopVarp, nodep, "Can't find interface var ref: " << findName);
@ -2057,8 +2060,8 @@ private:
// DOT(DOT(DOT(PARSEREF(text), ... // DOT(DOT(DOT(PARSEREF(text), ...
if (nodep->user3SetOnce()) return; if (nodep->user3SetOnce()) return;
UINFO(8, " " << nodep << endl); UINFO(8, " " << nodep << endl);
DotStates lastStates = m_ds; const DotStates lastStates = m_ds;
bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed const bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
{ {
if (start) { // Starting dot sequence if (start) { // Starting dot sequence
if (debug() >= 9) nodep->dumpTree("-dot-in: "); if (debug() >= 9) nodep->dumpTree("-dot-in: ");
@ -2088,14 +2091,14 @@ private:
nodep->v3error("'super' used outside class (IEEE 1800-2017 8.15)"); nodep->v3error("'super' used outside class (IEEE 1800-2017 8.15)");
m_ds.m_dotErr = true; m_ds.m_dotErr = true;
} else { } else {
auto classp = VN_CAST(classSymp->nodep(), Class); const auto classp = VN_CAST(classSymp->nodep(), Class);
if (!classp->extendsp()) { if (!classp->extendsp()) {
nodep->v3error("'super' used on non-extended class (IEEE 1800-2017 8.15)"); nodep->v3error("'super' used on non-extended class (IEEE 1800-2017 8.15)");
m_ds.m_dotErr = true; m_ds.m_dotErr = true;
} else { } else {
auto cextp = VN_CAST(classp->extendsp(), ClassExtends); const auto cextp = VN_CAST(classp->extendsp(), ClassExtends);
UASSERT_OBJ(cextp, nodep, "Bad super extends link"); UASSERT_OBJ(cextp, nodep, "Bad super extends link");
auto sclassp = cextp->classp(); const auto sclassp = cextp->classp();
UASSERT_OBJ(sclassp, nodep, "Bad superclass"); UASSERT_OBJ(sclassp, nodep, "Bad superclass");
m_ds.m_dotSymp = m_statep->getNodeSym(sclassp); m_ds.m_dotSymp = m_statep->getNodeSym(sclassp);
UINFO(8, " super. " << m_ds.ascii() << endl); UINFO(8, " super. " << m_ds.ascii() << endl);
@ -2161,8 +2164,8 @@ private:
UASSERT_OBJ(m_statep->forPrimary() || m_statep->forPrearray(), nodep, UASSERT_OBJ(m_statep->forPrimary() || m_statep->forPrearray(), nodep,
"ParseRefs should no longer exist"); "ParseRefs should no longer exist");
if (nodep->name() == "super") nodep->v3warn(E_UNSUPPORTED, "Unsupported: super"); if (nodep->name() == "super") nodep->v3warn(E_UNSUPPORTED, "Unsupported: super");
DotStates lastStates = m_ds; const DotStates lastStates = m_ds;
bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed const bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
if (start) { if (start) {
m_ds.init(m_curSymp); m_ds.init(m_curSymp);
// Note m_ds.m_dot remains nullptr; this is a reference not under a dot // Note m_ds.m_dot remains nullptr; this is a reference not under a dot
@ -2175,8 +2178,8 @@ private:
&& nodep->name() == "index") { && nodep->name() == "index") {
// 'with' statement's 'item.index' // 'with' statement's 'item.index'
iterateChildren(nodep); iterateChildren(nodep);
auto newp = new AstLambdaArgRef(nodep->fileline(), const auto newp = new AstLambdaArgRef(
m_ds.m_unlinkedScopep->name() + "__DOT__index", true); nodep->fileline(), m_ds.m_unlinkedScopep->name() + "__DOT__index", true);
nodep->replaceWith(newp); nodep->replaceWith(newp);
VL_DO_DANGLING(pushDeletep(nodep), nodep); VL_DO_DANGLING(pushDeletep(nodep), nodep);
return; return;
@ -2304,8 +2307,8 @@ private:
} }
m_ds.m_dotText = ""; m_ds.m_dotText = "";
if (m_ds.m_unresolved && m_ds.m_unlinkedScopep) { if (m_ds.m_unresolved && m_ds.m_unlinkedScopep) {
string dotted = refp->dotted(); const string dotted = refp->dotted();
size_t pos = dotted.find("__BRA__??__KET__"); const size_t pos = dotted.find("__BRA__??__KET__");
// Arrays of interfaces all have the same parameters // Arrays of interfaces all have the same parameters
if (pos != string::npos && varp->isParam() if (pos != string::npos && varp->isParam()
&& VN_IS(m_ds.m_unlinkedScopep, CellArrayRef)) { && VN_IS(m_ds.m_unlinkedScopep, CellArrayRef)) {
@ -2402,9 +2405,9 @@ private:
// //
if (!ok) { if (!ok) {
// Cells/interfaces can't be implicit // Cells/interfaces can't be implicit
bool isCell = foundp ? VN_IS(foundp->nodep(), Cell) : false; const bool isCell = foundp ? VN_IS(foundp->nodep(), Cell) : false;
bool checkImplicit = (!m_ds.m_dotp && m_ds.m_dotText == "" && !isCell); const bool checkImplicit = (!m_ds.m_dotp && m_ds.m_dotText == "" && !isCell);
bool err = !(checkImplicit && m_statep->implicitOk(m_modp, nodep->name())); const bool err = !(checkImplicit && m_statep->implicitOk(m_modp, nodep->name()));
if (err) { if (err) {
if (foundp) { if (foundp) {
nodep->v3error("Found definition of '" nodep->v3error("Found definition of '"
@ -2415,7 +2418,7 @@ private:
} else if (m_ds.m_dotText == "") { } else if (m_ds.m_dotText == "") {
UINFO(7, " ErrParseRef curSymp=se" << cvtToHex(m_curSymp) UINFO(7, " ErrParseRef curSymp=se" << cvtToHex(m_curSymp)
<< " ds=" << m_ds.ascii() << endl); << " ds=" << m_ds.ascii() << endl);
string suggest = m_statep->suggestSymFallback( const string suggest = m_statep->suggestSymFallback(
m_ds.m_dotSymp, nodep->name(), VNodeMatcher()); m_ds.m_dotSymp, nodep->name(), VNodeMatcher());
nodep->v3error("Can't find definition of " nodep->v3error("Can't find definition of "
<< expectWhat << ": " << nodep->prettyNameQ() << '\n' << expectWhat << ": " << nodep->prettyNameQ() << '\n'
@ -2486,7 +2489,7 @@ private:
// variable name lower down with same scope name we want to // variable name lower down with same scope name we want to
// ignore (t_math_divw) // ignore (t_math_divw)
dotSymp = m_modSymp; dotSymp = m_modSymp;
string inl = AstNode::dedotName(nodep->inlinedDots()); const string inl = AstNode::dedotName(nodep->inlinedDots());
dotSymp = m_statep->findDotted(nodep->fileline(), dotSymp, inl, baddot, okSymp); dotSymp = m_statep->findDotted(nodep->fileline(), dotSymp, inl, baddot, okSymp);
UASSERT_OBJ(dotSymp, nodep, UASSERT_OBJ(dotSymp, nodep,
"Couldn't resolve inlined scope " << AstNode::prettyNameQ(baddot) "Couldn't resolve inlined scope " << AstNode::prettyNameQ(baddot)
@ -2641,7 +2644,7 @@ private:
// variable name lower down with same scope name we want // variable name lower down with same scope name we want
// to ignore (t_math_divw) // to ignore (t_math_divw)
dotSymp = m_modSymp; dotSymp = m_modSymp;
string inl = AstNode::dedotName(nodep->inlinedDots()); const string inl = AstNode::dedotName(nodep->inlinedDots());
UINFO(8, " Inlined " << inl << endl); UINFO(8, " Inlined " << inl << endl);
dotSymp dotSymp
= m_statep->findDotted(nodep->fileline(), dotSymp, inl, baddot, okSymp); = m_statep->findDotted(nodep->fileline(), dotSymp, inl, baddot, okSymp);
@ -2708,14 +2711,14 @@ private:
"Unsupported or unknown PLI call: " << nodep->prettyNameQ()); "Unsupported or unknown PLI call: " << nodep->prettyNameQ());
} }
} else { } else {
string suggest = m_statep->suggestSymFallback(dotSymp, nodep->name(), const string suggest = m_statep->suggestSymFallback(
LinkNodeMatcherFTask()); dotSymp, nodep->name(), LinkNodeMatcherFTask());
nodep->v3error("Can't find definition of task/function: " nodep->v3error("Can't find definition of task/function: "
<< nodep->prettyNameQ() << '\n' << nodep->prettyNameQ() << '\n'
<< (suggest.empty() ? "" : nodep->warnMore() + suggest)); << (suggest.empty() ? "" : nodep->warnMore() + suggest));
} }
} else { } else {
string suggest = m_statep->suggestSymFallback(dotSymp, nodep->name(), const string suggest = m_statep->suggestSymFallback(dotSymp, nodep->name(),
LinkNodeMatcherFTask()); LinkNodeMatcherFTask());
nodep->v3error("Can't find definition of " nodep->v3error("Can't find definition of "
<< AstNode::prettyNameQ(baddot) << " in dotted task/function: '" << AstNode::prettyNameQ(baddot) << " in dotted task/function: '"
@ -2880,7 +2883,7 @@ private:
} }
} }
if (!ok) { if (!ok) {
string suggest = m_statep->suggestSymFallback( const string suggest = m_statep->suggestSymFallback(
m_curSymp, cpackagerefp->name(), LinkNodeMatcherClass{}); m_curSymp, cpackagerefp->name(), LinkNodeMatcherClass{});
cpackagerefp->v3error( cpackagerefp->v3error(
"Class to extend not found: " "Class to extend not found: "

View File

@ -189,7 +189,7 @@ private:
// Prepare a temporary variable // Prepare a temporary variable
FileLine* fl = backp->fileline(); FileLine* fl = backp->fileline();
string name = string("__Vincrement") + cvtToStr(++m_modIncrementsNum); const string name = string("__Vincrement") + cvtToStr(++m_modIncrementsNum);
AstVar* varp = new AstVar(fl, AstVarType::BLOCKTEMP, name, VFlagChildDType(), AstVar* varp = new AstVar(fl, AstVarType::BLOCKTEMP, name, VFlagChildDType(),
varrefp->varp()->subDTypep()->cloneTree(true)); varrefp->varp()->subDTypep()->cloneTree(true));

View File

@ -144,7 +144,7 @@ private:
// REPEAT(count,body) -> loop=count,WHILE(loop>0) { body, loop-- } // REPEAT(count,body) -> loop=count,WHILE(loop>0) { body, loop-- }
// Note var can be signed or unsigned based on original number. // Note var can be signed or unsigned based on original number.
AstNode* countp = nodep->countp()->unlinkFrBackWithNext(); AstNode* countp = nodep->countp()->unlinkFrBackWithNext();
string name = string("__Vrepeat") + cvtToStr(m_modRepeatNum++); const string name = string("__Vrepeat") + cvtToStr(m_modRepeatNum++);
// Spec says value is integral, if negative is ignored // Spec says value is integral, if negative is ignored
AstVar* varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name, AstVar* varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name,
nodep->findSigned32DType()); nodep->findSigned32DType());

View File

@ -157,13 +157,13 @@ private:
// We check this rule in the parser, so shouldn't fire // We check this rule in the parser, so shouldn't fire
nodep->v3error("Enum ranges must be integral, per spec"); nodep->v3error("Enum ranges must be integral, per spec");
} // LCOV_EXCL_STOP } // LCOV_EXCL_STOP
int left = nodep->rangep()->leftConst(); const int left = nodep->rangep()->leftConst();
int right = nodep->rangep()->rightConst(); const int right = nodep->rangep()->rightConst();
int increment = (left > right) ? -1 : 1; const int increment = (left > right) ? -1 : 1;
int offset_from_init = 0; int offset_from_init = 0;
AstNode* addp = nullptr; AstNode* addp = nullptr;
for (int i = left; i != (right + increment); i += increment, offset_from_init++) { for (int i = left; i != (right + increment); i += increment, offset_from_init++) {
string name = nodep->name() + cvtToStr(i); const string name = nodep->name() + cvtToStr(i);
AstNode* valuep = nullptr; AstNode* valuep = nullptr;
if (nodep->valuep()) { if (nodep->valuep()) {
valuep = new AstAdd( valuep = new AstAdd(
@ -350,7 +350,7 @@ private:
m_varp->addNext(nodep); m_varp->addNext(nodep);
// lvalue is true, because we know we have a verilator public_flat_rw // lvalue is true, because we know we have a verilator public_flat_rw
// but someday we may be more general // but someday we may be more general
bool lvalue = m_varp->isSigUserRWPublic(); const bool lvalue = m_varp->isSigUserRWPublic();
nodep->addStmtp( nodep->addStmtp(
new AstVarRef(nodep->fileline(), m_varp, lvalue ? VAccess::WRITE : VAccess::READ)); new AstVarRef(nodep->fileline(), m_varp, lvalue ? VAccess::WRITE : VAccess::READ));
} }
@ -540,7 +540,7 @@ private:
cleanFileline(nodep); cleanFileline(nodep);
AstNode* backp = nodep->backp(); AstNode* backp = nodep->backp();
// IEEE says directly nested item is not a new block // IEEE says directly nested item is not a new block
bool nestedIf = (nodep->implied() // User didn't provide begin/end const bool nestedIf = (nodep->implied() // User didn't provide begin/end
&& (VN_IS(nodep->stmtsp(), GenIf) && (VN_IS(nodep->stmtsp(), GenIf)
|| VN_IS(nodep->stmtsp(), GenCase)) // Has an if/case || VN_IS(nodep->stmtsp(), GenCase)) // Has an if/case
&& !nodep->stmtsp()->nextp()); // Has only one item && !nodep->stmtsp()->nextp()); // Has only one item

View File

@ -153,7 +153,7 @@ private:
AstNode* sensp = nodep->sensp(); AstNode* sensp = nodep->sensp();
if (sensp && !VN_IS(sensp, NodeVarRef) && !VN_IS(sensp, Const)) { if (sensp && !VN_IS(sensp, NodeVarRef) && !VN_IS(sensp, Const)) {
// Make a new temp wire // Make a new temp wire
string newvarname = "__Vsenitemexpr" + cvtToStr(++m_senitemCvtNum); const string newvarname = "__Vsenitemexpr" + cvtToStr(++m_senitemCvtNum);
AstVar* newvarp = new AstVar(sensp->fileline(), AstVarType::MODULETEMP, newvarname, AstVar* newvarp = new AstVar(sensp->fileline(), AstVarType::MODULETEMP, newvarname,
VFlagLogicPacked(), 1); VFlagLogicPacked(), 1);
// We can't just add under the module, because we may be // We can't just add under the module, because we may be
@ -354,14 +354,14 @@ private:
continue; continue;
} }
AstConst* constp = VN_CAST(argp, Const); AstConst* constp = VN_CAST(argp, Const);
bool isFromString = (constp) ? constp->num().isFromString() : false; const bool isFromString = (constp) ? constp->num().isFromString() : false;
if (isFromString) { if (isFromString) {
int numchars = argp->dtypep()->width() / 8; const int numchars = argp->dtypep()->width() / 8;
string str(numchars, ' '); string str(numchars, ' ');
// now scan for % operators // now scan for % operators
bool inpercent = false; bool inpercent = false;
for (int i = 0; i < numchars; i++) { for (int i = 0; i < numchars; i++) {
int ii = numchars - i - 1; const int ii = numchars - i - 1;
char c = constp->num().dataByte(ii); char c = constp->num().dataByte(ii);
str[i] = c; str[i] = c;
if (!inpercent && c == '%') { if (!inpercent && c == '%') {
@ -454,7 +454,7 @@ private:
} }
nodep->hasFormat(true); nodep->hasFormat(true);
} }
string newFormat = expectFormat(nodep, nodep->text(), nodep->exprsp(), false); const string newFormat = expectFormat(nodep, nodep->text(), nodep->exprsp(), false);
nodep->text(newFormat); nodep->text(newFormat);
if ((VN_IS(nodep->backp(), Display) if ((VN_IS(nodep->backp(), Display)
&& VN_CAST(nodep->backp(), Display)->displayType().needScopeTracking()) && VN_CAST(nodep->backp(), Display)->displayType().needScopeTracking())

View File

@ -78,7 +78,7 @@ public:
void pushBack(V3List<T>& listr, T newp) { void pushBack(V3List<T>& listr, T newp) {
// "this" must be a element inside of *newp // "this" must be a element inside of *newp
// cppcheck-suppress thisSubtraction // cppcheck-suppress thisSubtraction
size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(newp); const size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(newp);
m_nextp = nullptr; m_nextp = nullptr;
if (!listr.m_headp) listr.m_headp = newp; if (!listr.m_headp) listr.m_headp = newp;
m_prevp = listr.m_tailp; m_prevp = listr.m_tailp;
@ -88,7 +88,7 @@ public:
void pushFront(V3List<T>& listr, T newp) { void pushFront(V3List<T>& listr, T newp) {
// "this" must be a element inside of *newp // "this" must be a element inside of *newp
// cppcheck-suppress thisSubtraction // cppcheck-suppress thisSubtraction
size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(newp); const size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(newp);
m_nextp = listr.m_headp; m_nextp = listr.m_headp;
if (m_nextp) baseToListEnt(m_nextp, offset)->m_prevp = newp; if (m_nextp) baseToListEnt(m_nextp, offset)->m_prevp = newp;
listr.m_headp = newp; listr.m_headp = newp;
@ -99,7 +99,7 @@ public:
void unlink(V3List<T>& listr, T oldp) { void unlink(V3List<T>& listr, T oldp) {
// "this" must be a element inside of *oldp // "this" must be a element inside of *oldp
// cppcheck-suppress thisSubtraction // cppcheck-suppress thisSubtraction
size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(oldp); const size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(oldp);
if (m_nextp) { if (m_nextp) {
baseToListEnt(m_nextp, offset)->m_prevp = m_prevp; baseToListEnt(m_nextp, offset)->m_prevp = m_prevp;
} else { } else {

View File

@ -48,16 +48,16 @@ private:
void rename(AstNode* nodep, bool addPvt) { void rename(AstNode* nodep, bool addPvt) {
if (!nodep->user1()) { // Not already done if (!nodep->user1()) { // Not already done
if (addPvt) { if (addPvt) {
string newname = string("__PVT__") + nodep->name(); const string newname = string("__PVT__") + nodep->name();
nodep->name(newname); nodep->name(newname);
nodep->editCountInc(); nodep->editCountInc();
} else if (VN_IS(nodep, CFunc) && VN_CAST(nodep, CFunc)->isConstructor()) { } else if (VN_IS(nodep, CFunc) && VN_CAST(nodep, CFunc)->isConstructor()) {
} else { } else {
string rsvd = V3LanguageWords::isKeyword(nodep->name()); const string rsvd = V3LanguageWords::isKeyword(nodep->name());
if (rsvd != "") { if (rsvd != "") {
nodep->v3warn(SYMRSVDWORD, nodep->v3warn(SYMRSVDWORD,
"Symbol matches " + rsvd + ": " << nodep->prettyNameQ()); "Symbol matches " + rsvd + ": " << nodep->prettyNameQ());
string newname = string("__SYM__") + nodep->name(); const string newname = string("__SYM__") + nodep->name();
nodep->name(newname); nodep->name(newname);
nodep->editCountInc(); nodep->editCountInc();
} }

View File

@ -100,7 +100,7 @@ V3Number::V3Number(VerilogStringLiteral, AstNode* nodep, const string& str) {
init(nodep, str.length() * 8); init(nodep, str.length() * 8);
m_fromString = true; m_fromString = true;
for (unsigned pos = 0; pos < str.length(); ++pos) { for (unsigned pos = 0; pos < str.length(); ++pos) {
int topos = str.length() - 1 - pos; const int topos = str.length() - 1 - pos;
for (int bit = 0; bit < 8; ++bit) { for (int bit = 0; bit < 8; ++bit) {
if (str[pos] & (1UL << bit)) { if (str[pos] & (1UL << bit)) {
m_value[topos / 4] |= (1UL << (bit + (topos % 4) * 8)); m_value[topos / 4] |= (1UL << (bit + (topos % 4) * 8));
@ -515,7 +515,7 @@ string V3Number::ascii(bool prefixed, bool cleanVerilog) const {
if (isSigned()) out << "s"; if (isSigned()) out << "s";
} }
bool binary = (isFourState() const bool binary = (isFourState()
#ifdef V3NUMBER_ASCII_BINARY #ifdef V3NUMBER_ASCII_BINARY
// cppcheck-suppress konwnConditionTrueFalse // cppcheck-suppress konwnConditionTrueFalse
|| true || true
@ -586,7 +586,7 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
fmtsize += pos[0]; fmtsize += pos[0];
} }
string str; string str;
char code = tolower(pos[0]); const char code = tolower(pos[0]);
switch (code) { switch (code) {
case 'b': { case 'b': {
int bit = width() - 1; int bit = width() - 1;
@ -655,14 +655,14 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
if (fmtsize != "0") str += ' '; if (fmtsize != "0") str += ' ';
} }
} }
size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str())); const size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
str = displayPad(fmtsizen, ' ', left, str); str = displayPad(fmtsizen, ' ', left, str);
return str; return str;
} }
case '~': // Signed decimal case '~': // Signed decimal
case 't': // Time case 't': // Time
case 'd': { // Unsigned decimal case 'd': { // Unsigned decimal
bool issigned = (code == '~'); const bool issigned = (code == '~');
if (fmtsize == "") { if (fmtsize == "") {
const double mantissabits = this->width() - (issigned ? 1 : 0); const double mantissabits = this->width() - (issigned ? 1 : 0);
// To get the number of digits required, we want to compute // To get the number of digits required, we want to compute
@ -686,9 +686,9 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
str = cvtToStr(toUQuad()); str = cvtToStr(toUQuad());
} }
} }
bool zeropad = fmtsize.length() > 0 && fmtsize[0] == '0'; const bool zeropad = fmtsize.length() > 0 && fmtsize[0] == '0';
// fmtsize might have changed since we parsed the %fmtsize // fmtsize might have changed since we parsed the %fmtsize
size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str())); const size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
str = displayPad(fmtsizen, (zeropad ? '0' : ' '), left, str); str = displayPad(fmtsizen, (zeropad ? '0' : ' '), left, str);
return str; return str;
} }
@ -741,7 +741,7 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
return str; return str;
} }
case '@': { // Packed string case '@': { // Packed string
size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str())); const size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
str = displayPad(fmtsizen, ' ', left, toString()); str = displayPad(fmtsizen, ' ', left, toString());
return str; return str;
} }
@ -762,7 +762,7 @@ string V3Number::toDecimalS() const {
} }
string V3Number::toDecimalU() const { string V3Number::toDecimalU() const {
int maxdecwidth = (width() + 3) * 4 / 3; const int maxdecwidth = (width() + 3) * 4 / 3;
// Or (maxdecwidth+7)/8], but can't have more than 4 BCD bits per word // Or (maxdecwidth+7)/8], but can't have more than 4 BCD bits per word
V3Number bcd(this, maxdecwidth + 4); V3Number bcd(this, maxdecwidth + 4);
@ -1161,7 +1161,7 @@ V3Number& V3Number::opCLog2(const V3Number& lhs) {
NUM_ASSERT_LOGIC_ARGS1(lhs); NUM_ASSERT_LOGIC_ARGS1(lhs);
if (lhs.isFourState()) return setAllBitsX(); if (lhs.isFourState()) return setAllBitsX();
// IE if 4, this algorithm didn't pre-subtract 1, so we need to post-correct now // IE if 4, this algorithm didn't pre-subtract 1, so we need to post-correct now
int adjust = (lhs.countOnes() == 1) ? 0 : 1; const int adjust = (lhs.countOnes() == 1) ? 0 : 1;
for (int bit = lhs.width() - 1; bit >= 0; bit--) { for (int bit = lhs.width() - 1; bit >= 0; bit--) {
if (lhs.bitIs1(bit)) { if (lhs.bitIs1(bit)) {
setLong(bit + adjust); setLong(bit + adjust);
@ -1331,9 +1331,9 @@ V3Number& V3Number::opStreamL(const V3Number& lhs, const V3Number& rhs) {
v3warn(WIDTHCONCAT, "Unsized numbers/parameters not allowed in streams."); v3warn(WIDTHCONCAT, "Unsized numbers/parameters not allowed in streams.");
} }
// Slice size should never exceed the lhs width // Slice size should never exceed the lhs width
int ssize = std::min(rhs.toUInt(), static_cast<unsigned>(lhs.width())); const int ssize = std::min(rhs.toUInt(), static_cast<unsigned>(lhs.width()));
for (int istart = 0; istart < lhs.width(); istart += ssize) { for (int istart = 0; istart < lhs.width(); istart += ssize) {
int ostart = std::max(0, lhs.width() - ssize - istart); const int ostart = std::max(0, lhs.width() - ssize - istart);
for (int bit = 0; bit < ssize && bit < lhs.width() - istart; bit++) { for (int bit = 0; bit < ssize && bit < lhs.width() - istart; bit++) {
setBit(ostart + bit, lhs.bitIs(istart + bit)); setBit(ostart + bit, lhs.bitIs(istart + bit));
} }
@ -1472,8 +1472,8 @@ V3Number& V3Number::opCompareNN(const V3Number& lhs, const V3Number& rhs, bool i
// SystemVerilog Language Standard does not allow a string variable to contain '\0'. // SystemVerilog Language Standard does not allow a string variable to contain '\0'.
// So C functions such as strcmp() can correctly compare strings. // So C functions such as strcmp() can correctly compare strings.
int result; int result;
string lstring = lhs.toString(); const string lstring = lhs.toString();
string rstring = rhs.toString(); const string rstring = rhs.toString();
if (ignoreCase) { if (ignoreCase) {
result = VL_STRCASECMP(lstring.c_str(), rstring.c_str()); result = VL_STRCASECMP(lstring.c_str(), rstring.c_str());
} else { } else {
@ -1609,7 +1609,7 @@ V3Number& V3Number::opGtS(const V3Number& lhs, const V3Number& rhs) {
NUM_ASSERT_LOGIC_ARGS2(lhs, rhs); NUM_ASSERT_LOGIC_ARGS2(lhs, rhs);
char outc = 0; char outc = 0;
{ {
int mbit = std::max(lhs.width() - 1, rhs.width() - 1); const int mbit = std::max(lhs.width() - 1, rhs.width() - 1);
if (lhs.bitIsXZ(mbit)) { if (lhs.bitIsXZ(mbit)) {
outc = 'x'; outc = 'x';
} else if (rhs.bitIsXZ(mbit)) { } else if (rhs.bitIsXZ(mbit)) {
@ -1735,7 +1735,7 @@ V3Number& V3Number::opAdd(const V3Number& lhs, const V3Number& rhs) {
// Addem // Addem
int carry = 0; int carry = 0;
for (int bit = 0; bit < this->width(); bit++) { for (int bit = 0; bit < this->width(); bit++) {
int sum = ((lhs.bitIs1(bit) ? 1 : 0) + (rhs.bitIs1(bit) ? 1 : 0) + carry); const int sum = ((lhs.bitIs1(bit) ? 1 : 0) + (rhs.bitIs1(bit) ? 1 : 0) + carry);
if (sum & 1) setBit(bit, 1); if (sum & 1) setBit(bit, 1);
carry = (sum >= 2); carry = (sum >= 2);
} }
@ -1871,7 +1871,7 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
NUM_ASSERT_LOGIC_ARGS2(lhs, rhs); NUM_ASSERT_LOGIC_ARGS2(lhs, rhs);
setZero(); setZero();
// Find MSB and check for zero. // Find MSB and check for zero.
int words = lhs.words(); const int words = lhs.words();
int umsbp1 = lhs.mostSetBitP1(); // dividend int umsbp1 = lhs.mostSetBitP1(); // dividend
int vmsbp1 = rhs.mostSetBitP1(); // divisor int vmsbp1 = rhs.mostSetBitP1(); // divisor
if (VL_UNLIKELY(vmsbp1 == 0) // rwp==0 so division by zero. Return 0. if (VL_UNLIKELY(vmsbp1 == 0) // rwp==0 so division by zero. Return 0.
@ -1880,8 +1880,8 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
return *this; return *this;
} }
int uw = (umsbp1 + 31) / 32; // aka "m" in the algorithm const int uw = (umsbp1 + 31) / 32; // aka "m" in the algorithm
int vw = (vmsbp1 + 31) / 32; // aka "n" in the algorithm const int vw = (vmsbp1 + 31) / 32; // aka "n" in the algorithm
if (vw == 1) { // Single divisor word breaks rest of algorithm if (vw == 1) { // Single divisor word breaks rest of algorithm
vluint64_t k = 0; vluint64_t k = 0;
@ -2084,7 +2084,7 @@ V3Number& V3Number::opExtendS(const V3Number& lhs, uint32_t lbits) {
NUM_ASSERT_LOGIC_ARGS1(lhs); NUM_ASSERT_LOGIC_ARGS1(lhs);
setZero(); setZero();
for (int bit = 0; bit < width(); bit++) { for (int bit = 0; bit < width(); bit++) {
char extendWith = lhs.bitIsExtend(bit, lbits); const char extendWith = lhs.bitIsExtend(bit, lbits);
setBit(bit, extendWith); setBit(bit, extendWith);
} }
return *this; return *this;
@ -2170,7 +2170,7 @@ V3Number& V3Number::opIToRD(const V3Number& lhs, bool isSigned) {
V3Number noxz(lhs); V3Number noxz(lhs);
noxz.opAssignNonXZ(lhs); noxz.opAssignNonXZ(lhs);
double d = 0; double d = 0;
bool negate = isSigned && noxz.isNegative(); const bool negate = isSigned && noxz.isNegative();
if (negate) { if (negate) {
V3Number noxz_signed = noxz; V3Number noxz_signed = noxz;
noxz.opNegate(noxz_signed); noxz.opNegate(noxz_signed);
@ -2201,15 +2201,15 @@ V3Number& V3Number::opRToIRoundS(const V3Number& lhs) {
u.d = v; u.d = v;
if (u.d == 0.0) {} if (u.d == 0.0) {}
int exp = static_cast<int>((u.q >> 52ULL) & VL_MASK_Q(11)) - 1023; const int exp = static_cast<int>((u.q >> 52ULL) & VL_MASK_Q(11)) - 1023;
int lsb = exp - 52; const int lsb = exp - 52;
vluint64_t mantissa = (u.q & VL_MASK_Q(52)) | (1ULL << 52); vluint64_t mantissa = (u.q & VL_MASK_Q(52)) | (1ULL << 52);
if (v != 0) { if (v != 0) {
// IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa // IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa
// This does not need to support subnormals as they are sub-integral // This does not need to support subnormals as they are sub-integral
for (int bit = 0; bit <= 52; ++bit) { for (int bit = 0; bit <= 52; ++bit) {
if (mantissa & (1ULL << bit)) { if (mantissa & (1ULL << bit)) {
int outbit = bit + lsb; const int outbit = bit + lsb;
if (outbit >= 0) setBit(outbit, 1); if (outbit >= 0) setBit(outbit, 1);
} }
} }

View File

@ -34,7 +34,7 @@ void test(const string& lhss, const string& op, const string& rhss, const string
char* r1 = strdup(rhss.c_str()); char* r1 = strdup(rhss.c_str());
char* e1 = strdup(exps.c_str()); char* e1 = strdup(exps.c_str());
FileLine fl = new FileLine(FileLine::builtInFinename()); const FileLine fl = new FileLine(FileLine::builtInFinename());
V3Number lhnum(fl, l1); V3Number lhnum(fl, l1);
V3Number rhnum(fl, r1); V3Number rhnum(fl, r1);

View File

@ -116,7 +116,7 @@ V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbPartialMatchVal, void(const char*, cons
// Member functions of V3OptionParser // Member functions of V3OptionParser
V3OptionParser::ActionIfs* V3OptionParser::find(const char* optp) { V3OptionParser::ActionIfs* V3OptionParser::find(const char* optp) {
auto it = m_pimpl->m_options.find(optp); const auto it = m_pimpl->m_options.find(optp);
if (it != m_pimpl->m_options.end()) return it->second.get(); if (it != m_pimpl->m_options.end()) return it->second.get();
for (auto&& act : m_pimpl->m_options) { for (auto&& act : m_pimpl->m_options) {
if (act.second->isOnOffAllowed()) { // Find starts with "-no" if (act.second->isOnOffAllowed()) { // Find starts with "-no"
@ -218,7 +218,7 @@ V3OptionParser::ActionIfs&
V3OptionParser::AppendHelper::operator()(const char* optp, CbPartialMatch, V3OptionParser::AppendHelper::operator()(const char* optp, CbPartialMatch,
Impl::ActionCbPartialMatch::CbType cb) const { Impl::ActionCbPartialMatch::CbType cb) const {
const size_t prefixLen = std::strlen(optp); const size_t prefixLen = std::strlen(optp);
auto wrap = [prefixLen, cb](const char* optp) { cb(optp + prefixLen); }; const auto wrap = [prefixLen, cb](const char* optp) { cb(optp + prefixLen); };
return m_parser.add<Impl::ActionCbPartialMatch>(optp, std::move(wrap)); return m_parser.add<Impl::ActionCbPartialMatch>(optp, std::move(wrap));
} }

View File

@ -126,7 +126,7 @@ V3LangCode::V3LangCode(const char* textp) {
VTimescale::VTimescale(const string& value, bool& badr) VTimescale::VTimescale(const string& value, bool& badr)
: m_e{VTimescale::NONE} { : m_e{VTimescale::NONE} {
badr = true; badr = true;
string spaceless = VString::removeWhitespace(value); const string spaceless = VString::removeWhitespace(value);
for (int i = TS_100S; i < _ENUM_END; ++i) { for (int i = TS_100S; i < _ENUM_END; ++i) {
VTimescale ts(i); VTimescale ts(i);
if (spaceless == ts.ascii()) { if (spaceless == ts.ascii()) {
@ -339,7 +339,7 @@ bool V3Options::hasParameter(const string& name) {
} }
string V3Options::parameter(const string& name) { string V3Options::parameter(const string& name) {
string value = m_parameters.find(name)->second; const string value = m_parameters.find(name)->second;
m_parameters.erase(m_parameters.find(name)); m_parameters.erase(m_parameters.find(name));
return value; return value;
} }
@ -432,7 +432,7 @@ string V3Options::allArgsStringForHierBlock(bool forTop) const {
bool V3Options::fileStatNormal(const string& filename) { bool V3Options::fileStatNormal(const string& filename) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
struct stat sstat; // Stat information struct stat sstat; // Stat information
int err = stat(filename.c_str(), &sstat); const int err = stat(filename.c_str(), &sstat);
if (err != 0) return false; if (err != 0) return false;
if (S_ISDIR(sstat.st_mode)) return false; if (S_ISDIR(sstat.st_mode)) return false;
return true; return true;
@ -454,8 +454,8 @@ string V3Options::fileExists(const string& filename) {
// is quite slow; presumably because of re-reading each directory // is quite slow; presumably because of re-reading each directory
// many times. So we read a whole dir at once and cache it // many times. So we read a whole dir at once and cache it
string dir = V3Os::filenameDir(filename); const string dir = V3Os::filenameDir(filename);
string basename = V3Os::filenameNonDir(filename); const string basename = V3Os::filenameNonDir(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()) {
@ -477,14 +477,14 @@ string V3Options::fileExists(const string& filename) {
return ""; // Not found return ""; // Not found
} }
// Check if it is a directory, ignore if so // Check if it is a directory, ignore if so
string filenameOut = V3Os::filenameFromDirBase(dir, basename); const string filenameOut = V3Os::filenameFromDirBase(dir, basename);
if (!fileStatNormal(filenameOut)) return ""; // Directory if (!fileStatNormal(filenameOut)) return ""; // Directory
return filenameOut; return filenameOut;
} }
string V3Options::filePathCheckOneDir(const string& modname, const string& dirname) { string V3Options::filePathCheckOneDir(const string& modname, const string& dirname) {
for (const string& i : m_impp->m_libExtVs) { for (const string& i : m_impp->m_libExtVs) {
string fn = V3Os::filenameFromDirBase(dirname, modname + i); const string fn = V3Os::filenameFromDirBase(dirname, modname + i);
string exists = fileExists(fn); string exists = fileExists(fn);
if (exists != "") { if (exists != "") {
// Strip ./, it just looks ugly // Strip ./, it just looks ugly
@ -518,16 +518,16 @@ string V3Options::filePath(FileLine* fl, const string& modname, const string& la
// using the incdir and libext's. // using the incdir and libext's.
// Return "" if not found. // Return "" if not found.
for (const string& dir : m_impp->m_incDirUsers) { for (const string& dir : m_impp->m_incDirUsers) {
string exists = filePathCheckOneDir(modname, dir); const string exists = filePathCheckOneDir(modname, dir);
if (exists != "") return exists; if (exists != "") return exists;
} }
for (const string& dir : m_impp->m_incDirFallbacks) { for (const string& dir : m_impp->m_incDirFallbacks) {
string exists = filePathCheckOneDir(modname, dir); const string exists = filePathCheckOneDir(modname, dir);
if (exists != "") return exists; if (exists != "") return exists;
} }
if (m_relativeIncludes) { if (m_relativeIncludes) {
string exists = filePathCheckOneDir(modname, lastpath); const string exists = filePathCheckOneDir(modname, lastpath);
if (exists != "") return V3Os::filenameRealPath(exists); if (exists != "") return V3Os::filenameRealPath(exists);
} }
@ -554,13 +554,13 @@ void V3Options::filePathLookedMsg(FileLine* fl, const string& modname) {
std::cerr << V3Error::warnMore() << "... Looked in:" << endl; std::cerr << V3Error::warnMore() << "... Looked in:" << endl;
for (const string& dir : m_impp->m_incDirUsers) { for (const string& dir : m_impp->m_incDirUsers) {
for (const string& ext : m_impp->m_libExtVs) { for (const string& ext : m_impp->m_libExtVs) {
string fn = V3Os::filenameFromDirBase(dir, modname + ext); const string fn = V3Os::filenameFromDirBase(dir, modname + ext);
std::cerr << V3Error::warnMore() << " " << fn << endl; std::cerr << V3Error::warnMore() << " " << fn << endl;
} }
} }
for (const string& dir : m_impp->m_incDirFallbacks) { for (const string& dir : m_impp->m_incDirFallbacks) {
for (const string& ext : m_impp->m_libExtVs) { for (const string& ext : m_impp->m_libExtVs) {
string fn = V3Os::filenameFromDirBase(dir, modname + ext); const string fn = V3Os::filenameFromDirBase(dir, modname + ext);
std::cerr << V3Error::warnMore() << " " << fn << endl; std::cerr << V3Error::warnMore() << " " << fn << endl;
} }
} }
@ -633,16 +633,16 @@ string V3Options::getenvSYSTEMC_ARCH() {
if (var == "") { if (var == "") {
#if defined(__MINGW32__) #if defined(__MINGW32__)
// Hardcoded with MINGW current version. Would like a better way. // Hardcoded with MINGW current version. Would like a better way.
string sysname = "MINGW32_NT-5.0"; const string sysname = "MINGW32_NT-5.0";
var = "mingw32"; var = "mingw32";
#elif defined(_WIN32) #elif defined(_WIN32)
string sysname = "WIN32"; const string sysname = "WIN32";
var = "win32"; var = "win32";
#else #else
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
struct utsname uts; struct utsname uts;
uname(&uts); uname(&uts);
string sysname = VString::downcase(uts.sysname); // aka 'uname -s' const string sysname = VString::downcase(uts.sysname); // aka 'uname -s'
if (VL_UNCOVERABLE(VString::wildmatch(sysname.c_str(), "*solaris*"))) { if (VL_UNCOVERABLE(VString::wildmatch(sysname.c_str(), "*solaris*"))) {
var = "gccsparcOS5"; var = "gccsparcOS5";
} else if (VL_UNCOVERABLE(VString::wildmatch(sysname.c_str(), "*cygwin*"))) { } else if (VL_UNCOVERABLE(VString::wildmatch(sysname.c_str(), "*cygwin*"))) {
@ -663,7 +663,7 @@ string V3Options::getenvSYSTEMC_INCLUDE() {
V3Os::setenvStr("SYSTEMC_INCLUDE", var, "Hardcoded at build time"); V3Os::setenvStr("SYSTEMC_INCLUDE", var, "Hardcoded at build time");
} }
if (var == "") { if (var == "") {
string sc = getenvSYSTEMC(); const string sc = getenvSYSTEMC();
if (sc != "") var = sc + "/include"; if (sc != "") var = sc + "/include";
} }
return var; return var;
@ -676,8 +676,8 @@ string V3Options::getenvSYSTEMC_LIBDIR() {
V3Os::setenvStr("SYSTEMC_LIBDIR", var, "Hardcoded at build time"); V3Os::setenvStr("SYSTEMC_LIBDIR", var, "Hardcoded at build time");
} }
if (var == "") { if (var == "") {
string sc = getenvSYSTEMC(); const string sc = getenvSYSTEMC();
string arch = getenvSYSTEMC_ARCH(); const string arch = getenvSYSTEMC_ARCH();
if (sc != "" && arch != "") var = sc + "/lib-" + arch; if (sc != "" && arch != "") var = sc + "/lib-" + arch;
} }
return var; return var;
@ -899,7 +899,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
V3OptionParser::AppendHelper DECL_OPTION{parser}; V3OptionParser::AppendHelper DECL_OPTION{parser};
V3OPTION_PARSER_DECL_TAGS; V3OPTION_PARSER_DECL_TAGS;
auto callStrSetter = [this](void (V3Options::*cbStr)(const string&)) { const auto callStrSetter = [this](void (V3Options::*cbStr)(const string&)) {
return [this, cbStr](const string& v) { (this->*cbStr)(v); }; return [this, cbStr](const string& v) { (this->*cbStr)(v); };
}; };
// Usage // Usage
@ -1104,7 +1104,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
DECL_OPTION("-inline-mult", Set, &m_inlineMult); DECL_OPTION("-inline-mult", Set, &m_inlineMult);
DECL_OPTION("-LDFLAGS", CbVal, callStrSetter(&V3Options::addLdLibs)); DECL_OPTION("-LDFLAGS", CbVal, callStrSetter(&V3Options::addLdLibs));
auto setLang = [this, fl](const char* valp) { const auto setLang = [this, fl](const char* valp) {
V3LangCode optval = V3LangCode(valp); V3LangCode optval = V3LangCode(valp);
if (optval.legal()) { if (optval.legal()) {
m_defaultLanguage = optval; m_defaultLanguage = optval;
@ -1473,7 +1473,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
} }
} else { } else {
// Filename // Filename
string filename = parseFileArg(optdir, argv[i]); const string filename = parseFileArg(optdir, argv[i]);
if (suffixed(filename, ".cpp") // if (suffixed(filename, ".cpp") //
|| suffixed(filename, ".cxx") // || suffixed(filename, ".cxx") //
|| suffixed(filename, ".cc") // || suffixed(filename, ".cc") //
@ -1507,7 +1507,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
string whole_file; string whole_file;
bool inCmt = false; bool inCmt = false;
while (!ifp->eof()) { while (!ifp->eof()) {
string line = V3Os::getline(*ifp); const string line = V3Os::getline(*ifp);
// Strip simple comments // Strip simple comments
string oline; string oline;
// cppcheck-suppress StlMissingComparison // cppcheck-suppress StlMissingComparison
@ -1625,7 +1625,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
} }
// Path // Path
string optdir = (rel ? V3Os::filenameDir(filename) : "."); const string optdir = (rel ? V3Os::filenameDir(filename) : ".");
// Convert to argv style arg list and parse them // Convert to argv style arg list and parse them
std::vector<char*> argv; std::vector<char*> argv;
@ -1649,7 +1649,7 @@ string V3Options::parseFileArg(const string& optdir, const string& relfilename)
bool V3Options::parseLangExt(const char* swp, //!< argument text bool V3Options::parseLangExt(const char* swp, //!< argument text
const char* langswp, //!< option to match const char* langswp, //!< option to match
const V3LangCode& lc) { //!< language code const V3LangCode& lc) { //!< language code
int len = strlen(langswp); const int len = strlen(langswp);
if (!strncmp(swp, langswp, len)) { if (!strncmp(swp, langswp, len)) {
addLangExt(swp + len, lc); addLangExt(swp + len, lc);
return true; return true;
@ -1747,7 +1747,7 @@ void V3Options::setDebugSrcLevel(const string& srcfile, int level) {
int V3Options::debugSrcLevel(const string& srcfile_path, int default_level) { int V3Options::debugSrcLevel(const string& srcfile_path, int default_level) {
// For simplicity, calling functions can just use __FILE__ for srcfile. // For simplicity, calling functions can just use __FILE__ for srcfile.
// That means though we need to cleanup the filename from ../Foo.cpp -> Foo // That means though we need to cleanup the filename from ../Foo.cpp -> Foo
string srcfile = V3Os::filenameNonDirExt(srcfile_path); const string srcfile = V3Os::filenameNonDirExt(srcfile_path);
const auto iter = m_debugSrcs.find(srcfile); const auto iter = m_debugSrcs.find(srcfile);
if (iter != m_debugSrcs.end()) { if (iter != m_debugSrcs.end()) {
return iter->second; return iter->second;
@ -1768,7 +1768,7 @@ void V3Options::setDumpTreeLevel(const string& srcfile, int level) {
int V3Options::dumpTreeLevel(const string& srcfile_path) { int V3Options::dumpTreeLevel(const string& srcfile_path) {
// For simplicity, calling functions can just use __FILE__ for srcfile. // For simplicity, calling functions can just use __FILE__ for srcfile.
// That means though we need to cleanup the filename from ../Foo.cpp -> Foo // That means though we need to cleanup the filename from ../Foo.cpp -> Foo
string srcfile = V3Os::filenameNonDirExt(srcfile_path); const string srcfile = V3Os::filenameNonDirExt(srcfile_path);
const auto iter = m_dumpTrees.find(srcfile); const auto iter = m_dumpTrees.find(srcfile);
if (iter != m_dumpTrees.end()) { if (iter != m_dumpTrees.end()) {
return iter->second; return iter->second;
@ -1779,7 +1779,7 @@ int V3Options::dumpTreeLevel(const string& srcfile_path) {
void V3Options::optimize(int level) { void V3Options::optimize(int level) {
// Set all optimizations to on/off // Set all optimizations to on/off
bool flag = level > 0; const bool flag = level > 0;
m_oAcycSimp = flag; m_oAcycSimp = flag;
m_oAssemble = flag; m_oAssemble = flag;
m_oCase = flag; m_oCase = flag;

View File

@ -322,9 +322,9 @@ private:
virtual void visit(AstConcat* nodep) override { virtual void visit(AstConcat* nodep) override {
if (m_inAss) { if (m_inAss) {
iterateAndNextNull(nodep->lhsp()); iterateAndNextNull(nodep->lhsp());
int lw = m_childClkWidth; const int lw = m_childClkWidth;
iterateAndNextNull(nodep->rhsp()); iterateAndNextNull(nodep->rhsp());
int rw = m_childClkWidth; const int rw = m_childClkWidth;
m_childClkWidth = lw + rw; // Pass up m_childClkWidth = lw + rw; // Pass up
} }
} }
@ -502,7 +502,7 @@ private:
if (edgep->weight() == 0) { // Was cut if (edgep->weight() == 0) { // Was cut
continue; continue;
} }
int weight = edgep->weight(); const int weight = edgep->weight();
if (const OrderLogicVertex* toLVertexp if (const OrderLogicVertex* toLVertexp
= dynamic_cast<const OrderLogicVertex*>(edgep->top())) { = dynamic_cast<const OrderLogicVertex*>(edgep->top())) {
@ -758,7 +758,7 @@ private:
string cfuncName(AstNodeModule* modp, AstSenTree* domainp, AstScope* scopep, string cfuncName(AstNodeModule* modp, AstSenTree* domainp, AstScope* scopep,
AstNode* forWhatp) { AstNode* forWhatp) {
modp->user3Inc(); modp->user3Inc();
int funcnum = modp->user3(); const int funcnum = modp->user3();
string name = (domainp->hasCombo() string name = (domainp->hasCombo()
? "_combo" ? "_combo"
: (domainp->hasInitial() : (domainp->hasInitial()
@ -805,7 +805,7 @@ private:
nodep->fileline()->modifyWarnOff(V3ErrorCode::UNOPT, nodep->fileline()->modifyWarnOff(V3ErrorCode::UNOPT,
true); // Complain just once true); // Complain just once
// Give the user an example. // Give the user an example.
bool tempWeight = (edgep && edgep->weight() == 0); const bool tempWeight = (edgep && edgep->weight() == 0);
// Else the below loop detect can't see the loop // Else the below loop detect can't see the loop
if (tempWeight) edgep->weight(1); if (tempWeight) edgep->weight(1);
// Calls OrderGraph::loopsVertexCb // Calls OrderGraph::loopsVertexCb
@ -824,7 +824,7 @@ private:
nodep->fileline()->modifyWarnOff(V3ErrorCode::UNOPTFLAT, nodep->fileline()->modifyWarnOff(V3ErrorCode::UNOPTFLAT,
true); // Complain just once true); // Complain just once
// Give the user an example. // Give the user an example.
bool tempWeight = (edgep && edgep->weight() == 0); const bool tempWeight = (edgep && edgep->weight() == 0);
// Else the below loop detect can't see the loop // Else the below loop detect can't see the loop
if (tempWeight) edgep->weight(1); if (tempWeight) edgep->weight(1);
// Calls OrderGraph::loopsVertexCb // Calls OrderGraph::loopsVertexCb
@ -914,7 +914,7 @@ private:
// Only reporting on standard variable vertices // Only reporting on standard variable vertices
AstVar* varp = vsvertexp->varScp()->varp(); AstVar* varp = vsvertexp->varScp()->varp();
if (!varp->user3()) { if (!varp->user3()) {
string name = varp->prettyName(); const string name = varp->prettyName();
if ((varp->width() != 1) && (name.find("__Vdly") == string::npos) if ((varp->width() != 1) && (name.find("__Vdly") == string::npos)
&& (name.find("__Vcell") == string::npos)) { && (name.find("__Vcell") == string::npos)) {
// Variable to report on and not yet done // Variable to report on and not yet done
@ -1221,7 +1221,7 @@ public:
virtual ~OrderVisitor() override { virtual ~OrderVisitor() override {
// Stats // Stats
for (int type = 0; type < OrderVEdgeType::_ENUM_END; type++) { for (int type = 0; type < OrderVEdgeType::_ENUM_END; type++) {
double count = double(m_statCut[type]); const double count = double(m_statCut[type]);
if (count != 0.0) { if (count != 0.0) {
V3Stats::addStat(string("Order, cut, ") + OrderVEdgeType(type).ascii(), count); V3Stats::addStat(string("Order, cut, ") + OrderVEdgeType(type).ascii(), count);
} }
@ -1250,8 +1250,8 @@ static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) {
// //
// ... unless you know more about A and B, which sounds hard. // ... unless you know more about A and B, which sounds hard.
bool toInitial = top->hasInitial() || top->hasSettle(); const bool toInitial = top->hasInitial() || top->hasSettle();
bool fromInitial = fromp->hasInitial() || fromp->hasSettle(); const bool fromInitial = fromp->hasInitial() || fromp->hasSettle();
if (toInitial != fromInitial) return true; if (toInitial != fromInitial) return true;
const AstSenItem* fromSenListp = VN_CAST(fromp->sensesp(), SenItem); const AstSenItem* fromSenListp = VN_CAST(fromp->sensesp(), SenItem);
@ -1492,7 +1492,7 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) {
// Ignore that we have a constant (initial) input // Ignore that we have a constant (initial) input
} else if (domainp != fromVertexp->domainp()) { } else if (domainp != fromVertexp->domainp()) {
// Make a domain that merges the two domains // Make a domain that merges the two domains
bool ddebug = debug() >= 9; const bool ddebug = debug() >= 9;
if (ddebug) { // LCOV_EXCL_START if (ddebug) { // LCOV_EXCL_START
@ -1544,7 +1544,7 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) {
void OrderVisitor::processEdgeReport() { void OrderVisitor::processEdgeReport() {
// Make report of all signal names and what clock edges they have // Make report of all signal names and what clock edges they have
string filename = v3Global.debugFilename("order_edges.txt"); const string filename = v3Global.debugFilename("order_edges.txt");
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename)); const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
if (logp->fail()) v3fatal("Can't write " << filename); if (logp->fail()) v3fatal("Can't write " << filename);
// Testing emitter: V3EmitV::verilogForTree(v3Global.rootp(), *logp); // Testing emitter: V3EmitV::verilogForTree(v3Global.rootp(), *logp);
@ -1850,7 +1850,7 @@ void OrderVisitor::processMTasks() {
const V3GraphVertex* moveVxp; const V3GraphVertex* moveVxp;
while ((moveVxp = emit_logic.nextp())) { while ((moveVxp = emit_logic.nextp())) {
const MTaskMoveVertex* movep = dynamic_cast<const MTaskMoveVertex*>(moveVxp); const MTaskMoveVertex* movep = dynamic_cast<const MTaskMoveVertex*>(moveVxp);
unsigned mtaskId = movep->color(); const unsigned mtaskId = movep->color();
UASSERT(mtaskId > 0, "Every MTaskMoveVertex should have an mtask assignment >0"); UASSERT(mtaskId > 0, "Every MTaskMoveVertex should have an mtask assignment >0");
if (movep->logicp()) { if (movep->logicp()) {
// Add this logic to the per-mtask order // Add this logic to the per-mtask order
@ -2003,7 +2003,8 @@ void OrderVisitor::process() {
// Dump data // Dump data
m_graph.dumpDotFilePrefixed("orderg_done"); m_graph.dumpDotFilePrefixed("orderg_done");
if (false && debug()) { if (false && debug()) {
string dfilename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_INT_order"; const string dfilename
= v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_INT_order";
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(dfilename)); const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(dfilename));
if (logp->fail()) v3fatal("Can't write " << dfilename); if (logp->fail()) v3fatal("Can't write " << dfilename);
m_graph.dump(*logp); m_graph.dump(*logp);

View File

@ -103,7 +103,7 @@ void V3Os::setenvStr(const string& envvar, const string& value, const string& wh
#else #else
// setenv() replaced by putenv() in Solaris environment. Prototype is different // setenv() replaced by putenv() in Solaris environment. Prototype is different
// putenv() requires NAME=VALUE format // putenv() requires NAME=VALUE format
string vareq = envvar + "=" + value; const string vareq = envvar + "=" + value;
putenv(const_cast<char*>(vareq.c_str())); putenv(const_cast<char*>(vareq.c_str()));
#endif #endif
} }
@ -168,7 +168,7 @@ string V3Os::filenameSubstitute(const string& filename) {
|| ((brackets == PAREN) && (filename[endpos + 1] != ')'))) { || ((brackets == PAREN) && (filename[endpos + 1] != ')'))) {
v3fatal("Unmatched brackets in variable substitution in file: " + filename); v3fatal("Unmatched brackets in variable substitution in file: " + filename);
} }
string envvar = filename.substr(pos + 1, endpos - pos); const string envvar = filename.substr(pos + 1, endpos - pos);
string envvalue; string envvalue;
if (!envvar.empty()) envvalue = getenvStr(envvar, ""); if (!envvar.empty()) envvalue = getenvStr(envvar, "");
if (!envvalue.empty()) { if (!envvalue.empty()) {
@ -239,7 +239,7 @@ void V3Os::unlinkRegexp(const string& dir, const string& regexp) {
if (DIR* dirp = opendir(dir.c_str())) { if (DIR* dirp = opendir(dir.c_str())) {
while (struct dirent* direntp = readdir(dirp)) { while (struct dirent* direntp = readdir(dirp)) {
if (VString::wildmatch(direntp->d_name, regexp.c_str())) { if (VString::wildmatch(direntp->d_name, regexp.c_str())) {
string fullname = dir + "/" + string(direntp->d_name); const string fullname = dir + "/" + string(direntp->d_name);
#if defined(_WIN32) || defined(__MINGW32__) #if defined(_WIN32) || defined(__MINGW32__)
_unlink(fullname.c_str()); _unlink(fullname.c_str());
#else #else
@ -269,7 +269,7 @@ string V3Os::trueRandom(size_t size) {
// Note: std::string.data() returns a non-const Char* from C++17 onwards. // Note: std::string.data() returns a non-const Char* from C++17 onwards.
// For pre-C++17, this cast is OK in practice, even though it's UB. // For pre-C++17, this cast is OK in practice, even though it's UB.
#if defined(_WIN32) || defined(__MINGW32__) #if defined(_WIN32) || defined(__MINGW32__)
NTSTATUS hr = BCryptGenRandom(nullptr, reinterpret_cast<BYTE*>(data), size, const NTSTATUS hr = BCryptGenRandom(nullptr, reinterpret_cast<BYTE*>(data), size,
BCRYPT_USE_SYSTEM_PREFERRED_RNG); BCRYPT_USE_SYSTEM_PREFERRED_RNG);
if (!BCRYPT_SUCCESS(hr)) v3fatal("Could not acquire random data."); if (!BCRYPT_SUCCESS(hr)) v3fatal("Could not acquire random data.");
#else #else
@ -307,7 +307,7 @@ uint64_t V3Os::timeUsecs() {
uint64_t V3Os::memUsageBytes() { uint64_t V3Os::memUsageBytes() {
#if defined(_WIN32) || defined(__MINGW32__) #if defined(_WIN32) || defined(__MINGW32__)
HANDLE process = GetCurrentProcess(); const HANDLE process = GetCurrentProcess();
PROCESS_MEMORY_COUNTERS pmc; PROCESS_MEMORY_COUNTERS pmc;
if (GetProcessMemoryInfo(process, &pmc, sizeof(pmc))) { if (GetProcessMemoryInfo(process, &pmc, sizeof(pmc))) {
// The best we can do using simple Windows APIs is to get the size of the working set. // The best we can do using simple Windows APIs is to get the size of the working set.
@ -320,9 +320,9 @@ uint64_t V3Os::memUsageBytes() {
FILE* fp = fopen(statmFilename, "r"); FILE* fp = fopen(statmFilename, "r");
if (!fp) return 0; if (!fp) return 0;
vluint64_t size, resident, share, text, lib, data, dt; // All in pages vluint64_t size, resident, share, text, lib, data, dt; // All in pages
int items = fscanf(fp, const int items = fscanf(fp,
"%" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "%" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64
"u %" VL_PRI64 "u %" VL_PRI64 "u", "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u",
&size, &resident, &share, &text, &lib, &data, &dt); &size, &resident, &share, &text, &lib, &data, &dt);
fclose(fp); fclose(fp);
if (VL_UNCOVERABLE(7 != items)) return 0; if (VL_UNCOVERABLE(7 != items)) return 0;

View File

@ -282,7 +282,7 @@ class ParamProcessor final {
usedLetter[static_cast<int>(ch)]++; usedLetter[static_cast<int>(ch)]++;
} }
} else if (AstParamTypeDType* typep = VN_CAST(stmtp, ParamTypeDType)) { } else if (AstParamTypeDType* typep = VN_CAST(stmtp, ParamTypeDType)) {
char ch = 'T'; const char ch = 'T';
typep->user4(usedLetter[static_cast<int>(ch)] * 256 + ch); typep->user4(usedLetter[static_cast<int>(ch)] * 256 + ch);
usedLetter[static_cast<int>(ch)]++; usedLetter[static_cast<int>(ch)]++;
} }
@ -291,7 +291,7 @@ class ParamProcessor final {
string paramSmallName(AstNodeModule* modp, AstNode* varp) { string paramSmallName(AstNodeModule* modp, AstNode* varp) {
if (varp->user4() <= 1) makeSmallNames(modp); if (varp->user4() <= 1) makeSmallNames(modp);
int index = varp->user4() / 256; int index = varp->user4() / 256;
char ch = varp->user4() & 255; const char ch = varp->user4() & 255;
string st = cvtToStr(ch); string st = cvtToStr(ch);
while (index) { while (index) {
st += cvtToStr(char((index % 25) + 'A')); st += cvtToStr(char((index % 25) + 'A'));
@ -477,7 +477,7 @@ class ParamProcessor final {
string longname = modp->name(); string longname = modp->name();
for (auto&& defaultValue : paramsIt->second) { for (auto&& defaultValue : paramsIt->second) {
auto pinIt = pins.find(defaultValue.first); const auto pinIt = pins.find(defaultValue.first);
AstConst* constp = pinIt == pins.end() ? defaultValue.second : pinIt->second; AstConst* constp = pinIt == pins.end() ? defaultValue.second : pinIt->second;
// This longname is not valid as verilog symbol, but ok, because it will be hashed // This longname is not valid as verilog symbol, but ok, because it will be hashed
longname += "_" + defaultValue.first + "="; longname += "_" + defaultValue.first + "=";
@ -485,7 +485,7 @@ class ParamProcessor final {
if (constp) longname += constp->num().ascii(false); if (constp) longname += constp->num().ascii(false);
} }
auto iter = m_longMap.find(longname); const auto iter = m_longMap.find(longname);
if (iter != m_longMap.end()) return iter->second; // Already calculated if (iter != m_longMap.end()) return iter->second; // Already calculated
VHashSha256 hash; VHashSha256 hash;
@ -538,7 +538,7 @@ class ParamProcessor final {
insertp->addNextHere(newmodp); insertp->addNextHere(newmodp);
m_modNameMap.emplace(newmodp->name(), ModInfo(newmodp)); m_modNameMap.emplace(newmodp->name(), ModInfo(newmodp));
auto iter = m_modNameMap.find(newname); const 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);
@ -773,7 +773,8 @@ public:
// We need to relink the pins to the new module // We need to relink the pins to the new module
relinkPinsByName(nodep->pinsp(), paramedModp); relinkPinsByName(nodep->pinsp(), paramedModp);
} else { } else {
string newname = srcModp->hierBlock() ? longname : moduleCalcName(srcModp, longname); const string newname
= srcModp->hierBlock() ? longname : moduleCalcName(srcModp, longname);
const ModInfo* modInfop const ModInfo* modInfop
= moduleFindOrClone(srcModp, nodep, nodep->paramsp(), newname, ifaceRefRefs); = moduleFindOrClone(srcModp, nodep, nodep->paramsp(), newname, ifaceRefRefs);
// Have child use this module instead. // Have child use this module instead.
@ -980,7 +981,7 @@ class ParamVisitor final : public AstNVisitor {
} }
virtual void visit(AstVarXRef* nodep) override { virtual void visit(AstVarXRef* nodep) override {
// Check to see if the scope is just an interface because interfaces are special // Check to see if the scope is just an interface because interfaces are special
string dotted = nodep->dotted(); const string dotted = nodep->dotted();
if (!dotted.empty() && nodep->varp() && nodep->varp()->isParam()) { if (!dotted.empty() && nodep->varp() && nodep->varp()->isParam()) {
AstNode* backp = nodep; AstNode* backp = nodep;
while ((backp = backp->backp())) { while ((backp = backp->backp())) {
@ -1048,9 +1049,9 @@ class ParamVisitor final : public AstNVisitor {
virtual void visit(AstCellArrayRef* nodep) override { virtual void visit(AstCellArrayRef* nodep) override {
V3Const::constifyParamsEdit(nodep->selp()); V3Const::constifyParamsEdit(nodep->selp());
if (const AstConst* constp = VN_CAST(nodep->selp(), Const)) { if (const AstConst* constp = VN_CAST(nodep->selp(), Const)) {
string index = AstNode::encodeNumber(constp->toSInt()); const string index = AstNode::encodeNumber(constp->toSInt());
string replacestr = nodep->name() + "__BRA__??__KET__"; const string replacestr = nodep->name() + "__BRA__??__KET__";
size_t pos = m_unlinkedTxt.find(replacestr); const size_t pos = m_unlinkedTxt.find(replacestr);
UASSERT_OBJ(pos != string::npos, nodep, UASSERT_OBJ(pos != string::npos, nodep,
"Could not find array index in unlinked text: '" "Could not find array index in unlinked text: '"
<< m_unlinkedTxt << "' for node: " << nodep); << m_unlinkedTxt << "' for node: " << nodep);
@ -1105,7 +1106,7 @@ class ParamVisitor final : public AstNVisitor {
// doesn't conflict in V3LinkDot resolution with other genvars // doesn't conflict in V3LinkDot resolution with other genvars
// Now though we need to change BEGIN("zzz", GENFOR(...)) to // Now though we need to change BEGIN("zzz", GENFOR(...)) to
// a BEGIN("zzz__BRA__{loop#}__KET__") // a BEGIN("zzz__BRA__{loop#}__KET__")
string beginName = nodep->name(); const string beginName = nodep->name();
// Leave the original Begin, as need a container for the (possible) GENVAR // Leave the original Begin, as need a container for the (possible) GENVAR
// Note V3Unroll will replace some AstVarRef's to the loop variable with constants // Note V3Unroll will replace some AstVarRef's to the loop variable with constants
// Don't remove any deleted nodes in m_unroller until whole process finishes, // Don't remove any deleted nodes in m_unroller until whole process finishes,

View File

@ -165,11 +165,11 @@ void V3ParseImp::lexErrorPreprocDirective(FileLine* fl, const char* textp) {
VSpellCheck speller; VSpellCheck speller;
for (V3LanguageWords::const_iterator it = V3LanguageWords::begin(); for (V3LanguageWords::const_iterator it = V3LanguageWords::begin();
it != V3LanguageWords::end(); ++it) { it != V3LanguageWords::end(); ++it) {
string ppDirective = it->first; const string ppDirective = it->first;
if (ppDirective[0] == '`') speller.pushCandidate(ppDirective); if (ppDirective[0] == '`') speller.pushCandidate(ppDirective);
} }
V3PreShell::candidateDefines(&speller); V3PreShell::candidateDefines(&speller);
string suggest = speller.bestCandidateMsg(textp); const string suggest = speller.bestCandidateMsg(textp);
fl->v3error("Define or directive not defined: '" fl->v3error("Define or directive not defined: '"
<< textp << "'\n" << textp << "'\n"
<< (suggest.empty() ? "" : fl->warnMore() + suggest)); << (suggest.empty() ? "" : fl->warnMore() + suggest));
@ -183,7 +183,7 @@ string V3ParseImp::lexParseTag(const char* textp) {
} }
double V3ParseImp::lexParseTimenum(const char* textp) { double V3ParseImp::lexParseTimenum(const char* textp) {
size_t length = strlen(textp); const size_t length = strlen(textp);
char* strgp = new char[length + 1]; char* strgp = new char[length + 1];
char* dp = strgp; char* dp = strgp;
const char* sp = textp; const char* sp = textp;
@ -227,7 +227,7 @@ size_t V3ParseImp::ppInputToLex(char* buf, size_t max_size) {
m_ppBuffers.pop_front(); m_ppBuffers.pop_front();
size_t len = front.length(); size_t len = front.length();
if (len > (max_size - got)) { // Front string too big if (len > (max_size - got)) { // Front string too big
string remainder = front.substr(max_size - got); const string remainder = front.substr(max_size - got);
front = front.substr(0, max_size - got); front = front.substr(0, max_size - got);
m_ppBuffers.push_front(remainder); // Put back remainder for next time m_ppBuffers.push_front(remainder); // Put back remainder for next time
len = (max_size - got); len = (max_size - got);
@ -236,7 +236,7 @@ size_t V3ParseImp::ppInputToLex(char* buf, size_t max_size) {
got += len; got += len;
} }
if (debug() >= 9) { if (debug() >= 9) {
string out = string(buf, got); const string out = string(buf, got);
cout << " inputToLex got=" << got << " '" << out << "'" << endl; cout << " inputToLex got=" << got << " '" << out << "'" << endl;
} }
// Note returns 0 at EOF // Note returns 0 at EOF
@ -247,7 +247,7 @@ void V3ParseImp::preprocDumps(std::ostream& os) {
if (v3Global.opt.dumpDefines()) { if (v3Global.opt.dumpDefines()) {
V3PreShell::dumpDefines(os); V3PreShell::dumpDefines(os);
} else { } else {
bool noblanks = v3Global.opt.preprocOnly() && v3Global.opt.preprocNoLine(); const bool noblanks = v3Global.opt.preprocOnly() && v3Global.opt.preprocNoLine();
for (auto& buf : m_ppBuffers) { for (auto& buf : m_ppBuffers) {
if (noblanks) { if (noblanks) {
bool blank = true; bool blank = true;
@ -266,7 +266,7 @@ void V3ParseImp::preprocDumps(std::ostream& os) {
void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool inLibrary, void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool inLibrary,
const string& errmsg) { // "" for no error, make fake node const string& errmsg) { // "" for no error, make fake node
string modname = V3Os::filenameNonExt(modfilename); const string modname = V3Os::filenameNonExt(modfilename);
UINFO(2, __FUNCTION__ << ": " << modname << (inLibrary ? " [LIB]" : "") << endl); UINFO(2, __FUNCTION__ << ": " << modname << (inLibrary ? " [LIB]" : "") << endl);
m_lexFileline = new FileLine(fileline); m_lexFileline = new FileLine(fileline);
@ -275,7 +275,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
m_inLibrary = inLibrary; m_inLibrary = inLibrary;
// Preprocess into m_ppBuffer // Preprocess into m_ppBuffer
bool ok = V3PreShell::preproc(fileline, modfilename, m_filterp, this, errmsg); const bool ok = V3PreShell::preproc(fileline, modfilename, m_filterp, this, errmsg);
if (!ok) { if (!ok) {
if (errmsg != "") return; // Threw error already if (errmsg != "") return; // Threw error already
// Create fake node for later error reporting // Create fake node for later error reporting
@ -351,7 +351,7 @@ size_t V3ParseImp::tokenPipeScanParam(size_t depth) {
depth += 2; // Past the ( depth += 2; // Past the (
int parens = 1; // Count first ( int parens = 1; // Count first (
while (true) { while (true) {
int tok = tokenPeekp(depth)->token; const int tok = tokenPeekp(depth)->token;
if (tok == 0) { if (tok == 0) {
UINFO(9, "tokenPipeScanParam hit EOF; probably syntax error to come"); UINFO(9, "tokenPipeScanParam hit EOF; probably syntax error to come");
break; break;
@ -392,7 +392,7 @@ void V3ParseImp::tokenPipeline() {
} }
V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead
const V3ParseBisonYYSType* nexttokp = tokenPeekp(0); const V3ParseBisonYYSType* nexttokp = tokenPeekp(0);
int nexttok = nexttokp->token; const int nexttok = nexttokp->token;
yylval = curValue; yylval = curValue;
// Now potentially munge the current token // Now potentially munge the current token
if (token == '(' if (token == '('
@ -467,7 +467,7 @@ void V3ParseImp::tokenPipeline() {
} else if (nexttok == '#') { } else if (nexttok == '#') {
V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead
{ {
size_t depth = tokenPipeScanParam(0); const size_t depth = tokenPipeScanParam(0);
if (tokenPeekp(depth)->token == yP_COLONCOLON) token = yaID__CC; if (tokenPeekp(depth)->token == yP_COLONCOLON) token = yaID__CC;
} }
yylval = curValue; yylval = curValue;

View File

@ -53,7 +53,7 @@ void V3ParseImp::lexUnputString(const char* textp, size_t length) {
void V3ParseImp::yylexReadTok() { void V3ParseImp::yylexReadTok() {
// Call yylex() remembering last non-whitespace token // Call yylex() remembering last non-whitespace token
parsep()->lexFileline()->startToken(); parsep()->lexFileline()->startToken();
int token = parsep()->m_lexerp->yylex(); const int token = parsep()->m_lexerp->yylex();
m_lexPrevToken = token; // Save so can find '#' to parse following number m_lexPrevToken = token; // Save so can find '#' to parse following number
yylval.token = token; yylval.token = token;
} }

View File

@ -622,7 +622,7 @@ public:
} }
static void dumpCpFilePrefixed(const V3Graph* graphp, const string& nameComment) { static void dumpCpFilePrefixed(const V3Graph* graphp, const string& nameComment) {
string filename = v3Global.debugFilename(nameComment) + ".txt"; const string filename = v3Global.debugFilename(nameComment) + ".txt";
UINFO(1, "Writing " << filename << endl); UINFO(1, "Writing " << filename << endl);
std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename)); std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename));
std::ostream* osp = &(*ofp); // &* needed to deref unique_ptr std::ostream* osp = &(*ofp); // &* needed to deref unique_ptr
@ -901,7 +901,7 @@ private:
// vertex. // vertex.
static void partInitHalfCriticalPaths(GraphWay way, V3Graph* mtasksp, bool checkOnly) { static void partInitHalfCriticalPaths(GraphWay way, V3Graph* mtasksp, bool checkOnly) {
GraphStreamUnordered order(mtasksp, way); GraphStreamUnordered order(mtasksp, way);
GraphWay rev = way.invert(); const GraphWay rev = way.invert();
for (const V3GraphVertex* vertexp; (vertexp = order.nextp());) { for (const V3GraphVertex* vertexp; (vertexp = order.nextp());) {
const LogicMTask* mtaskcp = dynamic_cast<const LogicMTask*>(vertexp); const LogicMTask* mtaskcp = dynamic_cast<const LogicMTask*>(vertexp);
LogicMTask* mtaskp = const_cast<LogicMTask*>(mtaskcp); LogicMTask* mtaskp = const_cast<LogicMTask*>(mtaskcp);
@ -997,7 +997,7 @@ static V3GraphEdge* partBlastEdgep(GraphWay way, V3GraphEdge* edgep) {
static void partMergeEdgesFrom(V3Graph* mtasksp, LogicMTask* recipientp, LogicMTask* donorp, static void partMergeEdgesFrom(V3Graph* mtasksp, LogicMTask* recipientp, LogicMTask* donorp,
V3Scoreboard<MergeCandidate, uint32_t>* sbp) { V3Scoreboard<MergeCandidate, uint32_t>* sbp) {
for (unsigned wi = 0; wi < 2; ++wi) { for (unsigned wi = 0; wi < 2; ++wi) {
GraphWay way = wi ? GraphWay::REVERSE : GraphWay::FORWARD; const GraphWay way = wi ? GraphWay::REVERSE : GraphWay::FORWARD;
for (V3GraphEdge* edgep = donorp->beginp(way); edgep; edgep = partBlastEdgep(way, edgep)) { for (V3GraphEdge* edgep = donorp->beginp(way); edgep; edgep = partBlastEdgep(way, edgep)) {
MTaskEdge* tedgep = MTaskEdge::cast(edgep); MTaskEdge* tedgep = MTaskEdge::cast(edgep);
if (sbp && !tedgep->removedFromSb()) sbp->removeElem(tedgep); if (sbp && !tedgep->removedFromSb()) sbp->removeElem(tedgep);
@ -1252,7 +1252,7 @@ private:
erased = m_pairs.erase(*pairp); erased = m_pairs.erase(*pairp);
UASSERT_OBJ(erased > 0, mtaskp, "Expected existing mtask"); UASSERT_OBJ(erased > 0, mtaskp, "Expected existing mtask");
} }
size_t erased = m_mtask2sibs.erase(mtaskp); const size_t erased = m_mtask2sibs.erase(mtaskp);
UASSERT_OBJ(erased > 0, mtaskp, "Expected existing mtask"); UASSERT_OBJ(erased > 0, mtaskp, "Expected existing mtask");
} }
@ -1297,10 +1297,10 @@ private:
// //
// These 'NewCp' objects carry a bit indicating whether we must // These 'NewCp' objects carry a bit indicating whether we must
// propagate CP for each of the four cases: // propagate CP for each of the four cases:
NewCp recipientNewCpFwd = newCp(GraphWay::FORWARD, recipientp, donorp, mergeEdgep); const NewCp recipientNewCpFwd = newCp(GraphWay::FORWARD, recipientp, donorp, mergeEdgep);
NewCp donorNewCpFwd = newCp(GraphWay::FORWARD, donorp, recipientp, mergeEdgep); const NewCp donorNewCpFwd = newCp(GraphWay::FORWARD, donorp, recipientp, mergeEdgep);
NewCp recipientNewCpRev = newCp(GraphWay::REVERSE, recipientp, donorp, mergeEdgep); const NewCp recipientNewCpRev = newCp(GraphWay::REVERSE, recipientp, donorp, mergeEdgep);
NewCp donorNewCpRev = newCp(GraphWay::REVERSE, donorp, recipientp, mergeEdgep); const NewCp donorNewCpRev = newCp(GraphWay::REVERSE, donorp, recipientp, mergeEdgep);
if (mergeEdgep) { if (mergeEdgep) {
// Remove and free the connecting edge. Must do this before // Remove and free the connecting edge. Must do this before
@ -2456,7 +2456,7 @@ void V3Partition::go(V3Graph* mtasksp) {
// remove this later if it doesn't really help. // remove this later if it doesn't really help.
mtasksp->orderPreRanked(); mtasksp->orderPreRanked();
int targetParFactor = v3Global.opt.threads(); const int targetParFactor = v3Global.opt.threads();
if (targetParFactor < 2) v3fatalSrc("We should not reach V3Partition when --threads <= 1"); if (targetParFactor < 2) v3fatalSrc("We should not reach V3Partition when --threads <= 1");
// Set cpLimit to roughly totalGraphCost / nThreads // Set cpLimit to roughly totalGraphCost / nThreads
@ -2464,8 +2464,8 @@ void V3Partition::go(V3Graph* mtasksp) {
// Actually set it a bit lower, by a hardcoded fudge factor. This // Actually set it a bit lower, by a hardcoded fudge factor. This
// results in more smaller mtasks, which helps reduce fragmentation // results in more smaller mtasks, which helps reduce fragmentation
// when scheduling them. // when scheduling them.
unsigned fudgeNumerator = 3; const unsigned fudgeNumerator = 3;
unsigned fudgeDenominator = 5; const unsigned fudgeDenominator = 5;
uint32_t cpLimit = ((totalGraphCost * fudgeNumerator) / (targetParFactor * fudgeDenominator)); uint32_t cpLimit = ((totalGraphCost * fudgeNumerator) / (targetParFactor * fudgeDenominator));
UINFO(4, "V3Partition set cpLimit = " << cpLimit << endl); UINFO(4, "V3Partition set cpLimit = " << cpLimit << endl);

View File

@ -550,7 +550,7 @@ void V3PreProcImp::unputString(const string& strg) {
} }
void V3PreProcImp::unputDefrefString(const string& strg) { void V3PreProcImp::unputDefrefString(const string& strg) {
int multiline = std::count(strg.begin(), strg.end(), '\n'); const int multiline = std::count(strg.begin(), strg.end(), '\n');
unputString(strg); unputString(strg);
// A define that inserts multiple newlines are really attributed to one source line, // A define that inserts multiple newlines are really attributed to one source line,
// so temporarily don't increment lineno. // so temporarily don't increment lineno.
@ -591,7 +591,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
UINFO(4, "defineArg[" << i << "] = '" << refp->args()[i] << "'" << endl); UINFO(4, "defineArg[" << i << "] = '" << refp->args()[i] << "'" << endl);
} }
// Grab value // Grab value
string value = defValue(refp->name()); const string value = defValue(refp->name());
UINFO(4, "defineValue '" << V3PreLex::cleanDbgStrg(value) << "'" << endl); UINFO(4, "defineValue '" << V3PreLex::cleanDbgStrg(value) << "'" << endl);
std::map<const string, string> argValueByName; std::map<const string, string> argValueByName;
@ -603,7 +603,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
bool quote = false; bool quote = false;
bool haveDefault = false; bool haveDefault = false;
// Note there's a leading ( and trailing ), so parens==1 is the base parsing level // Note there's a leading ( and trailing ), so parens==1 is the base parsing level
string params = refp->params(); // Must keep str in scope to get pointer const string params = refp->params(); // Must keep str in scope to get pointer
const char* cp = params.c_str(); const char* cp = params.c_str();
if (*cp == '(') cp++; if (*cp == '(') cp++;
for (; *cp; cp++) { for (; *cp; cp++) {
@ -626,7 +626,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
// A call `def( a ) must be equivalent to `def(a ), so trimWhitespace // A call `def( a ) must be equivalent to `def(a ), so trimWhitespace
// At one point we didn't trim trailing // At one point we didn't trim trailing
// whitespace, but this confuses `" // whitespace, but this confuses `"
string arg = trimWhitespace(refp->args()[numArgs], true); const string arg = trimWhitespace(refp->args()[numArgs], true);
if (arg != "") valueDef = arg; if (arg != "") valueDef = arg;
} else if (!haveDefault) { } else if (!haveDefault) {
error("Define missing argument '" + argName + "' for: " + refp->name() error("Define missing argument '" + argName + "' for: " + refp->name()
@ -698,7 +698,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
const auto iter = argValueByName.find(argName); const auto iter = argValueByName.find(argName);
if (iter != argValueByName.end()) { if (iter != argValueByName.end()) {
// Substitute // Substitute
string subst = iter->second; const string subst = iter->second;
if (subst == "") { if (subst == "") {
// Normally `` is removed later, but with no token after, we're otherwise // Normally `` is removed later, but with no token after, we're otherwise
// stuck, so remove proceeding `` // stuck, so remove proceeding ``
@ -780,7 +780,7 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam
// Read a list<string> with the whole file. // Read a list<string> with the whole file.
StrList wholefile; StrList wholefile;
bool ok = filterp->readWholefile(filename, wholefile /*ref*/); const bool ok = filterp->readWholefile(filename, wholefile /*ref*/);
if (!ok) { if (!ok) {
error("File not found: " + filename + "\n"); error("File not found: " + filename + "\n");
return; return;
@ -956,7 +956,7 @@ void V3PreProcImp::debugToken(int tok, const char* cmtp) {
string::size_type pos; string::size_type pos;
while ((pos = buf.find('\n')) != string::npos) { buf.replace(pos, 1, "\\n"); } while ((pos = buf.find('\n')) != string::npos) { buf.replace(pos, 1, "\\n"); }
while ((pos = buf.find('\r')) != string::npos) { buf.replace(pos, 1, "\\r"); } while ((pos = buf.find('\r')) != string::npos) { buf.replace(pos, 1, "\\r"); }
string flcol = m_lexp->m_tokFilelinep->asciiLineCol(); const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
fprintf(stderr, "%s: %s %s %s(%d) dr%d: <%d>%-10s: %s\n", flcol.c_str(), cmtp, fprintf(stderr, "%s: %s %s %s(%d) dr%d: <%d>%-10s: %s\n", flcol.c_str(), cmtp,
(m_off ? "of" : "on"), procStateName(state()), static_cast<int>(m_states.size()), (m_off ? "of" : "on"), procStateName(state()), static_cast<int>(m_states.size()),
static_cast<int>(m_defRefs.size()), m_lexp->currentStartState(), tokenName(tok), static_cast<int>(m_defRefs.size()), m_lexp->currentStartState(), tokenName(tok),
@ -1069,11 +1069,11 @@ int V3PreProcImp::getStateToken() {
error("`elsif with no matching `if\n"); error("`elsif with no matching `if\n");
} else { } else {
// Handle `else portion // Handle `else portion
VPreIfEntry lastIf = m_ifdefStack.top(); const VPreIfEntry lastIf = m_ifdefStack.top();
m_ifdefStack.pop(); m_ifdefStack.pop();
if (!lastIf.on()) parsingOn(); if (!lastIf.on()) parsingOn();
// Handle `if portion // Handle `if portion
bool enable = !lastIf.everOn() && defExists(m_lastSym); const bool enable = !lastIf.everOn() && defExists(m_lastSym);
UINFO(4, "Elsif " << m_lastSym << (enable ? " ON" : " OFF") << endl); UINFO(4, "Elsif " << m_lastSym << (enable ? " ON" : " OFF") << endl);
m_ifdefStack.push(VPreIfEntry(enable, lastIf.everOn())); m_ifdefStack.push(VPreIfEntry(enable, lastIf.everOn()));
if (!enable) parsingOff(); if (!enable) parsingOff();
@ -1142,7 +1142,7 @@ int V3PreProcImp::getStateToken() {
<< "' formals='" << V3PreLex::cleanDbgStrg(m_formals) << "'\n"; << "' formals='" << V3PreLex::cleanDbgStrg(m_formals) << "'\n";
} }
// Add any formals // Add any formals
string formals = m_formals; const string formals = m_formals;
string value = m_lexp->m_defValue; string value = m_lexp->m_defValue;
// Remove returns // Remove returns
// Not removing returns in values has two problems, // Not removing returns in values has two problems,
@ -1165,7 +1165,7 @@ int V3PreProcImp::getStateToken() {
define(fileline(), m_lastSym, value, formals, false); define(fileline(), m_lastSym, value, formals, false);
} }
} else { } else {
string msg = string("Bad define text, unexpected ") + tokenName(tok) + "\n"; const string msg = string("Bad define text, unexpected ") + tokenName(tok) + "\n";
fatalSrc(msg); fatalSrc(msg);
} }
statePop(); statePop();
@ -1220,7 +1220,7 @@ int V3PreProcImp::getStateToken() {
if (VL_UNCOVERABLE(m_joinStack.empty())) { if (VL_UNCOVERABLE(m_joinStack.empty())) {
fatalSrc("`` join stack empty, but in a ``"); fatalSrc("`` join stack empty, but in a ``");
} }
string lhs = m_joinStack.top(); const string lhs = m_joinStack.top();
m_joinStack.pop(); m_joinStack.pop();
out.insert(0, lhs); out.insert(0, lhs);
UINFO(5, "``-end-defarg Out:" << out << endl); UINFO(5, "``-end-defarg Out:" << out << endl);
@ -1309,12 +1309,12 @@ int V3PreProcImp::getStateToken() {
if (VL_UNCOVERABLE(m_joinStack.empty())) { if (VL_UNCOVERABLE(m_joinStack.empty())) {
fatalSrc("`` join stack empty, but in a ``"); fatalSrc("`` join stack empty, but in a ``");
} }
string lhs = m_joinStack.top(); const string lhs = m_joinStack.top();
m_joinStack.pop(); m_joinStack.pop();
UINFO(5, "`` LHS:" << lhs << endl); UINFO(5, "`` LHS:" << lhs << endl);
string rhs(yyourtext(), yyourleng()); string rhs(yyourtext(), yyourleng());
UINFO(5, "`` RHS:" << rhs << endl); UINFO(5, "`` RHS:" << rhs << endl);
string out = lhs + rhs; const string out = lhs + rhs;
UINFO(5, "`` Out:" << out << endl); UINFO(5, "`` Out:" << out << endl);
unputString(out); unputString(out);
statePop(); statePop();
@ -1323,7 +1323,7 @@ int V3PreProcImp::getStateToken() {
// Other compilers just ignore this, so no warning // Other compilers just ignore this, so no warning
// "Expecting symbol to terminate ``; whitespace etc cannot // "Expecting symbol to terminate ``; whitespace etc cannot
// follow ``. Found: "+tokenName(tok)+"\n" // follow ``. Found: "+tokenName(tok)+"\n"
string lhs = m_joinStack.top(); const string lhs = m_joinStack.top();
m_joinStack.pop(); m_joinStack.pop();
unputString(lhs); unputString(lhs);
statePop(); statePop();
@ -1384,9 +1384,9 @@ int V3PreProcImp::getStateToken() {
if (m_ifdefStack.empty()) { if (m_ifdefStack.empty()) {
error("`else with no matching `if\n"); error("`else with no matching `if\n");
} else { } else {
VPreIfEntry lastIf = m_ifdefStack.top(); const VPreIfEntry lastIf = m_ifdefStack.top();
m_ifdefStack.pop(); m_ifdefStack.pop();
bool enable = !lastIf.everOn(); const bool enable = !lastIf.everOn();
UINFO(4, "Else " << (enable ? " ON" : " OFF") << endl); UINFO(4, "Else " << (enable ? " ON" : " OFF") << endl);
m_ifdefStack.push(VPreIfEntry(enable, lastIf.everOn())); m_ifdefStack.push(VPreIfEntry(enable, lastIf.everOn()));
if (!lastIf.on()) parsingOn(); if (!lastIf.on()) parsingOn();
@ -1398,7 +1398,7 @@ int V3PreProcImp::getStateToken() {
if (m_ifdefStack.empty()) { if (m_ifdefStack.empty()) {
error("`endif with no matching `if\n"); error("`endif with no matching `if\n");
} else { } else {
VPreIfEntry lastIf = m_ifdefStack.top(); const VPreIfEntry lastIf = m_ifdefStack.top();
m_ifdefStack.pop(); m_ifdefStack.pop();
if (!lastIf.on()) parsingOn(); if (!lastIf.on()) parsingOn();
// parsingOn() really only enables parsing if // parsingOn() really only enables parsing if
@ -1432,7 +1432,7 @@ int V3PreProcImp::getStateToken() {
goto next_tok; goto next_tok;
} }
} else { } else {
string params = defParams(name); const string params = defParams(name);
if (params == "0" || params == "") { // Found, as simple substitution if (params == "0" || params == "") { // Found, as simple substitution
string out; string out;
if (!m_off) { if (!m_off) {
@ -1447,7 +1447,7 @@ int V3PreProcImp::getStateToken() {
if (VL_UNCOVERABLE(m_joinStack.empty())) { if (VL_UNCOVERABLE(m_joinStack.empty())) {
fatalSrc("`` join stack empty, but in a ``"); fatalSrc("`` join stack empty, but in a ``");
} }
string lhs = m_joinStack.top(); const string lhs = m_joinStack.top();
m_joinStack.pop(); m_joinStack.pop();
out.insert(0, lhs); out.insert(0, lhs);
UINFO(5, "``-end-defref Out:" << out << endl); UINFO(5, "``-end-defref Out:" << out << endl);
@ -1533,11 +1533,11 @@ int V3PreProcImp::getFinalToken(string& buf) {
m_finToken = getStateToken(); m_finToken = getStateToken();
m_finBuf = string(yyourtext(), yyourleng()); m_finBuf = string(yyourtext(), yyourleng());
} }
int tok = m_finToken; const int tok = m_finToken;
buf = m_finBuf; buf = m_finBuf;
if (false && debug() >= 5) { if (false && debug() >= 5) {
string bufcln = V3PreLex::cleanDbgStrg(buf); const string bufcln = V3PreLex::cleanDbgStrg(buf);
string flcol = m_lexp->m_tokFilelinep->asciiLineCol(); const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
fprintf(stderr, "%s: FIN: %-10s: %s\n", flcol.c_str(), tokenName(tok), fprintf(stderr, "%s: FIN: %-10s: %s\n", flcol.c_str(), tokenName(tok),
bufcln.c_str()); bufcln.c_str());
} }
@ -1552,7 +1552,7 @@ int V3PreProcImp::getFinalToken(string& buf) {
if (int outBehind if (int outBehind
= (m_lexp->m_tokFilelinep->lastLineno() - m_finFilelinep->lastLineno())) { = (m_lexp->m_tokFilelinep->lastLineno() - m_finFilelinep->lastLineno())) {
if (debug() >= 5) { if (debug() >= 5) {
string flcol = m_lexp->m_tokFilelinep->asciiLineCol(); const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
fprintf(stderr, "%s: FIN: readjust, fin at %d request at %d\n", flcol.c_str(), fprintf(stderr, "%s: FIN: readjust, fin at %d request at %d\n", flcol.c_str(),
m_finFilelinep->lastLineno(), m_lexp->m_tokFilelinep->lastLineno()); m_finFilelinep->lastLineno(), m_lexp->m_tokFilelinep->lastLineno());
} }
@ -1594,10 +1594,10 @@ string V3PreProcImp::getline() {
bool gotEof = false; bool gotEof = false;
while (nullptr == (rtnp = strchr(m_lineChars.c_str(), '\n')) && !gotEof) { while (nullptr == (rtnp = strchr(m_lineChars.c_str(), '\n')) && !gotEof) {
string buf; string buf;
int tok = getFinalToken(buf /*ref*/); const int tok = getFinalToken(buf /*ref*/);
if (debug() >= 5) { if (debug() >= 5) {
string bufcln = V3PreLex::cleanDbgStrg(buf); const string bufcln = V3PreLex::cleanDbgStrg(buf);
string flcol = m_lexp->m_tokFilelinep->asciiLineCol(); const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
fprintf(stderr, "%s: GETFETC: %-10s: %s\n", flcol.c_str(), tokenName(tok), fprintf(stderr, "%s: GETFETC: %-10s: %s\n", flcol.c_str(), tokenName(tok),
bufcln.c_str()); bufcln.c_str());
} }
@ -1613,12 +1613,12 @@ string V3PreProcImp::getline() {
} }
// Make new string with data up to the newline. // Make new string with data up to the newline.
int len = rtnp - m_lineChars.c_str() + 1; const int len = rtnp - m_lineChars.c_str() + 1;
string theLine(m_lineChars, 0, len); string theLine(m_lineChars, 0, len);
m_lineChars = m_lineChars.erase(0, len); // Remove returned characters m_lineChars = m_lineChars.erase(0, len); // Remove returned characters
if (debug() >= 4) { if (debug() >= 4) {
string lncln = V3PreLex::cleanDbgStrg(theLine); const string lncln = V3PreLex::cleanDbgStrg(theLine);
string flcol = m_lexp->m_tokFilelinep->asciiLineCol(); const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
fprintf(stderr, "%s: GETLINE: %s\n", flcol.c_str(), lncln.c_str()); fprintf(stderr, "%s: GETLINE: %s\n", flcol.c_str(), lncln.c_str());
} }
return theLine; return theLine;

View File

@ -95,7 +95,7 @@ protected:
// Preprocess // Preprocess
s_filterp = filterp; s_filterp = filterp;
string modfilename = preprocOpen(fl, s_filterp, modname, "", errmsg); const string modfilename = preprocOpen(fl, s_filterp, modname, "", errmsg);
if (modfilename.empty()) return false; if (modfilename.empty()) return false;
// Set language standard up front // Set language standard up front
@ -112,7 +112,7 @@ protected:
} }
while (!s_preprocp->isEof()) { while (!s_preprocp->isEof()) {
string line = s_preprocp->getline(); const string line = s_preprocp->getline();
V3Parse::ppPushText(parsep, line); V3Parse::ppPushText(parsep, line);
} }
return true; return true;
@ -138,7 +138,7 @@ private:
if (filename == "") { if (filename == "") {
// Allow user to put `defined names on the command line instead of filenames, // Allow user to put `defined names on the command line instead of filenames,
// then convert them properly. // then convert them properly.
string ppmodname = s_preprocp->removeDefines(modname); const string ppmodname = s_preprocp->removeDefines(modname);
filename = v3Global.opt.filePath(fl, ppmodname, lastpath, errmsg); filename = v3Global.opt.filePath(fl, ppmodname, lastpath, errmsg);
} }

View File

@ -235,7 +235,7 @@ private:
virtual void visit(AstNodeAssign* nodep) override { virtual void visit(AstNodeAssign* nodep) override {
startStatement(nodep); startStatement(nodep);
{ {
bool noopt = PremitAssignVisitor(nodep).noOpt(); const bool noopt = PremitAssignVisitor(nodep).noOpt();
if (noopt && !nodep->user1()) { if (noopt && !nodep->user1()) {
nodep->user1(true); nodep->user1(true);
// Need to do this even if not wide, as e.g. a select may be on a wide operator // Need to do this even if not wide, as e.g. a select may be on a wide operator

View File

@ -70,7 +70,7 @@ private:
AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) { AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) {
AstVar* varp = VN_CAST(cfuncp->user1p(), Var); AstVar* varp = VN_CAST(cfuncp->user1p(), Var);
if (!varp) { if (!varp) {
string newvarname = string("__Vilp"); const string newvarname = string("__Vilp");
varp = new AstVar(fl, AstVarType::STMTTEMP, newvarname, VFlagLogicPacked(), 32); varp = new AstVar(fl, AstVarType::STMTTEMP, newvarname, VFlagLogicPacked(), 32);
UASSERT_OBJ(cfuncp, fl, "Assignment not under a function"); UASSERT_OBJ(cfuncp, fl, "Assignment not under a function");
cfuncp->addInitsp(varp); cfuncp->addInitsp(varp);

View File

@ -291,7 +291,7 @@ private:
} }
virtual void visit(AstScopeName* nodep) override { virtual void visit(AstScopeName* nodep) override {
// If there's a %m in the display text, we add a special node that will contain the name() // If there's a %m in the display text, we add a special node that will contain the name()
string prefix = string("__DOT__") + m_scopep->name(); const string prefix = string("__DOT__") + m_scopep->name();
// TOP and above will be the user's name(). // TOP and above will be the user's name().
// Note 'TOP.' is stripped by scopePrettyName // Note 'TOP.' is stripped by scopePrettyName
// To keep correct visual order, must add before other Text's // To keep correct visual order, must add before other Text's

View File

@ -232,7 +232,7 @@ private:
// removed from the map. // removed from the map.
// Clear the m_vals mapping for k. // Clear the m_vals mapping for k.
KeySet& keysAtOldVal = m_vals[oldVal]; KeySet& keysAtOldVal = m_vals[oldVal];
size_t erased = keysAtOldVal.erase(k); const size_t erased = keysAtOldVal.erase(k);
UASSERT(erased == 1, "removeKeyFromOldVal() removal key not found"); UASSERT(erased == 1, "removeKeyFromOldVal() removal key not found");
if (keysAtOldVal.empty()) { if (keysAtOldVal.empty()) {
// Don't keep empty sets in the value map. // Don't keep empty sets in the value map.
@ -451,7 +451,7 @@ public:
// and sort all elements by their current score. // and sort all elements by their current score.
void rescore() { void rescore() {
for (const T_Elem* elp : m_unknown) { for (const T_Elem* elp : m_unknown) {
T_Score sortScore = m_scoreFnp(elp); const T_Score sortScore = m_scoreFnp(elp);
m_sorted.set(elp, sortScore); m_sorted.set(elp, sortScore);
} }
m_unknown.clear(); m_unknown.clear();

View File

@ -125,9 +125,9 @@ private:
out << "'{"; out << "'{";
for (AstMemberDType* itemp = stp->membersp(); itemp; for (AstMemberDType* itemp = stp->membersp(); itemp;
itemp = VN_CAST(itemp->nextp(), MemberDType)) { itemp = VN_CAST(itemp->nextp(), MemberDType)) {
int width = itemp->width(); const int width = itemp->width();
int lsb = itemp->lsb(); const int lsb = itemp->lsb();
int msb = lsb + width - 1; const int msb = lsb + width - 1;
V3Number fieldNum(nump, width); V3Number fieldNum(nump, width);
fieldNum.opSel(*nump, msb, lsb); fieldNum.opSel(*nump, msb, lsb);
out << itemp->name() << ": "; out << itemp->name() << ": ";
@ -145,14 +145,14 @@ private:
if (AstNodeDType* childTypep = arrayp->subDTypep()) { if (AstNodeDType* childTypep = arrayp->subDTypep()) {
std::ostringstream out; std::ostringstream out;
out << "["; out << "[";
int arrayElements = arrayp->elementsConst(); const int arrayElements = arrayp->elementsConst();
for (int element = 0; element < arrayElements; ++element) { for (int element = 0; element < arrayElements; ++element) {
int width = childTypep->width(); const int width = childTypep->width();
int lsb = width * element; const int lsb = width * element;
int msb = lsb + width - 1; const int msb = lsb + width - 1;
V3Number fieldNum(nump, width); V3Number fieldNum(nump, width);
fieldNum.opSel(*nump, msb, lsb); fieldNum.opSel(*nump, msb, lsb);
int arrayElem = arrayp->lo() + element; const int arrayElem = arrayp->lo() + element;
out << arrayElem << " = " << prettyNumber(&fieldNum, childTypep); out << arrayElem << " = " << prettyNumber(&fieldNum, childTypep);
if (element < arrayElements - 1) out << ", "; if (element < arrayElements - 1) out << ", ";
} }
@ -424,7 +424,7 @@ private:
clearOptimizable(nodep, "Var write & read"); clearOptimizable(nodep, "Var write & read");
} }
vscp->user1(vscp->user1() | VU_RV); vscp->user1(vscp->user1() | VU_RV);
bool isConst = nodep->varp()->isParam() && nodep->varp()->valuep(); const bool isConst = nodep->varp()->isParam() && nodep->varp()->valuep();
AstNode* valuep = isConst ? fetchValueNull(nodep->varp()->valuep()) : nullptr; AstNode* valuep = isConst ? fetchValueNull(nodep->varp()->valuep()) : nullptr;
if (isConst if (isConst
&& valuep) { // Propagate PARAM constants for constant function analysis && valuep) { // Propagate PARAM constants for constant function analysis
@ -1021,7 +1021,7 @@ private:
AstNode* nextArgp = nodep->exprsp(); AstNode* nextArgp = nodep->exprsp();
string result; string result;
string format = nodep->text(); const string format = nodep->text();
auto pos = format.cbegin(); auto pos = format.cbegin();
bool inPct = false; bool inPct = false;
for (; pos != format.cend(); ++pos) { for (; pos != format.cend(); ++pos) {
@ -1041,7 +1041,7 @@ private:
nodep, "Argument for $display like statement is not constant"); nodep, "Argument for $display like statement is not constant");
break; break;
} }
string pformat = string("%") + pos[0]; const string pformat = string("%") + pos[0];
result += constp->num().displayed(nodep, pformat); result += constp->num().displayed(nodep, pformat);
} else { } else {
switch (tolower(pos[0])) { switch (tolower(pos[0])) {

View File

@ -86,7 +86,7 @@ class SliceVisitor final : public AstNVisitor {
AstNode* newp; AstNode* newp;
if (AstInitArray* initp = VN_CAST(nodep, InitArray)) { if (AstInitArray* initp = VN_CAST(nodep, InitArray)) {
UINFO(9, " cloneInitArray(" << elements << "," << offset << ") " << nodep << endl); UINFO(9, " cloneInitArray(" << elements << "," << offset << ") " << nodep << endl);
int leOffset = !arrayp->rangep()->littleEndian() const int leOffset = !arrayp->rangep()->littleEndian()
? arrayp->rangep()->elementsConst() - 1 - offset ? arrayp->rangep()->elementsConst() - 1 - offset
: offset; : offset;
AstNode* itemp = initp->getIndexDefaultedValuep(leOffset); AstNode* itemp = initp->getIndexDefaultedValuep(leOffset);
@ -103,7 +103,7 @@ class SliceVisitor final : public AstNVisitor {
cloneAndSel(snodep->expr2p(), elements, offset)); cloneAndSel(snodep->expr2p(), elements, offset));
} else if (AstSliceSel* snodep = VN_CAST(nodep, SliceSel)) { } else if (AstSliceSel* snodep = VN_CAST(nodep, SliceSel)) {
UINFO(9, " cloneSliceSel(" << elements << "," << offset << ") " << nodep << endl); UINFO(9, " cloneSliceSel(" << elements << "," << offset << ") " << nodep << endl);
int leOffset = (snodep->declRange().lo() const int leOffset = (snodep->declRange().lo()
+ (!snodep->declRange().littleEndian() + (!snodep->declRange().littleEndian()
? snodep->declRange().elements() - 1 - offset ? snodep->declRange().elements() - 1 - offset
: offset)); : offset));
@ -111,7 +111,7 @@ class SliceVisitor final : public AstNVisitor {
} else if (VN_IS(nodep, ArraySel) || VN_IS(nodep, NodeVarRef) || VN_IS(nodep, NodeSel) } else if (VN_IS(nodep, ArraySel) || VN_IS(nodep, NodeVarRef) || VN_IS(nodep, NodeSel)
|| VN_IS(nodep, CMethodHard) || VN_IS(nodep, MemberSel)) { || VN_IS(nodep, CMethodHard) || VN_IS(nodep, MemberSel)) {
UINFO(9, " cloneSel(" << elements << "," << offset << ") " << nodep << endl); UINFO(9, " cloneSel(" << elements << "," << offset << ") " << nodep << endl);
int leOffset = !arrayp->rangep()->littleEndian() const int leOffset = !arrayp->rangep()->littleEndian()
? arrayp->rangep()->elementsConst() - 1 - offset ? arrayp->rangep()->elementsConst() - 1 - offset
: offset; : offset;
newp = new AstArraySel(nodep->fileline(), nodep->cloneTree(false), leOffset); newp = new AstArraySel(nodep->fileline(), nodep->cloneTree(false), leOffset);
@ -138,7 +138,7 @@ class SliceVisitor final : public AstNVisitor {
// and all variables are realigned to start at zero // and all variables are realigned to start at zero
// Assign of a little endian'ed slice to a big endian one must reverse the elements // Assign of a little endian'ed slice to a big endian one must reverse the elements
AstNode* newlistp = nullptr; AstNode* newlistp = nullptr;
int elements = arrayp->rangep()->elementsConst(); const int elements = arrayp->rangep()->elementsConst();
for (int offset = 0; offset < elements; ++offset) { for (int offset = 0; offset < elements; ++offset) {
AstNode* newp = nodep->cloneType // AstNodeAssign AstNode* newp = nodep->cloneType // AstNodeAssign
(cloneAndSel(nodep->lhsp(), elements, offset), (cloneAndSel(nodep->lhsp(), elements, offset),

View File

@ -89,7 +89,7 @@ private:
return; return;
} }
UINFO(6, " CL STMT " << nodep << endl); UINFO(6, " CL STMT " << nodep << endl);
bool oldKeep = m_keepStmt; const bool oldKeep = m_keepStmt;
{ {
m_matches = false; m_matches = false;
m_keepStmt = false; m_keepStmt = false;

View File

@ -294,7 +294,7 @@ private:
bool addCore(AstVarRef* refp, const UnpackRef& ref) { bool addCore(AstVarRef* refp, const UnpackRef& ref) {
AstVar* varp = refp->varp(); AstVar* varp = refp->varp();
UASSERT_OBJ(varp->attrSplitVar(), varp, " no split_var metacomment"); UASSERT_OBJ(varp->attrSplitVar(), varp, " no split_var metacomment");
MapIt it = m_map.find(varp); const MapIt it = m_map.find(varp);
if (it == m_map.end()) return false; // Not registered if (it == m_map.end()) return false; // Not registered
const bool ok = m_map[varp].insert(ref).second; const bool ok = m_map[varp].insert(ref).second;
return ok; return ok;

View File

@ -99,7 +99,7 @@ private:
if (v3Global.opt.statsVars()) m_statVarWidthNames.resize(nodep->width() + 5); if (v3Global.opt.statsVars()) m_statVarWidthNames.resize(nodep->width() + 5);
} }
++m_statVarWidths.at(nodep->width()); ++m_statVarWidths.at(nodep->width());
string pn = nodep->prettyName(); const string pn = nodep->prettyName();
if (v3Global.opt.statsVars()) { if (v3Global.opt.statsVars()) {
NameMap& nameMapr = m_statVarWidthNames.at(nodep->width()); NameMap& nameMapr = m_statVarWidthNames.at(nodep->width());
if (nameMapr.find(pn) != nameMapr.end()) { if (nameMapr.find(pn) != nameMapr.end()) {
@ -230,7 +230,7 @@ public:
V3Stats::addStat(m_stage, "Var space, scoped, bytes", m_statVarScpBytes); V3Stats::addStat(m_stage, "Var space, scoped, bytes", m_statVarScpBytes);
} }
for (unsigned i = 0; i < m_statVarWidths.size(); i++) { for (unsigned i = 0; i < m_statVarWidths.size(); i++) {
double count = double(m_statVarWidths.at(i)); const double count = double(m_statVarWidths.at(i));
if (count != 0.0) { if (count != 0.0) {
if (v3Global.opt.statsVars()) { if (v3Global.opt.statsVars()) {
NameMap& nameMapr = m_statVarWidthNames.at(i); NameMap& nameMapr = m_statVarWidthNames.at(i);
@ -248,14 +248,14 @@ public:
} }
// Node types // Node types
for (int type = 0; type < AstType::_ENUM_END; type++) { for (int type = 0; type < AstType::_ENUM_END; type++) {
double count = double(m_statTypeCount.at(type)); const double count = double(m_statTypeCount.at(type));
if (count != 0.0) { if (count != 0.0) {
V3Stats::addStat(m_stage, string("Node count, ") + AstType(type).ascii(), count); V3Stats::addStat(m_stage, string("Node count, ") + AstType(type).ascii(), count);
} }
} }
for (int type = 0; type < AstType::_ENUM_END; type++) { for (int type = 0; type < AstType::_ENUM_END; type++) {
for (int type2 = 0; type2 < AstType::_ENUM_END; type2++) { for (int type2 = 0; type2 < AstType::_ENUM_END; type2++) {
double count = double(m_statAbove[type][type2]); const double count = double(m_statAbove[type][type2]);
if (count != 0.0) { if (count != 0.0) {
V3Stats::addStat(m_stage, V3Stats::addStat(m_stage,
(string("Node pairs, ") + AstType(type).ascii() + "_" (string("Node pairs, ") + AstType(type).ascii() + "_"
@ -266,7 +266,7 @@ public:
} }
// Branch pred // Branch pred
for (int type = 0; type < VBranchPred::_ENUM_END; type++) { for (int type = 0; type < VBranchPred::_ENUM_END; type++) {
double count = double(m_statPred[type]); const double count = double(m_statPred[type]);
if (count != 0.0) { if (count != 0.0) {
V3Stats::addStat( V3Stats::addStat(
m_stage, (string("Branch prediction, ") + VBranchPred(type).ascii()), count); m_stage, (string("Branch prediction, ") + VBranchPred(type).ascii()), count);

View File

@ -206,13 +206,13 @@ void V3Stats::statsStage(const string& name) {
const string digitName = V3Global::digitsFilename(++fileNumber) + "_" + name; const string digitName = V3Global::digitsFilename(++fileNumber) + "_" + name;
double wallTime = V3Os::timeUsecs() / 1.0e6; const double wallTime = V3Os::timeUsecs() / 1.0e6;
if (lastWallTime < 0) lastWallTime = wallTime; if (lastWallTime < 0) lastWallTime = wallTime;
double wallTimeDelta = wallTime - lastWallTime; const double wallTimeDelta = wallTime - lastWallTime;
lastWallTime = wallTime; lastWallTime = wallTime;
V3Stats::addStatPerf("Stage, Elapsed time (sec), " + digitName, wallTimeDelta); V3Stats::addStatPerf("Stage, Elapsed time (sec), " + digitName, wallTimeDelta);
double memory = V3Os::memUsageBytes() / 1024.0 / 1024.0; const double memory = V3Os::memUsageBytes() / 1024.0 / 1024.0;
V3Stats::addStatPerf("Stage, Memory (MB), " + digitName, memory); V3Stats::addStatPerf("Stage, Memory (MB), " + digitName, memory);
} }
@ -220,7 +220,8 @@ void V3Stats::statsReport() {
UINFO(2, __FUNCTION__ << ": " << endl); UINFO(2, __FUNCTION__ << ": " << endl);
// Open stats file // Open stats file
string filename = v3Global.opt.hierTopDataDir() + "/" + v3Global.opt.prefix() + "__stats.txt"; const string filename
= v3Global.opt.hierTopDataDir() + "/" + v3Global.opt.prefix() + "__stats.txt";
std::ofstream* ofp(V3File::new_ofstream(filename)); std::ofstream* ofp(V3File::new_ofstream(filename));
if (ofp->fail()) v3fatal("Can't write " << filename); if (ofp->fail()) v3fatal("Can't write " << filename);

View File

@ -149,7 +149,7 @@ double VString::parseDouble(const string& str, bool* successp) {
*dp++ = '\0'; *dp++ = '\0';
char* endp = strgp; char* endp = strgp;
double d = strtod(strgp, &endp); double d = strtod(strgp, &endp);
size_t parsed_len = endp - strgp; const size_t parsed_len = endp - strgp;
if (parsed_len != strlen(strgp)) { if (parsed_len != strlen(strgp)) {
if (successp) *successp = false; if (successp) *successp = false;
} }
@ -406,7 +406,7 @@ string VName::dehash(const string& in) {
for (string::size_type last_dot_pos = 0; last_dot_pos < in.size();) { for (string::size_type last_dot_pos = 0; last_dot_pos < in.size();) {
const string::size_type next_dot_pos = in.find("__DOT__", last_dot_pos); const string::size_type next_dot_pos = in.find("__DOT__", last_dot_pos);
// Two iterators defining the range between the last and next dots. // Two iterators defining the range between the last and next dots.
auto search_begin = std::begin(in) + last_dot_pos; const auto search_begin = std::begin(in) + last_dot_pos;
auto search_end auto search_end
= next_dot_pos == string::npos ? std::end(in) : std::begin(in) + next_dot_pos; = next_dot_pos == string::npos ? std::end(in) : std::begin(in) + next_dot_pos;
@ -451,7 +451,7 @@ string VName::hashedName() {
return m_hashed; return m_hashed;
} else { } else {
VHashSha256 hash(m_name); VHashSha256 hash(m_name);
string suffix = "__Vhsh" + hash.digestSymbol(); const string suffix = "__Vhsh" + hash.digestSymbol();
if (s_minLength < s_maxLength) { if (s_minLength < s_maxLength) {
s_dehashMap[suffix] = m_name.substr(s_minLength); s_dehashMap[suffix] = m_name.substr(s_minLength);
m_hashed = m_name.substr(0, s_minLength) + suffix; m_hashed = m_name.substr(0, s_minLength) + suffix;
@ -468,8 +468,8 @@ string VName::hashedName() {
VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const string& t) { VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const string& t) {
// Wagner-Fischer algorithm for the Damerau-Levenshtein distance // Wagner-Fischer algorithm for the Damerau-Levenshtein distance
size_t sLen = s.length(); const size_t sLen = s.length();
size_t tLen = t.length(); const size_t tLen = t.length();
if (sLen == 0) return tLen; if (sLen == 0) return tLen;
if (tLen == 0) return sLen; if (tLen == 0) return sLen;
if (sLen >= LENGTH_LIMIT) return sLen; if (sLen >= LENGTH_LIMIT) return sLen;
@ -484,14 +484,14 @@ VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const strin
for (size_t i = 0; i < tLen; i++) { for (size_t i = 0; i < tLen; i++) {
s_v_next[0] = i + 1; s_v_next[0] = i + 1;
for (size_t j = 0; j < sLen; j++) { for (size_t j = 0; j < sLen; j++) {
EditDistance cost = (s[j] == t[i] ? 0 : 1); const EditDistance cost = (s[j] == t[i] ? 0 : 1);
EditDistance deletion = s_v_next[j] + 1; const EditDistance deletion = s_v_next[j] + 1;
EditDistance insertion = s_v_one_ago[j + 1] + 1; const EditDistance insertion = s_v_one_ago[j + 1] + 1;
EditDistance substitution = s_v_one_ago[j] + cost; const EditDistance substitution = s_v_one_ago[j] + cost;
EditDistance cheapest = std::min(deletion, insertion); EditDistance cheapest = std::min(deletion, insertion);
cheapest = std::min(cheapest, substitution); cheapest = std::min(cheapest, substitution);
if (i > 0 && j > 0 && s[j] == t[i - 1] && s[j - 1] == t[i]) { if (i > 0 && j > 0 && s[j] == t[i - 1] && s[j - 1] == t[i]) {
EditDistance transposition = s_v_two_ago[j - 1] + 1; const EditDistance transposition = s_v_two_ago[j - 1] + 1;
cheapest = std::min(cheapest, transposition); cheapest = std::min(cheapest, transposition);
} }
s_v_next[j + 1] = cheapest; s_v_next[j + 1] = cheapest;
@ -502,14 +502,14 @@ VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const strin
} }
} }
EditDistance result = s_v_next[sLen]; const EditDistance result = s_v_next[sLen];
return result; return result;
} }
VSpellCheck::EditDistance VSpellCheck::cutoffDistance(size_t goal_len, size_t candidate_len) { VSpellCheck::EditDistance VSpellCheck::cutoffDistance(size_t goal_len, size_t candidate_len) {
// Return max acceptable edit distance // Return max acceptable edit distance
size_t max_length = std::max(goal_len, candidate_len); const size_t max_length = std::max(goal_len, candidate_len);
size_t min_length = std::min(goal_len, candidate_len); const size_t min_length = std::min(goal_len, candidate_len);
if (max_length <= 1) return 0; if (max_length <= 1) return 0;
if (max_length - min_length <= 1) return std::max(max_length / 3, static_cast<size_t>(1)); if (max_length - min_length <= 1) return std::max(max_length / 3, static_cast<size_t>(1));
return (max_length + 2) / 3; return (max_length + 2) / 3;
@ -517,19 +517,19 @@ VSpellCheck::EditDistance VSpellCheck::cutoffDistance(size_t goal_len, size_t ca
string VSpellCheck::bestCandidateInfo(const string& goal, EditDistance& distancer) const { string VSpellCheck::bestCandidateInfo(const string& goal, EditDistance& distancer) const {
string bestCandidate; string bestCandidate;
size_t gLen = goal.length(); const size_t gLen = goal.length();
distancer = LENGTH_LIMIT * 10; distancer = LENGTH_LIMIT * 10;
for (const string& candidate : m_candidates) { for (const string& candidate : m_candidates) {
size_t cLen = candidate.length(); const size_t cLen = candidate.length();
// Min distance must be inserting/deleting to make lengths match // Min distance must be inserting/deleting to make lengths match
EditDistance min_distance = (cLen > gLen ? (cLen - gLen) : (gLen - cLen)); const EditDistance min_distance = (cLen > gLen ? (cLen - gLen) : (gLen - cLen));
if (min_distance >= distancer) continue; // Short-circuit if already better if (min_distance >= distancer) continue; // Short-circuit if already better
EditDistance cutoff = cutoffDistance(gLen, cLen); const EditDistance cutoff = cutoffDistance(gLen, cLen);
if (min_distance > cutoff) continue; // Short-circuit if already too bad if (min_distance > cutoff) continue; // Short-circuit if already too bad
EditDistance dist = editDistance(goal, candidate); const EditDistance dist = editDistance(goal, candidate);
UINFO(9, "EditDistance dist=" << dist << " cutoff=" << cutoff << " goal=" << goal UINFO(9, "EditDistance dist=" << dist << " cutoff=" << cutoff << " goal=" << goal
<< " candidate=" << candidate << endl); << " candidate=" << candidate << endl);
if (dist < distancer && dist <= cutoff) { if (dist < distancer && dist <= cutoff) {
@ -553,7 +553,7 @@ void VSpellCheck::selfTestSuggestOne(bool matches, const string& c, const string
EditDistance gdist; EditDistance gdist;
VSpellCheck speller; VSpellCheck speller;
speller.pushCandidate(c); speller.pushCandidate(c);
string got = speller.bestCandidateInfo(goal, gdist /*ref*/); const string got = speller.bestCandidateInfo(goal, gdist /*ref*/);
if (matches) { if (matches) {
UASSERT_SELFTEST(const string&, got, c); UASSERT_SELFTEST(const string&, got, c);
UASSERT_SELFTEST(EditDistance, gdist, dist); UASSERT_SELFTEST(EditDistance, gdist, dist);

View File

@ -226,7 +226,7 @@ public:
} }
// Return friendly message // Return friendly message
string bestCandidateMsg(const string& goal) const { string bestCandidateMsg(const string& goal) const {
string candidate = bestCandidate(goal); const string candidate = bestCandidate(goal);
if (candidate.empty()) { if (candidate.empty()) {
return ""; return "";
} else { } else {

View File

@ -276,7 +276,7 @@ private:
} else if (AstWordSel* wordp = VN_CAST(nodep->lhsp(), WordSel)) { } else if (AstWordSel* wordp = VN_CAST(nodep->lhsp(), WordSel)) {
if (AstVarRef* varrefp = VN_CAST(wordp->lhsp(), VarRef)) { if (AstVarRef* varrefp = VN_CAST(wordp->lhsp(), VarRef)) {
if (VN_IS(wordp->rhsp(), Const) && isSubstVar(varrefp->varp())) { if (VN_IS(wordp->rhsp(), Const) && isSubstVar(varrefp->varp())) {
int word = VN_CAST(wordp->rhsp(), Const)->toUInt(); const int word = VN_CAST(wordp->rhsp(), Const)->toUInt();
SubstVarEntry* entryp = getEntryp(varrefp); SubstVarEntry* entryp = getEntryp(varrefp);
hit = true; hit = true;
if (m_ops > SUBST_MAX_OPS_SUBST) { if (m_ops > SUBST_MAX_OPS_SUBST) {
@ -309,7 +309,7 @@ private:
if (varrefp && isSubstVar(varrefp->varp()) && varrefp->access().isReadOnly() && constp) { if (varrefp && isSubstVar(varrefp->varp()) && varrefp->access().isReadOnly() && constp) {
// Nicely formed lvalues handled in NodeAssign // Nicely formed lvalues handled in NodeAssign
// Other lvalues handled as unknown mess in AstVarRef // Other lvalues handled as unknown mess in AstVarRef
int word = constp->toUInt(); const int word = constp->toUInt();
UINFO(8, " USEword" << word << " " << varrefp << endl); UINFO(8, " USEword" << word << " " << varrefp << endl);
SubstVarEntry* entryp = getEntryp(varrefp); SubstVarEntry* entryp = getEntryp(varrefp);
if (AstNode* substp = entryp->substWord(nodep, word)) { if (AstNode* substp = entryp->substWord(nodep, word)) {

View File

@ -315,7 +315,7 @@ public:
} }
void dumpFilePrefixed(const string& nameComment) { void dumpFilePrefixed(const string& nameComment) {
if (v3Global.opt.dumpTree()) { if (v3Global.opt.dumpTree()) {
string filename = v3Global.debugFilename(nameComment) + ".txt"; const string filename = v3Global.debugFilename(nameComment) + ".txt";
UINFO(2, "Dumping " << filename << endl); UINFO(2, "Dumping " << filename << endl);
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename)); const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
if (logp->fail()) v3fatal("Can't write " << filename); if (logp->fail()) v3fatal("Can't write " << filename);

View File

@ -102,7 +102,7 @@ public:
// The only time we may create duplicate edges is when // The only time we may create duplicate edges is when
// combining the MST with the perfect-matched pairs, // combining the MST with the perfect-matched pairs,
// and in that case, we want to permit duplicate edges. // and in that case, we want to permit duplicate edges.
unsigned edgeId = ++V3TSP::edgeIdNext; const unsigned edgeId = ++V3TSP::edgeIdNext;
// Record the 'id' which identifies a single bidir edge // Record the 'id' which identifies a single bidir edge
// in the user field of each V3GraphEdge: // in the user field of each V3GraphEdge:
@ -127,8 +127,8 @@ public:
EdgeCmp() = default; EdgeCmp() = default;
// METHODS // METHODS
bool operator()(const V3GraphEdge* ap, const V3GraphEdge* bp) { bool operator()(const V3GraphEdge* ap, const V3GraphEdge* bp) {
int aCost = ap->weight(); const int aCost = ap->weight();
int bCost = bp->weight(); const int bCost = bp->weight();
// Sort first on cost, lowest cost edges first: // Sort first on cost, lowest cost edges first:
if (aCost < bCost) return true; if (aCost < bCost) return true;
if (bCost < aCost) return false; if (bCost < aCost) return false;
@ -188,7 +188,7 @@ public:
// to the pending set. // to the pending set.
Vertex* neighborp = castVertexp(bestEdgep->top()); Vertex* neighborp = castVertexp(bestEdgep->top());
if (visited_set.find(neighborp) == visited_set.end()) { if (visited_set.find(neighborp) == visited_set.end()) {
int bestCost = bestEdgep->weight(); const int bestCost = bestEdgep->weight();
UINFO(6, "bestCost = " << bestCost << " from " << from_vertexp->key() << " to " UINFO(6, "bestCost = " << bestCost << " from " << from_vertexp->key() << " to "
<< neighborp->key() << endl); << neighborp->key() << endl);
@ -354,7 +354,7 @@ public:
} }
void dumpGraphFilePrefixed(const string& nameComment) const { void dumpGraphFilePrefixed(const string& nameComment) const {
if (v3Global.opt.dumpTree()) { if (v3Global.opt.dumpTree()) {
string filename = v3Global.debugFilename(nameComment) + ".txt"; const string filename = v3Global.debugFilename(nameComment) + ".txt";
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename)); const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
if (logp->fail()) v3fatal("Can't write " << filename); if (logp->fail()) v3fatal("Can't write " << filename);
dumpGraph(*logp, nameComment); dumpGraph(*logp, nameComment);
@ -463,7 +463,7 @@ void V3TSP::tspSort(const V3TSP::StateVec& states, V3TSP::StateVec* resultp) {
const TspStateBase* ap = (*resultp)[i]; const TspStateBase* ap = (*resultp)[i];
const TspStateBase* bp const TspStateBase* bp
= (i + 1 == resultp->size()) ? (*resultp)[0] : (*resultp)[i + 1]; = (i + 1 == resultp->size()) ? (*resultp)[0] : (*resultp)[i + 1];
unsigned cost = ap->cost(bp); const unsigned cost = ap->cost(bp);
if (cost > max_cost) { if (cost > max_cost) {
max_cost = cost; max_cost = cost;
max_cost_idx = i; max_cost_idx = i;

View File

@ -628,7 +628,7 @@ private:
} }
} }
// First argument is symbol table, then output if a function // First argument is symbol table, then output if a function
bool needSyms = !refp->taskp()->dpiImport(); const bool needSyms = !refp->taskp()->dpiImport();
if (needSyms) ccallp->argTypes("vlSymsp"); if (needSyms) ccallp->argTypes("vlSymsp");
if (refp->taskp()->dpiContext()) { if (refp->taskp()->dpiContext()) {
@ -691,7 +691,7 @@ private:
AstNode* createAssignInternalToDpi(AstVar* portp, bool isPtr, const string& frSuffix, AstNode* createAssignInternalToDpi(AstVar* portp, bool isPtr, const string& frSuffix,
const string& toSuffix) { const string& toSuffix) {
string stmt = V3Task::assignInternalToDpi(portp, isPtr, frSuffix, toSuffix); const string stmt = V3Task::assignInternalToDpi(portp, isPtr, frSuffix, toSuffix);
return new AstCStmt(portp->fileline(), stmt); return new AstCStmt(portp->fileline(), stmt);
} }
@ -992,14 +992,14 @@ private:
// Ideally we'd make a table of variable // Ideally we'd make a table of variable
// characteristics, and reuse it wherever we can // characteristics, and reuse it wherever we can
// At least put them into the module's CTOR as static? // At least put them into the module's CTOR as static?
string propName = portp->name() + "__Vopenprops"; const string propName = portp->name() + "__Vopenprops";
string propCode = portp->vlPropDecl(propName); const string propCode = portp->vlPropDecl(propName);
cfuncp->addStmtsp(new AstCStmt(portp->fileline(), propCode)); cfuncp->addStmtsp(new AstCStmt(portp->fileline(), propCode));
// //
// At runtime we need the svOpenArrayHandle to // At runtime we need the svOpenArrayHandle to
// point to this task & thread's data, in addition // point to this task & thread's data, in addition
// to static info about the variable // to static info about the variable
string name = portp->name() + "__Vopenarray"; const string name = portp->name() + "__Vopenarray";
string varCode string varCode
= ("VerilatedDpiOpenVar " = ("VerilatedDpiOpenVar "
// NOLINTNEXTLINE(performance-inefficient-string-concatenation) // NOLINTNEXTLINE(performance-inefficient-string-concatenation)
@ -1025,7 +1025,7 @@ private:
// Store context, if needed // Store context, if needed
if (nodep->dpiContext()) { if (nodep->dpiContext()) {
string stmt = "Verilated::dpiContext(__Vscopep, __Vfilenamep, __Vlineno);\n"; const string stmt = "Verilated::dpiContext(__Vscopep, __Vfilenamep, __Vlineno);\n";
cfuncp->addStmtsp(new AstCStmt(nodep->fileline(), stmt)); cfuncp->addStmtsp(new AstCStmt(nodep->fileline(), stmt));
} }
@ -1135,7 +1135,7 @@ private:
// so make it unique now. // so make it unique now.
string suffix; // So, make them unique string suffix; // So, make them unique
if (!nodep->taskPublic() && !nodep->classMethod()) suffix = "_" + m_scopep->nameDotless(); if (!nodep->taskPublic() && !nodep->classMethod()) suffix = "_" + m_scopep->nameDotless();
string name = ((nodep->name() == "new") ? "new" : prefix + nodep->name() + suffix); const string name = ((nodep->name() == "new") ? "new" : prefix + nodep->name() + suffix);
AstCFunc* cfuncp = new AstCFunc( AstCFunc* cfuncp = new AstCFunc(
nodep->fileline(), name, m_scopep, nodep->fileline(), name, m_scopep,
((nodep->taskPublic() && rtnvarp) ? rtnvarp->cPubArgType(true, true) : "")); ((nodep->taskPublic() && rtnvarp) ? rtnvarp->cPubArgType(true, true) : ""));
@ -1307,7 +1307,7 @@ private:
UINFO(4, " FTask REF " << nodep << endl); UINFO(4, " FTask REF " << nodep << endl);
if (debug() >= 9) nodep->dumpTree(cout, "-inlfunc:"); if (debug() >= 9) nodep->dumpTree(cout, "-inlfunc:");
UASSERT_OBJ(m_scopep, nodep, "func ref not under scope"); UASSERT_OBJ(m_scopep, nodep, "func ref not under scope");
string namePrefix = ((VN_IS(nodep, FuncRef) ? "__Vfunc_" : "__Vtask_") const string namePrefix = ((VN_IS(nodep, FuncRef) ? "__Vfunc_" : "__Vtask_")
+ nodep->taskp()->shortName() + "__" + cvtToStr(m_modNCalls++)); + nodep->taskp()->shortName() + "__" + cvtToStr(m_modNCalls++));
// Create output variable // Create output variable
AstVarScope* outvscp = nullptr; AstVarScope* outvscp = nullptr;
@ -1621,8 +1621,8 @@ string V3Task::assignInternalToDpi(AstVar* portp, bool isPtr, const string& frSu
string ket; string ket;
// Someday we'll have better type support, and this can make variables and casts. // Someday we'll have better type support, and this can make variables and casts.
// But for now, we'll just text-bash it. // But for now, we'll just text-bash it.
string frName = frPrefix + portp->name() + frSuffix; const string frName = frPrefix + portp->name() + frSuffix;
string toName = portp->name() + toSuffix; const string toName = portp->name() + toSuffix;
size_t unpackSize = 1; // non-unpacked array is treated as size 1 size_t unpackSize = 1; // non-unpacked array is treated as size 1
int unpackDim = 0; int unpackDim = 0;
if (AstUnpackArrayDType* unpackp = VN_CAST(portp->dtypep()->skipRefp(), UnpackArrayDType)) { if (AstUnpackArrayDType* unpackp = VN_CAST(portp->dtypep()->skipRefp(), UnpackArrayDType)) {

View File

@ -640,7 +640,7 @@ private:
// If required, create the conditional node checking the activity flags // If required, create the conditional node checking the activity flags
if (!prevActSet || actSet != *prevActSet) { if (!prevActSet || actSet != *prevActSet) {
FileLine* const flp = m_topScopep->fileline(); FileLine* const flp = m_topScopep->fileline();
bool always = actSet.count(TraceActivityVertex::ACTIVITY_ALWAYS) != 0; const bool always = actSet.count(TraceActivityVertex::ACTIVITY_ALWAYS) != 0;
AstNode* condp = nullptr; AstNode* condp = nullptr;
if (always) { if (always) {
condp = new AstConst(flp, 1); // Always true, will be folded later condp = new AstConst(flp, 1); // Always true, will be folded later

View File

@ -165,7 +165,7 @@ private:
const string irpName = irp->prettyName(); const string irpName = irp->prettyName();
if (scopeLen > irpName.length()) continue; if (scopeLen > irpName.length()) continue;
string intfScopeName = irpName.substr(0, scopeLen); const string intfScopeName = irpName.substr(0, scopeLen);
if (scopeName != intfScopeName) continue; if (scopeName != intfScopeName) continue;
callCFuncSub(origSubFunc, m_initSubFuncp, irp); callCFuncSub(origSubFunc, m_initSubFuncp, irp);
++origSubStmts; ++origSubStmts;

View File

@ -1138,7 +1138,7 @@ class TristateVisitor final : public TristateBaseVisitor {
if (debug() >= 9) nodep->dumpTree(cout, "-pin-pre: "); if (debug() >= 9) nodep->dumpTree(cout, "-pin-pre: ");
// Empty/in-only; need Z to propagate // Empty/in-only; need Z to propagate
bool inDeclProcessing = (nodep->exprp() const bool inDeclProcessing = (nodep->exprp()
&& nodep->modVarp()->direction() == VDirection::INPUT && nodep->modVarp()->direction() == VDirection::INPUT
// Need to consider the original state // Need to consider the original state
// instead of current state as we converted // instead of current state as we converted

View File

@ -87,7 +87,7 @@ private:
} }
} else if (prev) { } else if (prev) {
AstBasicDType* bdtypep = m_varp->basicp(); AstBasicDType* bdtypep = m_varp->basicp();
int lsb = bit + 1; const int lsb = bit + 1;
if (bits != "") bits += ","; if (bits != "") bits += ",";
if (lsb == msb) { if (lsb == msb) {
bits += cvtToStr(lsb + bdtypep->lo()); bits += cvtToStr(lsb + bdtypep->lo());
@ -141,9 +141,9 @@ public:
return isUsedNotDrivenBit(0, m_bitFlags.size() / FLAGS_PER_BIT); return isUsedNotDrivenBit(0, m_bitFlags.size() / FLAGS_PER_BIT);
} }
bool unusedMatch(AstVar* nodep) { bool unusedMatch(AstVar* nodep) {
string regexp = v3Global.opt.unusedRegexp(); const string regexp = v3Global.opt.unusedRegexp();
if (regexp == "") return false; if (regexp == "") return false;
string prettyName = nodep->prettyName(); const string prettyName = nodep->prettyName();
return VString::wildmatch(prettyName.c_str(), regexp.c_str()); return VString::wildmatch(prettyName.c_str(), regexp.c_str());
} }
void reportViolations() { void reportViolations() {
@ -158,8 +158,8 @@ public:
bool anyDnotU = false; bool anyDnotU = false;
bool anynotDU = false; bool anynotDU = false;
for (unsigned bit = 0; bit < m_bitFlags.size() / FLAGS_PER_BIT; bit++) { for (unsigned bit = 0; bit < m_bitFlags.size() / FLAGS_PER_BIT; bit++) {
bool used = usedFlag(bit); const bool used = usedFlag(bit);
bool driv = drivenFlag(bit); const bool driv = drivenFlag(bit);
allU &= used; allU &= used;
anyU |= used; anyU |= used;
allD &= driv; allD &= driv;
@ -326,7 +326,7 @@ private:
if (varrefp && constp && !constp->num().isFourState()) { if (varrefp && constp && !constp->num().isFourState()) {
for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) { for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) {
UndrivenVarEntry* entryp = getEntryp(varrefp->varp(), usr); UndrivenVarEntry* entryp = getEntryp(varrefp->varp(), usr);
int lsb = constp->toUInt(); const int lsb = constp->toUInt();
if (m_inBBox || varrefp->access().isWriteOrRW()) { if (m_inBBox || varrefp->access().isWriteOrRW()) {
// Don't warn if already driven earlier as "a=0; if(a) a=1;" is fine. // Don't warn if already driven earlier as "a=0; if(a) a=1;" is fine.
if (usr == 2 && m_alwaysCombp if (usr == 2 && m_alwaysCombp
@ -365,7 +365,7 @@ private:
} }
for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) { for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) {
UndrivenVarEntry* entryp = getEntryp(nodep->varp(), usr); UndrivenVarEntry* entryp = getEntryp(nodep->varp(), usr);
bool fdrv = nodep->access().isWriteOrRW() const bool fdrv = nodep->access().isWriteOrRW()
&& nodep->varp()->attrFileDescr(); // FD's are also being read from && nodep->varp()->attrFileDescr(); // FD's are also being read from
if (m_inBBox || nodep->access().isWriteOrRW()) { if (m_inBBox || nodep->access().isWriteOrRW()) {
if (usr == 2 && m_alwaysCombp && entryp->isUsedNotDrivenAny()) { if (usr == 2 && m_alwaysCombp && entryp->isUsedNotDrivenAny()) {

View File

@ -84,7 +84,7 @@ private:
m_assignwp->convertToAlways(); m_assignwp->convertToAlways();
VL_DO_CLEAR(pushDeletep(m_assignwp), m_assignwp = nullptr); VL_DO_CLEAR(pushDeletep(m_assignwp), m_assignwp = nullptr);
} }
bool needDly = (m_assigndlyp != nullptr); const bool needDly = (m_assigndlyp != nullptr);
if (m_assigndlyp) { if (m_assigndlyp) {
// Delayed assignments become normal assignments, // Delayed assignments become normal assignments,
// then the temp created becomes the delayed assignment // then the temp created becomes the delayed assignment
@ -113,7 +113,7 @@ private:
UINFO(4, "Edit BOUNDLVALUE " << newp << endl); UINFO(4, "Edit BOUNDLVALUE " << newp << endl);
replaceHandle.relink(newp); replaceHandle.relink(newp);
} else { } else {
string name = (string("__Vlvbound") + cvtToStr(m_modp->varNumGetInc())); const string name = (string("__Vlvbound") + cvtToStr(m_modp->varNumGetInc()));
AstVar* varp = new AstVar(fl, AstVarType::MODULETEMP, name, prep->dtypep()); AstVar* varp = new AstVar(fl, AstVarType::MODULETEMP, name, prep->dtypep());
m_modp->addStmtp(varp); m_modp->addStmtp(varp);
@ -322,7 +322,7 @@ private:
// Make a Vxrand variable // Make a Vxrand variable
// We use the special XTEMP type so it doesn't break pure functions // We use the special XTEMP type so it doesn't break pure functions
UASSERT_OBJ(m_modp, nodep, "X number not under module"); UASSERT_OBJ(m_modp, nodep, "X number not under module");
string newvarname = (string("__Vxrand") + cvtToStr(m_modp->varNumGetInc())); const string newvarname = (string("__Vxrand") + cvtToStr(m_modp->varNumGetInc()));
AstVar* newvarp = new AstVar(nodep->fileline(), AstVarType::XTEMP, newvarname, AstVar* newvarp = new AstVar(nodep->fileline(), AstVarType::XTEMP, newvarname,
VFlagLogicPacked(), nodep->width()); VFlagLogicPacked(), nodep->width());
++m_statUnkVars; ++m_statUnkVars;
@ -365,7 +365,7 @@ private:
} }
// Find range of dtype we are selecting from // Find range of dtype we are selecting from
// Similar code in V3Const::warnSelect // Similar code in V3Const::warnSelect
int maxmsb = nodep->fromp()->dtypep()->width() - 1; const int maxmsb = nodep->fromp()->dtypep()->width() - 1;
if (debug() >= 9) nodep->dumpTree(cout, "sel_old: "); if (debug() >= 9) nodep->dumpTree(cout, "sel_old: ");
// If (maxmsb >= selected), we're in bound // If (maxmsb >= selected), we're in bound

View File

@ -324,8 +324,8 @@ private:
VL_DO_DANGLING(tempp->deleteTree(), tempp); VL_DO_DANGLING(tempp->deleteTree(), tempp);
} }
if (m_generate) { if (m_generate) {
string index = AstNode::encodeNumber(m_varValuep->toSInt()); const string index = AstNode::encodeNumber(m_varValuep->toSInt());
string nname = m_beginName + "__BRA__" + index + "__KET__"; const string nname = m_beginName + "__BRA__" + index + "__KET__";
oneloopp = new AstBegin(oneloopp->fileline(), nname, oneloopp, true); oneloopp = new AstBegin(oneloopp->fileline(), nname, oneloopp, true);
} }
VL_DO_CLEAR(pushDeletep(m_varValuep), m_varValuep = nullptr); VL_DO_CLEAR(pushDeletep(m_varValuep), m_varValuep = nullptr);

View File

@ -467,9 +467,10 @@ private:
} else if (nodep->expr1p()->isString() || nodep->expr2p()->isString()) { } else if (nodep->expr1p()->isString() || nodep->expr2p()->isString()) {
nodep->dtypeSetString(); nodep->dtypeSetString();
} else { } else {
int width = std::max(nodep->expr1p()->width(), nodep->expr2p()->width()); const int width = std::max(nodep->expr1p()->width(), nodep->expr2p()->width());
int mwidth = std::max(nodep->expr1p()->widthMin(), nodep->expr2p()->widthMin()); const int mwidth
bool issigned = nodep->expr1p()->isSigned() && nodep->expr2p()->isSigned(); = std::max(nodep->expr1p()->widthMin(), nodep->expr2p()->widthMin());
const bool issigned = nodep->expr1p()->isSigned() && nodep->expr2p()->isSigned();
nodep->dtypeSetLogicUnsized(width, mwidth, VSigning::fromBool(issigned)); nodep->dtypeSetLogicUnsized(width, mwidth, VSigning::fromBool(issigned));
} }
} }
@ -757,7 +758,7 @@ private:
checkConstantOrReplace(nodep->rightp(), "right side of bit range isn't a constant"); checkConstantOrReplace(nodep->rightp(), "right side of bit range isn't a constant");
if (m_vup->prelim()) { if (m_vup->prelim()) {
// Don't need to iterate because V3Const already constified // Don't need to iterate because V3Const already constified
int width = nodep->elementsConst(); const int width = nodep->elementsConst();
if (width > (1 << 28)) { if (width > (1 << 28)) {
nodep->v3error("Width of bit range is huge; vector of over 1billion bits: 0x" nodep->v3error("Width of bit range is huge; vector of over 1billion bits: 0x"
<< std::hex << width); << std::hex << width);
@ -818,7 +819,7 @@ private:
// variable[15:15] and 5 bits for [15:-2] // variable[15:15] and 5 bits for [15:-2]
int frommsb = nodep->fromp()->width() - 1; int frommsb = nodep->fromp()->width() - 1;
int fromlsb = 0; int fromlsb = 0;
int elw = nodep->declElWidth(); // Must adjust to tell user bit ranges const int elw = nodep->declElWidth(); // Must adjust to tell user bit ranges
if (nodep->declRange().ranged()) { if (nodep->declRange().ranged()) {
frommsb = nodep->declRange().hiMaxSelect() * elw frommsb = nodep->declRange().hiMaxSelect() * elw
+ (elw - 1); // Corrected for negative lsb + (elw - 1); // Corrected for negative lsb
@ -826,7 +827,7 @@ private:
} else { } else {
// nodep->v3fatalSrc("Should have been declRanged in V3WidthSel"); // nodep->v3fatalSrc("Should have been declRanged in V3WidthSel");
} }
int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit const int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit
AstNodeDType* selwidthDTypep AstNodeDType* selwidthDTypep
= nodep->findLogicDType(selwidth, selwidth, nodep->lsbp()->dtypep()->numeric()); = nodep->findLogicDType(selwidth, selwidth, nodep->lsbp()->dtypep()->numeric());
userIterateAndNext(nodep->fromp(), WidthVP(SELF, FINAL).p()); userIterateAndNext(nodep->fromp(), WidthVP(SELF, FINAL).p());
@ -907,7 +908,7 @@ private:
nodep->v3fatalSrc("Array reference exceeds dimension of array"); nodep->v3fatalSrc("Array reference exceeds dimension of array");
frommsb = fromlsb = 0; frommsb = fromlsb = 0;
} }
int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit const int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit
AstNodeDType* selwidthDTypep AstNodeDType* selwidthDTypep
= nodep->findLogicDType(selwidth, selwidth, nodep->bitp()->dtypep()->numeric()); = nodep->findLogicDType(selwidth, selwidth, nodep->bitp()->dtypep()->numeric());
if (widthBad(nodep->bitp(), selwidthDTypep) && nodep->bitp()->width() != 32) { if (widthBad(nodep->bitp(), selwidthDTypep) && nodep->bitp()->width() != 32) {
@ -1270,7 +1271,7 @@ private:
iterateCheckSizedSelf(nodep, "THS", nodep->thsp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "THS", nodep->thsp(), SELF, BOTH);
iterateCheckSizedSelf(nodep, "FHS", nodep->fhsp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "FHS", nodep->fhsp(), SELF, BOTH);
// If it's a 32 bit number, we need a 6 bit number as we need to return '32'. // If it's a 32 bit number, we need a 6 bit number as we need to return '32'.
int selwidth = V3Number::log2b(nodep->lhsp()->width()) + 1; const int selwidth = V3Number::log2b(nodep->lhsp()->width()) + 1;
nodep->dtypeSetLogicSized(selwidth, nodep->dtypeSetLogicSized(selwidth,
VSigning::UNSIGNED); // Spec doesn't indicate if an integer VSigning::UNSIGNED); // Spec doesn't indicate if an integer
} }
@ -1279,7 +1280,7 @@ private:
if (m_vup->prelim()) { if (m_vup->prelim()) {
iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH);
// If it's a 32 bit number, we need a 6 bit number as we need to return '32'. // If it's a 32 bit number, we need a 6 bit number as we need to return '32'.
int selwidth = V3Number::log2b(nodep->lhsp()->width()) + 1; const int selwidth = V3Number::log2b(nodep->lhsp()->width()) + 1;
nodep->dtypeSetLogicSized(selwidth, nodep->dtypeSetLogicSized(selwidth,
VSigning::UNSIGNED); // Spec doesn't indicate if an integer VSigning::UNSIGNED); // Spec doesn't indicate if an integer
} }
@ -1327,7 +1328,7 @@ private:
case AstAttrType::DIM_UNPK_DIMENSIONS: { case AstAttrType::DIM_UNPK_DIMENSIONS: {
UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, "Unsized expression"); UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, "Unsized expression");
std::pair<uint32_t, uint32_t> dim = nodep->fromp()->dtypep()->dimensions(true); std::pair<uint32_t, uint32_t> dim = nodep->fromp()->dtypep()->dimensions(true);
int val = (nodep->attrType() == AstAttrType::DIM_UNPK_DIMENSIONS const int val = (nodep->attrType() == AstAttrType::DIM_UNPK_DIMENSIONS
? dim.second ? dim.second
: (dim.first + dim.second)); : (dim.first + dim.second));
nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::Signed32(), val)); nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::Signed32(), val));
@ -1392,13 +1393,13 @@ private:
= nodep->fromp()->dtypep()->skipRefp()->dimensions(true); = nodep->fromp()->dtypep()->skipRefp()->dimensions(true);
uint32_t msbdim = dimpair.first + dimpair.second; uint32_t msbdim = dimpair.first + dimpair.second;
if (!nodep->dimp() || msbdim < 1) { if (!nodep->dimp() || msbdim < 1) {
int dim = 1; const int dim = 1;
AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(), AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(),
nodep->attrType(), dim); nodep->attrType(), dim);
nodep->replaceWith(newp); nodep->replaceWith(newp);
VL_DO_DANGLING(nodep->deleteTree(), nodep); VL_DO_DANGLING(nodep->deleteTree(), nodep);
} else if (VN_IS(nodep->dimp(), Const)) { } else if (VN_IS(nodep->dimp(), Const)) {
int dim = VN_CAST(nodep->dimp(), Const)->toSInt(); const int dim = VN_CAST(nodep->dimp(), Const)->toSInt();
AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(), AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(),
nodep->attrType(), dim); nodep->attrType(), dim);
nodep->replaceWith(newp); nodep->replaceWith(newp);
@ -1420,7 +1421,7 @@ private:
} }
case AstAttrType::TYPENAME: { case AstAttrType::TYPENAME: {
UASSERT_OBJ(nodep->fromp(), nodep, "Unprovided expression"); UASSERT_OBJ(nodep->fromp(), nodep, "Unprovided expression");
string result = nodep->fromp()->dtypep()->prettyDTypeName(); const string result = nodep->fromp()->dtypep()->prettyDTypeName();
AstNode* newp = new AstConst(nodep->fileline(), AstConst::String(), result); AstNode* newp = new AstConst(nodep->fileline(), AstConst::String(), result);
nodep->replaceWith(newp); nodep->replaceWith(newp);
VL_DO_DANGLING(nodep->deleteTree(), nodep); VL_DO_DANGLING(nodep->deleteTree(), nodep);
@ -1470,7 +1471,7 @@ private:
nodep->widthFromSub(nodep->subDTypep()); nodep->widthFromSub(nodep->subDTypep());
if (nodep->subDTypep()->skipRefp()->isCompound()) adtypep->isCompound(true); if (nodep->subDTypep()->skipRefp()->isCompound()) adtypep->isCompound(true);
} else { } else {
int width = nodep->subDTypep()->width() * nodep->rangep()->elementsConst(); const int width = nodep->subDTypep()->width() * nodep->rangep()->elementsConst();
nodep->widthForce(width, width); nodep->widthForce(width, width);
} }
UINFO(4, "dtWidthed " << nodep << endl); UINFO(4, "dtWidthed " << nodep << endl);
@ -1653,7 +1654,7 @@ private:
auto* enumDtp = VN_CAST(toDtp, EnumDType); auto* enumDtp = VN_CAST(toDtp, EnumDType);
UASSERT_OBJ(enumDtp, nodep, "$cast determined as enum, but not enum type"); UASSERT_OBJ(enumDtp, nodep, "$cast determined as enum, but not enum type");
uint64_t maxval = enumMaxValue(nodep, enumDtp); uint64_t maxval = enumMaxValue(nodep, enumDtp);
int selwidth = V3Number::log2b(maxval) + 1; // Width to address a bit const int selwidth = V3Number::log2b(maxval) + 1; // Width to address a bit
AstVar* varp = enumVarp(enumDtp, AstAttrType::ENUM_VALID, (1ULL << selwidth) - 1); AstVar* varp = enumVarp(enumDtp, AstAttrType::ENUM_VALID, (1ULL << selwidth) - 1);
AstVarRef* varrefp = new AstVarRef(fl, varp, VAccess::READ); AstVarRef* varrefp = new AstVarRef(fl, varp, VAccess::READ);
varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp()); varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp());
@ -1755,7 +1756,7 @@ private:
if (bad) { if (bad) {
} else if (AstBasicDType* basicp = toDtp->basicp()) { } else if (AstBasicDType* basicp = toDtp->basicp()) {
if (!basicp->isDouble() && !fromDtp->isDouble()) { if (!basicp->isDouble() && !fromDtp->isDouble()) {
int width = toDtp->width(); const int width = toDtp->width();
castSized(nodep, nodep->fromp(), width); castSized(nodep, nodep->fromp(), width);
// Note castSized might modify nodep->fromp() // Note castSized might modify nodep->fromp()
} else { } else {
@ -1840,7 +1841,7 @@ private:
// However the output width is exactly that requested. // However the output width is exactly that requested.
// So two steps, first do the calculation's width (max of the two widths) // So two steps, first do the calculation's width (max of the two widths)
{ {
int calcWidth = std::max(width, underDtp->width()); const int calcWidth = std::max(width, underDtp->width());
AstNodeDType* calcDtp AstNodeDType* calcDtp
= (underDtp->isFourstate() = (underDtp->isFourstate()
? nodep->findLogicDType(calcWidth, calcWidth, underDtp->numeric()) ? nodep->findLogicDType(calcWidth, calcWidth, underDtp->numeric())
@ -1895,7 +1896,7 @@ private:
// Parameters if implicit untyped inherit from what they are assigned to // Parameters if implicit untyped inherit from what they are assigned to
AstBasicDType* bdtypep = VN_CAST(nodep->dtypep(), BasicDType); AstBasicDType* bdtypep = VN_CAST(nodep->dtypep(), BasicDType);
bool didchk = false; bool didchk = false;
bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit(); const bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit();
if (implicitParam) { if (implicitParam) {
if (nodep->valuep()) { if (nodep->valuep()) {
userIterateAndNext(nodep->valuep(), WidthVP(nodep->dtypep(), PRELIM).p()); userIterateAndNext(nodep->valuep(), WidthVP(nodep->dtypep(), PRELIM).p());
@ -2403,7 +2404,7 @@ private:
} }
classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr; classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr;
} }
string suggest = speller.bestCandidateMsg(nodep->prettyName()); const string suggest = speller.bestCandidateMsg(nodep->prettyName());
nodep->v3error( nodep->v3error(
"Member " << nodep->prettyNameQ() << " not found in class " "Member " << nodep->prettyNameQ() << " not found in class "
<< first_classp->prettyNameQ() << "\n" << first_classp->prettyNameQ() << "\n"
@ -2509,7 +2510,7 @@ private:
++narg; ++narg;
UASSERT_OBJ(VN_IS(argp, Arg), nodep, "Method arg without Arg type"); UASSERT_OBJ(VN_IS(argp, Arg), nodep, "Method arg without Arg type");
} }
bool ok = (narg >= minArg) && (narg <= maxArg); const bool ok = (narg >= minArg) && (narg <= maxArg);
if (!ok) { if (!ok) {
nodep->v3error("The " << narg << " arguments passed to ." << nodep->prettyName() nodep->v3error("The " << narg << " arguments passed to ." << nodep->prettyName()
<< " method does not match its requiring " << cvtToStr(minArg) << " method does not match its requiring " << cvtToStr(minArg)
@ -2601,7 +2602,7 @@ private:
} }
// Need a runtime lookup table. Yuk. // Need a runtime lookup table. Yuk.
uint64_t msbdim = enumMaxValue(nodep, adtypep); uint64_t msbdim = enumMaxValue(nodep, adtypep);
int selwidth = V3Number::log2b(msbdim) + 1; // Width to address a bit const int selwidth = V3Number::log2b(msbdim) + 1; // Width to address a bit
AstVar* varp = enumVarp(adtypep, attrType, (1ULL << selwidth) - 1); AstVar* varp = enumVarp(adtypep, attrType, (1ULL << selwidth) - 1);
AstVarRef* varrefp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); AstVarRef* varrefp = new AstVarRef(nodep->fileline(), varp, VAccess::READ);
varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp()); varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp());
@ -3000,7 +3001,7 @@ private:
} }
classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr; classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr;
} }
string suggest = speller.bestCandidateMsg(nodep->prettyName()); const string suggest = speller.bestCandidateMsg(nodep->prettyName());
nodep->v3error("Class method " nodep->v3error("Class method "
<< nodep->prettyNameQ() << " not found in class " << nodep->prettyNameQ() << " not found in class "
<< first_classp->prettyNameQ() << "\n" << first_classp->prettyNameQ() << "\n"
@ -3272,7 +3273,7 @@ private:
// widths need to be individually determined // widths need to be individually determined
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp; for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
patp = VN_CAST(patp->nextp(), PatMember)) { patp = VN_CAST(patp->nextp(), PatMember)) {
int times = visitPatMemberRep(patp); const int times = visitPatMemberRep(patp);
for (int i = 1; i < times; i++) { for (int i = 1; i < times; i++) {
AstNode* newp = patp->cloneTree(false); AstNode* newp = patp->cloneTree(false);
patp->addNextHere(newp); patp->addNextHere(newp);
@ -3428,7 +3429,7 @@ private:
VL_DO_DANGLING(pushDeletep(nodep), nodep); // Deletes defaultp also, if present VL_DO_DANGLING(pushDeletep(nodep), nodep); // Deletes defaultp also, if present
} }
void patternArray(AstPattern* nodep, AstNodeArrayDType* arrayDtp, AstPatMember* defaultp) { void patternArray(AstPattern* nodep, AstNodeArrayDType* arrayDtp, AstPatMember* defaultp) {
VNumRange range = arrayDtp->declRange(); const VNumRange range = arrayDtp->declRange();
PatVecMap patmap = patVectorMap(nodep, range); PatVecMap patmap = patVectorMap(nodep, range);
UINFO(9, "ent " << range.left() << " to " << range.right() << endl); UINFO(9, "ent " << range.left() << " to " << range.right() << endl);
AstNode* newp = nullptr; AstNode* newp = nullptr;
@ -3533,7 +3534,7 @@ private:
} }
void patternBasic(AstPattern* nodep, AstNodeDType* vdtypep, AstPatMember* defaultp) { void patternBasic(AstPattern* nodep, AstNodeDType* vdtypep, AstPatMember* defaultp) {
AstBasicDType* bdtypep = VN_CAST(vdtypep, BasicDType); AstBasicDType* bdtypep = VN_CAST(vdtypep, BasicDType);
VNumRange range = bdtypep->declRange(); const VNumRange range = bdtypep->declRange();
PatVecMap patmap = patVectorMap(nodep, range); PatVecMap patmap = patVectorMap(nodep, range);
UINFO(9, "ent " << range.hi() << " to " << range.lo() << endl); UINFO(9, "ent " << range.hi() << " to " << range.lo() << endl);
AstNode* newp = nullptr; AstNode* newp = nullptr;
@ -3670,9 +3671,9 @@ private:
if (condp->dtypep()->isDouble()) { if (condp->dtypep()->isDouble()) {
subDTypep = nodep->findDoubleDType(); subDTypep = nodep->findDoubleDType();
} else { } else {
int width = std::max(subDTypep->width(), condp->width()); const int width = std::max(subDTypep->width(), condp->width());
int mwidth = std::max(subDTypep->widthMin(), condp->widthMin()); const int mwidth = std::max(subDTypep->widthMin(), condp->widthMin());
bool issigned = subDTypep->isSigned() && condp->isSigned(); const bool issigned = subDTypep->isSigned() && condp->isSigned();
subDTypep subDTypep
= nodep->findLogicDType(width, mwidth, VSigning::fromBool(issigned)); = nodep->findLogicDType(width, mwidth, VSigning::fromBool(issigned));
} }
@ -3789,7 +3790,7 @@ private:
string newFormat; string newFormat;
bool inPct = false; bool inPct = false;
AstNode* argp = nodep->exprsp(); AstNode* argp = nodep->exprsp();
string txt = nodep->text(); const string txt = nodep->text();
string fmt; string fmt;
for (char ch : txt) { for (char ch : txt) {
if (!inPct && ch == '%') { if (!inPct && ch == '%') {
@ -4145,13 +4146,13 @@ private:
modDTypep = modDTypep->skipRefp(); modDTypep = modDTypep->skipRefp();
conDTypep = conDTypep->skipRefp(); conDTypep = conDTypep->skipRefp();
AstNodeDType* subDTypep = modDTypep; AstNodeDType* subDTypep = modDTypep;
int pinwidth = modDTypep->width(); const int pinwidth = modDTypep->width();
int conwidth = conDTypep->width(); const int conwidth = conDTypep->width();
if (conDTypep == modDTypep // If match, we're golden if (conDTypep == modDTypep // If match, we're golden
|| similarDTypeRecurse(conDTypep, modDTypep)) { || similarDTypeRecurse(conDTypep, modDTypep)) {
userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p()); userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p());
} else if (m_cellp->rangep()) { } else if (m_cellp->rangep()) {
int numInsts = m_cellp->rangep()->elementsConst(); const int numInsts = m_cellp->rangep()->elementsConst();
if (conwidth == pinwidth) { if (conwidth == pinwidth) {
// Arrayed instants: widths match so connect to each instance // Arrayed instants: widths match so connect to each instance
subDTypep = conDTypep; // = same expr dtype subDTypep = conDTypep; // = same expr dtype
@ -4216,8 +4217,8 @@ private:
AstNodeArrayDType* modArrayp = VN_CAST(modDTypep, UnpackArrayDType); AstNodeArrayDType* modArrayp = VN_CAST(modDTypep, UnpackArrayDType);
if (exprArrayp && modArrayp && VN_IS(exprArrayp->subDTypep(), IfaceRefDType) if (exprArrayp && modArrayp && VN_IS(exprArrayp->subDTypep(), IfaceRefDType)
&& exprArrayp->declRange().elements() != modArrayp->declRange().elements()) { && exprArrayp->declRange().elements() != modArrayp->declRange().elements()) {
int exprSize = exprArrayp->declRange().elements(); const int exprSize = exprArrayp->declRange().elements();
int modSize = modArrayp->declRange().elements(); const int modSize = modArrayp->declRange().elements();
nodep->v3error("Illegal " nodep->v3error("Illegal "
<< nodep->prettyOperatorName() << "," << nodep->prettyOperatorName() << ","
<< " mismatch between port which is an interface array of size " << " mismatch between port which is an interface array of size "
@ -4265,9 +4266,9 @@ private:
nodep->dtypeFrom(nodep->rangep()); nodep->dtypeFrom(nodep->rangep());
// Very much like like an pin // Very much like like an pin
AstNodeDType* conDTypep = nodep->exprp()->dtypep(); AstNodeDType* conDTypep = nodep->exprp()->dtypep();
int numInsts = nodep->rangep()->elementsConst(); const int numInsts = nodep->rangep()->elementsConst();
int pinwidth = numInsts; const int pinwidth = numInsts;
int conwidth = conDTypep->width(); const int conwidth = conDTypep->width();
if (conwidth == 1 && pinwidth > 1) { // Multiple connections if (conwidth == 1 && pinwidth > 1) { // Multiple connections
AstNodeDType* subDTypep = nodep->findLogicDType(1, 1, conDTypep->numeric()); AstNodeDType* subDTypep = nodep->findLogicDType(1, 1, conDTypep->numeric());
userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p()); userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p());
@ -4714,13 +4715,13 @@ private:
iterateCheckString(nodep, "RHS", nodep->rhsp(), FINAL); iterateCheckString(nodep, "RHS", nodep->rhsp(), FINAL);
} }
} else { } else {
bool signedFl = nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned(); const bool signedFl = nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned();
if (AstNodeBiop* newp = replaceWithUOrSVersion(nodep, signedFl)) { if (AstNodeBiop* newp = replaceWithUOrSVersion(nodep, signedFl)) {
VL_DANGLING(nodep); VL_DANGLING(nodep);
nodep = newp; // Process new node instead nodep = newp; // Process new node instead
} }
int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width()); const int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
int ewidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin()); const int ewidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
AstNodeDType* subDTypep AstNodeDType* subDTypep
= nodep->findLogicDType(width, ewidth, VSigning::fromBool(signedFl)); = nodep->findLogicDType(width, ewidth, VSigning::fromBool(signedFl));
bool warnOn = true; bool warnOn = true;
@ -4828,7 +4829,7 @@ private:
if (m_vup->prelim()) { if (m_vup->prelim()) {
userIterateAndNext(nodep->lhsp(), WidthVP(SELF, PRELIM).p()); userIterateAndNext(nodep->lhsp(), WidthVP(SELF, PRELIM).p());
checkCvtUS(nodep->lhsp()); checkCvtUS(nodep->lhsp());
int width = nodep->lhsp()->width(); const int width = nodep->lhsp()->width();
AstNodeDType* expDTypep = nodep->findLogicDType(width, width, rs_out); AstNodeDType* expDTypep = nodep->findLogicDType(width, width, rs_out);
nodep->dtypep(expDTypep); nodep->dtypep(expDTypep);
AstNodeDType* subDTypep = expDTypep; AstNodeDType* subDTypep = expDTypep;
@ -4909,9 +4910,9 @@ private:
userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p());
checkCvtUS(nodep->lhsp()); checkCvtUS(nodep->lhsp());
checkCvtUS(nodep->rhsp()); checkCvtUS(nodep->rhsp());
int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width()); const int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
int mwidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin()); const int mwidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned()); const bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned());
nodep->dtypeChgWidthSigned(width, mwidth, VSigning::fromBool(expSigned)); nodep->dtypeChgWidthSigned(width, mwidth, VSigning::fromBool(expSigned));
} }
if (m_vup->final()) { if (m_vup->final()) {
@ -4957,9 +4958,9 @@ private:
iterateCheckReal(nodep, "RHS", nodep->rhsp(), FINAL); iterateCheckReal(nodep, "RHS", nodep->rhsp(), FINAL);
return; return;
} else { } else {
int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width()); const int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
int mwidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin()); const int mwidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned()); const bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned());
nodep->dtypeChgWidthSigned(width, mwidth, VSigning::fromBool(expSigned)); nodep->dtypeChgWidthSigned(width, mwidth, VSigning::fromBool(expSigned));
} }
} }
@ -5016,7 +5017,7 @@ private:
// LOWER LEVEL WIDTH METHODS (none iterate) // LOWER LEVEL WIDTH METHODS (none iterate)
bool widthBad(AstNode* nodep, AstNodeDType* expDTypep) { bool widthBad(AstNode* nodep, AstNodeDType* expDTypep) {
int expWidth = expDTypep->width(); const int expWidth = expDTypep->width();
int expWidthMin = expDTypep->widthMin(); int expWidthMin = expDTypep->widthMin();
UASSERT_OBJ(nodep->dtypep(), nodep, UASSERT_OBJ(nodep->dtypep(), nodep,
"Under node " << nodep->prettyTypeName() "Under node " << nodep->prettyTypeName()
@ -5048,7 +5049,7 @@ private:
UINFO(4, " widthExtend_(r=" << extendRule << ") old: " << nodep << endl); UINFO(4, " widthExtend_(r=" << extendRule << ") old: " << nodep << endl);
if (extendRule == EXTEND_OFF) return; if (extendRule == EXTEND_OFF) return;
AstConst* constp = VN_CAST(nodep, Const); AstConst* constp = VN_CAST(nodep, Const);
int expWidth = expDTypep->width(); const int expWidth = expDTypep->width();
if (constp && !constp->num().isNegative()) { if (constp && !constp->num().isNegative()) {
// Save later constant propagation work, just right-size it. // Save later constant propagation work, just right-size it.
V3Number num(nodep, expWidth); V3Number num(nodep, expWidth);
@ -5100,8 +5101,8 @@ private:
// IF (A(CONSTwide)) becomes IF (A(CONSTreduced)) // IF (A(CONSTwide)) becomes IF (A(CONSTreduced))
// IF (A(somewide)) becomes IF (A(REDOR(somewide))) // IF (A(somewide)) becomes IF (A(REDOR(somewide)))
// Attempt to fix it quietly // Attempt to fix it quietly
int expWidth = 1; const int expWidth = 1;
int expSigned = false; const int expSigned = false;
UINFO(4, " widthReduce_old: " << nodep << endl); UINFO(4, " widthReduce_old: " << nodep << endl);
AstConst* constp = VN_CAST(nodep, Const); AstConst* constp = VN_CAST(nodep, Const);
if (constp) { if (constp) {
@ -5287,7 +5288,7 @@ private:
underp->replaceWith(new AstConst(nodep->fileline(), AstConst::BitFalse())); underp->replaceWith(new AstConst(nodep->fileline(), AstConst::BitFalse()));
VL_DO_DANGLING(pushDeletep(underp), underp); VL_DO_DANGLING(pushDeletep(underp), underp);
} else { } else {
bool bad = widthBad(underp, nodep->findBitDType()); const bool bad = widthBad(underp, nodep->findBitDType());
if (bad) { if (bad) {
{ // if (warnOn), but not needed here { // if (warnOn), but not needed here
if (debug() > 4) nodep->backp()->dumpTree(cout, " back: "); if (debug() > 4) nodep->backp()->dumpTree(cout, " back: ");
@ -5401,10 +5402,10 @@ private:
#endif #endif
return; return;
} else { } else {
int expWidth = expDTypep->width(); const int expWidth = expDTypep->width();
int expWidthMin = expDTypep->widthMin(); int expWidthMin = expDTypep->widthMin();
if (expWidthMin == 0) expWidthMin = expWidth; if (expWidthMin == 0) expWidthMin = expWidth;
bool bad = widthBad(underp, expDTypep); const bool bad = widthBad(underp, expDTypep);
if ((bad || underp->width() != expWidth) && fixAutoExtend(underp /*ref*/, expWidth)) { if ((bad || underp->width() != expWidth) && fixAutoExtend(underp /*ref*/, expWidth)) {
underp = nullptr; // Changes underp underp = nullptr; // Changes underp
return; return;
@ -6003,7 +6004,7 @@ private:
} }
static Castable computeCastableImp(AstNodeDType* toDtp, AstNodeDType* fromDtp, static Castable computeCastableImp(AstNodeDType* toDtp, AstNodeDType* fromDtp,
AstNode* fromConstp) { AstNode* fromConstp) {
Castable castable = UNSUPPORTED; const Castable castable = UNSUPPORTED;
toDtp = toDtp->skipRefToEnump(); toDtp = toDtp->skipRefToEnump();
fromDtp = fromDtp->skipRefToEnump(); fromDtp = fromDtp->skipRefToEnump();
if (toDtp == fromDtp) return COMPATIBLE; if (toDtp == fromDtp) return COMPATIBLE;
@ -6014,7 +6015,8 @@ private:
fromBaseDtp = refp->refDTypep(); fromBaseDtp = refp->refDTypep();
} }
} }
bool fromNumericable = VN_IS(fromBaseDtp, BasicDType) || VN_IS(fromBaseDtp, EnumDType) const bool fromNumericable = VN_IS(fromBaseDtp, BasicDType)
|| VN_IS(fromBaseDtp, EnumDType)
|| VN_IS(fromBaseDtp, NodeUOrStructDType); || VN_IS(fromBaseDtp, NodeUOrStructDType);
// UNSUP unpacked struct/unions (treated like BasicDType) // UNSUP unpacked struct/unions (treated like BasicDType)
if (VN_IS(toDtp, BasicDType) || VN_IS(toDtp, NodeUOrStructDType)) { if (VN_IS(toDtp, BasicDType) || VN_IS(toDtp, NodeUOrStructDType)) {
@ -6027,8 +6029,8 @@ private:
} else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromDtp, ClassRefDType)) { } else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromDtp, ClassRefDType)) {
const auto toClassp = VN_CAST(toDtp, ClassRefDType)->classp(); const auto toClassp = VN_CAST(toDtp, ClassRefDType)->classp();
const auto fromClassp = VN_CAST(fromDtp, ClassRefDType)->classp(); const auto fromClassp = VN_CAST(fromDtp, ClassRefDType)->classp();
bool downcast = AstClass::isClassExtendedFrom(toClassp, fromClassp); const bool downcast = AstClass::isClassExtendedFrom(toClassp, fromClassp);
bool upcast = AstClass::isClassExtendedFrom(fromClassp, toClassp); const bool upcast = AstClass::isClassExtendedFrom(fromClassp, toClassp);
if (upcast) { if (upcast) {
return COMPATIBLE; return COMPATIBLE;
} else if (downcast) { } else if (downcast) {

View File

@ -129,7 +129,7 @@ private:
nodep->v3fatalSrc("ref to unhandled definition type " << defp->prettyTypeName()); nodep->v3fatalSrc("ref to unhandled definition type " << defp->prettyTypeName());
} }
if (local || prot) { if (local || prot) {
auto refClassp = VN_CAST(m_modp, Class); const auto refClassp = VN_CAST(m_modp, Class);
const char* how = nullptr; const char* how = nullptr;
if (local && defClassp && refClassp != defClassp) { if (local && defClassp && refClassp != defClassp) {
how = "'local'"; how = "'local'";

View File

@ -207,9 +207,9 @@ private:
AstNode* fromp = nodep->fromp()->unlinkFrBack(); AstNode* fromp = nodep->fromp()->unlinkFrBack();
AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); // bit we're extracting AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); // bit we're extracting
if (debug() >= 9) nodep->dumpTree(cout, "--SELBT2: "); if (debug() >= 9) nodep->dumpTree(cout, "--SELBT2: ");
FromData fromdata = fromDataForArray(nodep, fromp); const FromData fromdata = fromDataForArray(nodep, fromp);
AstNodeDType* ddtypep = fromdata.m_dtypep; AstNodeDType* ddtypep = fromdata.m_dtypep;
VNumRange fromRange = fromdata.m_fromRange; const VNumRange fromRange = fromdata.m_fromRange;
UINFO(6, " ddtypep " << ddtypep << endl); UINFO(6, " ddtypep " << ddtypep << endl);
if (AstUnpackArrayDType* adtypep = VN_CAST(ddtypep, UnpackArrayDType)) { if (AstUnpackArrayDType* adtypep = VN_CAST(ddtypep, UnpackArrayDType)) {
// SELBIT(array, index) -> ARRAYSEL(array, index) // SELBIT(array, index) -> ARRAYSEL(array, index)
@ -234,7 +234,7 @@ private:
adtypep, adtypep,
"Array extraction with width miscomputed " << adtypep->width() << "/" "Array extraction with width miscomputed " << adtypep->width() << "/"
<< fromRange.elements()); << fromRange.elements());
int elwidth = adtypep->width() / fromRange.elements(); const int elwidth = adtypep->width() / fromRange.elements();
AstSel* newp = new AstSel( AstSel* newp = new AstSel(
nodep->fileline(), fromp, nodep->fileline(), fromp,
new AstMul(nodep->fileline(), new AstMul(nodep->fileline(),
@ -335,9 +335,9 @@ private:
vlsint32_t msb = VN_CAST(msbp, Const)->toSInt(); vlsint32_t msb = VN_CAST(msbp, Const)->toSInt();
vlsint32_t lsb = VN_CAST(lsbp, Const)->toSInt(); vlsint32_t lsb = VN_CAST(lsbp, Const)->toSInt();
vlsint32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1); vlsint32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1);
FromData fromdata = fromDataForArray(nodep, fromp); const FromData fromdata = fromDataForArray(nodep, fromp);
AstNodeDType* ddtypep = fromdata.m_dtypep; AstNodeDType* ddtypep = fromdata.m_dtypep;
VNumRange fromRange = fromdata.m_fromRange; const VNumRange fromRange = fromdata.m_fromRange;
if (VN_IS(ddtypep, UnpackArrayDType)) { if (VN_IS(ddtypep, UnpackArrayDType)) {
// Slice extraction // Slice extraction
if (fromRange.elements() == elem if (fromRange.elements() == elem
@ -378,7 +378,7 @@ private:
msb = lsb; msb = lsb;
lsb = x; lsb = x;
} }
int elwidth = adtypep->width() / fromRange.elements(); const int elwidth = adtypep->width() / fromRange.elements();
AstSel* newp = new AstSel( AstSel* newp = new AstSel(
nodep->fileline(), fromp, nodep->fileline(), fromp,
new AstMul(nodep->fileline(), newSubLsbOf(lsbp, fromRange), new AstMul(nodep->fileline(), newSubLsbOf(lsbp, fromRange),
@ -479,15 +479,15 @@ private:
AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
AstNode* widthp = nodep->thsp()->unlinkFrBack(); AstNode* widthp = nodep->thsp()->unlinkFrBack();
warnTri(rhsp); warnTri(rhsp);
int width = VN_CAST(widthp, Const)->toSInt(); const int width = VN_CAST(widthp, Const)->toSInt();
if (width > (1 << 28)) { if (width > (1 << 28)) {
nodep->v3error("Width of :+ or :- is huge; vector of over 1billion bits: " nodep->v3error("Width of :+ or :- is huge; vector of over 1billion bits: "
<< widthp->prettyName()); << widthp->prettyName());
} }
if (width < 0) nodep->v3error("Width of :+ or :- is < 0: " << widthp->prettyName()); if (width < 0) nodep->v3error("Width of :+ or :- is < 0: " << widthp->prettyName());
FromData fromdata = fromDataForArray(nodep, fromp); const FromData fromdata = fromDataForArray(nodep, fromp);
AstNodeDType* ddtypep = fromdata.m_dtypep; AstNodeDType* ddtypep = fromdata.m_dtypep;
VNumRange fromRange = fromdata.m_fromRange; const VNumRange fromRange = fromdata.m_fromRange;
if (VN_IS(ddtypep, UnpackArrayDType)) { if (VN_IS(ddtypep, UnpackArrayDType)) {
// Slice +: and -: extraction // Slice +: and -: extraction
if (fromRange.elements() == width && VN_IS(rhsp, Const) if (fromRange.elements() == width && VN_IS(rhsp, Const)

View File

@ -704,7 +704,7 @@ int main(int argc, char** argv, char** env) {
// Command option parsing // Command option parsing
v3Global.opt.bin(argv[0]); v3Global.opt.bin(argv[0]);
string argString = V3Options::argString(argc - 1, argv + 1); const string argString = V3Options::argString(argc - 1, argv + 1);
v3Global.opt.parseOpts(new FileLine(FileLine::commandLineFilename()), argc - 1, argv + 1); v3Global.opt.parseOpts(new FileLine(FileLine::commandLineFilename()), argc - 1, argv + 1);
// Validate settings (aka Boost.Program_options) // Validate settings (aka Boost.Program_options)

View File

@ -79,7 +79,7 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
for (int i = 0; i < argc;) { for (int i = 0; i < argc;) {
UINFO(9, " Option: " << argv[i] << endl); UINFO(9, " Option: " << argv[i] << endl);
if (argv[i][0] == '-') { if (argv[i][0] == '-') {
if (int consumed = parser.parse(i, argc, argv)) { if (const int consumed = parser.parse(i, argc, argv)) {
i += consumed; i += consumed;
} else { } else {
v3fatal("Invalid option: " << argv[i] << parser.getSuggestion(argv[i])); v3fatal("Invalid option: " << argv[i] << parser.getSuggestion(argv[i]));

View File

@ -61,7 +61,7 @@ public:
// METHODS // METHODS
string keyExtract(const char* shortKey) const { string keyExtract(const char* shortKey) const {
// Hot function // Hot function
size_t shortLen = std::strlen(shortKey); const size_t shortLen = std::strlen(shortKey);
const string namestr = name(); const string namestr = name();
for (const char* cp = namestr.c_str(); *cp; ++cp) { for (const char* cp = namestr.c_str(); *cp; ++cp) {
if (*cp == '\001') { if (*cp == '\001') {

View File

@ -37,14 +37,14 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) {
VlcTest* testp = tests().newTest(filename, 0, 0); VlcTest* testp = tests().newTest(filename, 0, 0);
while (!is.eof()) { while (!is.eof()) {
string line = V3Os::getline(is); const string line = V3Os::getline(is);
// UINFO(9," got "<<line<<endl); // UINFO(9," got "<<line<<endl);
if (line[0] == 'C') { if (line[0] == 'C') {
string::size_type secspace = 3; string::size_type secspace = 3;
for (; secspace < line.length(); secspace++) { for (; secspace < line.length(); secspace++) {
if (line[secspace] == '\'' && line[secspace + 1] == ' ') break; if (line[secspace] == '\'' && line[secspace + 1] == ' ') break;
} }
string point = line.substr(3, secspace - 3); const string point = line.substr(3, secspace - 3);
vluint64_t hits = std::atoll(line.c_str() + secspace + 1); vluint64_t hits = std::atoll(line.c_str() + secspace + 1);
// UINFO(9," point '"<<point<<"'"<<" "<<hits<<endl); // UINFO(9," point '"<<point<<"'"<<" "<<hits<<endl);
@ -112,7 +112,7 @@ void VlcTop::writeInfo(const string& filename) {
os << "SF:" << source.name() << '\n'; os << "SF:" << source.name() << '\n';
VlcSource::LinenoMap& lines = source.lines(); VlcSource::LinenoMap& lines = source.lines();
for (auto& li : lines) { for (auto& li : lines) {
int lineno = li.first; const int lineno = li.first;
VlcSource::ColumnMap& cmap = li.second; VlcSource::ColumnMap& cmap = li.second;
bool first = true; bool first = true;
vluint64_t min_count = 0; // Minimum across all columns on line vluint64_t min_count = 0; // Minimum across all columns on line
@ -198,14 +198,14 @@ void VlcTop::annotateCalc() {
// Calculate per-line information into filedata structure // Calculate per-line information into filedata structure
for (const auto& i : m_points) { for (const auto& i : m_points) {
const VlcPoint& point = m_points.pointNumber(i.second); const VlcPoint& point = m_points.pointNumber(i.second);
string filename = point.filename(); const string filename = point.filename();
int lineno = point.lineno(); const int lineno = point.lineno();
if (!filename.empty() && lineno != 0) { if (!filename.empty() && lineno != 0) {
VlcSource& source = sources().findNewSource(filename); VlcSource& source = sources().findNewSource(filename);
string threshStr = point.thresh(); const string threshStr = point.thresh();
unsigned thresh unsigned thresh
= (!threshStr.empty()) ? std::atoi(threshStr.c_str()) : opt.annotateMin(); = (!threshStr.empty()) ? std::atoi(threshStr.c_str()) : opt.annotateMin();
bool ok = (point.count() >= thresh); const bool ok = (point.count() >= thresh);
UINFO(9, "AnnoCalc count " << filename << ":" << lineno << ":" << point.column() << " " UINFO(9, "AnnoCalc count " << filename << ":" << lineno << ":" << point.column() << " "
<< point.count() << " " << point.linescov() << '\n'); << point.count() << " " << point.linescov() << '\n');
// Base coverage // Base coverage
@ -214,7 +214,7 @@ void VlcTop::annotateCalc() {
bool range = false; bool range = false;
int start = 0; int start = 0;
int end = 0; int end = 0;
string linescov = point.linescov(); const string linescov = point.linescov();
for (const char* covp = linescov.c_str(); true; ++covp) { for (const char* covp = linescov.c_str(); true; ++covp) {
if (!*covp || *covp == ',') { // Ending if (!*covp || *covp == ',') { // Ending
for (int lni = start; start && lni <= end; ++lni) { for (int lni = start; start && lni <= end; ++lni) {
@ -262,7 +262,7 @@ void VlcTop::annotateCalcNeeded() {
} }
} }
} }
float pct = totCases ? (100 * totOk / totCases) : 0; const float pct = totCases ? (100 * totOk / totCases) : 0;
cout << "Total coverage (" << totOk << "/" << totCases << ") "; cout << "Total coverage (" << totOk << "/" << totCases << ") ";
cout << std::fixed << std::setw(3) << std::setprecision(2) << pct << "%\n"; cout << std::fixed << std::setw(3) << std::setprecision(2) << pct << "%\n";
if (totOk != totCases) cout << "See lines with '%00' in " << opt.annotateOut() << '\n'; if (totOk != totCases) cout << "See lines with '%00' in " << opt.annotateOut() << '\n';
@ -274,8 +274,8 @@ void VlcTop::annotateOutputFiles(const string& dirname) {
for (auto& si : m_sources) { for (auto& si : m_sources) {
VlcSource& source = si.second; VlcSource& source = si.second;
if (!source.needed()) continue; if (!source.needed()) continue;
string filename = source.name(); const string filename = source.name();
string outfilename = dirname + "/" + V3Os::filenameNonDir(filename); const string outfilename = dirname + "/" + V3Os::filenameNonDir(filename);
UINFO(1, "annotateOutputFile " << filename << " -> " << outfilename << endl); UINFO(1, "annotateOutputFile " << filename << " -> " << outfilename << endl);