Internals: Eliminate extra constructor call in FileLine warn off, and commentary.

This commit is contained in:
Wilson Snyder 2010-01-19 21:30:12 -05:00
parent bb20331f9e
commit 28eb5b9bc4
6 changed files with 21 additions and 12 deletions

View File

@ -781,6 +781,7 @@ public:
string prettyName() const { return prettyName(name()); } string prettyName() const { return prettyName(name()); }
string prettyTypeName() const; // "VARREF name" for error messages string prettyTypeName() const; // "VARREF name" for error messages
FileLine* fileline() const { return m_fileline; } FileLine* fileline() const { return m_fileline; }
void fileline(FileLine* fl) { m_fileline=fl; }
int width() const { return m_width; } int width() const { return m_width; }
bool width1() const { return width()==1; } bool width1() const { return width()==1; }
int widthWords() const { return VL_WORDS_I(width()); } int widthWords() const { return VL_WORDS_I(width()); }

View File

@ -174,11 +174,11 @@ bool FileLine::warnIsOff(V3ErrorCode code) const {
return false; return false;
} }
void FileLine::warnStateInherit(const FileLine& from) { void FileLine::modifyStateInherit(const FileLine* fromp) {
// Any warnings that are off in "from", become off in "this". // Any warnings that are off in "from", become off in "this".
for (int codei=V3ErrorCode::FIRST_WARN; codei<V3ErrorCode::MAX; codei++) { for (int codei=V3ErrorCode::FIRST_WARN; codei<V3ErrorCode::MAX; codei++) {
V3ErrorCode code = (V3ErrorCode)codei; V3ErrorCode code = (V3ErrorCode)codei;
if (from.warnIsOff(code)) { if (fromp->warnIsOff(code)) {
this->warnOff(code, true); this->warnOff(code, true);
} }
} }

View File

@ -243,6 +243,7 @@ public:
FileLine (FileLine* fromp) { m_lineno=fromp->lineno(); m_filename = fromp->filename(); m_warnOn=fromp->m_warnOn; } FileLine (FileLine* fromp) { m_lineno=fromp->lineno(); m_filename = fromp->filename(); m_warnOn=fromp->m_warnOn; }
FileLine (EmptySecret); FileLine (EmptySecret);
~FileLine() { } ~FileLine() { }
static void deleteAllRemaining();
#ifdef VL_LEAK_CHECKS #ifdef VL_LEAK_CHECKS
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);
@ -258,21 +259,27 @@ public:
bool warnIsOff(V3ErrorCode code) const; bool warnIsOff(V3ErrorCode code) const;
void warnLintOff(bool flag); void warnLintOff(bool flag);
void warnStateFrom(const FileLine& from) { m_warnOn=from.m_warnOn; } void warnStateFrom(const FileLine& from) { m_warnOn=from.m_warnOn; }
void warnStateInherit(const FileLine& from);
void warnResetDefault() { warnStateFrom(s_defaultFileLine); } void warnResetDefault() { warnStateFrom(s_defaultFileLine); }
// Boolean ACCESSORS/METHODS // Specific flag ACCESSORS/METHODS
bool coverageOn() const { return m_warnOn.test(V3ErrorCode::I_COVERAGE); } bool coverageOn() const { return m_warnOn.test(V3ErrorCode::I_COVERAGE); }
void coverageOn(bool flag) { m_warnOn.set(V3ErrorCode::I_COVERAGE,flag); } void coverageOn(bool flag) { m_warnOn.set(V3ErrorCode::I_COVERAGE,flag); }
bool tracingOn() const { return m_warnOn.test(V3ErrorCode::I_TRACING); } bool tracingOn() const { return m_warnOn.test(V3ErrorCode::I_TRACING); }
void tracingOn(bool flag) { m_warnOn.set(V3ErrorCode::I_TRACING,flag); } void tracingOn(bool flag) { m_warnOn.set(V3ErrorCode::I_TRACING,flag); }
// METHODS // METHODS - Called from netlist
void v3errorEnd(ostringstream& str); // Merge warning disables from another fileline
void modifyStateInherit(const FileLine* fromp);
// Change the current fileline due to actions discovered after parsing
// and may have side effects on other nodes sharing this FileLine.
// Use only when this is intended
void modifyWarnOff(V3ErrorCode code, bool flag) { warnOff(code,flag); }
// OPERATORS
void v3errorEnd(ostringstream& str);
inline bool operator==(FileLine rhs) { inline bool operator==(FileLine rhs) {
return (m_lineno==rhs.m_lineno && m_filename==rhs.m_filename && m_warnOn==rhs.m_warnOn); return (m_lineno==rhs.m_lineno && m_filename==rhs.m_filename && m_warnOn==rhs.m_warnOn);
} }
static void deleteAllRemaining();
}; };
ostream& operator<<(ostream& os, FileLine* fileline); ostream& operator<<(ostream& os, FileLine* fileline);

