clang-tidy cleanups. No functional change intended.

This commit is contained in:
Wilson Snyder 2020-08-16 14:55:46 -04:00
parent d75a8624c1
commit 6013b54f7b
40 changed files with 100 additions and 90 deletions

View File

@ -438,7 +438,7 @@ CPPCHECK_INC = -I$(srcdir)/include -I$(srcdir)/src/obj_dbg -I$(srcdir)/src
cppcheck: $(CPPCHECK_DEP) cppcheck: $(CPPCHECK_DEP)
%.cppcheck: %.cpp %.cppcheck: %.cpp
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 $(CPPCHECK_INC) $< $(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -DVL_CPPCHECK=1 -DVL_THREADED=1 $(CPPCHECK_INC) $<
CLANGTIDY = clang-tidy CLANGTIDY = clang-tidy
CLANGTIDY_FLAGS = -config='' CLANGTIDY_FLAGS = -config=''

View File

@ -40,7 +40,8 @@
#endif #endif
// clang-format on // clang-format on
#define VL_VALUE_STRING_MAX_WIDTH 8192 ///< Max static char array for VL_VALUE_STRING /// Max static char array for VL_VALUE_STRING
constexpr unsigned VL_VALUE_STRING_MAX_WIDTH = 8192;
//=========================================================================== //===========================================================================
// Static sanity checks (when get C++11 can use static_assert) // Static sanity checks (when get C++11 can use static_assert)
@ -764,8 +765,8 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
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);
} else { } else {
std::string fmt(pctp, pos - pctp + 1); std::string fmts(pctp, pos - pctp + 1);
sprintf(tmp, fmt.c_str(), d); sprintf(tmp, fmts.c_str(), d);
output += tmp; output += tmp;
} }
break; break;
@ -1699,7 +1700,7 @@ IData VL_ATOI_N(const std::string& str, int base) VL_PURE {
str_mod.erase(std::remove(str_mod.begin(), str_mod.end(), '_'), str_mod.end()); str_mod.erase(std::remove(str_mod.begin(), str_mod.end(), '_'), str_mod.end());
errno = 0; errno = 0;
long v = std::strtol(str_mod.c_str(), nullptr, base); auto v = std::strtol(str_mod.c_str(), nullptr, base);
if (errno != 0) v = 0; if (errno != 0) v = 0;
return static_cast<IData>(v); return static_cast<IData>(v);
} }

View File

@ -51,13 +51,14 @@
// This size comes form VCD allowing use of printable ASCII characters between // This size comes form VCD allowing use of printable ASCII characters between
// '!' and '~' inclusive, which are a total of 94 different values. Encoding a // '!' and '~' inclusive, which are a total of 94 different values. Encoding a
// 32 bit code hence needs a maximum of ceil(log94(2**32-1)) == 5 bytes. // 32 bit code hence needs a maximum of ceil(log94(2**32-1)) == 5 bytes.
#define VL_TRACE_MAX_VCD_CODE_SIZE 5 ///< Maximum length of a VCD string code constexpr unsigned VL_TRACE_MAX_VCD_CODE_SIZE = 5; ///< Maximum length of a VCD string code
// We use 8 bytes per code in a suffix buffer array. // We use 8 bytes per code in a suffix buffer array.
// 1 byte optional separator + VL_TRACE_MAX_VCD_CODE_SIZE bytes for code // 1 byte optional separator + VL_TRACE_MAX_VCD_CODE_SIZE bytes for code
// + 1 byte '\n' + 1 byte suffix size. This luckily comes out to a power of 2, // + 1 byte '\n' + 1 byte suffix size. This luckily comes out to a power of 2,
// meaning the array can be aligned such that entries never straddle multiple // meaning the array can be aligned such that entries never straddle multiple
// cache-lines. // cache-lines.
#define VL_TRACE_SUFFIX_ENTRY_SIZE 8 ///< Size of a suffix entry constexpr unsigned VL_TRACE_SUFFIX_ENTRY_SIZE = 8; ///< Size of a suffix entry
//============================================================================= //=============================================================================
// Specialization of the generics for this trace format // Specialization of the generics for this trace format

View File

@ -100,7 +100,7 @@ private:
void dumpHeader(); void dumpHeader();
char* writeCode(char* writep, vluint32_t code); static char* writeCode(char* writep, vluint32_t code);
void finishLine(vluint32_t code, char* writep); void finishLine(vluint32_t code, char* writep);

View File

