Internals: Fix GCC8 cppcheck warnings. No functional change.

This commit is contained in:
Wilson Snyder 2018-02-07 19:31:21 -05:00
parent 32859d9fc2
commit 22573d238b
15 changed files with 24 additions and 21 deletions

View File

@ -66,7 +66,7 @@ extern IData VL_FOPEN_NI(const std::string& filename, IData mode) VL_MT_SAFE;
extern void VL_READMEM_N(bool hex, int width, int depth, int array_lsb, int fnwords,
const std::string& ofilename, void* memp, IData start, IData end) VL_MT_SAFE;
extern IData VL_SSCANF_INX(int lbits, const std::string& ld, const char* formatp, ...) VL_MT_SAFE;
extern void VL_SFORMAT_X(int obits_ignored, std::string &output, const char* formatp, ...) VL_MT_SAFE;
extern void VL_SFORMAT_X(int obits_ignored, std::string& output, const char* formatp, ...) VL_MT_SAFE;
extern std::string VL_SFORMATF_NX(const char* formatp, ...) VL_MT_SAFE;
extern IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rdp) VL_MT_SAFE;
inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, IData& rdr) VL_MT_SAFE {

View File

@ -459,7 +459,7 @@ public:
m_errorInfo.level = level;
return this;
}
void setMessage(std::string file, PLI_INT32 line, std::string message, ...) {
void setMessage(std::string file, PLI_INT32 line, const std::string& message, ...) {
static VL_THREAD_LOCAL std::string filehold;
va_list args;
va_start(args, message);

View File

@ -77,7 +77,8 @@ public:
m_numStmts += 1;
}
V3CCtorsVisitor(AstNodeModule* nodep, string basename, string argsp="", string callargsp="",
V3CCtorsVisitor(AstNodeModule* nodep, const string& basename,
const string& argsp="", const string& callargsp="",
const string& stmt="") {
m_basename = basename;
m_argsp = argsp;

View File

@ -144,7 +144,7 @@ V3ConfigIgnores V3ConfigIgnores::s_singleton;
//######################################################################
// V3Config
void V3Config::addIgnore(V3ErrorCode code, bool on, string filename, int min, int max) {
void V3Config::addIgnore(V3ErrorCode code, bool on, const string& filename, int min, int max) {
if (filename=="*") {
FileLine::globalWarnOff(code,!on);
} else {

View File

@ -30,7 +30,7 @@
class V3Config {
public:
static void addIgnore(V3ErrorCode code, bool on, string filename, int min, int max);
static void addIgnore(V3ErrorCode code, bool on, const string& filename, int min, int max);
static void applyIgnores(FileLine* filelinep);
};

View File

@ -978,7 +978,6 @@ class EmitCImp : EmitCStmts {
void emitStaticDecl(AstNodeModule* modp);
void emitWrapEval(AstNodeModule* modp);
void emitInt(AstNodeModule* modp);
void writeMakefile(string filename);
public:
EmitCImp() {

View File

@ -69,7 +69,12 @@ private:
// MEMBERS
uint32_t m_step; // Processing step, so we can avoid clearUser all the time
HashMap m_hashMap; // Dfa Vertex for each set of NFA vertexes
#ifdef VL_CPPCHECK
static int debug() { return 9; }
#else
static int debug() { return 0; }
#endif
// METHODS
DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); }

View File

@ -604,7 +604,7 @@ class LinkDotFindVisitor : public AstNVisitor {
// METHODS
int debug() { return LinkDotState::debug(); }
virtual AstConst* parseParamLiteral(FileLine* fl, string literal) {
virtual AstConst* parseParamLiteral(FileLine* fl, const string& literal) {
bool success = false;
if (literal[0] == '"') {
// This is a string
@ -2110,10 +2110,8 @@ private:
}
dotSymp = m_statep->findDotted(dotSymp, nodep->dotted(), baddot, okSymp); // Maybe NULL
}
VSymEnt* foundp = NULL;
AstNodeFTask* taskp = NULL;
foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot);
taskp = foundp ? foundp->nodep()->castNodeFTask() : NULL; // Maybe NULL
VSymEnt* foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot);
AstNodeFTask* taskp = foundp ? foundp->nodep()->castNodeFTask() : NULL; // Maybe NULL
if (taskp) {
nodep->taskp(taskp);
nodep->packagep(foundp->packagep());

View File

@ -66,6 +66,7 @@ protected:
int m_stdFuncAsn:1; // Found simple assignment
int m_done:1; // Removed
};
// cppcheck-suppress unusedStructMember
uint32_t m_flags;
VarFlags(AstNode* nodep) { m_flags = nodep->user2(); }
void setNodeFlags(AstNode* nodep) { nodep->user2(m_flags); }

View File

@ -155,11 +155,11 @@ void V3Options::addParameter(const string& paramline, bool allowPlus) {
}
}
bool V3Options::hasParameter(string name) {
bool V3Options::hasParameter(const string& name) {
return m_parameters.find(name) != m_parameters.end();
}
string V3Options::parameter(string name) {
string V3Options::parameter(const string& name) {
string value = m_parameters.find(name)->second;
m_parameters.erase(m_parameters.find(name));
return value;

View File

@ -293,8 +293,8 @@ class V3Options {
const V3StringList& forceIncs() const { return m_forceIncs; }
const V3LangCode& defaultLanguage() const { return m_defaultLanguage; }
bool hasParameter(string name);
string parameter(string name);
bool hasParameter(const string& name);
string parameter(const string& name);
void checkParameters();
bool isFuture(const string& flag) const;

View File

@ -795,7 +795,7 @@ private:
makePortList(nodep, rtnvarp, dpip);
}
bool duplicatedDpiProto(AstNodeFTask* nodep, string dpiproto) {
bool duplicatedDpiProto(AstNodeFTask* nodep, const string& dpiproto) {
// Only create one DPI extern prototype for each specified cname
// as it's legal for the user to attach multiple tasks to one dpi cname
DpiNames::iterator iter = m_dpiNames.find(nodep->cname());

View File

@ -455,7 +455,7 @@ private:
public:
// CONSTUCTORS
UnrollVisitor(AstNode* nodep, bool generate, string beginName) {
UnrollVisitor(AstNode* nodep, bool generate, const string& beginName) {
m_forVarp = NULL;
m_forVscp = NULL;
m_ignoreIncp = NULL;
@ -481,7 +481,7 @@ void V3Unroll::unrollAll(AstNetlist* nodep) {
V3Global::dumpCheckGlobalTree("unroll", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3);
}
void V3Unroll::unrollGen(AstNodeFor* nodep, string beginName) {
void V3Unroll::unrollGen(AstNodeFor* nodep, const string& beginName) {
UINFO(2,__FUNCTION__<<": "<<endl);
UnrollVisitor visitor (nodep, true, beginName);
}

View File

@ -30,7 +30,7 @@
class V3Unroll {
public:
static void unrollAll(AstNetlist* nodep);
static void unrollGen(AstNodeFor* nodep, string beginName);
static void unrollGen(AstNodeFor* nodep, const string& beginName);
};
#endif // Guard

View File

@ -3155,8 +3155,7 @@ private:
} else {
bool bad = widthBad(underp,nodep->findLogicBoolDType());
if (bad) {
bool warnOn = true; // Not used
if (warnOn) {
{ // if (warnOn), but not needed here
if (debug()>4) nodep->backp()->dumpTree(cout," back: ");
nodep->v3warn(WIDTH,"Logical Operator "<<nodep->prettyTypeName()
<<" expects 1 bit on the "<<side<<", but "<<side<<"'s "