Internals: Use standard 'result' name for return variable. No functional change.

This commit is contained in:
Wilson Snyder 2023-04-08 22:11:28 -04:00
parent 7ae0c5d546
commit fff0eb5d88
11 changed files with 98 additions and 98 deletions

View File

@ -232,9 +232,9 @@ std::string _vl_string_vprintf(const char* formatp, va_list ap) VL_MT_SAFE {
char* const bufp = new char[len + 1];
VL_VSNPRINTF(bufp, len + 1, formatp, ap);
std::string out{bufp, len}; // Not const to allow move optimization
std::string result{bufp, len}; // Not const to allow move optimization
delete[] bufp;
return out;
return result;
}
uint64_t _vl_dbg_sequence_number() VL_MT_SAFE {
@ -255,24 +255,24 @@ void VL_DBG_MSGF(const char* formatp, ...) VL_MT_SAFE {
// includes that otherwise would be required in every Verilated module
va_list ap;
va_start(ap, formatp);
const std::string out = _vl_string_vprintf(formatp, ap);
const std::string result = _vl_string_vprintf(formatp, ap);
va_end(ap);
// printf("-imm-V{t%d,%" PRId64 "}%s", VL_THREAD_ID(), _vl_dbg_sequence_number(),
// out.c_str());
// result.c_str());
// Using VL_PRINTF not VL_PRINTF_MT so that we can call VL_DBG_MSGF
// from within the guts of the thread execution machinery (and it goes
// to the screen and not into the queues we're debugging)
VL_PRINTF("-V{t%u,%" PRIu64 "}%s", VL_THREAD_ID(), _vl_dbg_sequence_number(), out.c_str());
VL_PRINTF("-V{t%u,%" PRIu64 "}%s", VL_THREAD_ID(), _vl_dbg_sequence_number(), result.c_str());
}
void VL_PRINTF_MT(const char* formatp, ...) VL_MT_SAFE {
va_list ap;
va_start(ap, formatp);
const std::string out = _vl_string_vprintf(formatp, ap);
const std::string result = _vl_string_vprintf(formatp, ap);
va_end(ap);
VerilatedThreadMsgQueue::post(VerilatedMsg{[=]() { //
VL_PRINTF("%s", out.c_str());
VL_PRINTF("%s", result.c_str());
}});
}
@ -321,8 +321,8 @@ void VlRNG::srandom(uint64_t n) VL_MT_UNSAFE {
// Unused: }
// Unused: }
// Unused: std::string VlRNG::get_randstate() const VL_MT_UNSAFE {
// Unused: std::string out{reinterpret_cast<const char *>(&m_state), sizeof(m_state)};
// Unused: return out;
// Unused: std::string result{reinterpret_cast<const char *>(&m_state), sizeof(m_state)};
// Unused: return result;
// Unused: }
static uint32_t vl_sys_rand32() VL_MT_SAFE {
@ -566,12 +566,12 @@ QData VL_POW_QQW(int, int, int rbits, QData lhs, const WDataInP rwp) VL_MT_SAFE
// Skip check for rhs == 0, as short-circuit doesn't save time
if (VL_UNLIKELY(lhs == 0)) return 0;
QData power = lhs;
QData out = 1ULL;
QData result = 1ULL;
for (int bit = 0; bit < rbits; ++bit) {
if (bit > 0) power = power * power;
if (VL_BITISSET_W(rwp, bit)) out *= power;
if (VL_BITISSET_W(rwp, bit)) result *= power;
}
return out;
return result;
}
WDataOutP VL_POWSS_WWW(int obits, int, int rbits, WDataOutP owp, const WDataInP lwp,
@ -1699,15 +1699,15 @@ std::string VL_STACKTRACE_N() VL_MT_SAFE {
// cppcheck-suppress knownConditionTrueFalse
if (!strings) return "Unable to backtrace\n";
std::string out = "Backtrace:\n";
for (int j = 0; j < nptrs; j++) out += std::string{strings[j]} + std::string{"\n"};
std::string result = "Backtrace:\n";
for (int j = 0; j < nptrs; j++) result += std::string{strings[j]} + std::string{"\n"};
free(strings);
return out;
return result;
}
void VL_STACKTRACE() VL_MT_SAFE {
const std::string out = VL_STACKTRACE_N();
VL_PRINTF("%s", out.c_str());
const std::string result = VL_STACKTRACE_N();
VL_PRINTF("%s", result.c_str());
}
IData VL_SYSTEM_IQ(QData lhs) VL_MT_SAFE {
@ -1853,14 +1853,14 @@ std::string VL_TO_STRING_W(int words, const WDataInP obj) {
}
std::string VL_TOLOWER_NN(const std::string& ld) VL_PURE {
std::string out = ld;
for (auto& cr : out) cr = std::tolower(cr);
return out;
std::string result = ld;
for (auto& cr : result) cr = std::tolower(cr);
return result;
}
std::string VL_TOUPPER_NN(const std::string& ld) VL_PURE {
std::string out = ld;
for (auto& cr : out) cr = std::toupper(cr);
return out;
std::string result = ld;
for (auto& cr : result) cr = std::toupper(cr);
return result;
}
std::string VL_CVT_PACK_STR_NW(int lwords, const WDataInP lwp) VL_PURE {

View File

@ -208,11 +208,11 @@ private:
// Forward to . so we have a whole word
const std::string suffix = *bpost ? std::string{bpost + 1} : "";
std::string out = prefix + "*" + suffix;
std::string result = prefix + "*" + suffix;
// cout << "\nch pre="<<prefix<<" s="<<suffix<<"\nch a="<<old<<"\nch b="<<add
// <<"\ncho="<<out<<endl;
return out;
// <<"\ncho="<<result<<endl;
return result;
}
bool itemMatchesString(VerilatedCovImpItem* itemp, const std::string& match)
VL_REQUIRES(m_mutex) {

View File

@ -2201,10 +2201,10 @@ inline std::string VL_CONCATN_NNN(const std::string& lhs, const std::string& rhs
return lhs + rhs;
}
inline std::string VL_REPLICATEN_NNQ(const std::string& lhs, IData rep) VL_PURE {
std::string out;
out.reserve(lhs.length() * rep);
for (unsigned times = 0; times < rep; ++times) out += lhs;
return out;
std::string result;
result.reserve(lhs.length() * rep);
for (unsigned times = 0; times < rep; ++times) result += lhs;
return result;
}
inline std::string VL_REPLICATEN_NNI(const std::string& lhs, IData rep) VL_PURE {
return VL_REPLICATEN_NNQ(lhs, rep);

View File

@ -917,10 +917,10 @@ void AstScope::cloneRelink() {
}
}
string AstScope::nameDotless() const {
string out = shortName();
string result = shortName();
string::size_type pos;
while ((pos = out.find('.')) != string::npos) out.replace(pos, 1, "__");
return out;
while ((pos = result.find('.')) != string::npos) result.replace(pos, 1, "__");
return result;
}
AstVarScope* AstScope::createTemp(const string& name, unsigned width) {

View File

@ -584,14 +584,14 @@ protected:
return true;
}
static size_t listSize(const StrList& sl) {
size_t out = 0;
for (const string& i : sl) out += i.length();
return out;
size_t result = 0;
for (const string& i : sl) result += i.length();
return result;
}
static string listString(const StrList& sl) {
string out;
for (const string& i : sl) out += i;
return out;
string result;
for (const string& i : sl) result += i;
return result;
}
// CONSTRUCTORS
explicit VInFilterImp(const string& command) { start(command); }

View File

@ -467,13 +467,13 @@ string FileLine::warnContext() const {
}
string FileLine::warnContextParent() const VL_REQUIRES(V3Error::s().m_mutex) {
string out;
string result;
for (FileLine* parentFl = parent(); parentFl; parentFl = parentFl->parent()) {
if (parentFl->filenameIsGlobal()) break;
out += parentFl->warnOther() + "... note: In file included from "
+ parentFl->filebasename() + "\n";
result += parentFl->warnOther() + "... note: In file included from "
+ parentFl->filebasename() + "\n";
}
return out;
return result;
}
#ifdef VL_LEAK_CHECKS
std::unordered_set<FileLine*> fileLineLeakChecks;

View File

@ -395,12 +395,12 @@ void V3Options::addForceInc(const string& filename) { m_forceIncs.push_back(file
void V3Options::addArg(const string& arg) { m_impp->m_allArgs.push_back(arg); }
string V3Options::allArgsString() const VL_MT_SAFE {
string out;
string result;
for (const string& i : m_impp->m_allArgs) {
if (out != "") out += " ";
out += i;
if (result != "") result += " ";
result += i;
}
return out;
return result;
}
// Delete some options for Verilation of the hierarchical blocks.

View File

@ -161,7 +161,7 @@ string V3Os::filenameNonExt(const string& filename) VL_PURE {
}
string V3Os::filenameSubstitute(const string& filename) {
string out;
string result;
// cppcheck-has-bug-suppress unusedLabel
enum : uint8_t { NONE, PAREN, CURLY } brackets = NONE;
for (string::size_type pos = 0; pos < filename.length(); ++pos) {
@ -188,20 +188,20 @@ string V3Os::filenameSubstitute(const string& filename) {
string envvalue;
if (!envvar.empty()) envvalue = getenvStr(envvar, "");
if (!envvalue.empty()) {
out += envvalue;
result += envvalue;
if (brackets == NONE) {
pos = endpos;
} else {
pos = endpos + 1;
}
} else {
out += filename[pos]; // *pos == '$'
result += filename[pos]; // *pos == '$'
}
} else {
out += filename[pos];
result += filename[pos];
}
}
return out;
return result;
}
string V3Os::filenameRealPath(const string& filename) {

View File

@ -720,11 +720,11 @@ void V3PreLex::dumpStack() {
}
string V3PreLex::cleanDbgStrg(const string& in) {
string out = in;
string result = in;
string::size_type pos;
while ((pos = out.find('\n')) != string::npos) { out.replace(pos, 1, "\\n"); }
while ((pos = out.find('\r')) != string::npos) { out.replace(pos, 1, "\\r"); }
return out;
while ((pos = result.find('\n')) != string::npos) result.replace(pos, 1, "\\n");
while ((pos = result.find('\r')) != string::npos) result.replace(pos, 1, "\\r");
return result;
}
void V3PreLex::unused() {

View File

@ -79,24 +79,24 @@ string VString::dot(const string& a, const string& dot, const string& b) {
}
string VString::downcase(const string& str) {
string out = str;
for (auto& cr : out) cr = std::tolower(cr);
return out;
string result = str;
for (char& cr : result) cr = std::tolower(cr);
return result;
}
string VString::upcase(const string& str) {
string out = str;
for (auto& cr : out) cr = std::toupper(cr);
return out;
string result = str;
for (char& cr : result) cr = std::toupper(cr);
return result;
}
string VString::quoteAny(const string& str, char tgt, char esc) {
string out;
string result;
for (const char c : str) {
if (c == tgt) out += esc;
out += c;
if (c == tgt) result += esc;
result += c;
}
return out;
return result;
}
string VString::quoteStringLiteralForShell(const string& str) {
@ -131,24 +131,24 @@ string VString::escapeStringForPath(const string& str) {
}
string VString::spaceUnprintable(const string& str) VL_PURE {
string out;
string result;
for (const char c : str) {
if (std::isprint(c)) {
out += c;
result += c;
} else {
out += ' ';
result += ' ';
}
}
return out;
return result;
}
string VString::removeWhitespace(const string& str) {
string out;
out.reserve(str.size());
string result;
result.reserve(str.size());
for (const char c : str) {
if (!std::isspace(c)) out += c;
if (!std::isspace(c)) result += c;
}
return out;
return result;
}
bool VString::isWhitespace(const string& str) {
@ -331,34 +331,34 @@ void VHashSha256::finalize() {
string VHashSha256::digestBinary() {
finalize();
string out;
out.reserve(32);
string result;
result.reserve(32);
for (size_t i = 0; i < 32; ++i) {
out += (m_inthash[i >> 2] >> (((3 - i) & 0x3) << 3)) & 0xff;
result += (m_inthash[i >> 2] >> (((3 - i) & 0x3) << 3)) & 0xff;
}
return out;
return result;
}
uint64_t VHashSha256::digestUInt64() {
const string& binhash = digestBinary();
uint64_t out = 0;
uint64_t result = 0;
for (size_t byte = 0; byte < sizeof(uint64_t); ++byte) {
const unsigned char c = binhash[byte];
out = (out << 8) | c;
result = (result << 8) | c;
}
return out;
return result;
}
string VHashSha256::digestHex() {
static const char* const digits = "0123456789abcdef";
const string& binhash = digestBinary();
string out;
out.reserve(70);
string result;
result.reserve(70);
for (size_t byte = 0; byte < 32; ++byte) {
out += digits[(binhash[byte] >> 4) & 0xf];
out += digits[(binhash[byte] >> 0) & 0xf];
result += digits[(binhash[byte] >> 4) & 0xf];
result += digits[(binhash[byte] >> 0) & 0xf];
}
return out;
return result;
}
string VHashSha256::digestSymbol() {
@ -369,19 +369,19 @@ string VHashSha256::digestSymbol() {
static const char* const digits
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AB";
const string& binhash = digestBinary();
string out;
out.reserve(28);
string result;
result.reserve(28);
int pos = 0;
for (; pos < (256 / 8) - 2; pos += 3) {
out += digits[((binhash[pos] >> 2) & 0x3f)];
out += digits[((binhash[pos] & 0x3) << 4)
| (static_cast<int>(binhash[pos + 1] & 0xf0) >> 4)];
out += digits[((binhash[pos + 1] & 0xf) << 2)
| (static_cast<int>(binhash[pos + 2] & 0xc0) >> 6)];
out += digits[((binhash[pos + 2] & 0x3f))];
result += digits[((binhash[pos] >> 2) & 0x3f)];
result += digits[((binhash[pos] & 0x3) << 4)
| (static_cast<int>(binhash[pos + 1] & 0xf0) >> 4)];
result += digits[((binhash[pos + 1] & 0xf) << 2)
| (static_cast<int>(binhash[pos + 2] & 0xc0) >> 6)];
result += digits[((binhash[pos + 2] & 0x3f))];
}
// Any leftover bits don't matter for our purpose
return out;
return result;
}
void VHashSha256::selfTestOne(const string& data, const string& data2, const string& exp,

View File

@ -70,9 +70,9 @@ inline uint32_t cvtToHash(const void* vp) {
}
inline string ucfirst(const string& text) {
string out = text;
out[0] = std::toupper(out[0]);
return out;
string result = text;
result[0] = std::toupper(result[0]);
return result;
}
//######################################################################