@ -35,7 +35,7 @@
// Internal constants // Internal constants
#define VL_DEBUG_IF_PLI VL_DEBUG_IF #define VL_DEBUG_IF_PLI VL_DEBUG_IF
#define VL_VPI_LINE_SIZE 8192 constexpr unsigned VL_VPI_LINE_SIZE = 8192;
//====================================================================== //======================================================================
// Internal macros // Internal macros
@ -246,7 +246,7 @@ public:
vluint32_t mask() const { return m_mask.u32; } vluint32_t mask() const { return m_mask.u32; }
vluint8_t mask_byte(int idx) { return m_mask.u8[idx & 3]; } vluint8_t mask_byte(int idx) { return m_mask.u8[idx & 3]; }
vluint32_t entSize() const { return m_entSize; } vluint32_t entSize() const { return m_entSize; }
vluint32_t index() { return m_index; } vluint32_t index() const { return m_index; }
virtual vluint32_t type() const override { virtual vluint32_t type() const override {
return (varp()->dims() > 1) ? vpiMemory : vpiReg; // but might be wire, logic return (varp()->dims() > 1) ? vpiMemory : vpiReg; // but might be wire, logic
} }
@ -1606,7 +1606,6 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep,
} }
_VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) as requested for %s", VL_FUNC, _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) as requested for %s", VL_FUNC,
VerilatedVpiError::strFromVpiVal(valuep->format), fullname); VerilatedVpiError::strFromVpiVal(valuep->format), fullname);
return;
} }
void vpi_get_value(vpiHandle object, p_vpi_value valuep) { void vpi_get_value(vpiHandle object, p_vpi_value valuep) {
@ -1708,7 +1707,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_
for (int i = 0; i < chars; ++i) { for (int i = 0; i < chars; ++i) {
union { union {
char byte[2]; char byte[2];
short half; vluint16_t half;
} val; } val;
idx = div(i * 3, 8); idx = div(i * 3, 8);
if (i < len) { if (i < len) {

View File

@ -129,7 +129,6 @@ public:
return activep; return activep;
} }
public:
// CONSTRUCTORS // CONSTRUCTORS
ActiveNamer() {} ActiveNamer() {}
virtual ~ActiveNamer() override {} virtual ~ActiveNamer() override {}

View File

@ -315,7 +315,7 @@ public:
bool m_isRef; // Is it a reference? bool m_isRef; // Is it a reference?
string m_type; // The base type, e.g.: "Foo_t"s string m_type; // The base type, e.g.: "Foo_t"s
string m_dims; // Array dimensions, e.g.: "[3][2][1]" string m_dims; // Array dimensions, e.g.: "[3][2][1]"
string render(const string& name) { string render(const string& name) const {
string out; string out;
out += m_type; out += m_type;
out += " "; out += " ";
@ -462,7 +462,7 @@ string AstVar::vlEnumDir() const {
return out; return out;
} }
string AstVar::vlPropDecl(string propName) const { string AstVar::vlPropDecl(const string& propName) const {
string out; string out;
std::vector<int> ulims; // Unpacked dimension limits std::vector<int> ulims; // Unpacked dimension limits
@ -902,8 +902,9 @@ AstBasicDType* AstTypeTable::findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kw
return newp; return newp;
} }
AstBasicDType* AstTypeTable::findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, VNumRange range, AstBasicDType* AstTypeTable::findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd,
int widthMin, VSigning numeric) { const VNumRange& range, int widthMin,
VSigning numeric) {
AstBasicDType* new1p = new AstBasicDType(fl, kwd, numeric, range, widthMin); AstBasicDType* new1p = new AstBasicDType(fl, kwd, numeric, range, widthMin);
AstBasicDType* newp = findInsertSameDType(new1p); AstBasicDType* newp = findInsertSameDType(new1p);
if (newp != new1p) { if (newp != new1p) {

View File

@ -2010,7 +2010,7 @@ public:
string vlArgType(bool named, bool forReturn, bool forFunc, const string& namespc = "") const; string vlArgType(bool named, bool forReturn, bool forFunc, const string& namespc = "") const;
string vlEnumType() const; // Return VerilatorVarType: VLVT_UINT32, etc string vlEnumType() const; // Return VerilatorVarType: VLVT_UINT32, etc
string vlEnumDir() const; // Return VerilatorVarDir: VLVD_INOUT, etc string vlEnumDir() const; // Return VerilatorVarDir: VLVD_INOUT, etc
string vlPropDecl(string propName) const; // Return VerilatorVarProps declaration string vlPropDecl(const string& propName) const; // Return VerilatorVarProps declaration
void combineType(AstVarType type); void combineType(AstVarType type);
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
// op1 = Range of variable // op1 = Range of variable
@ -8840,7 +8840,7 @@ public:
AstBasicDType* findBasicDType(FileLine* fl, AstBasicDTypeKwd kwd); AstBasicDType* findBasicDType(FileLine* fl, AstBasicDTypeKwd kwd);
AstBasicDType* findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, int width, int widthMin, AstBasicDType* findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, int width, int widthMin,
VSigning numeric); VSigning numeric);
AstBasicDType* findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, VNumRange range, AstBasicDType* findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, const VNumRange& range,
int widthMin, VSigning numeric); int widthMin, VSigning numeric);
AstBasicDType* findInsertSameDType(AstBasicDType* nodep); AstBasicDType* findInsertSameDType(AstBasicDType* nodep);
void clearCache(); void clearCache();

View File

@ -49,6 +49,7 @@ private:
enum { FLAG_LINKABLE = 0x04 }; // Is in netlist tree, can be linked to enum { FLAG_LINKABLE = 0x04 }; // Is in netlist tree, can be linked to
enum { FLAG_LEAKED = 0x08 }; // Known to have been leaked enum { FLAG_LEAKED = 0x08 }; // Known to have been leaked
enum { FLAG_UNDER_NOW = 0x10 }; // Is in tree as parent of current node enum { FLAG_UNDER_NOW = 0x10 }; // Is in tree as parent of current node
public: public:
// METHODS // METHODS
static void deleted(const AstNode* nodep) { static void deleted(const AstNode* nodep) {
@ -188,7 +189,6 @@ public:
} }
} }
public:
// CONSTRUCTORS // CONSTRUCTORS
BrokenTable() {} BrokenTable() {}
virtual ~BrokenTable() override {} virtual ~BrokenTable() override {}
@ -239,7 +239,7 @@ public:
class BrokenCheckVisitor : public AstNVisitor { class BrokenCheckVisitor : public AstNVisitor {
private: private:
void checkWidthMin(const AstNode* nodep) { static void checkWidthMin(const AstNode* nodep) {
UASSERT_OBJ(nodep->width() == nodep->widthMin() UASSERT_OBJ(nodep->width() == nodep->widthMin()
|| v3Global.widthMinUsage() != VWidthMinUsage::MATCHES_WIDTH, || v3Global.widthMinUsage() != VWidthMinUsage::MATCHES_WIDTH,
nodep, "Width != WidthMin"); nodep, "Width != WidthMin");

View File

@ -196,7 +196,7 @@ public:
explicit CdcWidthVisitor(AstNode* nodep) { iterate(nodep); } explicit CdcWidthVisitor(AstNode* nodep) { iterate(nodep); }
virtual ~CdcWidthVisitor() override {} virtual ~CdcWidthVisitor() override {}
// ACCESSORS // ACCESSORS
int maxWidth() { int maxWidth() const {
size_t width = 1; size_t width = 1;
width += m_maxFilenameLen; width += m_maxFilenameLen;
width += 1; // The : width += 1; // The :

View File

@ -135,10 +135,10 @@ private:
m_statep->m_numStmts += visitor.count(); m_statep->m_numStmts += visitor.count();
} }
virtual void visit(AstBasicDType* nodep) override { // virtual void visit(AstBasicDType*) override { //
newChangeDet(); newChangeDet();
} }
virtual void visit(AstPackArrayDType* nodep) override { // virtual void visit(AstPackArrayDType*) override { //
newChangeDet(); newChangeDet();
} }
virtual void visit(AstUnpackArrayDType* nodep) override { virtual void visit(AstUnpackArrayDType* nodep) override {

View File

@ -138,7 +138,7 @@ public:
void setNoInline(bool set) { m_noinline = set; } void setNoInline(bool set) { m_noinline = set; }
void setPublic(bool set) { m_public = set; } void setPublic(bool set) { m_public = set; }
void apply(AstNodeFTask* ftaskp) { void apply(AstNodeFTask* ftaskp) const {
if (m_noinline) if (m_noinline)
ftaskp->addStmtsp(new AstPragma(ftaskp->fileline(), AstPragmaType::NO_INLINE_TASK)); ftaskp->addStmtsp(new AstPragma(ftaskp->fileline(), AstPragmaType::NO_INLINE_TASK));
if (m_public) if (m_public)

View File

@ -65,7 +65,7 @@ private:
int m_handle = 0; // Opaque handle for index into line tracking int m_handle = 0; // Opaque handle for index into line tracking
const AstNode* m_nodep = nullptr; // Node establishing this state const AstNode* m_nodep = nullptr; // Node establishing this state
CheckState() {} CheckState() {}
bool lineCoverageOn(const AstNode* nodep) { bool lineCoverageOn(const AstNode* nodep) const {
return m_on && !m_inModOff && nodep->fileline()->coverageOn() return m_on && !m_inModOff && nodep->fileline()->coverageOn()
&& v3Global.opt.coverageLine(); && v3Global.opt.coverageLine();
} }

View File

@ -63,7 +63,7 @@ public:
int splitSize() const { return m_splitSize; } int splitSize() const { return m_splitSize; }
void splitSizeInc(int count) { m_splitSize += count; } void splitSizeInc(int count) { m_splitSize += count; }
void splitSizeInc(AstNode* nodep) { splitSizeInc(EmitCBaseCounterVisitor(nodep).count()); } void splitSizeInc(AstNode* nodep) { splitSizeInc(EmitCBaseCounterVisitor(nodep).count()); }
bool splitNeeded() { bool splitNeeded() const {
return (splitSize() && v3Global.opt.outputSplit() return (splitSize() && v3Global.opt.outputSplit()
&& v3Global.opt.outputSplit() < splitSize()); && v3Global.opt.outputSplit() < splitSize());
} }
@ -1222,18 +1222,16 @@ public:
nodep->v3fatalSrc("Unknown node type reached emitter: " << nodep->prettyTypeName()); nodep->v3fatalSrc("Unknown node type reached emitter: " << nodep->prettyTypeName());
} }
void init() { public:
EmitCStmts() {
m_suppressSemi = false; m_suppressSemi = false;
m_wideTempRefp = nullptr; m_wideTempRefp = nullptr;
m_labelNum = 0; m_labelNum = 0;
m_splitSize = 0; m_splitSize = 0;
m_splitFilenum = 0; m_splitFilenum = 0;
} }
EmitCStmts(AstNode* nodep, V3OutCFile* ofp, bool trackText = false)
public: : EmitCStmts{} {
EmitCStmts() { init(); }
EmitCStmts(AstNode* nodep, V3OutCFile* ofp, bool trackText = false) {
init();
m_ofp = ofp; m_ofp = ofp;
m_trackText = trackText; m_trackText = trackText;
iterate(nodep); iterate(nodep);
@ -2104,10 +2102,11 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
} }
// End // End
puts(")"); puts(")");
if (isStmt) if (isStmt) {
puts(";\n"); puts(";\n");
else } else {
puts(" "); puts(" ");
}
// Prep for next // Prep for next
emitDispState.clear(); emitDispState.clear();
} }

View File

@ -35,7 +35,7 @@ class EmitCMain : EmitCBaseVisitor {
public: public:
// CONSTRUCTORS // CONSTRUCTORS
explicit EmitCMain(AstNetlist* nodep) { emitInt(); } explicit EmitCMain(AstNetlist*) { emitInt(); }
private: private:
// MAIN METHOD // MAIN METHOD

View File

@ -125,7 +125,11 @@ class CMakeEmitter {
: "0"); : "0");
*of << "\n### Sources...\n"; *of << "\n### Sources...\n";
std::vector<string> classes_fast, classes_slow, support_fast, support_slow, global; std::vector<string> classes_fast;
std::vector<string> classes_slow;
std::vector<string> support_fast;
std::vector<string> support_slow;
std::vector<string> global;
for (AstNodeFile* nodep = v3Global.rootp()->filesp(); nodep; for (AstNodeFile* nodep = v3Global.rootp()->filesp(); nodep;
nodep = VN_CAST(nodep->nextp(), NodeFile)) { nodep = VN_CAST(nodep->nextp(), NodeFile)) {
AstCFile* cfilep = VN_CAST(nodep, CFile); AstCFile* cfilep = VN_CAST(nodep, CFile);

View File

@ -120,7 +120,7 @@ class EmitCSyms : EmitCBaseVisitor {
void emitDpiHdr(); void emitDpiHdr();
void emitDpiImp(); void emitDpiImp();
void nameCheck(AstNode* nodep) { static void nameCheck(AstNode* nodep) {
// Prevent GCC compile time error; name check all things that reach C++ code // Prevent GCC compile time error; name check all things that reach C++ code
if (nodep->name() != "" if (nodep->name() != ""
&& !(VN_IS(nodep, CFunc) && !(VN_IS(nodep, CFunc)
@ -139,7 +139,7 @@ class EmitCSyms : EmitCBaseVisitor {
} }
} }
string scopeSymString(const string& scpname) { static string scopeSymString(const string& scpname) {
string out = scpname; string out = scpname;
string::size_type pos; string::size_type pos;
while ((pos = out.find("__PVT__")) != string::npos) out.replace(pos, 7, ""); while ((pos = out.find("__PVT__")) != string::npos) out.replace(pos, 7, "");
@ -150,7 +150,7 @@ class EmitCSyms : EmitCBaseVisitor {
return out; return out;
} }
string scopeDecodeIdentifier(const string& scpname) { static string scopeDecodeIdentifier(const string& scpname) {
string out = scpname; string out = scpname;
// Remove hierarchy // Remove hierarchy
string::size_type pos = out.rfind('.'); string::size_type pos = out.rfind('.');
@ -800,16 +800,16 @@ void EmitCSyms::emitSymImp() {
if (varp->isParam()) { if (varp->isParam()) {
if (varp->vlEnumType() == "VLVT_STRING") { if (varp->vlEnumType() == "VLVT_STRING") {
puts(", const_cast<void*>(static_cast<const void*>("); puts(", const_cast<void*>(static_cast<const void*>(");
puts(varName.c_str()); puts(varName);
puts(".c_str())), "); puts(".c_str())), ");
} else { } else {
puts(", const_cast<void*>(static_cast<const void*>(&("); puts(", const_cast<void*>(static_cast<const void*>(&(");
puts(varName.c_str()); puts(varName);
puts("))), "); puts("))), ");
} }
} else { } else {
puts(", &("); puts(", &(");
puts(varName.c_str()); puts(varName);
puts("), "); puts("), ");
} }

View File

@ -147,7 +147,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
iterateAndNextNull(nodep->rhsp()); iterateAndNextNull(nodep->rhsp());
if (!m_suppressSemi) puts(";\n"); if (!m_suppressSemi) puts(";\n");
} }
virtual void visit(AstBreak* nodep) override { virtual void visit(AstBreak*) override {
putbs("break"); putbs("break");
if (!m_suppressSemi) puts(";\n"); if (!m_suppressSemi) puts(";\n");
} }
@ -201,7 +201,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
puts(string("// ") + nodep->name() + "\n"); puts(string("// ") + nodep->name() + "\n");
iterateChildren(nodep); iterateChildren(nodep);
} }
virtual void visit(AstContinue* nodep) override { virtual void visit(AstContinue*) override {
putbs("continue"); putbs("continue");
if (!m_suppressSemi) puts(";\n"); if (!m_suppressSemi) puts(";\n");
} }

View File

@ -144,19 +144,21 @@ class EmitXmlFileVisitor : public AstNVisitor {
puts(" origName="); puts(" origName=");
putsQuoted(nodep->origName()); putsQuoted(nodep->origName());
// Attributes // Attributes
if (nodep->attrClocker() == VVarAttrClocker::CLOCKER_YES) if (nodep->attrClocker() == VVarAttrClocker::CLOCKER_YES) {
puts(" clocker=\"true\""); puts(" clocker=\"true\"");
else if (nodep->attrClocker() == VVarAttrClocker::CLOCKER_NO) } else if (nodep->attrClocker() == VVarAttrClocker::CLOCKER_NO) {
puts(" clocker=\"false\""); puts(" clocker=\"false\"");
}
if (nodep->attrClockEn()) puts(" clock_enable=\"true\""); if (nodep->attrClockEn()) puts(" clock_enable=\"true\"");
if (nodep->attrIsolateAssign()) puts(" isolate_assignments=\"true\""); if (nodep->attrIsolateAssign()) puts(" isolate_assignments=\"true\"");
if (nodep->isSigPublic()) puts(" public=\"true\""); if (nodep->isSigPublic()) puts(" public=\"true\"");
if (nodep->isSigUserRdPublic()) puts(" public_flat_rd=\"true\""); if (nodep->isSigUserRdPublic()) puts(" public_flat_rd=\"true\"");
if (nodep->isSigUserRWPublic()) puts(" public_flat_rw=\"true\""); if (nodep->isSigUserRWPublic()) puts(" public_flat_rw=\"true\"");
if (nodep->isGParam()) if (nodep->isGParam()) {
puts(" param=\"true\""); puts(" param=\"true\"");
else if (nodep->isParam()) } else if (nodep->isParam()) {
puts(" localparam=\"true\""); puts(" localparam=\"true\"");
}
if (nodep->attrScBv()) puts(" sc_bv=\"true\""); if (nodep->attrScBv()) puts(" sc_bv=\"true\"");
if (nodep->attrScClocked()) puts(" sc_clock=\"true\""); if (nodep->attrScClocked()) puts(" sc_clock=\"true\"");
if (nodep->attrSFormat()) puts(" sformat=\"true\""); if (nodep->attrSFormat()) puts(" sformat=\"true\"");
@ -286,9 +288,7 @@ private:
public: public:
// CONSTRUCTORS // CONSTRUCTORS
ModuleFilesXmlVisitor(AstNetlist* nodep, std::ostream& os) ModuleFilesXmlVisitor(AstNetlist* nodep, std::ostream& os)
: m_os{os} : m_os{os} {
, m_modulesCovered{}
, m_nodeModules{} {
// Operate on whole netlist // Operate on whole netlist
nodep->accept(*this); nodep->accept(*this);
// Xml output // Xml output

View File

@ -212,7 +212,7 @@ void V3Error::v3errorEnd(std::ostringstream& sstr, const string& locationStr) {
s_messages.insert(msg); s_messages.insert(msg);
if (!locationStr.empty()) { if (!locationStr.empty()) {
string locationMsg = warnMore() + locationStr + "\n"; string locationMsg = warnMore() + locationStr + "\n";
size_t pos = msg.find("\n"); size_t pos = msg.find('\n');
msg.insert(pos + 1, locationMsg); msg.insert(pos + 1, locationMsg);
} }
// Output // Output

View File

@ -991,9 +991,9 @@ public:
string protectIf(const string& old, bool doIt) { string protectIf(const string& old, bool doIt) {
if (!v3Global.opt.protectIds() || old.empty() || !doIt) return old; if (!v3Global.opt.protectIds() || old.empty() || !doIt) return old;
const auto it = m_nameMap.find(old); const auto it = m_nameMap.find(old);
if (it != m_nameMap.end()) if (it != m_nameMap.end()) {
return it->second; return it->second;
else { } else {
string out; string out;
if (v3Global.opt.debugProtect()) { if (v3Global.opt.debugProtect()) {
// This lets us see the symbol being protected to debug cases // This lets us see the symbol being protected to debug cases

View File

@ -1345,7 +1345,7 @@ private:
} }
return VNUser(0); return VNUser(0);
} }
virtual VNUser visit(GateLogicVertex* lvertexp, VNUser vu) override { // virtual VNUser visit(GateLogicVertex*, VNUser vu) override { //
return VNUser(0); return VNUser(0);
} }

View File

@ -39,7 +39,7 @@ void V3Global::shutdown() {
VL_DO_CLEAR(delete m_hierPlanp, m_hierPlanp = nullptr); // delete nullptr is safe VL_DO_CLEAR(delete m_hierPlanp, m_hierPlanp = nullptr); // delete nullptr is safe
} }
void V3Global::checkTree() { rootp()->checkTree(); } void V3Global::checkTree() const { rootp()->checkTree(); }
void V3Global::readFiles() { void V3Global::readFiles() {
// NODE STATE // NODE STATE

View File

@ -108,7 +108,7 @@ public:
// METHODS // METHODS
void readFiles(); void readFiles();
void checkTree(); void checkTree() const;
static void dumpCheckGlobalTree(const string& stagename, int newNumber = 0, static void dumpCheckGlobalTree(const string& stagename, int newNumber = 0,
bool doDump = true); bool doDump = true);
void assertDTypesResolved(bool flag) { m_assertDTypesResolved = flag; } void assertDTypesResolved(bool flag) { m_assertDTypesResolved = flag; }

View File

@ -52,7 +52,7 @@ void V3GraphVertex::verticesPushBack(V3Graph* graphp) {
m_vertices.pushBack(graphp->m_vertices, this); m_vertices.pushBack(graphp->m_vertices, this);
} }
void V3GraphVertex::unlinkEdges(V3Graph* graphp) { void V3GraphVertex::unlinkEdges(V3Graph*) {
for (V3GraphEdge* edgep = outBeginp(); edgep; /*BELOW*/) { for (V3GraphEdge* edgep = outBeginp(); edgep; /*BELOW*/) {
V3GraphEdge* nextp = edgep->outNextp(); V3GraphEdge* nextp = edgep->outNextp();
edgep->unlinkDelete(); edgep->unlinkDelete();

View File

@ -280,7 +280,7 @@ public:
private: private:
// METHODS // METHODS
string indent() { return string(m_depth, ':') + " "; } string indent() const { return string(m_depth, ':') + " "; }
virtual void visit(AstNode* nodep) override { virtual void visit(AstNode* nodep) override {
++m_depth; ++m_depth;
if (unsigned costPlus1 = nodep->user4()) { if (unsigned costPlus1 = nodep->user4()) {

View File

@ -717,7 +717,7 @@ class LinkDotFindVisitor : public AstNVisitor {
int m_modBlockNum = 0; // Begin block number in module, 0=none seen int m_modBlockNum = 0; // Begin block number in module, 0=none seen
// METHODS // METHODS
int debug() { return LinkDotState::debug(); } static int debug() { return LinkDotState::debug(); }
void makeImplicitNew(AstClass* nodep) { void makeImplicitNew(AstClass* nodep) {
AstFunc* newp = new AstFunc(nodep->fileline(), "new", nullptr, nullptr); AstFunc* newp = new AstFunc(nodep->fileline(), "new", nullptr, nullptr);
@ -1273,7 +1273,7 @@ private:
LinkDotState* m_statep; // State to pass between visitors, including symbol table LinkDotState* m_statep; // State to pass between visitors, including symbol table
AstNodeModule* m_modp = nullptr; // Current module AstNodeModule* m_modp = nullptr; // Current module
int debug() { return LinkDotState::debug(); } static int debug() { return LinkDotState::debug(); }
void pinImplicitExprRecurse(AstNode* nodep) { void pinImplicitExprRecurse(AstNode* nodep) {
// Under a pin, Check interconnect expression for a pin reference or a concat. // Under a pin, Check interconnect expression for a pin reference or a concat.
@ -1433,7 +1433,7 @@ class LinkDotScopeVisitor : public AstNVisitor {
AstScope* m_scopep = nullptr; // The current scope AstScope* m_scopep = nullptr; // The current scope
VSymEnt* m_modSymp = nullptr; // Symbol entry for current module VSymEnt* m_modSymp = nullptr; // Symbol entry for current module
int debug() { return LinkDotState::debug(); } static int debug() { return LinkDotState::debug(); }
// VISITs // VISITs
virtual void visit(AstNetlist* nodep) override { virtual void visit(AstNetlist* nodep) override {
@ -1586,7 +1586,7 @@ class LinkDotIfaceVisitor : public AstNVisitor {
VSymEnt* m_curSymp; // Symbol Entry for current table, where to lookup/insert VSymEnt* m_curSymp; // Symbol Entry for current table, where to lookup/insert
// METHODS // METHODS
int debug() { return LinkDotState::debug(); } static int debug() { return LinkDotState::debug(); }
// VISITs // VISITs
virtual void visit(AstModport* nodep) override { virtual void visit(AstModport* nodep) override {
@ -1735,7 +1735,7 @@ private:
} }
} m_ds; // State to preserve across recursions } m_ds; // State to preserve across recursions
int debug() { return LinkDotState::debug(); } static int debug() { return LinkDotState::debug(); }
// METHODS - Variables // METHODS - Variables
void createImplicitVar(VSymEnt* lookupSymp, AstVarRef* nodep, AstNodeModule* modp, void createImplicitVar(VSymEnt* lookupSymp, AstVarRef* nodep, AstNodeModule* modp,
@ -2034,10 +2034,11 @@ private:
AstNode* varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack(); AstNode* varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack();
AstNode* newp AstNode* newp
= new AstMemberSel(nodep->fileline(), varEtcp, VFlagChildDType(), nodep->name()); = new AstMemberSel(nodep->fileline(), varEtcp, VFlagChildDType(), nodep->name());
if (m_ds.m_dotErr) if (m_ds.m_dotErr) {
nodep->unlinkFrBack(); // Avoid circular node loop on errors nodep->unlinkFrBack(); // Avoid circular node loop on errors
else } else {
nodep->replaceWith(newp); nodep->replaceWith(newp);
}
VL_DO_DANGLING(pushDeletep(nodep), nodep); VL_DO_DANGLING(pushDeletep(nodep), nodep);
} else { } else {
// //

View File

@ -153,10 +153,11 @@ private:
for (int i = msb; i != (lsb + increment); i += increment, offset_from_init++) { for (int i = msb; i != (lsb + increment); i += increment, offset_from_init++) {
string name = nodep->name() + cvtToStr(i); string name = nodep->name() + cvtToStr(i);
AstNode* valuep = nullptr; AstNode* valuep = nullptr;
if (nodep->valuep()) if (nodep->valuep()) {
valuep = new AstAdd( valuep = new AstAdd(
nodep->fileline(), nodep->valuep()->cloneTree(true), nodep->fileline(), nodep->valuep()->cloneTree(true),
new AstConst(nodep->fileline(), AstConst::Unsized32(), offset_from_init)); new AstConst(nodep->fileline(), AstConst::Unsized32(), offset_from_init));
}
AstNode* newp = new AstEnumItem(nodep->fileline(), name, nullptr, valuep); AstNode* newp = new AstEnumItem(nodep->fileline(), name, nullptr, valuep);
if (addp) { if (addp) {
addp = addp->addNextNull(newp); addp = addp->addNextNull(newp);

View File

@ -1452,7 +1452,7 @@ V3Number& V3Number::opAtoN(const V3Number& lhs, int base) {
str.erase(std::remove(str.begin(), str.end(), '_'), str.end()); str.erase(std::remove(str.begin(), str.end(), '_'), str.end());
errno = 0; errno = 0;
long v = std::strtol(str.c_str(), nullptr, base); auto v = std::strtol(str.c_str(), nullptr, base);
if (errno != 0) v = 0; if (errno != 0) v = 0;
return setLongS(static_cast<vlsint32_t>(v)); return setLongS(static_cast<vlsint32_t>(v));
} }
@ -2161,11 +2161,7 @@ V3Number& V3Number::opExtendXZ(const V3Number& lhs, uint32_t lbits) {
NUM_ASSERT_OP_ARGS1(lhs); NUM_ASSERT_OP_ARGS1(lhs);
NUM_ASSERT_LOGIC_ARGS1(lhs); NUM_ASSERT_LOGIC_ARGS1(lhs);
setZero(); setZero();
for (int bit = 0; bit < width(); bit++) { for (int bit = 0; bit < width(); bit++) { setBit(bit, lhs.bitIsExtend(bit, lbits)); }
char extendWith = lhs.bitIsExtend(bit, lbits);
if (extendWith == '1' || extendWith == 1) extendWith = 0;
setBit(bit, lhs.bitIsExtend(bit, lbits));
}
return *this; return *this;
} }

View File

@ -398,7 +398,7 @@ public:
explicit OrderClkAssVisitor(AstNode* nodep) { iterate(nodep); } explicit OrderClkAssVisitor(AstNode* nodep) { iterate(nodep); }
virtual ~OrderClkAssVisitor() override {} virtual ~OrderClkAssVisitor() override {}
// METHODS // METHODS
bool isClkAss() { return m_clkAss; } bool isClkAss() const { return m_clkAss; }
}; };
//###################################################################### //######################################################################
@ -1958,9 +1958,10 @@ void OrderVisitor::process() {
if (!v3Global.opt.mtasks()) { if (!v3Global.opt.mtasks()) {
UINFO(2, " Construct Move Graph...\n"); UINFO(2, " Construct Move Graph...\n");
processMoveBuildGraph(); processMoveBuildGraph();
if (debug() >= 4) if (debug() >= 4) {
m_pomGraph.dumpDotFilePrefixed( m_pomGraph.dumpDotFilePrefixed(
"ordermv_start"); // Different prefix (ordermv) as it's not the same graph "ordermv_start"); // Different prefix (ordermv) as it's not the same graph
}
m_pomGraph.removeRedundantEdges(&V3GraphEdge::followAlwaysTrue); m_pomGraph.removeRedundantEdges(&V3GraphEdge::followAlwaysTrue);
if (debug() >= 4) m_pomGraph.dumpDotFilePrefixed("ordermv_simpl"); if (debug() >= 4) m_pomGraph.dumpDotFilePrefixed("ordermv_simpl");

View File

@ -873,14 +873,14 @@ public:
m_totalGraphCost += vertexCost(vertexp); m_totalGraphCost += vertexCost(vertexp);
} }
} }
void statsReport(const string& stage) { void statsReport(const string& stage) const {
V3Stats::addStat("MTask graph, " + stage + ", critical path cost", m_longestCpCost); V3Stats::addStat("MTask graph, " + stage + ", critical path cost", m_longestCpCost);
V3Stats::addStat("MTask graph, " + stage + ", total graph cost", m_totalGraphCost); V3Stats::addStat("MTask graph, " + stage + ", total graph cost", m_totalGraphCost);
V3Stats::addStat("MTask graph, " + stage + ", mtask count", m_vertexCount); V3Stats::addStat("MTask graph, " + stage + ", mtask count", m_vertexCount);
V3Stats::addStat("MTask graph, " + stage + ", edge count", m_edgeCount); V3Stats::addStat("MTask graph, " + stage + ", edge count", m_edgeCount);
V3Stats::addStat("MTask graph, " + stage + ", parallelism factor", parallelismFactor()); V3Stats::addStat("MTask graph, " + stage + ", parallelism factor", parallelismFactor());
} }
void debugReport() { void debugReport() const {
UINFO(0, " Critical path cost = " << m_longestCpCost << endl); UINFO(0, " Critical path cost = " << m_longestCpCost << endl);
UINFO(0, " Total graph cost = " << m_totalGraphCost << endl); UINFO(0, " Total graph cost = " << m_totalGraphCost << endl);
UINFO(0, " MTask vertex count = " << m_vertexCount << endl); UINFO(0, " MTask vertex count = " << m_vertexCount << endl);

View File

@ -421,16 +421,18 @@ void V3PreProcImp::comment(const string& text) {
bool vlcomment = false; bool vlcomment = false;
if ((cp[0] == 'v' || cp[0] == 'V') && 0 == (strncmp(cp + 1, "erilator", 8))) { if ((cp[0] == 'v' || cp[0] == 'V') && 0 == (strncmp(cp + 1, "erilator", 8))) {
cp += strlen("verilator"); cp += strlen("verilator");
if (*cp == '_') if (*cp == '_') {
fileline()->v3error("Extra underscore in meta-comment;" fileline()->v3error("Extra underscore in meta-comment;"
" use /*verilator {...}*/ not /*verilator_{...}*/"); " use /*verilator {...}*/ not /*verilator_{...}*/");
}
vlcomment = true; vlcomment = true;
} else if (0 == (strncmp(cp, "synopsys", strlen("synopsys")))) { } else if (0 == (strncmp(cp, "synopsys", strlen("synopsys")))) {
cp += strlen("synopsys"); cp += strlen("synopsys");
synth = true; synth = true;
if (*cp == '_') if (*cp == '_') {
fileline()->v3error("Extra underscore in meta-comment;" fileline()->v3error("Extra underscore in meta-comment;"
" use /*synopsys {...}*/ not /*synopsys_{...}*/"); " use /*synopsys {...}*/ not /*synopsys_{...}*/");
}
} else if (0 == (strncmp(cp, "cadence", strlen("cadence")))) { } else if (0 == (strncmp(cp, "cadence", strlen("cadence")))) {
cp += strlen("cadence"); cp += strlen("cadence");
synth = true; synth = true;

View File

@ -110,6 +110,7 @@ protected:
modfileline->language(v3Global.opt.fileLanguage(modfilename)); modfileline->language(v3Global.opt.fileLanguage(modfilename));
V3Parse::ppPushText( V3Parse::ppPushText(
parsep, (string("`begin_keywords \"") + modfileline->language().ascii() + "\"\n")); parsep, (string("`begin_keywords \"") + modfileline->language().ascii() + "\"\n"));
// FileLine tracks and frees modfileline
} }
while (!s_preprocp->isEof()) { while (!s_preprocp->isEof()) {

View File

@ -188,9 +188,9 @@ class SliceVisitor : public AstNVisitor {
new AstArraySel(nodep->fileline(), new AstArraySel(nodep->fileline(),
nodep->rhsp()->cloneTree(false), index)), nodep->rhsp()->cloneTree(false), index)),
NodeBiop); NodeBiop);
if (!logp) if (!logp) {
logp = clonep; logp = clonep;
else { } else {
switch (nodep->type()) { switch (nodep->type()) {
case AstType::atEq: // FALLTHRU case AstType::atEq: // FALLTHRU
case AstType::atEqCase: case AstType::atEqCase:

View File

@ -71,7 +71,7 @@ class SubstVarEntry {
bool m_wordUse = false; // True if any individual word usage bool m_wordUse = false; // True if any individual word usage
SubstVarWord m_whole; // Data for whole vector used at once SubstVarWord m_whole; // Data for whole vector used at once
std::vector<SubstVarWord> m_words; // Data for every word, if multi word variable std::vector<SubstVarWord> m_words; // Data for every word, if multi word variable
int debug() { return SubstBaseVisitor::debug(); } static int debug() { return SubstBaseVisitor::debug(); }
public: public:
// CONSTRUCTORS // CONSTRUCTORS

View File

@ -327,7 +327,7 @@ private:
} }
} }
virtual void visit(AstEnumDType* nodep) override { iterate(nodep->skipRefp()); } virtual void visit(AstEnumDType* nodep) override { iterate(nodep->skipRefp()); }
virtual void visit(AstNodeDType* nodep) override { virtual void visit(AstNodeDType*) override {
// Note more specific dtypes above // Note more specific dtypes above
if (!m_traVscp) return; if (!m_traVscp) return;
addIgnore("Unsupported: data type"); addIgnore("Unsupported: data type");

View File

@ -943,7 +943,7 @@ class TristateVisitor : public TristateBaseVisitor {
FileLine* fl = nodep->fileline(); FileLine* fl = nodep->fileline();
V3Number oneIfEn = VN_CAST(constp->user1p(), Const) V3Number oneIfEn = VN_CAST(constp->user1p(), Const)
->num(); // visit(AstConst) already split into en/ones ->num(); // visit(AstConst) already split into en/ones
V3Number oneIfEnOne = constp->num(); const V3Number& oneIfEnOne = constp->num();
AstVar* envarp = getCreateEnVarp(varrefp->varp()); AstVar* envarp = getCreateEnVarp(varrefp->varp());
AstNode* newp = new AstLogAnd( AstNode* newp = new AstLogAnd(
fl, new AstEq(fl, new AstConst(fl, oneIfEn), new AstVarRef(fl, envarp, false)), fl, new AstEq(fl, new AstConst(fl, oneIfEn), new AstVarRef(fl, envarp, false)),

View File

@ -67,7 +67,7 @@ private:
return false; return false;
} }
int unrollCount() { int unrollCount() const {
return m_generate ? v3Global.opt.unrollCount() * 16 : v3Global.opt.unrollCount(); return m_generate ? v3Global.opt.unrollCount() * 16 : v3Global.opt.unrollCount();
} }

View File

@ -1820,11 +1820,13 @@ private:
// TODO IEEE says assigning sized number that is not same size as enum is illegal // TODO IEEE says assigning sized number that is not same size as enum is illegal
} }
if (!itemp->valuep()) { if (!itemp->valuep()) {
if (num.isEqZero() && itemp != nodep->itemsp()) if (num.isEqZero() && itemp != nodep->itemsp()) {
itemp->v3error("Enum value illegally wrapped around (IEEE 1800-2017 6.19)"); itemp->v3error("Enum value illegally wrapped around (IEEE 1800-2017 6.19)");
if (num.isFourState()) }
if (num.isFourState()) {
itemp->v3error("Enum value that is unassigned cannot follow value with X/Zs " itemp->v3error("Enum value that is unassigned cannot follow value with X/Zs "
"(IEEE 1800-2017 6.19)"); "(IEEE 1800-2017 6.19)");
}
if (!nodep->dtypep()->basicp() if (!nodep->dtypep()->basicp()
&& !nodep->dtypep()->basicp()->keyword().isIntNumeric()) { && !nodep->dtypep()->basicp()->keyword().isIntNumeric()) {
itemp->v3error("Enum names without values only allowed on numeric types"); itemp->v3error("Enum names without values only allowed on numeric types");
@ -1835,9 +1837,10 @@ private:
AstConst* constp = VN_CAST(itemp->valuep(), Const); AstConst* constp = VN_CAST(itemp->valuep(), Const);
if (constp->num().isFourState() && nodep->dtypep()->basicp() if (constp->num().isFourState() && nodep->dtypep()->basicp()
&& !nodep->dtypep()->basicp()->isFourstate()) && !nodep->dtypep()->basicp()->isFourstate()) {
itemp->v3error("Enum value with X/Zs cannot be assigned to non-fourstate type " itemp->v3error("Enum value with X/Zs cannot be assigned to non-fourstate type "
"(IEEE 1800-2017 6.19)"); "(IEEE 1800-2017 6.19)");
}
num.opAssign(constp->num()); num.opAssign(constp->num());
// Look for duplicates // Look for duplicates
if (inits.find(num) != inits.end()) { // IEEE says illegal if (inits.find(num) != inits.end()) { // IEEE says illegal

View File

@ -275,9 +275,10 @@ private:
} else if (VN_IS(ddtypep, BasicDType) && ddtypep->isString()) { } else if (VN_IS(ddtypep, BasicDType) && ddtypep->isString()) {
// SELBIT(string, index) -> GETC(string, index) // SELBIT(string, index) -> GETC(string, index)
AstNodeVarRef* varrefp = VN_CAST(fromp, NodeVarRef); AstNodeVarRef* varrefp = VN_CAST(fromp, NodeVarRef);
if (!varrefp) if (!varrefp) {
nodep->v3warn(E_UNSUPPORTED, nodep->v3warn(E_UNSUPPORTED,
"Unsupported: String array operation on non-variable"); "Unsupported: String array operation on non-variable");
}
AstNode* newp; AstNode* newp;
if (varrefp && varrefp->lvalue()) { if (varrefp && varrefp->lvalue()) {
newp = new AstGetcRefN(nodep->fileline(), fromp, rhsp); newp = new AstGetcRefN(nodep->fileline(), fromp, rhsp);