diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 6388097c1..f53982f0c 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -290,7 +290,6 @@ void AstNode::addNextHere(AstNode* newp) { // Add to m_nextp on exact node passed, not at the end. // This could be at head, tail, or both (single) // New could be head of single node, or list - UDEBUGONLY(UASSERT(dynamic_cast(this),"this should not be NULL");); UASSERT(newp,"Null item passed to addNext"); UASSERT(newp->backp()==NULL,"New node (back) already assigned?"); this->debugTreeChange("-addHereThs: ", __LINE__, false); @@ -646,7 +645,6 @@ AstNode* AstNode::cloneTreeIterList() { } AstNode* AstNode::cloneTree(bool cloneNextLink) { - UDEBUGONLY(UASSERT(dynamic_cast(this),"this should not be NULL");); this->debugTreeChange("-cloneThs: ", __LINE__, cloneNextLink); cloneClearTree(); AstNode* newp; @@ -802,7 +800,6 @@ void AstNode::iterateAndNext(AstNVisitor& v) { } void AstNode::iterateListBackwards(AstNVisitor& v) { - UDEBUGONLY(UASSERT(dynamic_cast(this),"this should not be NULL");); AstNode* nodep=this; while (nodep->m_nextp) nodep=nodep->m_nextp; while (nodep) { @@ -822,13 +819,13 @@ void AstNode::iterateChildrenBackwards(AstNVisitor& v) { void AstNode::iterateAndNextConst(AstNVisitor& v) { // Keep following the current list even if edits change it - UDEBUGONLY(UASSERT(dynamic_cast(this),"this should not be NULL");); - for (AstNode* nodep=this; nodep; ) { + AstNode* nodep=this; + do { AstNode* nnextp = nodep->m_nextp; ASTNODE_PREFETCH(nnextp); nodep->accept(v); nodep = nnextp; - } + } while (nodep); } AstNode* AstNode::iterateSubtreeReturnEdits(AstNVisitor& v) { @@ -871,7 +868,6 @@ AstNode* AstNode::iterateSubtreeReturnEdits(AstNVisitor& v) { void AstNode::cloneRelinkTree() { // private: Cleanup clone() operation on whole tree. Publicly call cloneTree() instead. - UDEBUGONLY(UASSERT(dynamic_cast(this),"this should not be NULL");); for (AstNode* nodep=this; nodep; nodep=nodep->m_nextp) { if (m_dtypep && m_dtypep->clonep()) { m_dtypep = m_dtypep->clonep(); @@ -976,17 +972,14 @@ void AstNode::checkTree() { } void AstNode::dumpGdb() { // For GDB only - if (!dynamic_cast(this)) { cout<<"This=NULL"<(this)) { cout<<"This=NULL"<(this)) { - // No known cases cause this, but better than a core dump - if (debug()) UINFO(0, "-node: NULL. Please report this along with a --gdbbt backtrace as a Verilator bug.\n"); - V3Error::v3errorEnd(str); - } else if (!m_fileline) { + if (!m_fileline) { V3Error::v3errorEnd(str); } else { std::ostringstream nsstr; diff --git a/src/V3Ast.h b/src/V3Ast.h index 6afdf7a2e..c1489d7e4 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -44,10 +44,10 @@ class VFlagChildDType {}; // Used by parser.y to select constructor that sets c //###################################################################### -// (V)erilator (N)ode (is)): True if AstNode is of a a given AstType +// (V)erilator (N)ode is: True if AstNode is of a a given AstType #define VN_IS(nodep,nodetypename) (AstNode::privateIs ## nodetypename(nodep)) -// (V)erilator (N)ode (cast): Cast to given type if can; effectively dynamic_cast(nodep)(nodetypename) +// (V)erilator (N)ode cast: Cast to given type if can; effectively dynamic_cast(nodep)(nodetypename) #define VN_CAST(nodep,nodetypename) (AstNode::privateCast ## nodetypename(nodep)) #define VN_CAST_CONST(nodep,nodetypename) (AstNode::privateConstCast ## nodetypename(nodep) ) diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 28989858f..077fa1f38 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -456,7 +456,6 @@ AstNodeDType* AstNodeDType::dtypeDimensionp(int dimension) { // TODO this function should be removed in favor of recursing the dtype(), // as that allows for more complicated data types. int dim = 0; - UDEBUGONLY(UASSERT(dynamic_cast(this),"this should not be NULL");); for (AstNodeDType* dtypep=this; dtypep; ) { dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node if (AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) { @@ -491,7 +490,6 @@ AstNodeDType* AstNodeDType::dtypeDimensionp(int dimension) { uint32_t AstNodeDType::arrayUnpackedElements() { uint32_t entries=1; - UDEBUGONLY(UASSERT(dynamic_cast(this),"this should not be NULL");); for (AstNodeDType* dtypep=this; dtypep; ) { dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { @@ -510,7 +508,6 @@ std::pair AstNodeDType::dimensions(bool includeBasic) { // How many array dimensions (packed,unpacked) does this Var have? uint32_t packed = 0; uint32_t unpacked = 0; - UDEBUGONLY(UASSERT(dynamic_cast(this),"this should not be NULL");); for (AstNodeDType* dtypep=this; dtypep; ) { dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node if (const AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) {