Internals: cppcheck 1.90 fixes. No functional change intended.

This commit is contained in:
Wilson Snyder 2020-04-05 18:30:46 -04:00
parent ff31abe341
commit 50535a1894
23 changed files with 116 additions and 93 deletions

View File

@ -857,9 +857,12 @@ 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) return feof(fp) ? 1 : 0; // 1:0 to prevent MSVC++ warning if (fp) {
else return (floc<0); return feof(fp) ? 1 : 0; // 1:0 to prevent MSVC++ warning
} else {
return floc < 0;
}
} }
static inline void _vl_vsss_advance(FILE* fp, int& floc) VL_MT_SAFE { static inline void _vl_vsss_advance(FILE* fp, int& floc) VL_MT_SAFE {
if (fp) fgetc(fp); if (fp) fgetc(fp);
@ -1689,7 +1692,6 @@ bool VlReadMem::get(QData& addrr, std::string& valuer) {
if (c == '_') continue; // Ignore _ e.g. inside a number if (c == '_') continue; // Ignore _ e.g. inside a number
if (indata && !isxdigit(c) && c != 'x' && c != 'X') { if (indata && !isxdigit(c) && c != 'x' && c != 'X') {
// printf("Got data @%lx = %s\n", m_addr, valuer.c_str()); // printf("Got data @%lx = %s\n", m_addr, valuer.c_str());
indata = false;
ungetc(c, m_fp); ungetc(c, m_fp);
addrr = m_addr; addrr = m_addr;
++m_addr; ++m_addr;
@ -1860,8 +1862,6 @@ void VL_READMEM_N(bool hex, // Hex format, else binary
) VL_MT_SAFE { ) VL_MT_SAFE {
QData addr_max = array_lsb + depth - 1; QData addr_max = array_lsb + depth - 1;
if (start < static_cast<QData>(array_lsb)) start = array_lsb; if (start < static_cast<QData>(array_lsb)) start = array_lsb;
QData addr_end = end;
if (addr_end > addr_max) addr_end = addr_max;
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;

View File

@ -85,7 +85,9 @@ template <std::size_t T_Words> class VlWide {
WData m_storage[T_Words]; WData m_storage[T_Words];
public: public:
// Default constructor/destructor/copy are fine // cppcheck-suppress uninitVar
VlWide() {}
~VlWide() {}
const WData& at(size_t index) const { return m_storage[index]; } const WData& at(size_t index) const { return m_storage[index]; }
WData& at(size_t index) { return m_storage[index]; } WData& at(size_t index) { return m_storage[index]; }
WData* data() { return &m_storage[0]; } WData* data() { return &m_storage[0]; }

View File

@ -142,6 +142,7 @@ void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed) {
FILE* fp = fopen(filenamep, "w"); FILE* fp = fopen(filenamep, "w");
if (VL_UNLIKELY(!fp)) { if (VL_UNLIKELY(!fp)) {
VL_FATAL_MT(filenamep, 0, "", "+prof+threads+file file not writable"); VL_FATAL_MT(filenamep, 0, "", "+prof+threads+file file not writable");
// cppcheck-suppress resourceLeak // bug, doesn't realize fp is nullptr
return; return;
} }

View File

@ -930,15 +930,14 @@ 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 (strcmp((got), (exp))) { \
std::string msg = std::string("%Error: ") \ std::string msg \
+ "GOT = '"+((got)?(got):"<null>")+"'" \ = std::string("%Error: ") + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \
+ " EXP = '"+((exp)?(exp):"<null>")+"'"; \ VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \
} }
#define CHECK_ENUM_STR(fn, enum) \ #define CHECK_ENUM_STR(fn, enum) \
do { \ do { \
const char* strVal = VerilatedVpiError::fn(enum); \ const char* strVal = VerilatedVpiError::fn(enum); \
CHECK_RESULT_CSTR(strVal, #enum); \ CHECK_RESULT_CSTR(strVal, #enum); \
} while (0) } while (0)

View File

@ -255,7 +255,8 @@ class AstClassPackage : public AstNodeModule {
AstClass* m_classp; // Class package this is under (weak pointer, hard link is other way) AstClass* m_classp; // Class package this is under (weak pointer, hard link is other way)
public: public:
AstClassPackage(FileLine* fl, const string& name) AstClassPackage(FileLine* fl, const string& name)
: ASTGEN_SUPER(fl, name) {} : ASTGEN_SUPER(fl, name)
, m_classp(NULL) {}
ASTNODE_NODE_FUNCS(ClassPackage) ASTNODE_NODE_FUNCS(ClassPackage)
virtual string verilogKwd() const { return "/*class*/package"; } virtual string verilogKwd() const { return "/*class*/package"; }
virtual const char* broken() const; virtual const char* broken() const;
@ -948,8 +949,11 @@ public:
virtual void virtRefDTypep(AstNodeDType* nodep) { refDTypep(nodep); } virtual void virtRefDTypep(AstNodeDType* nodep) { refDTypep(nodep); }
// METHODS // METHODS
virtual AstBasicDType* basicp() const { return NULL; } virtual AstBasicDType* basicp() const { return NULL; }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefp() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefp() const { return (AstNodeDType*)this; }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefToConstp() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefToConstp() const { return (AstNodeDType*)this; }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; }
virtual int widthAlignBytes() const { return subDTypep()->widthAlignBytes(); } virtual int widthAlignBytes() const { return subDTypep()->widthAlignBytes(); }
virtual int widthTotalBytes() const { return subDTypep()->widthTotalBytes(); } virtual int widthTotalBytes() const { return subDTypep()->widthTotalBytes(); }
@ -1111,8 +1115,11 @@ public:
virtual void virtRefDTypep(AstNodeDType* nodep) { } virtual void virtRefDTypep(AstNodeDType* nodep) { }
virtual bool similarDType(AstNodeDType* samep) const { return this==samep; } virtual bool similarDType(AstNodeDType* samep) const { return this==samep; }
virtual AstBasicDType* basicp() const { return NULL; } virtual AstBasicDType* basicp() const { return NULL; }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefp() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefp() const { return (AstNodeDType*)this; }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefToConstp() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefToConstp() const { return (AstNodeDType*)this; }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; }
virtual int widthAlignBytes() const { return 1; } virtual int widthAlignBytes() const { return 1; }
virtual int widthTotalBytes() const { return 1; } virtual int widthTotalBytes() const { return 1; }
@ -1207,6 +1214,7 @@ public:
virtual AstBasicDType* basicp() const { return subDTypep()->basicp(); } // (Slow) recurse down to find basic data type virtual AstBasicDType* basicp() const { return subDTypep()->basicp(); } // (Slow) recurse down to find basic data type
virtual AstNodeDType* skipRefp() const { return subDTypep()->skipRefp(); } virtual AstNodeDType* skipRefp() const { return subDTypep()->skipRefp(); }
virtual AstNodeDType* skipRefToConstp() const { return subDTypep()->skipRefToConstp(); } virtual AstNodeDType* skipRefToConstp() const { return subDTypep()->skipRefToConstp(); }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; }
virtual int widthAlignBytes() const { return subDTypep()->widthAlignBytes(); } virtual int widthAlignBytes() const { return subDTypep()->widthAlignBytes(); }
virtual int widthTotalBytes() const { return subDTypep()->widthTotalBytes(); } virtual int widthTotalBytes() const { return subDTypep()->widthTotalBytes(); }
@ -1225,7 +1233,9 @@ public:
virtual bool similarDType(AstNodeDType* samep) const { return this==samep; } virtual bool similarDType(AstNodeDType* samep) const { return this==samep; }
virtual AstBasicDType* basicp() const { return NULL; } virtual AstBasicDType* basicp() const { return NULL; }
virtual AstNodeDType* skipRefp() const { return NULL; } virtual AstNodeDType* skipRefp() const { return NULL; }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefToConstp() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefToConstp() const { return (AstNodeDType*)this; }
// cppcheck-suppress csyleCast
virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; }
virtual int widthAlignBytes() const { return 0; } virtual int widthAlignBytes() const { return 0; }
virtual int widthTotalBytes() const { return 0; } virtual int widthTotalBytes() const { return 0; }

View File

@ -87,6 +87,7 @@ public:
} }
static void addInTree(AstNode* nodep, bool linkable) { static void addInTree(AstNode* nodep, bool linkable) {
#ifndef VL_LEAK_CHECKS #ifndef VL_LEAK_CHECKS
// cppcheck-suppress knownConditionTrueFalse
if (!linkable) return; // save some time, else the map will get huge! if (!linkable) return; // save some time, else the map will get huge!
#endif #endif
NodeMap::iterator iter = s_nodes.find(nodep); NodeMap::iterator iter = s_nodes.find(nodep);

View File

@ -178,7 +178,7 @@ class CUseVisitor : public AstNVisitor {
if (nodep->extendsp() && nodep->extendsp()->classp()->user1()) { if (nodep->extendsp() && nodep->extendsp()->classp()->user1()) {
string stmt = "out += \""; string stmt = "out += \"";
if (!comma.empty()) stmt += "\", \"+ "; if (!comma.empty()) stmt += "\", \"+ ";
comma = ", "; // comma = ", "; // Nothing further so not needed
stmt += nodep->extendsp()->dtypep()->nameProtect(); stmt += nodep->extendsp()->dtypep()->nameProtect();
stmt += "::to_string_middle();\n"; stmt += "::to_string_middle();\n";
nodep->user1(true); // So what we extend dumps this nodep->user1(true); // So what we extend dumps this

View File

@ -1878,9 +1878,8 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
putbs(","); putbs(",");
iterate(dispp->lhsp()); iterate(dispp->lhsp());
putbs(","); putbs(",");
} else if (const AstSFormatF* dispp = VN_CAST(nodep, SFormatF)) { } else if (VN_IS(nodep, SFormatF)) {
isStmt = false; isStmt = false;
if (dispp) {}
puts("VL_SFORMATF_NX("); puts("VL_SFORMATF_NX(");
} else { } else {
nodep->v3fatalSrc("Unknown displayEmit node type"); nodep->v3fatalSrc("Unknown displayEmit node type");
@ -2916,11 +2915,13 @@ void EmitCImp::emitInt(AstNodeModule* modp) {
puts("\n// INTERNAL METHODS\n"); puts("\n// INTERNAL METHODS\n");
if (modp->isTop()) { if (modp->isTop()) {
ofp()->putsPrivate(true); // private: ofp()->putsPrivate(true); // private:
puts("static void "+protect("_eval_initial_loop") puts("static void " + protect("_eval_initial_loop") + "(" + EmitCBaseVisitor::symClassVar()
+"("+EmitCBaseVisitor::symClassVar()+");\n"); + ");\n");
if (v3Global.needTraceDumper() && !optSystemC()) puts("void _traceDump();"); if (v3Global.needTraceDumper()) {
if (v3Global.needTraceDumper()) puts("void _traceDumpOpen();"); if (!optSystemC()) puts("void _traceDump();");
if (v3Global.needTraceDumper()) puts("void _traceDumpClose();"); puts("void _traceDumpOpen();");
puts("void _traceDumpClose();");
}
} }
if (!VN_IS(modp, Class)) { if (!VN_IS(modp, Class)) {

View File

@ -116,6 +116,7 @@ public:
// ACCESSOR METHODS // ACCESSOR METHODS
void addSrcDepend(const string& filename) { void addSrcDepend(const string& filename) {
if (m_filenameSet.find(filename) == m_filenameSet.end()) { if (m_filenameSet.find(filename) == m_filenameSet.end()) {
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
m_filenameSet.insert(filename); m_filenameSet.insert(filename);
DependFile df (filename, false); DependFile df (filename, false);
df.loadStats(); // Get size now, in case changes during the run df.loadStats(); // Get size now, in case changes during the run
@ -124,6 +125,7 @@ public:
} }
void addTgtDepend(const string& filename) { void addTgtDepend(const string& filename) {
if (m_filenameSet.find(filename) == m_filenameSet.end()) { if (m_filenameSet.find(filename) == m_filenameSet.end()) {
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
m_filenameSet.insert(filename); m_filenameSet.insert(filename);
m_filenameList.insert(DependFile(filename, true)); m_filenameList.insert(DependFile(filename, true));
} }

View File

@ -155,6 +155,11 @@ FileLine::FileLine(FileLine::EmptySecret) {
} }
} }
void FileLine::newContent() {
m_contentp = new VFileContent;
m_contentLineno = 1;
}
const string FileLine::xmlDetailedLocation() const { const string FileLine::xmlDetailedLocation() const {
return "loc=\"" + return "loc=\"" +
cvtToStr(filenameLetters()) + "," + cvtToStr(filenameLetters()) + "," +

View File

@ -115,26 +115,26 @@ private:
return *defFilelinep; return *defFilelinep;
} }
public: public:
explicit FileLine(const string& filename) { explicit FileLine(const string& filename)
m_lastLineno = m_firstLineno = 0; : m_firstLineno(0)
m_lastColumn = m_firstColumn = 0; , m_firstColumn(0)
m_filenameno = singleton().nameToNumber(filename); , m_lastLineno(0)
m_contentLineno = 0; , m_lastColumn(0)
m_contentp = NULL; , m_filenameno(singleton().nameToNumber(filename))
m_parent = NULL; , m_contentLineno(0)
m_warnOn = defaultFileLine().m_warnOn; , m_contentp(NULL)
} , m_parent(NULL)
explicit FileLine(FileLine* fromp) { , m_warnOn(defaultFileLine().m_warnOn) {}
m_firstLineno = fromp->m_firstLineno; explicit FileLine(FileLine* fromp)
m_firstColumn = fromp->m_firstColumn; : m_firstLineno(fromp->m_firstLineno)
m_lastLineno = fromp->m_lastLineno; , m_firstColumn(fromp->m_firstColumn)
m_lastColumn = fromp->m_lastColumn; , m_lastLineno(fromp->m_lastLineno)
m_filenameno = fromp->m_filenameno; , m_lastColumn(fromp->m_lastColumn)
m_contentLineno = fromp->m_contentLineno; , m_filenameno(fromp->m_filenameno)
m_contentp = fromp->m_contentp; , m_contentLineno(fromp->m_contentLineno)
m_parent = fromp->m_parent; , m_contentp(fromp->m_contentp)
m_warnOn = fromp->m_warnOn; , m_parent(fromp->m_parent)
} , m_warnOn(fromp->m_warnOn) {}
struct EmptySecret {}; // Constructor selection struct EmptySecret {}; // Constructor selection
explicit FileLine(EmptySecret); explicit FileLine(EmptySecret);
FileLine* copyOrSameFileLine(); FileLine* copyOrSameFileLine();
@ -144,8 +144,8 @@ public:
static void* operator new(size_t size); static void* operator new(size_t size);
static void operator delete(void* obj, size_t size); static void operator delete(void* obj, size_t size);
#endif #endif
void newContent() { m_contentp = new VFileContent; m_contentLineno = 1; }
// METHODS // METHODS
void newContent();
void lineno(int num) { m_firstLineno = num; m_lastLineno = num; void lineno(int num) { m_firstLineno = num; m_lastLineno = num;
m_firstColumn = m_lastColumn = 1; } m_firstColumn = m_lastColumn = 1; }
void language(V3LangCode lang) { singleton().numberToLang(m_filenameno, lang); } void language(V3LangCode lang) { singleton().numberToLang(m_filenameno, lang); }

View File

@ -83,22 +83,21 @@ public:
// Options // Options
V3Options opt; // All options; let user see them directly V3Options opt; // All options; let user see them directly
public: public:
// CONSTRUCTORS // CONSTRUCTORS
V3Global() { V3Global()
m_debugFileNumber = 0; : m_rootp(NULL) // created by makeInitNetlist() so static constructors run first
m_widthMinUsage = VWidthMinUsage::LINT_WIDTH; , m_widthMinUsage(VWidthMinUsage::LINT_WIDTH)
m_assertDTypesResolved = false; , m_debugFileNumber(0)
m_constRemoveXs = false; , m_assertDTypesResolved(false)
m_needC11 = false; , m_constRemoveXs(false)
m_needHInlines = false; , m_needC11(false)
m_needHeavy = false; , m_needHInlines(false)
m_needTraceDumper = false; , m_needHeavy(false)
m_dpi = false; , m_needTraceDumper(false)
m_rootp = NULL; // created by makeInitNetlist() so static constructors run first , m_dpi(false) {}
}
AstNetlist* makeNetlist(); AstNetlist* makeNetlist();
void boot() { UASSERT(!m_rootp,"call once"); m_rootp = makeNetlist(); } void boot() { UASSERT(!m_rootp, "call once"); m_rootp = makeNetlist(); }
void clear(); void clear();
// ACCESSORS (general) // ACCESSORS (general)
AstNetlist* rootp() const { return m_rootp; } AstNetlist* rootp() const { return m_rootp; }

View File

@ -108,7 +108,6 @@ private:
m_setRefLvalue = true; m_setRefLvalue = true;
iterateAndNextNull(nodep->filep()); iterateAndNextNull(nodep->filep());
iterateAndNextNull(nodep->strp()); iterateAndNextNull(nodep->strp());
m_setRefLvalue = false;
} }
m_setRefLvalue = last_setRefLvalue; m_setRefLvalue = last_setRefLvalue;
} }

View File

@ -74,6 +74,7 @@ private:
// METHODS // METHODS
virtual void visit(AstVarRef* nodep) VL_OVERRIDE { virtual void visit(AstVarRef* nodep) VL_OVERRIDE {
// cppcheck-suppress unreadVariable // cppcheck 1.90 bug
VarFlags flags (nodep->varp()); VarFlags flags (nodep->varp());
if (flags.m_done) { if (flags.m_done) {
nodep->hiername(""); // Remove this-> nodep->hiername(""); // Remove this->

View File

@ -457,14 +457,14 @@ string V3Number::ascii(bool prefixed, bool cleanVerilog) const {
); );
//out<<"-"<<hex<<m_value[0]<<"-"; //out<<"-"<<hex<<m_value[0]<<"-";
// cppcheck-suppress konwnConditionTrueFalse
if (binary) { if (binary) {
out<<"b"; out << "b";
out<<displayed("%0b"); out << displayed("%0b");
} } else {
else { if (prefixed) out << "h";
if (prefixed) out<<"h";
// Always deal with 4 bits at once. Note no 4-state, it's above. // Always deal with 4 bits at once. Note no 4-state, it's above.
out<<displayed("%0h"); out << displayed("%0h");
} }
return out.str(); return out.str();
} }

View File

@ -66,6 +66,7 @@ public:
// ACCESSOR METHODS // ACCESSOR METHODS
void addIncDirUser(const string& incdir) { void addIncDirUser(const string& incdir) {
if (m_incDirUserSet.find(incdir) == m_incDirUserSet.end()) { if (m_incDirUserSet.find(incdir) == m_incDirUserSet.end()) {
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
m_incDirUserSet.insert(incdir); m_incDirUserSet.insert(incdir);
m_incDirUsers.push_back(incdir); m_incDirUsers.push_back(incdir);
m_incDirFallbacks.remove(incdir); // User has priority over Fallback m_incDirFallbacks.remove(incdir); // User has priority over Fallback
@ -75,6 +76,7 @@ public:
void addIncDirFallback(const string& incdir) { void addIncDirFallback(const string& incdir) {
if (m_incDirUserSet.find(incdir) == m_incDirUserSet.end()) { // User has priority over Fallback if (m_incDirUserSet.find(incdir) == m_incDirUserSet.end()) { // User has priority over Fallback
if (m_incDirFallbackSet.find(incdir) == m_incDirFallbackSet.end()) { if (m_incDirFallbackSet.find(incdir) == m_incDirFallbackSet.end()) {
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
m_incDirFallbackSet.insert(incdir); m_incDirFallbackSet.insert(incdir);
m_incDirFallbacks.push_back(incdir); m_incDirFallbacks.push_back(incdir);
} }
@ -88,6 +90,7 @@ public:
void addLibExtV(const string& libext) { void addLibExtV(const string& libext) {
if (m_libExtVSet.find(libext) == m_libExtVSet.end()) { if (m_libExtVSet.find(libext) == m_libExtVSet.end()) {
// cppcheck-suppress stlFindInsert // cppcheck 1.90 bug
m_libExtVSet.insert(libext); m_libExtVSet.insert(libext);
m_libExtVs.push_back(libext); m_libExtVs.push_back(libext);
} }

View File

@ -237,14 +237,14 @@ private:
// Process interface cells, then non-interface which may ref an interface cell // Process interface cells, then non-interface which may ref an interface cell
for (int nonIf=0; nonIf<2; ++nonIf) { for (int nonIf=0; nonIf<2; ++nonIf) {
for (CellList::iterator it=m_cellps.begin(); it!=m_cellps.end(); ++it) { for (CellList::iterator it=m_cellps.begin(); it!=m_cellps.end(); ++it) {
AstCell* nodep = *it; AstCell* cellp = *it;
if ((nonIf==0 && VN_IS(nodep->modp(), Iface)) if ((nonIf==0 && VN_IS(cellp->modp(), Iface))
|| (nonIf==1 && !VN_IS(nodep->modp(), Iface))) { || (nonIf==1 && !VN_IS(cellp->modp(), Iface))) {
string fullName (m_modp->hierName()); string fullName (m_modp->hierName());
if (string* genHierNamep = (string *) nodep->user5p()) { if (string* genHierNamep = (string *) cellp->user5p()) {
fullName += *genHierNamep; fullName += *genHierNamep;
} }
visitCell(nodep, fullName); visitCell(cellp, fullName);
} }
} }
} }

View File

@ -273,11 +273,11 @@ private:
} }
public: public:
AstNode* fetchValueNull(AstNode* nodep) { AstNode* fetchValueNull(AstNode* nodep) {
return (AstNode*)(nodep->user3p()); return nodep->user3p();
} }
private: private:
AstNode* fetchOutValueNull(AstNode* nodep) { AstNode* fetchOutValueNull(AstNode* nodep) {
return (AstNode*)(nodep->user2p()); return nodep->user2p();
} }
AstConst* fetchConstNull(AstNode* nodep) { AstConst* fetchConstNull(AstNode* nodep) {
return VN_CAST(fetchValueNull(nodep), Const); return VN_CAST(fetchValueNull(nodep), Const);

View File

@ -732,19 +732,19 @@ class SplitUnpackedVarVisitor : public AstNVisitor, public SplitVarImpl {
sit->lvalue()); sit->lvalue());
} else { } else {
AstVarRef* refp = VN_CAST(sit->nodep(), VarRef); AstVarRef* refp = VN_CAST(sit->nodep(), VarRef);
AstUnpackArrayDType* dtypep; AstUnpackArrayDType* adtypep;
int lsb = 0; int lsb = 0;
if (refp) { if (refp) {
dtypep = VN_CAST(refp->dtypep()->skipRefp(), UnpackArrayDType); adtypep = VN_CAST(refp->dtypep()->skipRefp(), UnpackArrayDType);
} else { } else {
AstSliceSel* selp = VN_CAST(sit->nodep(), SliceSel); AstSliceSel* selp = VN_CAST(sit->nodep(), SliceSel);
UASSERT_OBJ(selp, sit->nodep(), "Unexpected op is registered"); UASSERT_OBJ(selp, sit->nodep(), "Unexpected op is registered");
refp = VN_CAST(selp->fromp(), VarRef); refp = VN_CAST(selp->fromp(), VarRef);
UASSERT_OBJ(refp, selp, "Unexpected op is registered"); UASSERT_OBJ(refp, selp, "Unexpected op is registered");
dtypep = VN_CAST(selp->dtypep()->skipRefp(), UnpackArrayDType); adtypep = VN_CAST(selp->dtypep()->skipRefp(), UnpackArrayDType);
lsb = dtypep->lsb(); lsb = adtypep->lsb();
} }
AstVarRef* newrefp = createTempVar(sit->context(), refp, dtypep, varp->name(), AstVarRef* newrefp = createTempVar(sit->context(), refp, adtypep, varp->name(),
vars, lsb, refp->lvalue(), sit->ftask()); vars, lsb, refp->lvalue(), sit->ftask());
newp = newrefp; newp = newrefp;
refp->varp()->addNextHere(newrefp->varp()); refp->varp()->addNextHere(newrefp->varp());

View File

@ -97,10 +97,10 @@ public:
~VSymEnt() { ~VSymEnt() {
// Change links so we coredump if used // Change links so we coredump if used
#ifdef VL_DEBUG #ifdef VL_DEBUG
m_nodep = (AstNode*)1; m_nodep = reinterpret_cast<AstNode*>(1);
m_fallbackp = (VSymEnt*)1; m_fallbackp = reinterpret_cast<VSymEnt*>(1);
m_parentp = (VSymEnt*)1; m_parentp = reinterpret_cast<VSymEnt*>(1);
m_packagep = (AstPackage*)1; m_packagep = reinterpret_cast<AstPackage*>(1);
#endif #endif
} }
#if defined(VL_DEBUG) && !defined(VL_LEAK_CHECKS) #if defined(VL_DEBUG) && !defined(VL_LEAK_CHECKS)

View File

@ -526,14 +526,15 @@ private:
// Even if it's referencing a varref, we still make a temporary // Even if it's referencing a varref, we still make a temporary
// Else task(x,x,x) might produce incorrect results // Else task(x,x,x) might produce incorrect results
AstVarScope* outvscp AstVarScope* newvscp
= createVarScope(portp, namePrefix+"__"+portp->shortName()); = createVarScope(portp, namePrefix + "__" + portp->shortName());
portp->user2p(outvscp); portp->user2p(newvscp);
pinp->replaceWith(new AstVarRef(outvscp->fileline(), outvscp, true)); pinp->replaceWith(new AstVarRef(newvscp->fileline(), newvscp, true));
AstAssign* assp = new AstAssign(pinp->fileline(), AstAssign* assp
pinp, = new AstAssign(pinp->fileline(), pinp,
new AstVarRef(outvscp->fileline(), outvscp, false)); new AstVarRef(newvscp->fileline(), newvscp, false));
assp->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, true); // Ok if in <= block assp->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ,
true); // Ok if in <= block
// Put assignment BEHIND of all other statements // Put assignment BEHIND of all other statements
beginp->addNext(assp); beginp->addNext(assp);
} }

View File

@ -1142,9 +1142,9 @@ private:
default: nodep->v3error("Unhandled attribute type"); default: nodep->v3error("Unhandled attribute type");
} }
} else { } else {
std::pair<uint32_t, uint32_t> dimp std::pair<uint32_t, uint32_t> dimpair
= nodep->fromp()->dtypep()->skipRefp()->dimensions(true); = nodep->fromp()->dtypep()->skipRefp()->dimensions(true);
uint32_t msbdim = dimp.first + dimp.second; uint32_t msbdim = dimpair.first + dimpair.second;
if (!nodep->dimp() || msbdim < 1) { if (!nodep->dimp() || msbdim < 1) {
int dim = 1; int dim = 1;
AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(), AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(),
@ -2457,7 +2457,6 @@ private:
if (nodep->didWidthAndSet()) return; if (nodep->didWidthAndSet()) return;
AstDynArrayDType* adtypep = VN_CAST(m_vup->dtypeNullp(), DynArrayDType); AstDynArrayDType* adtypep = VN_CAST(m_vup->dtypeNullp(), DynArrayDType);
if (!adtypep) { // e.g. int a = new; if (!adtypep) { // e.g. int a = new;
if (adtypep) UINFO(1, "Got adtypep " << adtypep << endl);
nodep->v3error("dynamic new() not expected in this context (data type must be dynamic array)"); nodep->v3error("dynamic new() not expected in this context (data type must be dynamic array)");
return; return;
} }
@ -4698,11 +4697,10 @@ private:
declRange = VNumRange(); // ranged() set false declRange = VNumRange(); // ranged() set false
if (AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) { if (AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) {
declRange = adtypep->declRange(); declRange = adtypep->declRange();
if (i<dim) dtypep = adtypep->subDTypep()->skipRefp(); if (i < dim) dtypep = adtypep->subDTypep()->skipRefp();
continue; continue;
} else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) { } else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) {
declRange = adtypep->declRange(); declRange = adtypep->declRange();
if (adtypep) {} // UNUSED
break; // Sub elements don't look like arrays and can't iterate into break; // Sub elements don't look like arrays and can't iterate into
} else if (AstBasicDType* adtypep = VN_CAST(dtypep, BasicDType)) { } else if (AstBasicDType* adtypep = VN_CAST(dtypep, BasicDType)) {
if (adtypep->isRanged()) declRange = adtypep->declRange(); if (adtypep->isRanged()) declRange = adtypep->declRange();

View File

@ -40,8 +40,9 @@ private:
if (m_dataSize < point) m_dataSize = (point + 64) & ~63ULL; // Keep power of two if (m_dataSize < point) m_dataSize = (point + 64) & ~63ULL; // Keep power of two
m_dataSize *= 2; m_dataSize *= 2;
// UINFO(9, "Realloc "<<allocSize()<<" for "<<point<<" "<<cvtToHex(m_datap)<<endl); // UINFO(9, "Realloc "<<allocSize()<<" for "<<point<<" "<<cvtToHex(m_datap)<<endl);
vluint64_t* newp = (vluint64_t*)realloc(m_datap, allocSize()); vluint64_t* newp = static_cast<vluint64_t*>(realloc(m_datap, allocSize()));
if (!newp) { if (!newp) {
// cppcheck-suppress doubleFree // cppcheck 1.90 bug - realloc doesn't free on fail
free(m_datap); free(m_datap);
v3fatal("Out of memory increasing buckets"); v3fatal("Out of memory increasing buckets");
} }