Internals: Fix preincrements to reduce cppcheck warnings

This commit is contained in:
Wilson Snyder 2011-08-04 21:15:24 -04:00
parent ad53833040
commit c83f2a4abd
23 changed files with 43 additions and 45 deletions

View File

@ -86,8 +86,8 @@ private:
NameMap* m_namemapp; ///< List of names for the header
static vector<VerilatedVcd*> s_vcdVecp; ///< List of all created traces
inline size_t bufferSize() { return 256*1024; } // See below for slack calculation
inline size_t bufferInsertSize() { return 16*1024; }
inline static size_t bufferSize() { return 256*1024; } // See below for slack calculation
inline static size_t bufferInsertSize() { return 16*1024; }
void bufferFlush();
void bufferCheck() {
// Flush the write buffer if there's not enough space left for new information

View File

@ -184,7 +184,7 @@ private:
}
if (nodep->fullPragma() || nodep->priorityPragma()) {
// Simply need to add a default if there isn't one already
m_statAsFull++;
++m_statAsFull;
if (!has_default) {
nodep->addItemsp(new AstCaseItem(nodep->fileline(), NULL/*DEFAULT*/,
newFireAssert(nodep, "synthesis full_case, but non-match found")));
@ -193,7 +193,7 @@ private:
if (nodep->parallelPragma() || nodep->uniquePragma() || nodep->unique0Pragma()) {
// Need to check that one, and only one of the case items match at any moment
// If there's a default, we allow none to match, else exactly one must match
m_statAsFull++;
++m_statAsFull;
if (!has_default && !nodep->itemsp()) {
// Not parallel, but harmlessly so.
} else {
@ -241,18 +241,18 @@ private:
if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name());
newPslAssertion(nodep, nodep->propp(), nodep->sentreep(),
nodep->stmtsp(), nodep->name()); nodep=NULL;
m_statAsCover++;
++m_statAsCover;
}
virtual void visit(AstPslAssert* nodep, AstNUser*) {
nodep->iterateChildren(*this);
newPslAssertion(nodep, nodep->propp(), nodep->sentreep(),
NULL, nodep->name()); nodep=NULL;
m_statAsPsl++;
++m_statAsPsl;
}
virtual void visit(AstVAssert* nodep, AstNUser*) {
nodep->iterateChildren(*this);
newVAssertion(nodep, nodep->propp()); nodep=NULL;
m_statAsSV++;
++m_statAsSV;
}
virtual void visit(AstNodeModule* nodep, AstNUser*) {

View File

@ -452,10 +452,10 @@ private:
if (isCaseTreeFast(nodep) && v3Global.opt.oCase()) {
// It's a simple priority encoder or complete statement
// we can make a tree of statements to avoid extra comparisons
m_statCaseFast++;
++m_statCaseFast;
replaceCaseFast(nodep); nodep=NULL;
} else {
m_statCaseSlow++;
++m_statCaseSlow;
replaceCaseComplicated(nodep); nodep=NULL;
}
}

View File

@ -696,7 +696,7 @@ class GaterVisitor : public GaterBaseVisitor {
// Blow old statements from new body
GaterBodyVisitor(alwp,exprp,false);
m_statGaters++;
++m_statGaters;
if (debug()>=9) alwp->dumpTree(cout," new: ");
}

View File

@ -70,8 +70,8 @@ protected:
virtual ~CombBaseVisitor() {}
//***** optimization levels
bool emptyFunctionDeletion() { return true; }
bool duplicateFunctionCombine() { return true; }
static bool emptyFunctionDeletion() { return true; }
static bool duplicateFunctionCombine() { return true; }
// Note this is disabled, it still needed work
// Also repair it for DPI functions; when make __common need to insure proper
// flags get inherited from the old to new AstCFunc, and that AstText doesn't
@ -257,7 +257,7 @@ private:
UINFO(5," DupFunc "<<hex<<V3Hash(newfuncp->user4p())<<" "<<newfuncp<<endl);
UINFO(5," and "<<hex<<V3Hash(oldfuncp->user4p())<<" "<<oldfuncp<<endl);
// Mark user3p on entire old tree, so we don't process it more
m_statCombs++;
++m_statCombs;
CombMarkVisitor visitor(oldfuncp);
m_call.replaceFunc(oldfuncp, newfuncp);
oldfuncp->unlinkFrBack();

View File

@ -97,7 +97,7 @@ private:
removep->unlinkFrBack(); pushDeletep(removep); removep=NULL;
// Remove node from comparison so don't hit it again
hashed.erase(dupit);
m_statToggleJoins++;
++m_statToggleJoins;
}
}
}

