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 NameMap* m_namemapp; ///< List of names for the header
static vector<VerilatedVcd*> s_vcdVecp; ///< List of all created traces static vector<VerilatedVcd*> s_vcdVecp; ///< List of all created traces
inline size_t bufferSize() { return 256*1024; } // See below for slack calculation inline static size_t bufferSize() { return 256*1024; } // See below for slack calculation
inline size_t bufferInsertSize() { return 16*1024; } inline static size_t bufferInsertSize() { return 16*1024; }
void bufferFlush(); void bufferFlush();
void bufferCheck() { void bufferCheck() {
// Flush the write buffer if there's not enough space left for new information // 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()) { if (nodep->fullPragma() || nodep->priorityPragma()) {
// Simply need to add a default if there isn't one already // Simply need to add a default if there isn't one already
m_statAsFull++; ++m_statAsFull;
if (!has_default) { if (!has_default) {
nodep->addItemsp(new AstCaseItem(nodep->fileline(), NULL/*DEFAULT*/, nodep->addItemsp(new AstCaseItem(nodep->fileline(), NULL/*DEFAULT*/,
newFireAssert(nodep, "synthesis full_case, but non-match found"))); newFireAssert(nodep, "synthesis full_case, but non-match found")));
@ -193,7 +193,7 @@ private:
if (nodep->parallelPragma() || nodep->uniquePragma() || nodep->unique0Pragma()) { if (nodep->parallelPragma() || nodep->uniquePragma() || nodep->unique0Pragma()) {
// Need to check that one, and only one of the case items match at any moment // 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 // If there's a default, we allow none to match, else exactly one must match
m_statAsFull++; ++m_statAsFull;
if (!has_default && !nodep->itemsp()) { if (!has_default && !nodep->itemsp()) {
// Not parallel, but harmlessly so. // Not parallel, but harmlessly so.
} else { } else {
@ -241,18 +241,18 @@ private:
if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name()); if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name());
newPslAssertion(nodep, nodep->propp(), nodep->sentreep(), newPslAssertion(nodep, nodep->propp(), nodep->sentreep(),
nodep->stmtsp(), nodep->name()); nodep=NULL; nodep->stmtsp(), nodep->name()); nodep=NULL;
m_statAsCover++; ++m_statAsCover;
} }
virtual void visit(AstPslAssert* nodep, AstNUser*) { virtual void visit(AstPslAssert* nodep, AstNUser*) {
nodep->iterateChildren(*this); nodep->iterateChildren(*this);
newPslAssertion(nodep, nodep->propp(), nodep->sentreep(), newPslAssertion(nodep, nodep->propp(), nodep->sentreep(),
NULL, nodep->name()); nodep=NULL; NULL, nodep->name()); nodep=NULL;
m_statAsPsl++; ++m_statAsPsl;
} }
virtual void visit(AstVAssert* nodep, AstNUser*) { virtual void visit(AstVAssert* nodep, AstNUser*) {
nodep->iterateChildren(*this); nodep->iterateChildren(*this);
newVAssertion(nodep, nodep->propp()); nodep=NULL; newVAssertion(nodep, nodep->propp()); nodep=NULL;
m_statAsSV++; ++m_statAsSV;
} }
virtual void visit(AstNodeModule* nodep, AstNUser*) { virtual void visit(AstNodeModule* nodep, AstNUser*) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -70,7 +70,7 @@ private:
// MEMBERS // MEMBERS
uint32_t m_step; // Processing step, so we can avoid clearUser all the time 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 HashMap m_hashMap; // Dfa Vertex for each set of NFA vertexes
int debug() { return 0; } static int debug() { return 0; }
// METHODS // METHODS
DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); } DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); }
@ -94,7 +94,7 @@ private:
} }
// Hashing // Hashing
uint32_t hashVertex(V3GraphVertex* vertexp) { static uint32_t hashVertex(V3GraphVertex* vertexp) {
union { void* up; struct {uint32_t upper; uint32_t lower;} l;} u; union { void* up; struct {uint32_t upper; uint32_t lower;} l;} u;
u.l.upper=0; u.l.lower=0; u.up=vertexp; u.l.upper=0; u.l.lower=0; u.up=vertexp;
return u.l.upper ^ u.l.lower; return u.l.upper ^ u.l.lower;
@ -362,7 +362,7 @@ void DfaGraph::nfaToDfa() {
class DfaGraphReduce : GraphAlg { class DfaGraphReduce : GraphAlg {
private: private:
// METHODS // METHODS
int debug() { return 0; } static int debug() { return 0; }
DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); } DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); }
bool isDead(DfaVertex* vertexp) { bool isDead(DfaVertex* vertexp) {
@ -507,7 +507,7 @@ private:
DfaVertex* m_tempNewerReject; DfaVertex* m_tempNewerReject;
// METHODS // METHODS
int debug() { return 9; } static int debug() { return 9; }
DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); } DfaGraph* graphp() { return static_cast<DfaGraph*>(m_graphp); }
void add_complement_edges() { void add_complement_edges() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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