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.
// 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"
Vtop* top = new Vtop;

View File

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

View File

@ -20,7 +20,7 @@ vluint64_t main_time = 0;
double sc_time_stamp() { return main_time; }
int main(int argc, char** argv, char** env) {
if (0 && argc && argv && env) {}
if (false && argc && argv && env) {}
Verilated::debug(0);
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.
// 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
// 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.
// Prevent unused variable warnings
if (0 && argc && argv) {}
if (false && argc && argv) {}
// Set debug level, 0 is off, 9 is highest presently used
// 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
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
"- %s:%d: Verilog $finish\n", filename, linenum);
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
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);
if (filename && filename[0]) {
// 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 whole = static_cast<QData>(scaled) / fracDiv;
QData fraction = static_cast<QData>(scaled) % fracDiv;
int digits;
int digits = 0;
if (!fracDigits) {
digits = sprintf(tmp, "%" VL_PRI64 "u%s", whole, suffix.c_str());
} 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);
double d = va_arg(ap, double);
if (lbits) {} // UNUSED - always 64
switch (fmt) {
case '^': { // Realtime
if (fmt == '^') { // Realtime
if (!widthSet) width = VerilatedImp::timeFormatWidth();
output += _vl_vsformat_time(tmp, d, left, width);
break;
}
default: {
} else {
std::string fmt(pctp, pos - pctp + 1);
sprintf(tmp, fmt.c_str(), d);
output += tmp;
break;
} //
break;
} // switch
}
break;
}
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);
QData ld = 0;
WData qlwp[VL_WQ_WORDS_E];
WDataInP lwp;
WDataInP lwp = NULL;
if (lbits <= VL_QUADSIZE) {
ld = _VL_VA_ARG_Q(ap, lbits);
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) {
case 'c': {
IData charval = ld & 0xff;
output += charval;
output += static_cast<char>(charval);
break;
}
case 's': {
@ -784,7 +778,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
break;
}
case 'd': { // Signed decimal
int digits;
int digits = 0;
std::string append;
if (lbits <= VL_QUADSIZE) {
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;
}
case '#': { // Unsigned decimal
int digits;
int digits = 0;
std::string append;
if (lbits <= VL_QUADSIZE) {
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,
// so we need to grab each bit separately and check for overrun
// Octal is rare, so we'll do it a slow simple way
output += ('0' + ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 0)) ? 1 : 0)
+ ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 1)) ? 2 : 0)
+ ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 2)) ? 4 : 0));
output += static_cast<char>(
'0' + ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 0)) ? 1 : 0)
+ ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 1)) ? 2 : 0)
+ ((VL_BITISSETLIMIT_W(lwp, lbits, lsb + 2)) ? 4 : 0));
}
break;
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);
for (int byte = 0; byte < wr_bytes; byte++, bit += 8)
output += static_cast<char>(VL_BITRSHIFT_W(lwp, bit) & 0xff);
output.append(4 - wr_bytes, (char)0);
if (is_4_state) output.append(4, (char)0);
output.append(4 - wr_bytes, static_cast<char>(0));
if (is_4_state) output.append(4, static_cast<char>(0));
bytes_to_go -= wr_bytes;
}
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 {
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 {
return floc < 0;
}
@ -1076,7 +1071,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
_vl_vsss_skipspace(fp, floc, fromp, fstr);
_vl_vsss_read_str(fp, floc, fromp, fstr, tmp, "0123456789+-xXzZ?_");
if (!tmp[0]) goto done;
vlsint64_t ld;
vlsint64_t ld = 0;
sscanf(tmp, "%30" VL_PRI64 "d", &ld);
VL_SET_WQ(owp, ld);
break;
@ -1101,7 +1096,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
_vl_vsss_skipspace(fp, floc, fromp, fstr);
_vl_vsss_read_str(fp, floc, fromp, fstr, tmp, "0123456789+-xXzZ?_");
if (!tmp[0]) goto done;
QData ld;
QData ld = 0;
sscanf(tmp, "%30" VL_PRI64 "u", &ld);
VL_SET_WQ(owp, ld);
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);
char* op = reinterpret_cast<char*>(destp);
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 < 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);
switch (tolower(fmt)) {
case 'd':
vlsint64_t lld;
case 'd': {
vlsint64_t lld = 0;
sscanf(dp, "%30" VL_PRI64 "d", &lld);
VL_SET_WQ(rwp, lld);
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 'h': // FALLTHRU
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;
--posp) {
_vl_vsss_setbit(rwp, rbits, lsb, 8, dp[posp]);
lsb += 8;
}
break;
}
case 'e': {
double temp = 0.f;
double temp = 0.F;
sscanf(dp, "%le", &temp);
VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
break;
}
case 'f': {
double temp = 0.f;
double temp = 0.F;
sscanf(dp, "%lf", &temp);
VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
break;
}
case 'g': {
double temp = 0.f;
double temp = 0.F;
sscanf(dp, "%lg", &temp);
VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
break;
@ -1799,7 +1796,7 @@ bool VlReadMem::get(QData& addrr, std::string& valuer) {
m_addr = (m_addr << 4) + value;
} else {
indata = true;
valuer += c;
valuer += static_cast<char>(c);
// printf(" Value width=%d @%x = %c\n", width, m_addr, c);
if (VL_UNLIKELY(value > 1 && !m_hex)) {
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);
if (VL_UNLIKELY(!rmem.isOpen())) return;
while (true) {
QData addr;
QData addr = 0;
std::string value;
if (rmem.get(addr /*ref*/, value /*ref*/)) {
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,
const char* identifier, vlsint8_t timeunit,
const Type type) VL_MT_UNSAFE {
const Type& type) VL_MT_UNSAFE {
// Slowpath - called once/scope at construction
// We don't want the space and reference-count access overhead of strings.
m_symsp = symsp;

View File

@ -337,7 +337,7 @@ public: // But internals only - called from VerilatedModule's
VerilatedScope();
~VerilatedScope();
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 varInsert(int finalize, const char* namep, void* datap, VerilatedVarType vltype,
int vlflags, int dims, ...) VL_MT_UNSAFE;
@ -365,7 +365,7 @@ public: // But internals only - called from VerilatedModule's
class VerilatedHierarchy {
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 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 4: ret = ((ret >> 16) | (ret << 16));
case 4: ret = ((ret >> 16) | (ret << 16)); // FALLTHRU
default:;
}
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:
ret = (((ret >> 16) & 0x0000ffff0000ffffULL)
| ((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);
}

View File

@ -94,7 +94,6 @@ private:
typedef std::map<int, std::string> IndexValueMap;
typedef std::deque<VerilatedCovImpItem*> ItemList;
private:
// MEMBERS
VerilatedMutex m_mutex; ///< Protects all members
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
= m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL)));
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::string symbol_name(tokens.back());
tokens.pop_back(); // Remove symbol name from hierarchy

View File

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

View File

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

View File

@ -376,8 +376,8 @@ struct VerilatedVpiTimedCbsCmp {
/// Ordering sets keyed by time, then callback descriptor
bool operator()(const std::pair<QData, VerilatedVpioCb*>& a,
const std::pair<QData, VerilatedVpioCb*>& b) const {
if (a.first < b.first) return 1;
if (a.first > b.first) return 0;
if (a.first < b.first) return true;
if (a.first > b.first) return false;
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) \
if (strcmp((got), (exp))) { \
if (0 != strcmp((got), (exp))) { \
std::string msg \
= std::string("%Error: ") + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \
@ -2079,10 +2079,12 @@ PLI_INT32 vpi_control(PLI_INT32 operation, ...) {
VL_STOP_MT("", 0, "*VPI*");
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*/,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -335,7 +335,7 @@ public:
// UINFO(9, " Hit " << *m_lastIt << endl);
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) {
UINFO(9, " NXT " << *it << endl);
}

View File

@ -43,7 +43,7 @@ public:
static void applyModule(AstNodeModule* modulep);
static void applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp);
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

View File

@ -127,7 +127,7 @@ class EmitCSyms : EmitCBaseVisitor {
&& !(VN_IS(nodep, CFunc)
&& (VN_CAST(nodep, CFunc)->isConstructor()
|| VN_CAST(nodep, CFunc)->isDestructor()))) {
string rsvd = m_words.isKeyword(nodep->name());
string rsvd = V3LanguageWords::isKeyword(nodep->name());
if (rsvd != "") {
// Generally V3Name should find all of these and throw SYMRSVDWORD.
// 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); }
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());
puts("<" + tag + " " + nodep->fileline()->xml());
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 (nodep->op1p() || nodep->op2p() || nodep->op3p() || nodep->op4p()) {
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.
static char str[MAXSPACE + 20];
char* cp = str;

View File

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

View File

@ -36,7 +36,7 @@
//######################################################################
// 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
char out[size];
char* op = out + size - 1;
@ -165,7 +165,7 @@ void FileLine::newContent() {
m_contentLineno = 1;
}
const string FileLine::xmlDetailedLocation() const {
string FileLine::xmlDetailedLocation() const {
return "loc=\"" + cvtToStr(filenameLetters()) + "," + cvtToStr(firstLineno()) + ","
+ cvtToStr(firstColumn()) + "," + cvtToStr(lastLineno()) + "," + cvtToStr(lastColumn())
+ "\"";
@ -259,27 +259,27 @@ FileLine* FileLine::copyOrSameFileLine() {
return newp;
}
const string FileLine::filebasename() const {
string FileLine::filebasename() const {
string name = filename();
string::size_type pos;
if ((pos = name.rfind('/')) != string::npos) name.erase(0, pos + 1);
return name;
}
const string FileLine::filebasenameNoExt() const {
string FileLine::filebasenameNoExt() const {
string name = filebasename();
string::size_type pos;
if ((pos = name.find('.')) != string::npos) name = name.substr(0, pos);
return name;
}
const string FileLine::firstColumnLetters() const {
string FileLine::firstColumnLetters() const {
char a = ((firstColumn() / 26) % 26) + 'a';
char b = (firstColumn() % 26) + 'a';
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
string name = filebasenameNoExt();
string::size_type pos;

View File

@ -14,8 +14,8 @@
//
//*************************************************************************
#ifndef _V3FileLine_H_
#define _V3FileLine_H_ 1
#ifndef _V3FILELINE_H_
#define _V3FILELINE_H_ 1
#include "config_build.h"
#include "verilatedos.h"
@ -51,8 +51,8 @@ class FileLineSingleton {
protected:
friend class FileLine;
int nameToNumber(const string& filename);
const string numberToName(int filenameno) const { return m_names[filenameno]; }
const V3LangCode numberToLang(int filenameno) const { return m_languages[filenameno]; }
string numberToName(int filenameno) const { return m_names[filenameno]; }
V3LangCode numberToLang(int filenameno) const { return m_languages[filenameno]; }
void numberToLang(int filenameno, const V3LangCode& l) { m_languages[filenameno] = l; }
void clear() {
m_namemap.clear();
@ -60,7 +60,7 @@ protected:
m_languages.clear();
}
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
@ -193,19 +193,17 @@ public:
string ascii() const;
string asciiLineCol() const;
int filenameno() const { return m_filenameno; }
const string filename() const { return singleton().numberToName(filenameno()); }
string filename() const { return singleton().numberToName(filenameno()); }
bool filenameIsGlobal() const {
return (filename() == commandLineFilename() || filename() == builtInFilename());
}
const string filenameLetters() const { return singleton().filenameLetters(filenameno()); }
const string filebasename() const;
const string filebasenameNoExt() const;
const string firstColumnLetters() const;
const string profileFuncname() const;
const string xml() const {
return "fl=\"" + filenameLetters() + cvtToStr(lastLineno()) + "\"";
}
const string xmlDetailedLocation() const;
string filenameLetters() const { return FileLineSingleton::filenameLetters(filenameno()); }
string filebasename() const;
string filebasenameNoExt() const;
string firstColumnLetters() const;
string profileFuncname() const;
string xml() const { return "fl=\"" + filenameLetters() + cvtToStr(lastLineno()) + "\""; }
string xmlDetailedLocation() const;
string lineDirectiveStrg(int enterExit) const;
// Turn on/off warning messages on this line.

View File

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

View File

@ -79,9 +79,9 @@ public:
struct GraphAcycEdgeCmp {
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 0; // RHS goes first
return 0;
if (lhsp->weight() > rhsp->weight()) return true; // LHS goes first
if (lhsp->weight() < rhsp->weight()) return false; // RHS goes first
return false;
}
};

View File

@ -193,7 +193,7 @@ private:
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
// the nfa states a given dfa state was constructed from.
nextStep();

View File

@ -158,7 +158,7 @@ void V3Hashed::dumpFile(const string& filename, bool tree) {
V3Hash lasthash;
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 (num_in_bucket) {

View File

@ -54,7 +54,7 @@ private:
nodep->editCountInc();
} else if (VN_IS(nodep, CFunc) && VN_CAST(nodep, CFunc)->isConstructor()) {
} else {
string rsvd = m_words.isKeyword(nodep->name());
string rsvd = V3LanguageWords::isKeyword(nodep->name());
if (rsvd != "") {
nodep->v3warn(SYMRSVDWORD,
"Symbol matches " + rsvd + ": " << nodep->prettyNameQ());

View File

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

View File

@ -97,27 +97,43 @@ public:
VTimescale(const string& value, bool& badr);
VTimescale(double value, bool& badr) {
badr = false;
// clang-format off
if (value == 10e2) m_e = TS_100S;
else if (value == 1e1) m_e = TS_10S;
else if (value == 1e0) m_e = TS_1S;
else if (value == 1e-1) m_e = TS_100MS;
else if (value == 1e-2) m_e = TS_10MS;
else if (value == 1e-3) m_e = TS_1MS;
else if (value == 1e-4) m_e = TS_100US;
else if (value == 1e-5) m_e = TS_10US;
else if (value == 1e-6) m_e = TS_1US;
else if (value == 1e-7) m_e = TS_100NS;
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;
// clang-format on
else {
if (value == 10e2) {
m_e = TS_100S;
} else if (value == 1e1) {
m_e = TS_10S;
} else if (value == 1e0) {
m_e = TS_1S;
} else if (value == 1e-1) {
m_e = TS_100MS;
} else if (value == 1e-2) {
m_e = TS_10MS;
} else if (value == 1e-3) {
m_e = TS_1MS;
} else if (value == 1e-4) {
m_e = TS_100US;
} else if (value == 1e-5) {
m_e = TS_10US;
} else if (value == 1e-6) {
m_e = TS_1US;
} else if (value == 1e-7) {
m_e = TS_100NS;
} 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;
badr = true;
}
@ -132,7 +148,7 @@ public:
"10ns", "1ns", "100ps", "10ps", "1ps", "100fs", "10fs", "1fs", "NONE"};
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 {
static const double values[]
= {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) {
// Propagate PrimaryIn through simple assignments
if (vertexp->user()) return; // Already processed
if (0 && debug() >= 9) {
if (false && debug() >= 9) {
UINFO(9, " InIIter " << vertexp << endl);
if (OrderLogicVertex* vvertexp = dynamic_cast<OrderLogicVertex*>(vertexp)) {
vvertexp->nodep()->dumpTree(cout, "- TT: ");
@ -2011,7 +2011,7 @@ void OrderVisitor::process() {
// Dump data
m_graph.dumpDotFilePrefixed("orderg_done");
if (0 && debug()) {
if (false && debug()) {
string dfilename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_INT_order";
const vl_unique_ptr<std::ofstream> logp(V3File::new_ofstream(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
// Can't make this static as might get more defines later when read cells
VSpellCheck speller;
V3LanguageWords words;
for (V3LanguageWords::const_iterator it = words.begin(); it != words.end(); ++it) {
for (V3LanguageWords::const_iterator it = V3LanguageWords::begin();
it != V3LanguageWords::end(); ++it) {
string ppDirective = it->first;
if (ppDirective[0] == '`') speller.pushCandidate(ppDirective);
}

View File

@ -228,10 +228,10 @@ public:
void lexNew();
void lexDestroy();
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); }
const V3ParseBisonYYSType curBisonVal() const { return m_curBisonVal; }
const V3ParseBisonYYSType prevBisonVal() const { return m_prevBisonVal; }
V3ParseBisonYYSType curBisonVal() const { return m_curBisonVal; }
V3ParseBisonYYSType prevBisonVal() const { return m_prevBisonVal; }
//==== Symbol tables
V3ParseSym* symp() { return m_symp; }

View File

@ -129,7 +129,7 @@ public:
UINFO(1, "ParseSym Current: " << symCurrentp()->nodep() << endl);
}
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
VSymEnt* foundp = symCurrentp()->findIdFallback(name);
if (foundp) {

View File

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

View File

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

View File

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

View File

@ -14,8 +14,8 @@
//
//*************************************************************************
#ifndef _V3LINKSYMTABLE_H_
#define _V3LINKSYMTABLE_H_ 1
#ifndef _V3SYMTABLE_H_
#define _V3SYMTABLE_H_ 1
#include "config_build.h"
#include "verilatedos.h"
@ -189,7 +189,7 @@ private:
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 (VSymEnt* symp = findIdFlat(name)) { // Should already exist in current table
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);
}
public:
// METHODS
VSymEnt* rootp() const { return m_symRootp; }
// Debug

View File

@ -375,7 +375,8 @@ private:
// Sort the traces by activity sets
TraceVec traces;
uint32_t unused1, unused2;
uint32_t unused1;
uint32_t unused2;
sortTraces(traces, unused1, unused2);
// 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_bucketsCovered; ///< Num buckets with sufficient coverage
private:
static inline vluint64_t covBit(vluint64_t point) { return 1ULL << (point & 63); }
inline vluint64_t allocSize() const { return sizeof(vluint64_t) * m_dataSize / 64; }
void allocate(vluint64_t point) {

View File

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

View File

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

View File

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