View File

@ -224,7 +224,6 @@ private:
}
//
//=== Setting/not setting boolean: __Vdlyvset__
bool sharedVset = false;
AstVarScope* setvscp;
if (nodep->user3p()) {
@ -232,9 +231,8 @@ private:
// then we told this nodep->user3 we can use its Vdlyvset rather than making a new one.
// This is good for code like:
// for (i=0; i<5; i++) vector[i] <= something;
sharedVset = true;
setvscp = nodep->user3p()->castNode()->castVarScope();
m_statSharedSet++;
++m_statSharedSet;
} else { // Create new one
string setvarname = (string("__Vdlyvset__")+oldvarp->shortName()+"__v"+cvtToStr(modVecNum));
setvscp = createVarSc(varrefp->varScopep(), setvarname, 1);

View File

@ -535,7 +535,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) {
AstNode* substp = okVisitor.substTree();
if (debug()>=5) logicp->dumpTree(cout,"\telimVar: ");
if (debug()>=5) substp->dumpTree(cout,"\t subst: ");
m_statSigs++;
++m_statSigs;
while (V3GraphEdge* edgep = vvertexp->outBeginp()) {
GateLogicVertex* consumeVertexp = dynamic_cast<GateLogicVertex*>(edgep->top());
AstNode* consumerp = consumeVertexp->nodep();
@ -557,7 +557,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) {
}
// Remove the edge
edgep->unlinkDelete(); edgep=NULL;
m_statRefs++;
++m_statRefs;
}
// Remove input links
while (V3GraphEdge* edgep = vvertexp->inBeginp()) {

View File

@ -70,7 +70,7 @@ 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
int debug() { return 0; }
static int debug() { return 0; }
// METHODS
DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); }
@ -94,7 +94,7 @@ private:
}
// Hashing
uint32_t hashVertex(V3GraphVertex* vertexp) {
static uint32_t hashVertex(V3GraphVertex* vertexp) {
union { void* up; struct {uint32_t upper; uint32_t lower;} l;} u;
u.l.upper=0; u.l.lower=0; u.up=vertexp;
return u.l.upper ^ u.l.lower;
@ -362,7 +362,7 @@ void DfaGraph::nfaToDfa() {
class DfaGraphReduce : GraphAlg {
private:
// METHODS
int debug() { return 0; }
static int debug() { return 0; }
DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); }
bool isDead(DfaVertex* vertexp) {
@ -507,7 +507,7 @@ private:
DfaVertex* m_tempNewerReject;
// METHODS
int debug() { return 9; }
static int debug() { return 9; }
DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); }
void add_complement_edges() {

View File

@ -106,7 +106,7 @@ private:
if (m_cellp) nodep->v3error("Cloning should have already been done bottom-up");
UINFO(5," Inline CELL "<<nodep<<endl);
UINFO(5," To MOD "<<m_modp<<endl);
m_statCells++;
++m_statCells;
// Before cloning simplify pin assignments
// Better off before, as if module has multiple instantiations

View File

@ -157,7 +157,7 @@ private:
// Mark so LifePostElimVisitor will get it
rhsp->varScopep()->user4p(lhsp->varScopep());
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
m_statAssnDel++;
++m_statAssnDel;
}
}
}

View File

