From 28eb5b9bc4082933b79b0d4f3ac0fb09eb021def Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 19 Jan 2010 21:30:12 -0500 Subject: [PATCH] Internals: Eliminate extra constructor call in FileLine warn off, and commentary. --- src/V3Ast.h | 1 + src/V3Error.cpp | 4 ++-- src/V3Error.h | 17 ++++++++++++----- src/V3Inline.cpp | 5 +++-- src/V3Link.cpp | 2 +- src/V3Order.cpp | 4 ++-- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index 10aa07592..c02be0217 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -781,6 +781,7 @@ public: string prettyName() const { return prettyName(name()); } string prettyTypeName() const; // "VARREF name" for error messages FileLine* fileline() const { return m_fileline; } + void fileline(FileLine* fl) { m_fileline=fl; } int width() const { return m_width; } bool width1() const { return width()==1; } int widthWords() const { return VL_WORDS_I(width()); } diff --git a/src/V3Error.cpp b/src/V3Error.cpp index 460e76a4d..65a3402e1 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -174,11 +174,11 @@ bool FileLine::warnIsOff(V3ErrorCode code) const { 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". for (int codei=V3ErrorCode::FIRST_WARN; codeiwarnIsOff(code)) { this->warnOff(code, true); } } diff --git a/src/V3Error.h b/src/V3Error.h index 4daebb7c1..7d2a68ab4 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -243,6 +243,7 @@ public: FileLine (FileLine* fromp) { m_lineno=fromp->lineno(); m_filename = fromp->filename(); m_warnOn=fromp->m_warnOn; } FileLine (EmptySecret); ~FileLine() { } + static void deleteAllRemaining(); #ifdef VL_LEAK_CHECKS static void* operator new(size_t size); static void operator delete(void* obj, size_t size); @@ -258,21 +259,27 @@ public: bool warnIsOff(V3ErrorCode code) const; void warnLintOff(bool flag); void warnStateFrom(const FileLine& from) { m_warnOn=from.m_warnOn; } - void warnStateInherit(const FileLine& from); void warnResetDefault() { warnStateFrom(s_defaultFileLine); } - // Boolean ACCESSORS/METHODS + // Specific flag ACCESSORS/METHODS bool coverageOn() const { return m_warnOn.test(V3ErrorCode::I_COVERAGE); } void coverageOn(bool flag) { m_warnOn.set(V3ErrorCode::I_COVERAGE,flag); } bool tracingOn() const { return m_warnOn.test(V3ErrorCode::I_TRACING); } void tracingOn(bool flag) { m_warnOn.set(V3ErrorCode::I_TRACING,flag); } - // METHODS - void v3errorEnd(ostringstream& str); + // METHODS - Called from netlist + // 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) { 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); diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 6f4f20923..d0f12e54d 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -186,8 +186,9 @@ private: m_modp->addStmtp(new AstAssignAlias(nodep->fileline(), new AstVarRef(nodep->fileline(), nodep, true), new AstVarRef(nodep->fileline(), exprvarrefp->varp(), false))); - nodep->fileline()->warnStateInherit(exprvarrefp->varp()->fileline()); - exprvarrefp->varp()->fileline()->warnStateInherit(nodep->fileline()); + AstNode* nodebp=exprvarrefp->varp(); + nodep ->fileline()->modifyStateInherit(nodebp->fileline()); + nodebp->fileline()->modifyStateInherit(nodep ->fileline()); } } // Variable under the inline cell, need to rename to avoid conflicts diff --git a/src/V3Link.cpp b/src/V3Link.cpp index d99a16398..75a0a57bb 100644 --- a/src/V3Link.cpp +++ b/src/V3Link.cpp @@ -286,7 +286,7 @@ private: if ((findvarp->isIO() && nodep->isSignal()) || (findvarp->isSignal() && nodep->isIO())) { findvarp->combineType(nodep); - findvarp->fileline()->warnStateInherit(nodep->fileline()); + nodep->fileline()->modifyStateInherit(nodep->fileline()); nodep->unlinkFrBack()->deleteTree(); nodep=NULL; } else { nodep->v3error("Duplicate declaration of signal: "<prettyName()); diff --git a/src/V3Order.cpp b/src/V3Order.cpp index e4b591281..a2aca0097 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -399,7 +399,7 @@ private: } else if (nodep->varp()->isSigPublic()) { nodep->v3warn(UNOPT,"Signal unoptimizable: Feedback to public clock or circular logic: "<prettyName()); 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. bool tempWeight = (edgep && edgep->weight()==0); 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 nodep->v3warn(UNOPTFLAT,"Signal unoptimizable: Feedback to clock or circular logic: "<prettyName()); 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. bool tempWeight = (edgep && edgep->weight()==0); if (tempWeight) edgep->weight(1); // Else the below loop detect can't see the loop