Fix some clang-tidy warnings

This commit is contained in:
Wilson Snyder 2020-06-01 23:16:02 -04:00
parent a67ba04c37
commit 6ce878cb0d
46 changed files with 176 additions and 165 deletions

View File

@ -19,7 +19,7 @@ int main(int argc, char** argv, char** env) {
// e.g. examples/c_tracing. // e.g. examples/c_tracing.
// Prevent unused variable warnings // Prevent unused variable warnings
if (0 && argc && argv && env) {} if (false && argc && argv && env) {}
// Construct the Verilated model, from Vtop.h generated from Verilating "top.v" // Construct the Verilated model, from Vtop.h generated from Verilating "top.v"
Vtop* top = new Vtop; Vtop* top = new Vtop;

View File

@ -23,7 +23,7 @@ int sc_main(int argc, char* argv[]) {
// e.g. examples/c_tracing. // e.g. examples/c_tracing.
// Prevent unused variable warnings // Prevent unused variable warnings
if (0 && argc && argv) {} if (false && argc && argv) {}
// Construct the Verilated model, from Vtop.h generated from Verilating "top.v" // Construct the Verilated model, from Vtop.h generated from Verilating "top.v"
Vtop* top = new Vtop("top"); Vtop* top = new Vtop("top");

View File

@ -20,7 +20,7 @@ vluint64_t main_time = 0;
double sc_time_stamp() { return main_time; } double sc_time_stamp() { return main_time; }
int main(int argc, char** argv, char** env) { int main(int argc, char** argv, char** env) {
if (0 && argc && argv && env) {} if (false && argc && argv && env) {}
Verilated::debug(0); Verilated::debug(0);
Verilated::randReset(2); Verilated::randReset(2);

View File

@ -22,7 +22,7 @@ int main(int argc, char** argv, char** env) {
// This is a more complicated example, please also see the simpler examples/make_hello_c. // This is a more complicated example, please also see the simpler examples/make_hello_c.
// Prevent unused variable warnings // Prevent unused variable warnings
if (0 && argc && argv && env) {} if (false && argc && argv && env) {}
// Set debug level, 0 is off, 9 is highest presently used // Set debug level, 0 is off, 9 is highest presently used
// May be overridden by commandArgs // May be overridden by commandArgs

View File

@ -24,7 +24,7 @@ int sc_main(int argc, char* argv[]) {
// This is a more complicated example, please also see the simpler examples/make_hello_c. // This is a more complicated example, please also see the simpler examples/make_hello_c.
// Prevent unused variable warnings // Prevent unused variable warnings
if (0 && argc && argv) {} if (false && argc && argv) {}
// Set debug level, 0 is off, 9 is highest presently used // Set debug level, 0 is off, 9 is highest presently used
// May be overridden by commandArgs // May be overridden by commandArgs

View File

@ -77,7 +77,7 @@ VerilatedImp VerilatedImp::s_s;
#ifndef VL_USER_FINISH ///< Define this to override this function #ifndef VL_USER_FINISH ///< Define this to override this function
void vl_finish(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE { void vl_finish(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE {
if (0 && hier) {} if (false && hier) {}
VL_PRINTF( // Not VL_PRINTF_MT, already on main thread VL_PRINTF( // Not VL_PRINTF_MT, already on main thread
"- %s:%d: Verilog $finish\n", filename, linenum); "- %s:%d: Verilog $finish\n", filename, linenum);
if (Verilated::gotFinish()) { if (Verilated::gotFinish()) {
@ -100,7 +100,7 @@ void vl_stop(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE {
#ifndef VL_USER_FATAL ///< Define this to override this function #ifndef VL_USER_FATAL ///< Define this to override this function
void vl_fatal(const char* filename, int linenum, const char* hier, const char* msg) VL_MT_UNSAFE { void vl_fatal(const char* filename, int linenum, const char* hier, const char* msg) VL_MT_UNSAFE {
if (0 && hier) {} if (false && hier) {}
Verilated::gotFinish(true); Verilated::gotFinish(true);
if (filename && filename[0]) { if (filename && filename[0]) {
// Not VL_PRINTF_MT, already on main thread // Not VL_PRINTF_MT, already on main thread
@ -631,7 +631,7 @@ std::string _vl_vsformat_time(char* tmp, double ld, bool left, size_t width) {
QData fracDiv = static_cast<QData>(vl_time_multiplier(fracDigits)); QData fracDiv = static_cast<QData>(vl_time_multiplier(fracDigits));
QData whole = static_cast<QData>(scaled) / fracDiv; QData whole = static_cast<QData>(scaled) / fracDiv;
QData fraction = static_cast<QData>(scaled) % fracDiv; QData fraction = static_cast<QData>(scaled) % fracDiv;
int digits; int digits = 0;
if (!fracDigits) { if (!fracDigits) {
digits = sprintf(tmp, "%" VL_PRI64 "u%s", whole, suffix.c_str()); digits = sprintf(tmp, "%" VL_PRI64 "u%s", whole, suffix.c_str());
} else { } else {
@ -731,20 +731,14 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
const int lbits = va_arg(ap, int); const int lbits = va_arg(ap, int);
double d = va_arg(ap, double); double d = va_arg(ap, double);
if (lbits) {} // UNUSED - always 64 if (lbits) {} // UNUSED - always 64
switch (fmt) { if (fmt == '^') { // Realtime
case '^': { // Realtime
if (!widthSet) width = VerilatedImp::timeFormatWidth(); if (!widthSet) width = VerilatedImp::timeFormatWidth();
output += _vl_vsformat_time(tmp, d, left, width); output += _vl_vsformat_time(tmp, d, left, width);
break; } else {
}
default: {
std::string fmt(pctp, pos - pctp + 1); std::string fmt(pctp, pos - pctp + 1);
sprintf(tmp, fmt.c_str(), d); sprintf(tmp, fmt.c_str(), d);
output += tmp; output += tmp;
break; }
} //
break;
} // switch
break; break;
} }
default: { default: {
@ -752,7 +746,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
const int lbits = va_arg(ap, int); const int lbits = va_arg(ap, int);
QData ld = 0; QData ld = 0;
WData qlwp[VL_WQ_WORDS_E]; WData qlwp[VL_WQ_WORDS_E];
WDataInP lwp; WDataInP lwp = NULL;
if (lbits <= VL_QUADSIZE) { if (lbits <= VL_QUADSIZE) {
ld = _VL_VA_ARG_Q(ap, lbits); ld = _VL_VA_ARG_Q(ap, lbits);
VL_SET_WQ(qlwp, ld); VL_SET_WQ(qlwp, ld);
@ -768,7 +762,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
switch (fmt) { switch (fmt) {
case 'c': { case 'c': {
IData charval = ld & 0xff; IData charval = ld & 0xff;
output += charval; output += static_cast<char>(charval);
break; break;
} }
case 's': { case 's': {
@ -784,7 +778,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
break; break;
} }
case 'd': { // Signed decimal case 'd': { // Signed decimal
int digits; int digits = 0;
std::string append; std::string append;
if (lbits <= VL_QUADSIZE) { if (lbits <= VL_QUADSIZE) {
digits = sprintf(tmp, "%" VL_PRI64 "d", digits = sprintf(tmp, "%" VL_PRI64 "d",
@ -813,7 +807,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
break; break;
} }
case '#': { // Unsigned decimal case '#': { // Unsigned decimal
int digits; int digits = 0;
std::string append; std::string append;
if (lbits <= VL_QUADSIZE) { if (lbits <= VL_QUADSIZE) {
digits = sprintf(tmp, "%" VL_PRI64 "u", ld); digits = sprintf(tmp, "%" VL_PRI64 "u", ld);
@ -848,9 +842,10 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
// Octal numbers may span more than one wide word, // Octal numbers may span more than one wide word,
// so we need to grab each bit separately and check for overrun // so we need to grab each bit separately and check for overrun
// Octal is rare, so we'll do it a slow simple way // Octal is rare, so we'll do it a slow simple way
output += ('0' + ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 0)) ? 1 : 0) output += static_cast<char>(
+ ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 1)) ? 2 : 0) '0' + ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 0)) ? 1 : 0)
+ ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 2)) ? 4 : 0)); + ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 1)) ? 2 : 0)
+ ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 2)) ? 4 : 0));
} }
break; break;
case 'u': case 'u':
@ -863,8 +858,8 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
const int wr_bytes = std::min(4, bytes_to_go); const int wr_bytes = std::min(4, bytes_to_go);
for (int byte = 0; byte < wr_bytes; byte++, bit += 8) for (int byte = 0; byte < wr_bytes; byte++, bit += 8)
output += static_cast<char>(VL_BITRSHIFT_W(lwp, bit) & 0xff); output += static_cast<char>(VL_BITRSHIFT_W(lwp, bit) & 0xff);
output.append(4 - wr_bytes, (char)0); output.append(4 - wr_bytes, static_cast<char>(0));
if (is_4_state) output.append(4, (char)0); if (is_4_state) output.append(4, static_cast<char>(0));
bytes_to_go -= wr_bytes; bytes_to_go -= wr_bytes;
} }
break; break;
@ -898,7 +893,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
static inline bool _vl_vsss_eof(FILE* fp, int floc) VL_MT_SAFE { static inline bool _vl_vsss_eof(FILE* fp, int floc) VL_MT_SAFE {
if (fp) { if (fp) {
return feof(fp) ? 1 : 0; // 1:0 to prevent MSVC++ warning return feof(fp) ? true : false; // true : false to prevent MSVC++ warning
} else { } else {
return floc < 0; return floc < 0;
} }
@ -1076,7 +1071,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
_vl_vsss_skipspace(fp, floc, fromp, fstr); _vl_vsss_skipspace(fp, floc, fromp, fstr);
_vl_vsss_read_str(fp, floc, fromp, fstr, tmp, "0123456789+-xXzZ?_"); _vl_vsss_read_str(fp, floc, fromp, fstr, tmp, "0123456789+-xXzZ?_");
if (!tmp[0]) goto done; if (!tmp[0]) goto done;
vlsint64_t ld; vlsint64_t ld = 0;
sscanf(tmp, "%30" VL_PRI64 "d", &ld); sscanf(tmp, "%30" VL_PRI64 "d", &ld);
VL_SET_WQ(owp, ld); VL_SET_WQ(owp, ld);
break; break;
@ -1101,7 +1096,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
_vl_vsss_skipspace(fp, floc, fromp, fstr); _vl_vsss_skipspace(fp, floc, fromp, fstr);
_vl_vsss_read_str(fp, floc, fromp, fstr, tmp, "0123456789+-xXzZ?_"); _vl_vsss_read_str(fp, floc, fromp, fstr, tmp, "0123456789+-xXzZ?_");
if (!tmp[0]) goto done; if (!tmp[0]) goto done;
QData ld; QData ld = 0;
sscanf(tmp, "%30" VL_PRI64 "u", &ld); sscanf(tmp, "%30" VL_PRI64 "u", &ld);
VL_SET_WQ(owp, ld); VL_SET_WQ(owp, ld);
break; break;
@ -1216,7 +1211,7 @@ void _VL_STRING_TO_VINT(int obits, void* destp, size_t srclen, const char* srcp)
size_t bytes = VL_BYTES_I(obits); size_t bytes = VL_BYTES_I(obits);
char* op = reinterpret_cast<char*>(destp); char* op = reinterpret_cast<char*>(destp);
if (srclen > bytes) srclen = bytes; // Don't overflow destination if (srclen > bytes) srclen = bytes; // Don't overflow destination
size_t i; size_t i = 0;
for (i = 0; i < srclen; ++i) { *op++ = srcp[srclen - 1 - i]; } for (i = 0; i < srclen; ++i) { *op++ = srcp[srclen - 1 - i]; }
for (; i < bytes; ++i) { *op++ = 0; } for (; i < bytes; ++i) { *op++ = 0; }
} }
@ -1522,36 +1517,38 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M
VL_ZERO_RESET_W(rbits, rwp); VL_ZERO_RESET_W(rbits, rwp);
switch (tolower(fmt)) { switch (tolower(fmt)) {
case 'd': case 'd': {
vlsint64_t lld; vlsint64_t lld = 0;
sscanf(dp, "%30" VL_PRI64 "d", &lld); sscanf(dp, "%30" VL_PRI64 "d", &lld);
VL_SET_WQ(rwp, lld); VL_SET_WQ(rwp, lld);
break; break;
}
case 'b': _vl_vsss_based(rwp, rbits, 1, dp, 0, strlen(dp)); break; case 'b': _vl_vsss_based(rwp, rbits, 1, dp, 0, strlen(dp)); break;
case 'o': _vl_vsss_based(rwp, rbits, 3, dp, 0, strlen(dp)); break; case 'o': _vl_vsss_based(rwp, rbits, 3, dp, 0, strlen(dp)); break;
case 'h': // FALLTHRU case 'h': // FALLTHRU
case 'x': _vl_vsss_based(rwp, rbits, 4, dp, 0, strlen(dp)); break; case 'x': _vl_vsss_based(rwp, rbits, 4, dp, 0, strlen(dp)); break;
case 's': // string/no conversion case 's': { // string/no conversion
for (int i = 0, lsb = 0, posp = static_cast<int>(strlen(dp)) - 1; i < rbits && posp >= 0; for (int i = 0, lsb = 0, posp = static_cast<int>(strlen(dp)) - 1; i < rbits && posp >= 0;
--posp) { --posp) {
_vl_vsss_setbit(rwp, rbits, lsb, 8, dp[posp]); _vl_vsss_setbit(rwp, rbits, lsb, 8, dp[posp]);
lsb += 8; lsb += 8;
} }
break; break;
}
case 'e': { case 'e': {
double temp = 0.f; double temp = 0.F;
sscanf(dp, "%le", &temp); sscanf(dp, "%le", &temp);
VL_SET_WQ(rwp, VL_CVT_Q_D(temp)); VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
break; break;
} }
case 'f': { case 'f': {
double temp = 0.f; double temp = 0.F;
sscanf(dp, "%lf", &temp); sscanf(dp, "%lf", &temp);
VL_SET_WQ(rwp, VL_CVT_Q_D(temp)); VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
break; break;
} }
case 'g': { case 'g': {
double temp = 0.f; double temp = 0.F;
sscanf(dp, "%lg", &temp); sscanf(dp, "%lg", &temp);
VL_SET_WQ(rwp, VL_CVT_Q_D(temp)); VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
break; break;
@ -1799,7 +1796,7 @@ bool VlReadMem::get(QData& addrr, std::string& valuer) {
m_addr = (m_addr << 4) + value; m_addr = (m_addr << 4) + value;
} else { } else {
indata = true; indata = true;
valuer += c; valuer += static_cast<char>(c);
// printf(" Value width=%d @%x = %c\n", width, m_addr, c); // printf(" Value width=%d @%x = %c\n", width, m_addr, c);
if (VL_UNLIKELY(value > 1 && !m_hex)) { if (VL_UNLIKELY(value > 1 && !m_hex)) {
VL_FATAL_MT(m_filename.c_str(), m_linenum, "", VL_FATAL_MT(m_filename.c_str(), m_linenum, "",
@ -1944,7 +1941,7 @@ void VL_READMEM_N(bool hex, // Hex format, else binary
VlReadMem rmem(hex, bits, filename, start, end); VlReadMem rmem(hex, bits, filename, start, end);
if (VL_UNLIKELY(!rmem.isOpen())) return; if (VL_UNLIKELY(!rmem.isOpen())) return;
while (true) { while (true) {
QData addr; QData addr = 0;
std::string value; std::string value;
if (rmem.get(addr /*ref*/, value /*ref*/)) { if (rmem.get(addr /*ref*/, value /*ref*/)) {
if (VL_UNLIKELY(addr < static_cast<QData>(array_lsb) if (VL_UNLIKELY(addr < static_cast<QData>(array_lsb)
@ -2528,7 +2525,7 @@ VerilatedScope::~VerilatedScope() {
void VerilatedScope::configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp, void VerilatedScope::configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp,
const char* identifier, vlsint8_t timeunit, const char* identifier, vlsint8_t timeunit,
const Type type) VL_MT_UNSAFE { const Type& type) VL_MT_UNSAFE {
// Slowpath - called once/scope at construction // Slowpath - called once/scope at construction
// We don't want the space and reference-count access overhead of strings. // We don't want the space and reference-count access overhead of strings.
m_symsp = symsp; m_symsp = symsp;

View File

@ -337,7 +337,7 @@ public: // But internals only - called from VerilatedModule's
VerilatedScope(); VerilatedScope();
~VerilatedScope(); ~VerilatedScope();
void configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp, void configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp,
const char* identifier, vlsint8_t timeunit, const Type type) VL_MT_UNSAFE; const char* identifier, vlsint8_t timeunit, const Type& type) VL_MT_UNSAFE;
void exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE; void exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE;
void varInsert(int finalize, const char* namep, void* datap, VerilatedVarType vltype, void varInsert(int finalize, const char* namep, void* datap, VerilatedVarType vltype,
int vlflags, int dims, ...) VL_MT_UNSAFE; int vlflags, int dims, ...) VL_MT_UNSAFE;
@ -365,7 +365,7 @@ public: // But internals only - called from VerilatedModule's
class VerilatedHierarchy { class VerilatedHierarchy {
public: public:
void add(VerilatedScope* fromp, VerilatedScope* top); static void add(VerilatedScope* fromp, VerilatedScope* top);
}; };
//=========================================================================== //===========================================================================
@ -1909,7 +1909,8 @@ static inline IData VL_STREAML_FAST_III(int, int lbits, int, IData ld, IData rd_
case 1: ret = ((ret >> 2) & VL_UL(0x33333333)) | ((ret & VL_UL(0x33333333)) << 2); // FALLTHRU case 1: ret = ((ret >> 2) & VL_UL(0x33333333)) | ((ret & VL_UL(0x33333333)) << 2); // FALLTHRU
case 2: ret = ((ret >> 4) & VL_UL(0x0f0f0f0f)) | ((ret & VL_UL(0x0f0f0f0f)) << 4); // FALLTHRU case 2: ret = ((ret >> 4) & VL_UL(0x0f0f0f0f)) | ((ret & VL_UL(0x0f0f0f0f)) << 4); // FALLTHRU
case 3: ret = ((ret >> 8) & VL_UL(0x00ff00ff)) | ((ret & VL_UL(0x00ff00ff)) << 8); // FALLTHRU case 3: ret = ((ret >> 8) & VL_UL(0x00ff00ff)) | ((ret & VL_UL(0x00ff00ff)) << 8); // FALLTHRU
case 4: ret = ((ret >> 16) | (ret << 16)); case 4: ret = ((ret >> 16) | (ret << 16)); // FALLTHRU
default:;
} }
return ret >> (VL_IDATASIZE - lbits); return ret >> (VL_IDATASIZE - lbits);
} }
@ -1939,7 +1940,8 @@ static inline QData VL_STREAML_FAST_QQI(int, int lbits, int, QData ld, IData rd_
case 4: case 4:
ret = (((ret >> 16) & 0x0000ffff0000ffffULL) ret = (((ret >> 16) & 0x0000ffff0000ffffULL)
| ((ret & 0x0000ffff0000ffffULL) << 16)); // FALLTHRU | ((ret & 0x0000ffff0000ffffULL) << 16)); // FALLTHRU
case 5: ret = ((ret >> 32) | (ret << 32)); case 5: ret = ((ret >> 32) | (ret << 32)); // FALLTHRU
default:;
} }
return ret >> (VL_QUADSIZE - lbits); return ret >> (VL_QUADSIZE - lbits);
} }

View File

@ -94,7 +94,6 @@ private:
typedef std::map<int, std::string> IndexValueMap; typedef std::map<int, std::string> IndexValueMap;
typedef std::deque<VerilatedCovImpItem*> ItemList; typedef std::deque<VerilatedCovImpItem*> ItemList;
private:
// MEMBERS // MEMBERS
VerilatedMutex m_mutex; ///< Protects all members VerilatedMutex m_mutex; ///< Protects all members
ValueIndexMap m_valueIndexes VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for values ValueIndexMap m_valueIndexes VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for values

View File

@ -136,7 +136,8 @@ void VerilatedFst::declare(vluint32_t code, const char* name, int dtypenum, fstV
std::pair<Code2SymbolType::iterator, bool> p std::pair<Code2SymbolType::iterator, bool> p
= m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL))); = m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL)));
std::istringstream nameiss(name); std::istringstream nameiss(name);
std::istream_iterator<std::string> beg(nameiss), end; std::istream_iterator<std::string> beg(nameiss);
std::istream_iterator<std::string> end;
std::list<std::string> tokens(beg, end); // Split name std::list<std::string> tokens(beg, end); // Split name
std::string symbol_name(tokens.back()); std::string symbol_name(tokens.back());
tokens.pop_back(); // Remove symbol name from hierarchy tokens.pop_back(); // Remove symbol name from hierarchy

View File

@ -39,7 +39,7 @@
// Static utility functions // Static utility functions
static double timescaleToDouble(const char* unitp) { static double timescaleToDouble(const char* unitp) {
char* endp; char* endp = NULL;
double value = strtod(unitp, &endp); double value = strtod(unitp, &endp);
// On error so we allow just "ns" to return 1e-9. // On error so we allow just "ns" to return 1e-9.
if (value == 0.0 && endp == unitp) value = 1; if (value == 0.0 && endp == unitp) value = 1;

View File

@ -31,8 +31,8 @@
// //
//************************************************************************* //*************************************************************************
#ifndef _V3_UNORDERED_SET_MAP_H_ #ifndef _VERILATED_UNORDERED_SET_MAP_H_
#define _V3_UNORDERED_SET_MAP_H_ #define _VERILATED_UNORDERED_SET_MAP_H_
#include "verilatedos.h" #include "verilatedos.h"

View File

@ -376,8 +376,8 @@ struct VerilatedVpiTimedCbsCmp {
/// Ordering sets keyed by time, then callback descriptor /// Ordering sets keyed by time, then callback descriptor
bool operator()(const std::pair<QData, VerilatedVpioCb*>& a, bool operator()(const std::pair<QData, VerilatedVpioCb*>& a,
const std::pair<QData, VerilatedVpioCb*>& b) const { const std::pair<QData, VerilatedVpioCb*>& b) const {
if (a.first < b.first) return 1; if (a.first < b.first) return true;
if (a.first > b.first) return 0; if (a.first > b.first) return false;
return a.second < b.second; return a.second < b.second;
} }
}; };
@ -939,7 +939,7 @@ const char* VerilatedVpiError::strFromVpiProp(PLI_INT32 vpiVal) VL_MT_SAFE {
} }
#define CHECK_RESULT_CSTR(got, exp) \ #define CHECK_RESULT_CSTR(got, exp) \
if (strcmp((got), (exp))) { \ if (0 != strcmp((got), (exp))) { \
std::string msg \ std::string msg \
= std::string("%Error: ") + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \ = std::string("%Error: ") + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \ VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \
@ -2079,10 +2079,12 @@ PLI_INT32 vpi_control(PLI_INT32 operation, ...) {
VL_STOP_MT("", 0, "*VPI*"); VL_STOP_MT("", 0, "*VPI*");
return 1; return 1;
} }
default: {
_VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, ignoring", VL_FUNC,
VerilatedVpiError::strFromVpiProp(operation));
return 0;
}
} }
_VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, ignoring", VL_FUNC,
VerilatedVpiError::strFromVpiProp(operation));
return 0;
} }
vpiHandle vpi_handle_by_multi_index(vpiHandle /*obj*/, PLI_INT32 /*num_index*/, vpiHandle vpi_handle_by_multi_index(vpiHandle /*obj*/, PLI_INT32 /*num_index*/,

View File

@ -726,7 +726,7 @@ void AstNode::deleteNode() {
this->m_op4p = reinterpret_cast<AstNode*>(0x1); this->m_op4p = reinterpret_cast<AstNode*>(0x1);
if ( if (
#if !defined(VL_DEBUG) || defined(VL_LEAK_CHECKS) #if !defined(VL_DEBUG) || defined(VL_LEAK_CHECKS)
1 true
#else #else
!v3Global.opt.debugLeak() !v3Global.opt.debugLeak()
#endif #endif

View File

@ -1100,11 +1100,11 @@ public:
explicit VNUser(void* p) { m_u.up = p; } explicit VNUser(void* p) { m_u.up = p; }
~VNUser() {} ~VNUser() {}
// Casters // Casters
WidthVP* c() { return ((WidthVP*)m_u.up); } WidthVP* c() const { return reinterpret_cast<WidthVP*>(m_u.up); }
VSymEnt* toSymEnt() { return ((VSymEnt*)m_u.up); } VSymEnt* toSymEnt() const { return reinterpret_cast<VSymEnt*>(m_u.up); }
AstNode* toNodep() { return ((AstNode*)m_u.up); } AstNode* toNodep() const { return reinterpret_cast<AstNode*>(m_u.up); }
V3GraphVertex* toGraphVertex() { return ((V3GraphVertex*)m_u.up); } V3GraphVertex* toGraphVertex() const { return reinterpret_cast<V3GraphVertex*>(m_u.up); }
inline int toInt() { return m_u.ui; } int toInt() const { return m_u.ui; }
static inline VNUser fromInt(int i) { return VNUser(i); } static inline VNUser fromInt(int i) { return VNUser(i); }
}; };
@ -1310,7 +1310,7 @@ public:
class FullValue {}; // for creator type-overload selection class FullValue {}; // for creator type-overload selection
explicit V3Hash(Illegal) { m_both = 0; } explicit V3Hash(Illegal) { m_both = 0; }
// Saving and restoring inside a userp // Saving and restoring inside a userp
explicit V3Hash(VNUser u) { m_both = u.toInt(); } explicit V3Hash(const VNUser& u) { m_both = u.toInt(); }
V3Hash operator+=(const V3Hash& rh) { V3Hash operator+=(const V3Hash& rh) {
setBoth(depth() + rh.depth(), (hshval() * 31 + rh.hshval())); setBoth(depth() + rh.depth(), (hshval() * 31 + rh.hshval()));
return *this; return *this;
@ -2474,9 +2474,8 @@ public:
} // op1 = AstMember list } // op1 = AstMember list
void addMembersp(AstNode* nodep) { addNOp1p(nodep); } void addMembersp(AstNode* nodep) { addNOp1p(nodep); }
bool packed() const { return m_packed; } bool packed() const { return m_packed; }
bool packedUnsup() const { // packed() but as don't support unpacked, presently all structs
return true; static bool packedUnsup() { return true; }
} // packed() but as don't support unpacked, presently all structs
void isFourstate(bool flag) { m_isFourstate = flag; } void isFourstate(bool flag) { m_isFourstate = flag; }
virtual bool isFourstate() const { return m_isFourstate; } virtual bool isFourstate() const { return m_isFourstate; }
void clearCache() { m_members.clear(); } void clearCache() { m_members.clear(); }
@ -2485,7 +2484,7 @@ public:
MemberNameMap::const_iterator it = m_members.find(name); MemberNameMap::const_iterator it = m_members.find(name);
return (it == m_members.end()) ? NULL : it->second; return (it == m_members.end()) ? NULL : it->second;
} }
int lsb() const { return 0; } static int lsb() { return 0; }
int msb() const { return dtypep()->width() - 1; } // Packed classes look like arrays int msb() const { return dtypep()->width() - 1; } // Packed classes look like arrays
VNumRange declRange() const { return VNumRange(msb(), lsb(), false); } VNumRange declRange() const { return VNumRange(msb(), lsb(), false); }
}; };

View File

@ -1908,11 +1908,11 @@ public:
VDirection declDirection() const { return m_declDirection; } VDirection declDirection() const { return m_declDirection; }
void varType(AstVarType type) { m_varType = type; } void varType(AstVarType type) { m_varType = type; }
void varType2Out() { void varType2Out() {
m_tristate = 0; m_tristate = false;
m_direction = VDirection::OUTPUT; m_direction = VDirection::OUTPUT;
} }
void varType2In() { void varType2In() {
m_tristate = 0; m_tristate = false;
m_direction = VDirection::INPUT; m_direction = VDirection::INPUT;
} }
AstBasicDTypeKwd declKwd() const { return m_declKwd; } AstBasicDTypeKwd declKwd() const { return m_declKwd; }

View File

@ -255,7 +255,7 @@ private:
iterateChildren(nodep); iterateChildren(nodep);
m_logicVertexp = NULL; m_logicVertexp = NULL;
if (0 && debug() >= 9) { if (false && debug() >= 9) {
UINFO(9, "Trace Logic:\n"); UINFO(9, "Trace Logic:\n");
nodep->dumpTree(cout, "-log1: "); nodep->dumpTree(cout, "-log1: ");
} }
@ -295,7 +295,7 @@ private:
static bool told_file = false; static bool told_file = false;
nodep->v3warnCode(code, msg); nodep->v3warnCode(code, msg);
if (!told_file) { if (!told_file) {
told_file = 1; told_file = true;
std::cerr << V3Error::msgPrefix() << " See details in " << m_ofFilename << endl; std::cerr << V3Error::msgPrefix() << " See details in " << m_ofFilename << endl;
} }
*m_ofp << "%Warning-" << code.ascii() << ": " << nodep->fileline() << " " << msg << endl; *m_ofp << "%Warning-" << code.ascii() << ": " << nodep->fileline() << " " << msg << endl;

View File

@ -345,7 +345,7 @@ private:
// Grab statement bodies // Grab statement bodies
AstNRelinker relink1Handle; AstNRelinker relink1Handle;
AstNRelinker relink2Handle; AstNRelinker relink2Handle;
for (AstNode *nextp, *walkp = node1p; 1; walkp = nextp) { for (AstNode *nextp, *walkp = node1p; true; walkp = nextp) {
nextp = walkp->nextp(); nextp = walkp->nextp();
if (walkp == node1p) { if (walkp == node1p) {
walkp->unlinkFrBack(&relink1Handle); walkp->unlinkFrBack(&relink1Handle);
@ -355,7 +355,7 @@ private:
} }
if (walkp == last1p) break; if (walkp == last1p) break;
} }
for (AstNode *nextp, *walkp = node2p; 1; walkp = nextp) { for (AstNode *nextp, *walkp = node2p; true; walkp = nextp) {
nextp = walkp->nextp(); nextp = walkp->nextp();
if (walkp == node2p) { if (walkp == node2p) {
walkp->unlinkFrBack(&relink2Handle); walkp->unlinkFrBack(&relink2Handle);

View File

@ -335,7 +335,7 @@ public:
// UINFO(9, " Hit " << *m_lastIt << endl); // UINFO(9, " Hit " << *m_lastIt << endl);
filelinep->warnOn(m_lastIgnore.it->m_code, m_lastIgnore.it->m_on); filelinep->warnOn(m_lastIgnore.it->m_code, m_lastIgnore.it->m_on);
} }
if (0 && debug() >= 9) { if (false && debug() >= 9) {
for (IgnLines::const_iterator it = m_lastIgnore.it; it != m_ignLines.end(); ++it) { for (IgnLines::const_iterator it = m_lastIgnore.it; it != m_ignLines.end(); ++it) {
UINFO(9, " NXT " << *it << endl); UINFO(9, " NXT " << *it << endl);
} }

View File

@ -43,7 +43,7 @@ public:
static void applyModule(AstNodeModule* modulep); static void applyModule(AstNodeModule* modulep);
static void applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp); static void applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp);
static void applyVarAttr(AstNodeModule* modulep, AstNodeFTask* ftaskp, AstVar* varp); static void applyVarAttr(AstNodeModule* modulep, AstNodeFTask* ftaskp, AstVar* varp);
static bool waive(FileLine* filelinep, V3ErrorCode code, const string& match); static bool waive(FileLine* filelinep, V3ErrorCode code, const string& message);
}; };
#endif // Guard #endif // Guard

View File

@ -127,7 +127,7 @@ class EmitCSyms : 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 = m_words.isKeyword(nodep->name()); 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

View File

@ -58,7 +58,8 @@ class EmitXmlFileVisitor : public AstNVisitor {
if (!nodep->user1()) { nodep->user1(++m_id); } if (!nodep->user1()) { nodep->user1(++m_id); }
puts("\"" + cvtToStr(nodep->user1()) + "\""); puts("\"" + cvtToStr(nodep->user1()) + "\"");
} }
void outputTag(AstNode* nodep, string tag) { void outputTag(AstNode* nodep, const string& tagin) {
string tag = tagin;
if (tag == "") tag = VString::downcase(nodep->typeName()); if (tag == "") tag = VString::downcase(nodep->typeName());
puts("<" + tag + " " + nodep->fileline()->xml()); puts("<" + tag + " " + nodep->fileline()->xml());
puts(" " + nodep->fileline()->xmlDetailedLocation()); puts(" " + nodep->fileline()->xmlDetailedLocation());
@ -86,7 +87,8 @@ class EmitXmlFileVisitor : public AstNVisitor {
} }
} }
} }
void outputChildrenEnd(AstNode* nodep, string tag) { void outputChildrenEnd(AstNode* nodep, const string& tagin) {
string tag = tagin;
if (tag == "") tag = VString::downcase(nodep->typeName()); if (tag == "") tag = VString::downcase(nodep->typeName());
if (nodep->op1p() || nodep->op2p() || nodep->op3p() || nodep->op4p()) { if (nodep->op1p() || nodep->op2p() || nodep->op3p() || nodep->op4p()) {
puts(">\n"); puts(">\n");

View File

@ -644,7 +644,7 @@ V3OutFormatter::V3OutFormatter(const string& filename, V3OutFormatter::Language
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const string V3OutFormatter::indentSpaces(int num) { string V3OutFormatter::indentSpaces(int num) {
// Indent the specified number of spaces. Use spaces. // Indent the specified number of spaces. Use spaces.
static char str[MAXSPACE + 20]; static char str[MAXSPACE + 20];
char* cp = str; char* cp = str;

View File

@ -165,7 +165,7 @@ public:
if (!m_parenVec.empty()) m_parenVec.pop(); if (!m_parenVec.empty()) m_parenVec.pop();
} }
// STATIC METHODS // STATIC METHODS
static const string indentSpaces(int num); static string indentSpaces(int num);
// Add escaped characters to strings // Add escaped characters to strings
static string quoteNameControls(const string& namein, Language lang = LA_C); static string quoteNameControls(const string& namein, Language lang = LA_C);

View File

@ -36,7 +36,7 @@
//###################################################################### //######################################################################
// FileLineSingleton class functions // FileLineSingleton class functions
const string FileLineSingleton::filenameLetters(int fileno) { string FileLineSingleton::filenameLetters(int fileno) {
const int size = 1 + (64 / 4); // Each letter retires more than 4 bits of a > 64 bit number const int size = 1 + (64 / 4); // Each letter retires more than 4 bits of a > 64 bit number
char out[size]; char out[size];
char* op = out + size - 1; char* op = out + size - 1;
@ -165,7 +165,7 @@ void FileLine::newContent() {
m_contentLineno = 1; m_contentLineno = 1;
} }
const string FileLine::xmlDetailedLocation() const { string FileLine::xmlDetailedLocation() const {
return "loc=\"" + cvtToStr(filenameLetters()) + "," + cvtToStr(firstLineno()) + "," return "loc=\"" + cvtToStr(filenameLetters()) + "," + cvtToStr(firstLineno()) + ","
+ cvtToStr(firstColumn()) + "," + cvtToStr(lastLineno()) + "," + cvtToStr(lastColumn()) + cvtToStr(firstColumn()) + "," + cvtToStr(lastLineno()) + "," + cvtToStr(lastColumn())
+ "\""; + "\"";
@ -259,27 +259,27 @@ FileLine* FileLine::copyOrSameFileLine() {
return newp; return newp;
} }
const string FileLine::filebasename() const { string FileLine::filebasename() const {
string name = filename(); string name = filename();
string::size_type pos; string::size_type pos;
if ((pos = name.rfind('/')) != string::npos) name.erase(0, pos + 1); if ((pos = name.rfind('/')) != string::npos) name.erase(0, pos + 1);
return name; return name;
} }
const string FileLine::filebasenameNoExt() const { string FileLine::filebasenameNoExt() const {
string name = filebasename(); string name = filebasename();
string::size_type pos; string::size_type pos;
if ((pos = name.find('.')) != string::npos) name = name.substr(0, pos); if ((pos = name.find('.')) != string::npos) name = name.substr(0, pos);
return name; return name;
} }
const string FileLine::firstColumnLetters() const { string FileLine::firstColumnLetters() const {
char a = ((firstColumn() / 26) % 26) + 'a'; char a = ((firstColumn() / 26) % 26) + 'a';
char b = (firstColumn() % 26) + 'a'; char b = (firstColumn() % 26) + 'a';
return string(1, a) + string(1, b); return string(1, a) + string(1, b);
} }
const string FileLine::profileFuncname() const { string FileLine::profileFuncname() const {
// Return string that is OK as a function name - for profiling // Return string that is OK as a function name - for profiling
string name = filebasenameNoExt(); string name = filebasenameNoExt();
string::size_type pos; string::size_type pos;

View File

@ -14,8 +14,8 @@
// //
//************************************************************************* //*************************************************************************
#ifndef _V3FileLine_H_ #ifndef _V3FILELINE_H_
#define _V3FileLine_H_ 1 #define _V3FILELINE_H_ 1
#include "config_build.h" #include "config_build.h"
#include "verilatedos.h" #include "verilatedos.h"
@ -51,8 +51,8 @@ class FileLineSingleton {
protected: protected:
friend class FileLine; friend class FileLine;
int nameToNumber(const string& filename); int nameToNumber(const string& filename);
const string numberToName(int filenameno) const { return m_names[filenameno]; } string numberToName(int filenameno) const { return m_names[filenameno]; }
const V3LangCode numberToLang(int filenameno) const { return m_languages[filenameno]; } V3LangCode numberToLang(int filenameno) const { return m_languages[filenameno]; }
void numberToLang(int filenameno, const V3LangCode& l) { m_languages[filenameno] = l; } void numberToLang(int filenameno, const V3LangCode& l) { m_languages[filenameno] = l; }
void clear() { void clear() {
m_namemap.clear(); m_namemap.clear();
@ -60,7 +60,7 @@ protected:
m_languages.clear(); m_languages.clear();
} }
void fileNameNumMapDumpXml(std::ostream& os); void fileNameNumMapDumpXml(std::ostream& os);
static const string filenameLetters(int fileno); static string filenameLetters(int fileno);
}; };
//! All source lines from a file/stream, to enable errors to show sources //! All source lines from a file/stream, to enable errors to show sources
@ -193,19 +193,17 @@ public:
string ascii() const; string ascii() const;
string asciiLineCol() const; string asciiLineCol() const;
int filenameno() const { return m_filenameno; } int filenameno() const { return m_filenameno; }
const string filename() const { return singleton().numberToName(filenameno()); } string filename() const { return singleton().numberToName(filenameno()); }
bool filenameIsGlobal() const { bool filenameIsGlobal() const {
return (filename() == commandLineFilename() || filename() == builtInFilename()); return (filename() == commandLineFilename() || filename() == builtInFilename());
} }
const string filenameLetters() const { return singleton().filenameLetters(filenameno()); } string filenameLetters() const { return FileLineSingleton::filenameLetters(filenameno()); }
const string filebasename() const; string filebasename() const;
const string filebasenameNoExt() const; string filebasenameNoExt() const;
const string firstColumnLetters() const; string firstColumnLetters() const;
const string profileFuncname() const; string profileFuncname() const;
const string xml() const { string xml() const { return "fl=\"" + filenameLetters() + cvtToStr(lastLineno()) + "\""; }
return "fl=\"" + filenameLetters() + cvtToStr(lastLineno()) + "\""; string xmlDetailedLocation() const;
}
const string xmlDetailedLocation() const;
string lineDirectiveStrg(int enterExit) const; string lineDirectiveStrg(int enterExit) const;
// Turn on/off warning messages on this line. // Turn on/off warning messages on this line.

View File

@ -88,7 +88,6 @@ public:
// Options // Options
V3Options opt; // All options; let user see them directly V3Options opt; // All options; let user see them directly
public:
// CONSTRUCTORS // CONSTRUCTORS
V3Global() V3Global()
: m_rootp(NULL) // created by makeInitNetlist() so static constructors run first : m_rootp(NULL) // created by makeInitNetlist() so static constructors run first

View File

@ -79,9 +79,9 @@ public:
struct GraphAcycEdgeCmp { struct GraphAcycEdgeCmp {
inline bool operator()(const V3GraphEdge* lhsp, const V3GraphEdge* rhsp) const { inline bool operator()(const V3GraphEdge* lhsp, const V3GraphEdge* rhsp) const {
if (lhsp->weight() > rhsp->weight()) return 1; // LHS goes first if (lhsp->weight() > rhsp->weight()) return true; // LHS goes first
if (lhsp->weight() < rhsp->weight()) return 0; // RHS goes first if (lhsp->weight() < rhsp->weight()) return false; // RHS goes first
return 0; return false;
} }
}; };

View File

@ -193,7 +193,7 @@ private:
return NULL; // No match return NULL; // No match
} }
void findNfasWithInput(DfaVertex* dfaStatep, DfaInput input, DfaStates& nfasWithInput) { void findNfasWithInput(DfaVertex* dfaStatep, const DfaInput& input, DfaStates& nfasWithInput) {
// Return all NFA states, with the given input transition from // Return all NFA states, with the given input transition from
// the nfa states a given dfa state was constructed from. // the nfa states a given dfa state was constructed from.
nextStep(); nextStep();

View File

@ -158,7 +158,7 @@ void V3Hashed::dumpFile(const string& filename, bool tree) {
V3Hash lasthash; V3Hash lasthash;
int num_in_bucket = 0; int num_in_bucket = 0;
for (HashMmap::iterator it = begin(); 1; ++it) { for (HashMmap::iterator it = begin(); true; ++it) {
if (it == end() || lasthash != it->first) { if (it == end() || lasthash != it->first) {
if (it != end()) lasthash = it->first; if (it != end()) lasthash = it->first;
if (num_in_bucket) { if (num_in_bucket) {

View File

@ -54,7 +54,7 @@ private:
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 = m_words.isKeyword(nodep->name()); 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());

View File

@ -792,7 +792,7 @@ string V3Number::toDecimalU() const {
if (bcd.bitsValue(lsb, 4)) break; if (bcd.bitsValue(lsb, 4)) break;
} }
for (; lsb >= 0; lsb -= 4) { for (; lsb >= 0; lsb -= 4) {
output += ('0' + bcd.bitsValue(lsb, 4)); // 0..9 output += static_cast<char>('0' + bcd.bitsValue(lsb, 4)); // 0..9
} }
return output; return output;
} }
@ -946,12 +946,12 @@ bool V3Number::isAnyXZ() const {
bool V3Number::isLtXZ(const V3Number& rhs) const { bool V3Number::isLtXZ(const V3Number& rhs) const {
// Include X/Z in comparisons for sort ordering // Include X/Z in comparisons for sort ordering
for (int bit = 0; bit < std::max(this->width(), rhs.width()); bit++) { for (int bit = 0; bit < std::max(this->width(), rhs.width()); bit++) {
if (this->bitIs1(bit) && rhs.bitIs0(bit)) { return 1; } if (this->bitIs1(bit) && rhs.bitIs0(bit)) { return true; }
if (rhs.bitIs1(bit) && this->bitIs0(bit)) { return 0; } if (rhs.bitIs1(bit) && this->bitIs0(bit)) { return false; }
if (this->bitIsXZ(bit)) { return 1; } if (this->bitIsXZ(bit)) { return true; }
if (rhs.bitIsXZ(bit)) { return 0; } if (rhs.bitIsXZ(bit)) { return false; }
} }
return 0; return false;
} }
int V3Number::widthMin() const { int V3Number::widthMin() const {

View File

@ -97,27 +97,43 @@ public:
VTimescale(const string& value, bool& badr); VTimescale(const string& value, bool& badr);
VTimescale(double value, bool& badr) { VTimescale(double value, bool& badr) {
badr = false; badr = false;
// clang-format off if (value == 10e2) {
if (value == 10e2) m_e = TS_100S; m_e = TS_100S;
else if (value == 1e1) m_e = TS_10S; } else if (value == 1e1) {
else if (value == 1e0) m_e = TS_1S; m_e = TS_10S;
else if (value == 1e-1) m_e = TS_100MS; } else if (value == 1e0) {
else if (value == 1e-2) m_e = TS_10MS; m_e = TS_1S;
else if (value == 1e-3) m_e = TS_1MS; } else if (value == 1e-1) {
else if (value == 1e-4) m_e = TS_100US; m_e = TS_100MS;
else if (value == 1e-5) m_e = TS_10US; } else if (value == 1e-2) {
else if (value == 1e-6) m_e = TS_1US; m_e = TS_10MS;
else if (value == 1e-7) m_e = TS_100NS; } else if (value == 1e-3) {
else if (value == 1e-8) m_e = TS_10NS; m_e = TS_1MS;
else if (value == 1e-9) m_e = TS_1NS; } else if (value == 1e-4) {
else if (value == 1e-10) m_e = TS_100PS; m_e = TS_100US;
else if (value == 1e-11) m_e = TS_10PS; } else if (value == 1e-5) {
else if (value == 1e-12) m_e = TS_1PS; m_e = TS_10US;
else if (value == 1e-13) m_e = TS_100FS; } else if (value == 1e-6) {
else if (value == 1e-14) m_e = TS_10FS; m_e = TS_1US;
else if (value == 1e-15) m_e = TS_1FS; } else if (value == 1e-7) {
// clang-format on m_e = TS_100NS;
else { } else if (value == 1e-8) {
m_e = TS_10NS;
} else if (value == 1e-9) {
m_e = TS_1NS;
} else if (value == 1e-10) {
m_e = TS_100PS;
} else if (value == 1e-11) {
m_e = TS_10PS;
} else if (value == 1e-12) {
m_e = TS_1PS;
} else if (value == 1e-13) {
m_e = TS_100FS;
} else if (value == 1e-14) {
m_e = TS_10FS;
} else if (value == 1e-15) {
m_e = TS_1FS;
} else {
m_e = NONE; m_e = NONE;
badr = true; badr = true;
} }
@ -132,7 +148,7 @@ public:
"10ns", "1ns", "100ps", "10ps", "1ps", "100fs", "10fs", "1fs", "NONE"}; "10ns", "1ns", "100ps", "10ps", "1ps", "100fs", "10fs", "1fs", "NONE"};
return names[m_e]; return names[m_e];
} }
int powerOfTen() { return 2 - static_cast<int>(m_e); } int powerOfTen() const { return 2 - static_cast<int>(m_e); }
double multiplier() const { double multiplier() const {
static const double values[] static const double values[]
= {100, 10, 1, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, = {100, 10, 1, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7,

View File

@ -1342,7 +1342,7 @@ void OrderVisitor::processInputs() {
void OrderVisitor::processInputsInIterate(OrderEitherVertex* vertexp, VertexVec& todoVec) { void OrderVisitor::processInputsInIterate(OrderEitherVertex* vertexp, VertexVec& todoVec) {
// Propagate PrimaryIn through simple assignments // Propagate PrimaryIn through simple assignments
if (vertexp->user()) return; // Already processed if (vertexp->user()) return; // Already processed
if (0 && debug() >= 9) { if (false && debug() >= 9) {
UINFO(9, " InIIter " << vertexp << endl); UINFO(9, " InIIter " << vertexp << endl);
if (OrderLogicVertex* vvertexp = dynamic_cast<OrderLogicVertex*>(vertexp)) { if (OrderLogicVertex* vvertexp = dynamic_cast<OrderLogicVertex*>(vertexp)) {
vvertexp->nodep()->dumpTree(cout, "- TT: "); vvertexp->nodep()->dumpTree(cout, "- TT: ");
@ -2011,7 +2011,7 @@ void OrderVisitor::process() {
// Dump data // Dump data
m_graph.dumpDotFilePrefixed("orderg_done"); m_graph.dumpDotFilePrefixed("orderg_done");
if (0 && debug()) { if (false && debug()) {
string dfilename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_INT_order"; string dfilename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_INT_order";
const vl_unique_ptr<std::ofstream> logp(V3File::new_ofstream(dfilename)); const vl_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);

View File

@ -164,8 +164,8 @@ void V3ParseImp::errorPreprocDirective(const char* textp) {
// Find all `preprocessor spelling candidates // Find all `preprocessor spelling candidates
// Can't make this static as might get more defines later when read cells // Can't make this static as might get more defines later when read cells
VSpellCheck speller; VSpellCheck speller;
V3LanguageWords words; for (V3LanguageWords::const_iterator it = V3LanguageWords::begin();
for (V3LanguageWords::const_iterator it = words.begin(); it != words.end(); ++it) { it != V3LanguageWords::end(); ++it) {
string ppDirective = it->first; string ppDirective = it->first;
if (ppDirective[0] == '`') speller.pushCandidate(ppDirective); if (ppDirective[0] == '`') speller.pushCandidate(ppDirective);
} }

View File

@ -228,10 +228,10 @@ public:
void lexNew(); void lexNew();
void lexDestroy(); void lexDestroy();
static int stateVerilogRecent(); // Parser -> lexer communication static int stateVerilogRecent(); // Parser -> lexer communication
int prevLexToken() { return m_prevLexToken; } // Parser -> lexer communication int prevLexToken() const { return m_prevLexToken; } // Parser -> lexer communication
size_t flexPpInputToLex(char* buf, size_t max_size) { return ppInputToLex(buf, max_size); } size_t flexPpInputToLex(char* buf, size_t max_size) { return ppInputToLex(buf, max_size); }
const V3ParseBisonYYSType curBisonVal() const { return m_curBisonVal; } V3ParseBisonYYSType curBisonVal() const { return m_curBisonVal; }
const V3ParseBisonYYSType prevBisonVal() const { return m_prevBisonVal; } V3ParseBisonYYSType prevBisonVal() const { return m_prevBisonVal; }
//==== Symbol tables //==== Symbol tables
V3ParseSym* symp() { return m_symp; } V3ParseSym* symp() { return m_symp; }

View File

@ -129,7 +129,7 @@ public:
UINFO(1, "ParseSym Current: " << symCurrentp()->nodep() << endl); UINFO(1, "ParseSym Current: " << symCurrentp()->nodep() << endl);
} }
void dump(std::ostream& os, const string& indent = "") { m_syms.dump(os, indent); } void dump(std::ostream& os, const string& indent = "") { m_syms.dump(os, indent); }
AstNode* findEntUpward(const string& name) { AstNode* findEntUpward(const string& name) const {
// Lookup the given string as an identifier, return type of the id, scanning upward // Lookup the given string as an identifier, return type of the id, scanning upward
VSymEnt* foundp = symCurrentp()->findIdFallback(name); VSymEnt* foundp = symCurrentp()->findIdFallback(name);
if (foundp) { if (foundp) {

View File

@ -18,8 +18,8 @@
// It is not intended for user applications. // It is not intended for user applications.
//************************************************************************* //*************************************************************************
#ifndef _VPREPROCLEX_H_ // Guard #ifndef _VPRELEX_H_ // Guard
#define _VPREPROCLEX_H_ 1 #define _VPRELEX_H_ 1
#include "V3Error.h" #include "V3Error.h"
#include "V3FileLine.h" #include "V3FileLine.h"

View File

@ -286,9 +286,9 @@ public:
m_finFilelinep->lineno(1); m_finFilelinep->lineno(1);
// Create lexer // Create lexer
m_lexp = new V3PreLex(this, filelinep); m_lexp = new V3PreLex(this, filelinep);
m_lexp->m_keepComments = m_preprocp->keepComments(); m_lexp->m_keepComments = keepComments();
m_lexp->m_keepWhitespace = m_preprocp->keepWhitespace(); m_lexp->m_keepWhitespace = keepWhitespace();
m_lexp->m_pedantic = m_preprocp->pedantic(); m_lexp->m_pedantic = pedantic();
m_lexp->debug(debug() >= 5 ? debug() : 0); // See also V3PreProc::debug() method m_lexp->debug(debug() >= 5 ? debug() : 0); // See also V3PreProc::debug() method
} }
~V3PreProcImp() { ~V3PreProcImp() {
@ -1527,7 +1527,7 @@ int V3PreProcImp::getFinalToken(string& buf) {
} }
int tok = m_finToken; int tok = m_finToken;
buf = m_finBuf; buf = m_finBuf;
if (0 && debug() >= 5) { if (false && debug() >= 5) {
string bufcln = V3PreLex::cleanDbgStrg(buf); string bufcln = V3PreLex::cleanDbgStrg(buf);
string flcol = m_lexp->m_tokFilelinep->asciiLineCol(); 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),

View File

@ -350,7 +350,7 @@ private:
} }
} }
AstNode* varOrScope(AstVarRef* nodep) { AstNode* varOrScope(AstVarRef* nodep) const {
AstNode* vscp; AstNode* vscp;
if (m_scoped) { if (m_scoped) {
vscp = nodep->varScopep(); vscp = nodep->varScopep();

View File

@ -36,29 +36,29 @@ public:
~VDouble0() {} ~VDouble0() {}
// Implicit conversion operators: // Implicit conversion operators:
inline explicit VDouble0(const vluint64_t v) explicit VDouble0(const vluint64_t v)
: m_d(v) {} : m_d(v) {}
inline operator double() const { return m_d; } operator double() const { return m_d; }
// Explicit operators: // Explicit operators:
inline VDouble0& operator++() { // prefix VDouble0& operator++() { // prefix
++m_d; ++m_d;
return *this; return *this;
} }
inline VDouble0 operator++(int) { // postfix VDouble0 operator++(int) { // postfix
VDouble0 old = *this; VDouble0 old = *this;
m_d++; m_d++;
return old; return old;
} }
inline VDouble0& operator=(const double v) { VDouble0& operator=(const double v) {
m_d = v; m_d = v;
return *this; return *this;
} }
inline VDouble0& operator+=(const double v) { VDouble0& operator+=(const double v) {
m_d += v; m_d += v;
return *this; return *this;
} }
inline VDouble0& operator-=(const double v) { VDouble0& operator-=(const double v) {
m_d -= v; m_d -= v;
return *this; return *this;
} }

View File

@ -14,8 +14,8 @@
// //
//************************************************************************* //*************************************************************************
#ifndef _V3LINKSYMTABLE_H_ #ifndef _V3SYMTABLE_H_
#define _V3LINKSYMTABLE_H_ 1 #define _V3SYMTABLE_H_ 1
#include "config_build.h" #include "config_build.h"
#include "verilatedos.h" #include "verilatedos.h"
@ -189,7 +189,7 @@ private:
reinsert(name, symp); reinsert(name, symp);
} }
} }
void exportOneSymbol(VSymGraph* graphp, const string& name, const VSymEnt* srcp) { void exportOneSymbol(VSymGraph* graphp, const string& name, const VSymEnt* srcp) const {
if (srcp->exported()) { if (srcp->exported()) {
if (VSymEnt* symp = findIdFlat(name)) { // Should already exist in current table if (VSymEnt* symp = findIdFlat(name)) { // Should already exist in current table
if (!symp->exported()) symp->exported(true); if (!symp->exported()) symp->exported(true);
@ -283,7 +283,6 @@ public:
for (SymStack::iterator it = m_symsp.begin(); it != m_symsp.end(); ++it) delete (*it); for (SymStack::iterator it = m_symsp.begin(); it != m_symsp.end(); ++it) delete (*it);
} }
public:
// METHODS // METHODS
VSymEnt* rootp() const { return m_symRootp; } VSymEnt* rootp() const { return m_symRootp; }
// Debug // Debug

View File

@ -375,7 +375,8 @@ private:
// Sort the traces by activity sets // Sort the traces by activity sets
TraceVec traces; TraceVec traces;
uint32_t unused1, unused2; uint32_t unused1;
uint32_t unused2;
sortTraces(traces, unused1, unused2); sortTraces(traces, unused1, unused2);
// For each activity set with only a small number of signals, make those // For each activity set with only a small number of signals, make those

View File

@ -32,7 +32,6 @@ private:
vluint64_t m_dataSize; ///< Current entries in m_datap vluint64_t m_dataSize; ///< Current entries in m_datap
vluint64_t m_bucketsCovered; ///< Num buckets with sufficient coverage vluint64_t m_bucketsCovered; ///< Num buckets with sufficient coverage
private:
static inline vluint64_t covBit(vluint64_t point) { return 1ULL << (point & 63); } static inline vluint64_t covBit(vluint64_t point) { return 1ULL << (point & 63); }
inline vluint64_t allocSize() const { return sizeof(vluint64_t) * m_dataSize / 64; } inline vluint64_t allocSize() const { return sizeof(vluint64_t) * m_dataSize / 64; }
void allocate(vluint64_t point) { void allocate(vluint64_t point) {

View File

@ -108,7 +108,6 @@ public:
ByName::iterator begin() { return m_nameMap.begin(); } ByName::iterator begin() { return m_nameMap.begin(); }
ByName::iterator end() { return m_nameMap.end(); } ByName::iterator end() { return m_nameMap.end(); }
public:
// CONSTRUCTORS // CONSTRUCTORS
VlcPoints() VlcPoints()
: m_numPoints(0) {} : m_numPoints(0) {}

View File

@ -118,7 +118,6 @@ public:
NameMap::iterator begin() { return m_sources.begin(); } NameMap::iterator begin() { return m_sources.begin(); }
NameMap::iterator end() { return m_sources.end(); } NameMap::iterator end() { return m_sources.end(); }
public:
// CONSTRUCTORS // CONSTRUCTORS
VlcSources() {} VlcSources() {}
~VlcSources() {} ~VlcSources() {}

View File

@ -103,7 +103,6 @@ public:
ByName::iterator begin() { return m_tests.begin(); } ByName::iterator begin() { return m_tests.begin(); }
ByName::iterator end() { return m_tests.end(); } ByName::iterator end() { return m_tests.end(); }
public:
// CONSTRUCTORS // CONSTRUCTORS
VlcTests() {} VlcTests() {}
~VlcTests() { ~VlcTests() {