@ -141,7 +141,7 @@ private:
&& nodep->user1p()) { // Single cfunc
// We don't need to test for tracing; it would be in the tracefunc if it was needed
UINFO(4," ModVar->BlkVar "<<nodep<<endl);
m_statLocVars++;
++m_statLocVars;
AstCFunc* newfuncp = nodep->user1p()->castNode()->castCFunc();
nodep->unlinkFrBack();
newfuncp->addInitsp(nodep);

View File

@ -416,9 +416,9 @@ bool V3Number::displayedFmtLegal(char format) {
string V3Number::displayed(const string& vformat) const {
string::const_iterator pos = vformat.begin();
UASSERT(pos != vformat.end() && pos[0]=='%', "display with non format argument "<<*this);
pos++;
++pos;
string fmtsize;
for (; pos != vformat.end() && (isdigit(pos[0]) || pos[0]=='.'); pos++) {
for (; pos != vformat.end() && (isdigit(pos[0]) || pos[0]=='.'); ++pos) {
fmtsize += pos[0];
}
string str;

View File

@ -127,7 +127,7 @@ struct V3PreProcImp : public V3PreProc {
ps_DEFNAME_IFDEF, ps_DEFNAME_IFNDEF, ps_DEFNAME_ELSIF,
ps_DEFFORM, ps_DEFVALUE, ps_DEFPAREN, ps_DEFARG,
ps_INCNAME, ps_ERRORNAME, ps_JOIN, ps_STRIFY };
const char* procStateName(ProcState s) {
static const char* procStateName(ProcState s) {
static const char* states[]
= {"ps_TOP",
"ps_DEFNAME_UNDEF", "ps_DEFNAME_DEFINE",

View File

@ -67,10 +67,10 @@ public:
// CONTROL METHODS
// These options control how the parsing proceeds
int keepComments() { return 2; } // Return comments, 0=no, 1=yes, 2=callback
bool keepWhitespace() { return false; }
bool lineDirectives() { return true; } // Insert `line directives
bool pedantic() { return false; } // Obey standard; Don't substitute `error
static int keepComments() { return 2; } // Return comments, 0=no, 1=yes, 2=callback
static bool keepWhitespace() { return false; }
static bool lineDirectives() { return true; } // Insert `line directives
static bool pedantic() { return false; } // Obey standard; Don't substitute `error
static bool optPsl();
// CALLBACK METHODS

View File

@ -413,7 +413,7 @@ private:
newListp = newListp->addNext(nextp);
}
if (splitAlwaysp) {
m_statSplits++;
++m_statSplits;
AstAlways* alwaysp = new AstAlways(newListp->fileline(), NULL, NULL);
addAfterp->addNextHere(alwaysp); addAfterp=alwaysp;
alwaysp->addStmtp(newListp);

View File

@ -185,7 +185,7 @@ private:
// Now isolate the always
if (m_splitVscp) {
splitAlways(nodep);
m_statSplits++;
++m_statSplits;
} else {
nodep->user1(true);
}

View File

@ -309,7 +309,7 @@ private:
if (debug()>5) newp->dumpTree(cout," w_new: ");
nodep->replaceWith(newp);
pushDeletep(nodep); nodep=NULL;
m_statSubsts++;
++m_statSubsts;
}
virtual void visit(AstWordSel* nodep, AstNUser*) {
nodep->rhsp()->accept(*this);

View File

@ -176,8 +176,8 @@ public:
private:
void createTable(AstAlways* nodep) {
// We've determined this table of nodes is optimizable, do it.
m_modTables++;
m_statTablesCre++;
++m_modTables;
++m_statTablesCre;
// Index into our table
AstVar* indexVarp = new AstVar (nodep->fileline(), AstVarType::BLOCKTEMP,

View File

@ -484,7 +484,7 @@ private:
nodep->code(m_code);
m_code += nodep->codeInc();
m_statUniqCodes += nodep->codeInc();
m_statUniqSigs++;
++m_statUniqSigs;
}
return nodep->code();
}
@ -517,7 +517,7 @@ private:
if (!codePreassigned) {
// Add to trace cfuncs
if (needChg) {
m_statChgSigs++;
++m_statChgSigs;
incAddp = nodep->cloneTree(true);
}

View File

@ -137,12 +137,12 @@ private:
if (showname.substr(0,4) == "TOP ") showname.replace(0,4,"");
if (!m_initSubFuncp) nodep->v3fatalSrc("NULL");
if (varIgnoreTrace(varp)) {
m_statIgnSigs++;
++m_statIgnSigs;
m_initSubFuncp->addStmtsp(
new AstComment(nodep->fileline(),
"Tracing: "+showname+" // Ignored: "+varIgnoreTrace(varp)));
} else {
m_statSigs++;
++m_statSigs;
AstNode* valuep = NULL;
if (nodep->valuep()) valuep=nodep->valuep()->cloneTree(true);
else valuep = new AstVarRef(nodep->fileline(), nodep, false);

View File

@ -289,7 +289,7 @@ private:
AstVar* newvarp
= new AstVar (nodep->fileline(), AstVarType::XTEMP, newvarname,
AstLogicPacked(), nodep->width());
m_statUnkVars++;
++m_statUnkVars;
AstNRelinker replaceHandle;
nodep->unlinkFrBack(&replaceHandle);
AstNodeVarRef* newref1p = new AstVarRef(nodep->fileline(), newvarp, false);

View File

@ -259,7 +259,7 @@ private:
loopValue.opAssign(numInit);
AstNode* newbodysp = NULL;
m_statLoops++;
++m_statLoops;
if (stmtsp) {
int times = 0;
while (1) {
@ -287,7 +287,7 @@ private:
if (newbodysp) newbodysp->addNext(oneloopp);
else newbodysp = oneloopp;
m_statIters++;
++m_statIters;
if (++times > unrollCount()*3) {
nodep->v3error("Loop unrolling took too long; probably this is an infinite loop, or set --unroll-count above "<<unrollCount());
break;