From eafed88a6ef89341bb5d152290d89693c19c9c03 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 25 Jan 2020 10:19:59 -0500 Subject: [PATCH] Internals: Add assertions. No functional change intended. --- src/V3Descope.cpp | 1 + src/V3Graph.h | 1 + src/V3Life.cpp | 2 +- src/V3LinkDot.cpp | 2 +- src/V3Order.cpp | 1 + src/V3Tristate.cpp | 7 +++++-- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index bd80c51f4..5a1635586 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -104,6 +104,7 @@ private: // // V3Combine wouldn't likely be able to combine top-level // routines anyway, so there's no harm in keeping these static. + UASSERT_OBJ(m_modp, scopep, "Scope not under module"); if (m_modp->isTop()) relativeRefOk = false; // // Use absolute refs if this scope is the only instance of the module. diff --git a/src/V3Graph.h b/src/V3Graph.h index c16e38626..2af27c93c 100644 --- a/src/V3Graph.h +++ b/src/V3Graph.h @@ -104,6 +104,7 @@ public: // METHODS void clear(); // Empty it of all vertices/edges, as if making a new object void clearColors(); + bool empty() const { return m_vertices.empty(); } V3GraphVertex* verticesBeginp() const { return m_vertices.begin(); } diff --git a/src/V3Life.cpp b/src/V3Life.cpp index f575d0526..44d86ab18 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -420,7 +420,7 @@ private: } } virtual void visit(AstCFunc* nodep) VL_OVERRIDE { - //UINFO(4," CCALL "<entryPoint()) return; m_tracingCall = false; if (nodep->dpiImport() && !nodep->pure()) { diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index f2a5c6dde..5f2d0089e 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -400,7 +400,7 @@ public: VSymEnt* getScopeSym(AstScope* nodep) { NameScopeSymMap::iterator it = m_nameScopeSymMap.find(nodep->name()); UASSERT_OBJ(it != m_nameScopeSymMap.end(), nodep, - "Scope never assigned a symbol entry?"); + "Scope never assigned a symbol entry '" << nodep->name() << "'"); return it->second; } void implicitOkAdd(AstNodeModule* nodep, const string& varname) { diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 48474d564..430490054 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -1036,6 +1036,7 @@ private: } virtual void visit(AstVarScope* nodep) VL_OVERRIDE { // Create links to all input signals + UASSERT_OBJ(m_modp, nodep, "Scope not under module"); if (m_modp->isTop() && nodep->varp()->isNonOutput()) { OrderVarVertex* varVxp = newVarUserVertex(nodep, WV_STD); new OrderEdge(&m_graph, m_inputsVxp, varVxp, WEIGHT_INPUT); diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index b349fa296..85cba19b8 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -136,6 +136,7 @@ public: // CONSTRUCTORS TristateGraph() { clear(); } virtual ~TristateGraph() { clear(); } + VL_UNCOPYABLE(TristateGraph); private: // METHODS @@ -212,6 +213,7 @@ private: public: // METHODS + bool empty() const { return m_graph.empty(); } void clear() { for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp=itp->verticesNextp()) { TristateVertex* vvertexp = static_cast(itp); @@ -1311,7 +1313,8 @@ class TristateVisitor : public TristateBaseVisitor { bool origGraphing = m_graphing; int origUnique = m_unique; VarMap origLhsmap = m_lhsmap; - TristateGraph origTgraph = m_tgraph; + // Not preserved, needs pointer instead: TristateGraph origTgraph = m_tgraph; + UASSERT_OBJ(m_tgraph.empty(), nodep, "Unsupported: NodeModule under NodeModule"); { // Clear state m_graphing = false; @@ -1337,7 +1340,7 @@ class TristateVisitor : public TristateBaseVisitor { m_graphing = origGraphing; m_unique = origUnique; m_lhsmap = origLhsmap; - m_tgraph = origTgraph; + m_tgraph.clear(); // Recursion not supported } virtual void visit(AstNodeFTask* nodep) VL_OVERRIDE {