View File

@ -186,8 +186,9 @@ private:
m_modp->addStmtp(new AstAssignAlias(nodep->fileline(), m_modp->addStmtp(new AstAssignAlias(nodep->fileline(),
new AstVarRef(nodep->fileline(), nodep, true), new AstVarRef(nodep->fileline(), nodep, true),
new AstVarRef(nodep->fileline(), exprvarrefp->varp(), false))); new AstVarRef(nodep->fileline(), exprvarrefp->varp(), false)));
nodep->fileline()->warnStateInherit(exprvarrefp->varp()->fileline()); AstNode* nodebp=exprvarrefp->varp();
exprvarrefp->varp()->fileline()->warnStateInherit(nodep->fileline()); nodep ->fileline()->modifyStateInherit(nodebp->fileline());
nodebp->fileline()->modifyStateInherit(nodep ->fileline());
} }
} }
// Variable under the inline cell, need to rename to avoid conflicts // Variable under the inline cell, need to rename to avoid conflicts

View File

@ -286,7 +286,7 @@ private:
if ((findvarp->isIO() && nodep->isSignal()) if ((findvarp->isIO() && nodep->isSignal())
|| (findvarp->isSignal() && nodep->isIO())) { || (findvarp->isSignal() && nodep->isIO())) {
findvarp->combineType(nodep); findvarp->combineType(nodep);
findvarp->fileline()->warnStateInherit(nodep->fileline()); nodep->fileline()->modifyStateInherit(nodep->fileline());
nodep->unlinkFrBack()->deleteTree(); nodep=NULL; nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
} else { } else {
nodep->v3error("Duplicate declaration of signal: "<<nodep->prettyName()); nodep->v3error("Duplicate declaration of signal: "<<nodep->prettyName());

View File

@ -399,7 +399,7 @@ private:
} else if (nodep->varp()->isSigPublic()) { } else if (nodep->varp()->isSigPublic()) {
nodep->v3warn(UNOPT,"Signal unoptimizable: Feedback to public clock or circular logic: "<<nodep->prettyName()); nodep->v3warn(UNOPT,"Signal unoptimizable: Feedback to public clock or circular logic: "<<nodep->prettyName());
if (!nodep->fileline()->warnIsOff(V3ErrorCode::UNOPT)) { if (!nodep->fileline()->warnIsOff(V3ErrorCode::UNOPT)) {
nodep->fileline()->warnOff(V3ErrorCode::UNOPT, true); // Complain just once nodep->fileline()->modifyWarnOff(V3ErrorCode::UNOPT, true); // Complain just once
// Give the user an example. // Give the user an example.
bool tempWeight = (edgep && edgep->weight()==0); bool tempWeight = (edgep && edgep->weight()==0);
if (tempWeight) edgep->weight(1); // Else the below loop detect can't see the loop if (tempWeight) edgep->weight(1); // Else the below loop detect can't see the loop
@ -411,7 +411,7 @@ private:
// First v3warn not inside warnIsOff so we can see the suppressions with --debug // First v3warn not inside warnIsOff so we can see the suppressions with --debug
nodep->v3warn(UNOPTFLAT,"Signal unoptimizable: Feedback to clock or circular logic: "<<nodep->prettyName()); nodep->v3warn(UNOPTFLAT,"Signal unoptimizable: Feedback to clock or circular logic: "<<nodep->prettyName());
if (!nodep->fileline()->warnIsOff(V3ErrorCode::UNOPTFLAT)) { if (!nodep->fileline()->warnIsOff(V3ErrorCode::UNOPTFLAT)) {
nodep->fileline()->warnOff(V3ErrorCode::UNOPTFLAT, true); // Complain just once nodep->fileline()->modifyWarnOff(V3ErrorCode::UNOPTFLAT, true); // Complain just once
// Give the user an example. // Give the user an example.
bool tempWeight = (edgep && edgep->weight()==0); bool tempWeight = (edgep && edgep->weight()==0);
if (tempWeight) edgep->weight(1); // Else the below loop detect can't see the loop if (tempWeight) edgep->weight(1); // Else the below loop detect can't see the loop