diff --git a/src/V3Ast.h b/src/V3Ast.h index c44254d18..80efee82c 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -585,6 +585,7 @@ public: virtual int instrCount() const { return 0; } virtual V3Hash sameHash() const { return V3Hash(V3Hash::Illegal()); } // Not a node that supports it virtual bool same(AstNode* otherp) const { return true; } + virtual bool maybePointedTo() const { return false; } // Another AstNode* may have a pointer into this node, other then normal front/back/etc. virtual bool broken() const { return false; } virtual bool emitWordForm() { return false; } @@ -922,6 +923,7 @@ public: virtual ~AstNodeFTask() {} virtual void dump(ostream& str=cout); virtual string name() const { return m_name; } // * = Var name + virtual bool maybePointedTo() const { return true; } // {AstFunc only} op1 = Range output variable // op3 = Statements/Ports/Vars void name(const string& name) { m_name = name; } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 12dbcc7db..fc79a56b6 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -132,7 +132,7 @@ uint32_t AstVar::arrayElements() const { bool AstScope::broken() const { return ((m_aboveScopep && !m_aboveScopep->brokeExists()) || (m_aboveCellp && !m_aboveCellp->brokeExists()) - || !m_modp || !((AstNode*)m_modp)->brokeExists()); + || !m_modp || !m_modp->brokeExists()); } void AstScope::cloneRelink() { diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 9df92c688..1f33d1581 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -286,6 +286,7 @@ public: virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual void dump(ostream& str); virtual string name() const { return m_name; } // * = Var name + virtual bool maybePointedTo() const { return true; } AstVarType varType() const { return m_varType; } // * = Type of variable string cType() const; // Return C type: bool, uint32_t, uint64_t, etc. void combineType(AstVarType type); @@ -422,6 +423,7 @@ public: virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual void cloneRelink(); virtual bool broken() const; + virtual bool maybePointedTo() const { return true; } virtual string name() const { return m_name; } // * = Scope name void name(const string& name) { m_name = name; } string nameDotless() const; @@ -483,6 +485,7 @@ public: virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual bool broken() const { return ( (m_varp && !m_varp->brokeExists()) || (m_scopep && !m_scopep->brokeExists())); } + virtual bool maybePointedTo() const { return true; } virtual string name() const {return scopep()->name()+"->"+varp()->name();} // * = Var name virtual void dump(ostream& str); AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable @@ -607,6 +610,7 @@ public: virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual void dump(ostream& str); virtual bool broken() const { return (m_clkReqVarp && !m_clkReqVarp->brokeExists()); } + virtual bool maybePointedTo() const { return true; } virtual string name() const { return m_name; } AstNode* stmtsp() const { return op2p()->castNode(); } // op2 = List of statements AstActive* activesp() const { return op3p()->castActive(); } // op3 = List of i/sblocks @@ -651,6 +655,7 @@ public: virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual void dump(ostream& str); virtual bool broken() const { return (m_modp && !m_modp->brokeExists()); } + virtual bool maybePointedTo() const { return true; } // ACCESSORS virtual string name() const { return m_name; } // * = Cell name void name(const string& name) { m_name = name; } @@ -868,6 +873,7 @@ public: virtual AstNode* clone() { return new AstSenTree(*this); } virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual void dump(ostream& str); + virtual bool maybePointedTo() const { return true; } bool isMulti() const { return m_multi; } AstSenItem* sensesp() const { return op1p()->castSenItem(); } // op1 = Sensitivity list void addSensesp(AstSenItem* nodep) { addOp1p(nodep); } @@ -1053,6 +1059,7 @@ public: virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual void dump(ostream& str); virtual int instrCount() const { return 1+2*instrCountLd(); } + virtual bool maybePointedTo() const { return true; } int column() const { return m_column; } const string& comment() const { return m_text; } // text to insert in code const string& typeText() const { return m_typeText; } @@ -1506,6 +1513,7 @@ public: virtual AstNode* clone() { return new AstTraceDecl(*this); } virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual string name() const { return m_showname; } + virtual bool maybePointedTo() const { return true; } string showname() const { return m_showname; } // * = Var name virtual bool same(AstNode* samep) const { return false; } // Details on what we're tracing @@ -2801,6 +2809,8 @@ public: virtual AstNode* clone() { return new AstCFunc(*this); } virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); } virtual string name() const { return m_name; } + virtual bool broken() const { return ( (m_scopep && !m_scopep->brokeExists())); } + virtual bool maybePointedTo() const { return true; } virtual V3Hash sameHash() const { return V3Hash(); } virtual bool same(AstNode* samep) const { return ((funcType()==samep->castCFunc()->funcType()) && (rtnTypeVoid()==samep->castCFunc()->rtnTypeVoid()) diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index 5365fa17f..616900bac 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -81,13 +81,15 @@ private: // // so userp and friends may not be used // VISITORS virtual void visit(AstNode* nodep, AstNUser*) { - BrokenTable::add(nodep); + if (nodep->maybePointedTo()) { + BrokenTable::add(nodep); + } nodep->iterateChildren(*this); } public: // CONSTUCTORS - BrokenMarkVisitor(AstNode* nodep) { - nodep->iterateAndNext(*this, NULL); + BrokenMarkVisitor(AstNetlist* nodep) { + nodep->accept(*this); } virtual ~BrokenMarkVisitor() {} }; @@ -99,7 +101,7 @@ class BrokenCheckVisitor : public AstNVisitor { private: virtual void visit(AstNode* nodep, AstNUser*) { if (nodep->broken()) { - nodep->v3fatalSrc("Broken link in node\n"); + nodep->v3fatalSrc("Broken link in node (or something without maybePointedTo)\n"); } if (v3Global.assertWidthsSame()) { if (nodep->width() != nodep->widthMin()) { diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 8bfb59aff..63cff02b8 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1213,12 +1213,14 @@ void V3Const::constifyAll(AstNetlist* nodep) { visitor.main(nodep); } -void V3Const::constifyAllLint(AstNode* nodep) { +void V3Const::constifyAllLint(AstNetlist* nodep) { + UINFO(2,__FUNCTION__<<": "<