From fff0eb5d88c851496f05e6368e164dfbc9c2f5ed Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 8 Apr 2023 22:11:28 -0400 Subject: [PATCH] Internals: Use standard 'result' name for return variable. No functional change. --- include/verilated.cpp | 46 +++++++++++------------ include/verilated_cov.cpp | 6 +-- include/verilated_funcs.h | 8 ++-- src/V3AstNodes.cpp | 6 +-- src/V3File.cpp | 12 +++--- src/V3FileLine.cpp | 8 ++-- src/V3Options.cpp | 8 ++-- src/V3Os.cpp | 10 ++--- src/V3PreLex.l | 8 ++-- src/V3String.cpp | 78 +++++++++++++++++++-------------------- src/V3String.h | 6 +-- 11 files changed, 98 insertions(+), 98 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index 26f9e32fa..63affb724 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -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(&m_state), sizeof(m_state)}; -// Unused: return out; +// Unused: std::string result{reinterpret_cast(&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 { diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index 23953173c..7ed7e0031 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -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="<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 fileLineLeakChecks; diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 31d37e4b9..7227ae1ba 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -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. diff --git a/src/V3Os.cpp b/src/V3Os.cpp index 377e3594f..9d2fd0918 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -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) { diff --git a/src/V3PreLex.l b/src/V3PreLex.l index 3168f7025..4524374b4 100644 --- a/src/V3PreLex.l +++ b/src/V3PreLex.l @@ -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() { diff --git a/src/V3String.cpp b/src/V3String.cpp index b97a84b26..5dcf0f63d 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -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(binhash[pos + 1] & 0xf0) >> 4)]; - out += digits[((binhash[pos + 1] & 0xf) << 2) - | (static_cast(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(binhash[pos + 1] & 0xf0) >> 4)]; + result += digits[((binhash[pos + 1] & 0xf) << 2) + | (static_cast(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, diff --git a/src/V3String.h b/src/V3String.h index d56589c5e..bd31909cc 100644 --- a/src/V3String.h +++ b/src/V3String.h @@ -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; } //######################################################################