Internals: Use C++14 quoted literal std::string

This commit is contained in:
Wilson Snyder 2024-01-28 20:24:28 -05:00
parent eecdf4b0f3
commit 22687a6901
38 changed files with 92 additions and 107 deletions

View File

@ -943,7 +943,7 @@ void _vl_vsformat(std::string& output, const std::string& format, va_list ap) VL
if (VL_SIGN_E(lbits, lwp[VL_WORDS_I(lbits) - 1])) {
VlWide<VL_VALUE_STRING_MAX_WIDTH / 4 + 2> neg;
VL_NEGATE_W(VL_WORDS_I(lbits), neg, lwp);
append = std::string{"-"} + VL_DECIMAL_NW(lbits, neg);
append = "-"s + VL_DECIMAL_NW(lbits, neg);
} else {
append = VL_DECIMAL_NW(lbits, lwp);
}
@ -1085,7 +1085,7 @@ void _vl_vsformat(std::string& output, const std::string& format, va_list ap) VL
}
break;
default: { // LCOV_EXCL_START
const std::string msg = std::string{"Unknown _vl_vsformat code: "} + pos[0];
const std::string msg = "Unknown _vl_vsformat code: "s + pos[0];
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
break;
} // LCOV_EXCL_STOP
@ -1367,7 +1367,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
break;
}
default: { // LCOV_EXCL_START
const std::string msg = std::string{"Unknown _vl_vsscanf code: "} + pos[0];
const std::string msg = "Unknown _vl_vsscanf code: "s + pos[0];
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
break;
} // LCOV_EXCL_STOP
@ -1727,7 +1727,7 @@ std::string VL_STACKTRACE_N() VL_MT_SAFE {
if (!strings) return "Unable to backtrace\n";
std::string result = "Backtrace:\n";
for (int j = 0; j < nptrs; j++) result += std::string{strings[j]} + std::string{"\n"};
for (int j = 0; j < nptrs; j++) result += std::string{strings[j]} + "\n"s;
free(strings);
return result;
}
@ -2990,7 +2990,7 @@ void Verilated::nullPointerError(const char* filename, int linenum) VL_MT_SAFE {
void Verilated::overWidthError(const char* signame) VL_MT_SAFE {
// Slowpath - Called only when signal sets too high of a bit
const std::string msg = (std::string{"Testbench C set input '"} + signame
const std::string msg = ("Testbench C set input '"s + signame
+ "' to value that overflows what the signal's width can fit");
VL_FATAL_MT("unknown", 0, "", msg.c_str());
VL_UNREACHABLE;
@ -3212,8 +3212,7 @@ void VerilatedScope::varInsert(int finalize, const char* namep, void* datap, boo
} else {
// We could have a linked list of ranges, but really this whole thing needs
// to be generalized to support structs and unions, etc.
const std::string msg
= std::string{"Unsupported multi-dimensional public varInsert: "} + namep;
const std::string msg = "Unsupported multi-dimensional public varInsert: "s + namep;
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
}
}
@ -3233,10 +3232,9 @@ VerilatedVar* VerilatedScope::varFind(const char* namep) const VL_MT_SAFE_POSTIN
void* VerilatedScope::exportFindNullError(int funcnum) VL_MT_SAFE {
// Slowpath - Called only when find has failed
const std::string msg
= (std::string{"Testbench C called '"} + VerilatedImp::exportName(funcnum)
+ "' but scope wasn't set, perhaps due to dpi import call without "
+ "'context', or missing svSetScope. See IEEE 1800-2017 35.5.3.");
const std::string msg = ("Testbench C called '"s + VerilatedImp::exportName(funcnum)
+ "' but scope wasn't set, perhaps due to dpi import call without "
+ "'context', or missing svSetScope. See IEEE 1800-2017 35.5.3.");
VL_FATAL_MT("unknown", 0, "", msg.c_str());
return nullptr;
}
@ -3244,7 +3242,7 @@ void* VerilatedScope::exportFindNullError(int funcnum) VL_MT_SAFE {
void* VerilatedScope::exportFindError(int funcnum) const VL_MT_SAFE {
// Slowpath - Called only when find has failed
const std::string msg
= (std::string{"Testbench C called '"} + VerilatedImp::exportName(funcnum)
= ("Testbench C called '"s + VerilatedImp::exportName(funcnum)
+ "' but this DPI export function exists only in other scopes, not scope '" + name()
+ "'");
VL_FATAL_MT("unknown", 0, "", msg.c_str());

View File

@ -168,11 +168,11 @@ private:
const std::string& value) VL_PURE {
std::string name;
if (key.length() == 1 && std::isalpha(key[0])) {
name += std::string{"\001"} + key;
name += "\001"s + key;
} else {
name += std::string{"\001"} + dequote(key);
name += "\001"s + dequote(key);
}
name += std::string{"\002"} + dequote(value);
name += "\002"s + dequote(value);
return name;
}
static std::string combineHier(const std::string& old, const std::string& add) VL_PURE {
@ -364,7 +364,7 @@ public:
std::ofstream os{filename};
if (os.fail()) {
const std::string msg = std::string{"%Error: Can't write '"} + filename + "'";
const std::string msg = "%Error: Can't write '"s + filename + "'";
VL_FATAL_MT("", 0, "", msg.c_str());
return;
}

View File

@ -552,7 +552,7 @@ public:
const VerilatedLockGuard lock{s().m_exportMutex};
const auto& it = s().m_exportMap.find(namep);
if (VL_LIKELY(it != s().m_exportMap.end())) return it->second;
const std::string msg = (std::string{"%Error: Testbench C called "} + namep
const std::string msg = ("%Error: Testbench C called "s + namep
+ " but no such DPI export function name exists in ANY model");
VL_FATAL_MT("unknown", 0, "", msg.c_str());
return -1;

View File

@ -114,8 +114,7 @@ void VerilatedDeserialize::trailer() VL_MT_UNSAFE_ONE {
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_TRAILER_STR, std::strlen(VLTSAVE_TRAILER_STR)))) {
const std::string fn = filename();
const std::string msg
= std::string{"Can't deserialize; file has wrong end-of-file signature: "}
+ filename();
= "Can't deserialize; file has wrong end-of-file signature: "s + filename();
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
// Die before we close() as close would infinite loop
}

View File

@ -263,7 +263,7 @@ public:
inline std::string VL_TO_STRING(const VlEventBase& e);
inline std::string VL_TO_STRING(const VlEvent& e) {
return std::string{"triggered="} + (e.isTriggered() ? "true" : "false");
return "triggered="s + (e.isTriggered() ? "true" : "false");
}
inline std::string VL_TO_STRING(const VlAssignableEvent& e) {
@ -274,7 +274,7 @@ inline std::string VL_TO_STRING(const VlEventBase& e) {
if (const VlAssignableEvent& assignable = dynamic_cast<const VlAssignableEvent&>(e)) {
return VL_TO_STRING(assignable);
}
return std::string{"triggered="} + (e.isTriggered() ? "true" : "false");
return "triggered="s + (e.isTriggered() ? "true" : "false");
}
//===================================================================

View File

@ -282,8 +282,7 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE {
if (VL_UNCOVERABLE(errno != EAGAIN && errno != EINTR)) {
// LCOV_EXCL_START
// write failed, presume error (perhaps out of disk space)
const std::string msg
= std::string{"VerilatedVcd::bufferFlush: "} + std::strerror(errno);
const std::string msg = "VerilatedVcd::bufferFlush: "s + std::strerror(errno);
VL_FATAL_MT("", 0, "", msg.c_str());
closeErr();
break;

View File

@ -1402,8 +1402,7 @@ const char* VerilatedVpiError::strFromVpiConstType(PLI_INT32 constType) VL_PURE
#define SELF_CHECK_RESULT_CSTR(got, exp) \
if (0 != std::strcmp((got), (exp))) { \
const std::string msg \
= std::string{"%Error: "} + "GOT = '" + (got) + "'" + " EXP = '" + (exp) + "'"; \
const std::string msg = "%Error: GOT = '"s + (got) + "'" + " EXP = '" + (exp) + "'"; \
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \
}

View File

@ -1972,7 +1972,7 @@ public:
static string prettyName(const string& namein) VL_PURE; // Name for printing out to the user
static string vpiName(const string& namein); // Name for vpi access
static string prettyNameQ(const string& namein) { // Quoted pretty name (for errors)
return std::string{"'"} + prettyName(namein) + "'";
return "'"s + prettyName(namein) + "'";
}
// Encode user name into internal C representation
static string encodeName(const string& namein);

View File

@ -98,7 +98,7 @@ static void makeToString(AstClass* nodep) {
funcp->isStatic(false);
funcp->protect(false);
AstCExpr* const exprp
= new AstCExpr{nodep->fileline(), R"(std::string{"'{"} + to_string_middle() + "}")", 0};
= new AstCExpr{nodep->fileline(), R"("'{"s + to_string_middle() + "}")", 0};
exprp->dtypeSetString();
funcp->addStmtsp(new AstCReturn{nodep->fileline(), exprp});
nodep->addStmtsp(funcp);

View File

@ -273,7 +273,7 @@ class CoverageVisitor final : public VNVisitor {
// We'll do this, and make the if(...) coverinc later.
// Add signal to hold the old value
const string newvarname = std::string{"__Vtogcov__"} + nodep->shortName();
const string newvarname = "__Vtogcov__"s + nodep->shortName();
FileLine* const fl_nowarn = new FileLine{nodep->fileline()};
fl_nowarn->modifyWarnOff(V3ErrorCode::UNUSEDSIGNAL, true);
AstVar* const chgVarp
@ -284,7 +284,7 @@ class CoverageVisitor final : public VNVisitor {
// This is necessarily an O(n^2) expansion, which is why
// we limit coverage to signals with < 256 bits.
ToggleEnt newvec{std::string{""}, new AstVarRef{fl_nowarn, nodep, VAccess::READ},
ToggleEnt newvec{""s, new AstVarRef{fl_nowarn, nodep, VAccess::READ},
new AstVarRef{fl_nowarn, chgVarp, VAccess::WRITE}};
toggleVarRecurse(nodep->dtypeSkipRefp(), 0, newvec, nodep, chgVarp);
newvec.cleanup();
@ -308,8 +308,7 @@ class CoverageVisitor final : public VNVisitor {
for (int index_docs = bdtypep->lo(); index_docs < bdtypep->hi() + 1;
++index_docs) {
const int index_code = index_docs - bdtypep->lo();
ToggleEnt newent{above.m_comment + std::string{"["} + cvtToStr(index_docs)
+ "]",
ToggleEnt newent{above.m_comment + "["s + cvtToStr(index_docs) + "]",
new AstSel{varp->fileline(), above.m_varRefp->cloneTree(true),
index_code, 1},
new AstSel{varp->fileline(), above.m_chgRefp->cloneTree(true),
@ -323,7 +322,7 @@ class CoverageVisitor final : public VNVisitor {
} else if (const AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) {
for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) {
const int index_code = index_docs - adtypep->lo();
ToggleEnt newent{above.m_comment + std::string{"["} + cvtToStr(index_docs) + "]",
ToggleEnt newent{above.m_comment + "["s + cvtToStr(index_docs) + "]",
new AstArraySel{varp->fileline(),
above.m_varRefp->cloneTree(true), index_code},
new AstArraySel{varp->fileline(),
@ -336,7 +335,7 @@ class CoverageVisitor final : public VNVisitor {
for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) {
const AstNodeDType* const subtypep = adtypep->subDTypep()->skipRefp();
const int index_code = index_docs - adtypep->lo();
ToggleEnt newent{above.m_comment + std::string{"["} + cvtToStr(index_docs) + "]",
ToggleEnt newent{above.m_comment + "["s + cvtToStr(index_docs) + "]",
new AstSel{varp->fileline(), above.m_varRefp->cloneTree(true),
index_code * subtypep->width(), subtypep->width()},
new AstSel{varp->fileline(), above.m_chgRefp->cloneTree(true),
@ -351,7 +350,7 @@ class CoverageVisitor final : public VNVisitor {
itemp = VN_AS(itemp->nextp(), MemberDType)) {
AstNodeDType* const subtypep = itemp->subDTypep()->skipRefp();
const int index_code = itemp->lsb();
ToggleEnt newent{above.m_comment + std::string{"."} + itemp->name(),
ToggleEnt newent{above.m_comment + "."s + itemp->name(),
new AstSel{varp->fileline(), above.m_varRefp->cloneTree(true),
index_code, subtypep->width()},
new AstSel{varp->fileline(), above.m_chgRefp->cloneTree(true),
@ -369,8 +368,7 @@ class CoverageVisitor final : public VNVisitor {
varp->fileline(), above.m_varRefp->cloneTree(true), itemp->name()};
varRefp->dtypep(subtypep);
chgRefp->dtypep(subtypep);
ToggleEnt newent{above.m_comment + std::string{"."} + itemp->name(), varRefp,
chgRefp};
ToggleEnt newent{above.m_comment + "."s + itemp->name(), varRefp, chgRefp};
toggleVarRecurse(subtypep, depth + 1, newent, varp, chgVarp);
newent.cleanup();
}
@ -379,7 +377,7 @@ class CoverageVisitor final : public VNVisitor {
// Arbitrarily handle only the first member of the union
if (const AstMemberDType* const itemp = adtypep->membersp()) {
AstNodeDType* const subtypep = itemp->subDTypep()->skipRefp();
ToggleEnt newent{above.m_comment + std::string{"."} + itemp->name(),
ToggleEnt newent{above.m_comment + "."s + itemp->name(),
above.m_varRefp->cloneTree(true),
above.m_chgRefp->cloneTree(true)};
toggleVarRecurse(subtypep, depth + 1, newent, varp, chgVarp);

View File

@ -309,7 +309,7 @@ class EmitCModel final : public EmitCFunc {
const int vecnum = vects++;
UASSERT_OBJ(arrayp->hi() >= arrayp->lo(), varp,
"Should have swapped msb & lsb earlier.");
const string ivar = std::string{"__Vi"} + cvtToStr(vecnum);
const string ivar = "__Vi"s + cvtToStr(vecnum);
putns(varp, "for (int __Vi" + cvtToStr(vecnum) + " = "
+ cvtToStr(arrayp->lo()));
puts("; " + ivar + " <= " + cvtToStr(arrayp->hi()));

View File

@ -205,7 +205,7 @@ class EmitVBaseVisitorConst VL_NOT_FINAL : public EmitCBaseVisitorConst {
putqs(nodep, "end\n");
}
void visit(AstComment* nodep) override {
puts(std::string{"// "} + nodep->name() + "\n");
puts("// "s + nodep->name() + "\n");
iterateChildrenConst(nodep);
}
void visit(AstContinue*) override {
@ -747,7 +747,7 @@ class EmitVBaseVisitorConst VL_NOT_FINAL : public EmitCBaseVisitorConst {
void visit(AstCell*) override {} // Handled outside the Visit class
// Default
void visit(AstNode* nodep) override {
puts(std::string{"\n???? // "} + nodep->prettyTypeName() + "\n");
puts("\n???? // "s + nodep->prettyTypeName() + "\n");
iterateChildrenConst(nodep);
// Not v3fatalSrc so we keep processing
if (!m_suppressUnknown) {

View File

@ -111,7 +111,7 @@ string V3ErrorGuarded::warnMore() VL_REQUIRES(m_mutex) { return string(msgPrefix
void V3ErrorGuarded::suppressThisWarning() VL_REQUIRES(m_mutex) {
#ifndef V3ERROR_NO_GLOBAL_
V3Stats::addStatSum(std::string{"Warnings, Suppressed "} + errorCode().ascii(), 1);
V3Stats::addStatSum("Warnings, Suppressed "s + errorCode().ascii(), 1);
#endif
errorSuppressed(true);
}

View File

@ -877,26 +877,26 @@ string V3OutFormatter::quoteNameControls(const string& namein,
// Encode chars into XML string
for (const char c : namein) {
if (c == '"') {
out += std::string{"&quot;"};
out += "&quot;"s;
} else if (c == '\'') {
out += std::string{"&apos;"};
out += "&apos;"s;
} else if (c == '<') {
out += std::string{"&lt;"};
out += "&lt;"s;
} else if (c == '>') {
out += std::string{"&gt;"};
out += "&gt;"s;
} else if (c == '&') {
out += std::string{"&amp;"};
out += "&amp;"s;
} else if (std::isprint(c)) {
out += c;
} else {
out += std::string{"&#"} + cvtToStr((unsigned int)(c & 0xff)) + ";";
out += "&#"s + cvtToStr((unsigned int)(c & 0xff)) + ";";
}
}
} else {
// Encode control chars into C style escapes
for (const char c : namein) {
if (c == '\\' || c == '"') {
out += std::string{"\\"} + c;
out += "\\"s + c;
} else if (c == '\n') {
out += "\\n";
} else if (c == '\r') {
@ -907,8 +907,8 @@ string V3OutFormatter::quoteNameControls(const string& namein,
out += c;
} else {
// This will also cover \a etc
const string octal = std::string{"\\"} + cvtToStr((c >> 6) & 3)
+ cvtToStr((c >> 3) & 7) + cvtToStr(c & 7);
const string octal
= "\\"s + cvtToStr((c >> 6) & 3) + cvtToStr((c >> 3) & 7) + cvtToStr(c & 7);
out += octal;
}
}
@ -955,8 +955,7 @@ void V3OutFile::putsForceIncs() {
void V3OutCFile::putsGuard() {
UASSERT(!m_guard, "Already called putsGuard in emit file");
m_guard = true;
string var
= VString::upcase(std::string{"VERILATED_"} + V3Os::filenameNonDir(filename()) + "_");
string var = VString::upcase("VERILATED_"s + V3Os::filenameNonDir(filename()) + "_");
for (char& c : var) {
if (!std::isalnum(c)) c = '_';
}

View File

@ -203,7 +203,7 @@ string FileLine::xmlDetailedLocation() const {
}
string FileLine::lineDirectiveStrg(int enterExit) const {
return std::string{"`line "} + cvtToStr(lastLineno()) + " \""
return "`line "s + cvtToStr(lastLineno()) + " \""
+ V3OutFormatter::quoteNameControls(filename()) + "\" " + cvtToStr(enterExit) + "\n";
}

View File

@ -253,7 +253,7 @@ class HierBlockUsageCollectVisitor final : public VNVisitorConst {
// Don't visit twice
if (nodep->user1SetOnce()) return;
UINFO(5, "Checking " << nodep->prettyNameQ() << " from "
<< (m_hierBlockp ? m_hierBlockp->prettyNameQ() : std::string{"null"})
<< (m_hierBlockp ? m_hierBlockp->prettyNameQ() : "null"s)
<< std::endl);
VL_RESTORER(m_modp);
AstModule* const prevHierBlockp = m_hierBlockp;

View File

@ -421,13 +421,11 @@ class InlineRelinkVisitor final : public VNVisitor {
// To keep correct visual order, must add before other Text's
AstText* afterp = nodep->scopeAttrp();
if (afterp) afterp->unlinkFrBackWithNext();
nodep->addScopeAttrp(
new AstText{nodep->fileline(), std::string{"__DOT__"} + m_cellp->name()});
nodep->addScopeAttrp(new AstText{nodep->fileline(), "__DOT__"s + m_cellp->name()});
if (afterp) nodep->addScopeAttrp(afterp);
afterp = nodep->scopeEntrp();
if (afterp) afterp->unlinkFrBackWithNext();
nodep->addScopeEntrp(
new AstText{nodep->fileline(), std::string{"__DOT__"} + m_cellp->name()});
nodep->addScopeEntrp(new AstText{nodep->fileline(), "__DOT__"s + m_cellp->name()});
if (afterp) nodep->addScopeEntrp(afterp);
iterateChildren(nodep);
}

View File

@ -45,7 +45,7 @@ class NameVisitor final : public VNVisitorConst {
void rename(AstNode* nodep, bool addPvt) {
if (!nodep->user1()) { // Not already done
if (addPvt) {
const string newname = std::string{"__PVT__"} + nodep->name();
const string newname = "__PVT__"s + nodep->name();
nodep->name(newname);
nodep->editCountInc();
} else if (VN_IS(nodep, CFunc) && VN_AS(nodep, CFunc)->isConstructor()) {
@ -54,7 +54,7 @@ class NameVisitor final : public VNVisitorConst {
if (rsvd != "") {
nodep->v3warn(SYMRSVDWORD,
"Symbol matches " + rsvd + ": " << nodep->prettyNameQ());
const string newname = std::string{"__SYM__"} + nodep->name();
const string newname = "__SYM__"s + nodep->name();
nodep->name(newname);
nodep->editCountInc();
}

View File

@ -851,7 +851,7 @@ string V3Number::toDecimalS() const VL_MT_STABLE {
if (isNegative()) {
V3Number lhsNoSign = *this;
lhsNoSign.opNegate(*this);
return std::string{"-"} + lhsNoSign.toDecimalU();
return "-"s + lhsNoSign.toDecimalU();
} else {
return toDecimalU();
}

View File

@ -145,9 +145,7 @@ V3OptionParser::ActionIfs* V3OptionParser::find(const char* optp) {
if (act.second->isOnOffAllowed()) { // Find starts with "-no"
if (const char* const nop
= VString::startsWith(optp, "-no") ? (optp + std::strlen("-no")) : nullptr) {
if (act.first == nop || act.first == (std::string{"-"} + nop)) {
return act.second.get();
}
if (act.first == nop || act.first == ("-"s + nop)) { return act.second.get(); }
}
} else if (act.second->isPartialMatchAllowed()) {
if (VString::startsWith(optp, act.first)) return act.second.get();

View File

@ -1584,7 +1584,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc,
});
DECL_OPTION("-Wno-", CbPartialMatch, [fl, &parser](const char* optp) VL_MT_DISABLED {
if (!FileLine::globalWarnOff(optp, true)) {
const string fullopt = std::string{"-Wno-"} + optp;
const string fullopt = "-Wno-"s + optp;
fl->v3fatal("Unknown warning specified: " << fullopt
<< parser.getSuggestion(fullopt.c_str()));
}
@ -1606,7 +1606,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc,
const V3ErrorCode code{optp};
if (code == V3ErrorCode::EC_ERROR) {
if (!isFuture(optp)) {
const string fullopt = std::string{"-Wwarn-"} + optp;
const string fullopt = "-Wwarn-"s + optp;
fl->v3fatal("Unknown warning specified: "
<< fullopt << parser.getSuggestion(fullopt.c_str()));
}

View File

@ -367,7 +367,7 @@ class ParamProcessor final {
const auto pair = m_valueMap.emplace(hash, 0);
if (pair.second) pair.first->second = m_nextValue++;
num = pair.first->second;
return std::string{"z"} + cvtToStr(num);
return "z"s + cvtToStr(num);
}
string moduleCalcName(const AstNodeModule* srcModp, const string& longname) {
string newname = longname;

View File

@ -91,7 +91,7 @@ public:
void reinsert(AstNode* nodep, VSymEnt* parentp, string name) {
if (!parentp) parentp = symCurrentp();
if (name == "") { // New name with space in name so can't collide with users
name = std::string{" anon"} + nodep->type().ascii() + cvtToStr(++s_anonNum);
name = " anon"s + nodep->type().ascii() + cvtToStr(++s_anonNum);
}
parentp->reinsert(name, findNewTable(nodep));
}

View File

@ -84,9 +84,9 @@ public:
uint64_t profilerId() const { return m_profilerId; }
string cFuncName() const {
// If this MTask maps to a C function, this should be the name
return std::string{"__Vmtask"} + "__" + cvtToStr(m_id);
return "__Vmtask"s + "__" + cvtToStr(m_id);
}
string name() const override VL_MT_STABLE { return std::string{"mt"} + cvtToStr(id()); }
string name() const override VL_MT_STABLE { return "mt"s + cvtToStr(id()); }
string hashName() const { return m_hashName; }
void hashName(const string& name) { m_hashName = name; }
void dump(std::ostream& str) const {

View File

@ -329,7 +329,7 @@ FileLine* V3PreProcImp::defFileline(const string& name) {
void V3PreProcImp::define(FileLine* fl, const string& name, const string& value,
const string& params, bool cmdline) {
UINFO(4, "DEFINE '" << name << "' as '" << value << "' params '" << params << "'" << endl);
if (!V3LanguageWords::isKeyword(std::string{"`"} + name).empty()) {
if (!V3LanguageWords::isKeyword("`"s + name).empty()) {
fl->v3error("Attempting to define built-in directive: '`" << name
<< "' (IEEE 1800-2017 22.5.1)");
} else {
@ -887,7 +887,7 @@ void V3PreProcImp::dumpDefines(std::ostream& os) {
void V3PreProcImp::candidateDefines(VSpellCheck* spellerp) {
for (DefinesMap::const_iterator it = m_defines.begin(); it != m_defines.end(); ++it) {
spellerp->pushCandidate(std::string{"`"} + it->first);
spellerp->pushCandidate("`"s + it->first);
}
}
@ -1107,7 +1107,7 @@ int V3PreProcImp::getStateToken() {
// IE, `ifdef `MACRO(x): Substitute and come back here when state pops.
break;
} else {
error(std::string{"Expecting define name. Found: "} + tokenName(tok) + "\n");
error("Expecting define name. Found: "s + tokenName(tok) + "\n");
goto next_tok;
}
}
@ -1128,8 +1128,7 @@ int V3PreProcImp::getStateToken() {
goto next_tok;
}
} else {
error(std::string{"Expecting define formal arguments. Found: "} + tokenName(tok)
+ "\n");
error("Expecting define formal arguments. Found: "s + tokenName(tok) + "\n");
goto next_tok;
}
}
@ -1165,8 +1164,7 @@ int V3PreProcImp::getStateToken() {
define(fileline(), m_lastSym, value, formals, false);
}
} else {
const string msg
= std::string{"Bad define text, unexpected "} + tokenName(tok) + "\n";
const string msg = "Bad define text, unexpected "s + tokenName(tok) + "\n";
v3fatalSrc(msg);
}
statePop();
@ -1182,8 +1180,8 @@ int V3PreProcImp::getStateToken() {
} else {
UASSERT(!m_defRefs.empty(), "Shouldn't be in DEFPAREN w/o active defref");
const VDefineRef* const refp = &(m_defRefs.top());
error(std::string{"Expecting ( to begin argument list for define reference `"}
+ refp->name() + "\n");
error("Expecting ( to begin argument list for define reference `"s + refp->name()
+ "\n");
statePop();
goto next_tok;
}
@ -1282,7 +1280,7 @@ int V3PreProcImp::getStateToken() {
break;
} else {
statePop();
error(std::string{"Expecting include filename. Found: "} + tokenName(tok) + "\n");
error("Expecting include filename. Found: "s + tokenName(tok) + "\n");
goto next_tok;
}
}
@ -1295,7 +1293,7 @@ int V3PreProcImp::getStateToken() {
statePop();
goto next_tok;
} else {
error(std::string{"Expecting `error string. Found: "} + tokenName(tok) + "\n");
error("Expecting `error string. Found: "s + tokenName(tok) + "\n");
statePop();
goto next_tok;
}
@ -1338,7 +1336,7 @@ int V3PreProcImp::getStateToken() {
// multiline "..." without \ escapes.
// The spec is silent about this either way; simulators vary
std::replace(out.begin(), out.end(), '\n', ' ');
unputString(std::string{"\""} + out + "\"");
unputString("\""s + out + "\"");
statePop();
goto next_tok;
} else if (tok == VP_EOF) {
@ -1422,7 +1420,7 @@ int V3PreProcImp::getStateToken() {
} else {
// We want final text of `name, but that would cause
// recursion, so use a special character to get it through
unputDefrefString(std::string{"`\032"} + name);
unputDefrefString("`\032"s + name);
goto next_tok;
}
} else {
@ -1510,7 +1508,7 @@ int V3PreProcImp::getStateToken() {
case VP_DEFFORM: // Handled by state=ps_DEFFORM;
case VP_DEFVALUE: // Handled by state=ps_DEFVALUE;
default: // LCOV_EXCL_LINE
v3fatalSrc(std::string{"Internal error: Unexpected token "} + tokenName(tok) + "\n");
v3fatalSrc("Internal error: Unexpected token "s + tokenName(tok) + "\n");
break; // LCOV_EXCL_LINE
}
return tok;

View File

@ -102,8 +102,8 @@ protected:
// intervening +<lang>ext+ options since it was first encountered.
FileLine* const modfileline = new FileLine{modfilename};
modfileline->language(v3Global.opt.fileLanguage(modfilename));
V3Parse::ppPushText(parsep, (std::string{"`begin_keywords \""}
+ modfileline->language().ascii() + "\"\n"));
V3Parse::ppPushText(
parsep, ("`begin_keywords \""s + modfileline->language().ascii() + "\"\n"));
// FileLine tracks and frees modfileline
}

View File

@ -149,18 +149,16 @@ class ProtectVisitor final : public VNVisitor {
// Timescale
if (v3Global.opt.hierChild() && v3Global.rootp()->timescaleSpecified()) {
// Emit timescale for hierarchical Verilation if input HDL specifies timespec
txtp->addText(fl, std::string{"timeunit "} + modp->timeunit().ascii() + ";\n");
txtp->addText(fl, std::string{"timeprecision "}
+ +v3Global.rootp()->timeprecision().ascii() + ";\n");
txtp->addText(fl, "timeunit "s + modp->timeunit().ascii() + ";\n");
txtp->addText(fl,
"timeprecision "s + +v3Global.rootp()->timeprecision().ascii() + ";\n");
} else {
addComment(txtp, fl,
"Precision of submodule"
" (commented out to avoid requiring timescale on all modules)");
addComment(txtp, fl, "timeunit "s + v3Global.rootp()->timeunit().ascii() + ";");
addComment(txtp, fl,
std::string{"timeunit "} + v3Global.rootp()->timeunit().ascii() + ";");
addComment(txtp, fl,
std::string{"timeprecision "} + v3Global.rootp()->timeprecision().ascii()
+ ";\n");
"timeprecision "s + v3Global.rootp()->timeprecision().ascii() + ";\n");
}
// DPI declarations

View File

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

View File

@ -366,7 +366,7 @@ private:
// Call for node types we know we can't handle
checkNodeInfo(nodep);
if (optimizable()) {
clearOptimizable(nodep, std::string{"Known unhandled node type "} + nodep->typeName());
clearOptimizable(nodep, "Known unhandled node type "s + nodep->typeName());
}
}
void badNodeType(AstNode* nodep) {
@ -1130,7 +1130,7 @@ private:
nodep, "Argument for $display like statement is not constant");
break;
}
const string pformat = std::string{"%"} + width + pos[0];
const string pformat = "%"s + width + pos[0];
result += constp->num().displayed(nodep, pformat);
} else {
switch (std::tolower(pos[0])) {

View File

@ -156,7 +156,7 @@ public:
// Branch predictions
for (int t = 0; t < VBranchPred::_ENUM_END; ++t) {
if (const uint64_t c = m_counters.m_statPred[t]) {
addStat(std::string{"Branch prediction, "} + VBranchPred{t}.ascii(), c);
addStat("Branch prediction, "s + VBranchPred{t}.ascii(), c);
}
}
}

View File

@ -250,7 +250,7 @@ public:
if (candidate.empty()) {
return "";
} else {
return std::string{"... Suggested alternative: '"} + candidate + "'";
return "... Suggested alternative: '"s + candidate + "'";
}
}
static void selfTest();

View File

@ -714,8 +714,8 @@ class TraceVisitor final : public VNVisitor {
m_regFuncp->addStmtsp(new AstText{fl, ", vlSelf);\n", true});
// Clear global activity flag
cleanupFuncp->addStmtsp(new AstCStmt{m_topScopep->fileline(),
std::string{"vlSymsp->__Vm_activity = false;\n"}});
cleanupFuncp->addStmtsp(
new AstCStmt{m_topScopep->fileline(), "vlSymsp->__Vm_activity = false;\n"s});
// Clear fine grained activity flags
for (uint32_t i = 0; i < m_activityNumber; ++i) {

View File

@ -240,7 +240,7 @@ class TraceDeclVisitor final : public VNVisitor {
void addIgnore(const char* why) {
++m_statIgnSigs;
std::string cmt = std::string{"Tracing: "} + m_traName + " // Ignored: " + why;
std::string cmt = "Tracing: "s + m_traName + " // Ignored: " + why;
if (debug() > 3 && m_traVscp) std::cout << "- " << m_traVscp->fileline() << cmt << endl;
}

View File

@ -59,7 +59,7 @@ class UnrollVisitor final : public VNVisitor {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: Can't unroll generate for; " << reason);
UINFO(3, " Can't Unroll: " << reason << " :" << nodep << endl);
// if (debug() >= 9) nodep->dumpTree("- cant: ");
V3Stats::addStatSum(std::string{"Unrolling gave up, "} + reason, 1);
V3Stats::addStatSum("Unrolling gave up, "s + reason, 1);
return false;
}

View File

@ -67,6 +67,7 @@
using string = std::string;
using std::cout;
using std::endl;
using namespace std::literals; // "<std::string literal>"s; see SF.7 core guideline
//**********************************************************************
//**** OS and compiler specifics

View File

@ -384,7 +384,7 @@ int V3ParseGrammar::s_modTypeImpNum = 0;
static void ERRSVKWD(FileLine* fileline, const string& tokname) {
static int toldonce = 0;
fileline->v3error(
std::string{"Unexpected '"} + tokname + "': '" + tokname
"Unexpected '"s + tokname + "': '" + tokname
+ "' is a SystemVerilog keyword misused as an identifier."
+ (!toldonce++ ? "\n" + fileline->warnMore()
+ "... Suggest modify the Verilog-2001 code to avoid SV keywords,"

View File

@ -51,7 +51,7 @@ void mon_class_name(const char* namep) {
#endif
// Check the C's calling name of "" doesn't lead to extra dots in the name()
if (namep && namep[0] == '.')
vl_fatal(__FILE__, __LINE__, "", (std::string{"Unexp class name "} + namep).c_str());
vl_fatal(__FILE__, __LINE__, "", ("Unexp class name "s + namep).c_str());
}
extern "C" void mon_scope_name(const char* namep);
@ -61,9 +61,9 @@ void mon_scope_name(const char* namep) {
VL_PRINTF("- mon_scope_name('%s', \"%s\");\n", modp, namep);
#endif
if (std::strcmp(namep, "t.sub"))
vl_fatal(__FILE__, __LINE__, "", (std::string{"Unexp scope name "} + namep).c_str());
vl_fatal(__FILE__, __LINE__, "", ("Unexp scope name "s + namep).c_str());
if (std::strcmp(modp, "t.sub"))
vl_fatal(__FILE__, __LINE__, "", (std::string{"Unexp dpiscope name "} + modp).c_str());
vl_fatal(__FILE__, __LINE__, "", ("Unexp dpiscope name "s + modp).c_str());
}
extern "C" void mon_register_b(const char* namep, int isOut);

View File

@ -138,7 +138,7 @@ int main(int argc, char** argv) {
void* lib = dlopen(filenamep, RTLD_LAZY);
void* bootstrap = dlsym(lib, "vpi_compat_bootstrap");
if (!bootstrap) {
const std::string msg = std::string{"%Error: Could not dlopen "} + filenamep;
const std::string msg = "%Error: Could not dlopen "s + filenamep;
vl_fatal(__FILE__, __LINE__, "main", msg.c_str());
}
((void (*)(void))bootstrap)();