Fix GCC lint complaint of calling NULL->cloneTree. No functional change intended.

This commit is contained in:
Wilson Snyder 2018-03-10 17:44:17 -05:00
parent 2c30aecc5b
commit d08a91b71e
6 changed files with 21 additions and 8 deletions

View File

@ -646,7 +646,7 @@ AstNode* AstNode::cloneTreeIterList() {
}
AstNode* AstNode::cloneTree(bool cloneNextLink) {
if (!this) return NULL; // verilog.y relies on this
UDEBUGONLY(UASSERT(dynamic_cast<AstNode*>(this),"this should not be NULL"););
this->debugTreeChange("-cloneThs: ", __LINE__, cloneNextLink);
cloneClearTree();
AstNode* newp;

View File

@ -1312,6 +1312,8 @@ public:
virtual void addBeforeStmt(AstNode* newp, AstNode* belowp); // When calling, "this" is second argument
// METHODS - Iterate on a tree
static AstNode* cloneTreeNull(AstNode* nodep, bool cloneNextLink) { // Clone or return NULL if NULL
return nodep ? nodep->cloneTree(cloneNextLink) : NULL; }
AstNode* cloneTree(bool cloneNextLink);
bool gateTree() { return gateTreeIter(); } // Is tree isGateOptimizable?
bool sameTree(const AstNode* node2p) const; // Does tree of this == node2p?
@ -1373,6 +1375,8 @@ inline void AstNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); }
#define ASTNODE_BASE_FUNCS(name) \
virtual ~Ast ##name() {} \
static Ast ##name * cloneTreeNull(Ast ##name * nodep, bool cloneNextLink) { \
return nodep ? nodep->cloneTree(cloneNextLink) : NULL; } \
Ast ##name * cloneTree(bool cloneNext) { return static_cast<Ast ##name *>(AstNode::cloneTree(cloneNext)); } \
Ast ##name * clonep() const { return static_cast<Ast ##name *>(AstNode::clonep()); }

View File

@ -30,9 +30,11 @@
#define ASTNODE_NODE_FUNCS(name) \
virtual ~Ast ##name() {} \
virtual void accept(AstNVisitor& v) { v.visit(this); } \
virtual AstType type() const { return AstType::at ## name; } \
virtual AstNode* clone() { return new Ast ##name (*this); } \
virtual void accept(AstNVisitor& v) { v.visit(this); } \
static Ast ##name * cloneTreeNull(Ast ##name * nodep, bool cloneNextLink) { \
return nodep ? nodep->cloneTree(cloneNextLink) : NULL; } \
Ast ##name * cloneTree(bool cloneNext) { return static_cast<Ast ##name *>(AstNode::cloneTree(cloneNext)); } \
Ast ##name * clonep() const { return static_cast<Ast ##name *>(AstNode::clonep()); }

View File

@ -383,7 +383,7 @@ private:
} else {
UINFO(4,"Autoflush "<<nodep<<endl);
nodep->addNextHere(new AstFFlush(nodep->fileline(),
nodep->filep()->cloneTree(true)));
AstNode::cloneTreeNull(nodep->filep(), true)));
}
}
}

View File

@ -361,7 +361,7 @@ private:
AstNode* createInlinedFTask(AstNodeFTaskRef* refp, const string& namePrefix, AstVarScope* outvscp) {
// outvscp is the variable for functions only, if NULL, it's a task
if (!refp->taskp()) refp->v3fatalSrc("Unlinked?");
AstNode* newbodysp = refp->taskp()->stmtsp()->cloneTree(true); // Maybe NULL
AstNode* newbodysp = AstNode::cloneTreeNull(refp->taskp()->stmtsp(), true); // Maybe NULL
AstNode* beginp = new AstComment(refp->fileline(), (string)("Function: ")+refp->name());
if (newbodysp) beginp->addNext(newbodysp);
if (debug()>=9) { beginp->dumpTreeAndNext(cout,"-newbegi:"); }

View File

@ -1444,7 +1444,8 @@ member_decl_assignment<memberp>: // Derived from IEEE: variable_decl_assignment
// // At present we allow only packed structures/unions. So this is different from variable_decl_assignment
id variable_dimensionListE
{ if ($2) $2->v3error("Unsupported: Unpacked array in packed struct/union");
$$ = new AstMemberDType($<fl>1, *$1, VFlagChildDType(), GRAMMARP->m_memDTypep->cloneTree(true));
$$ = new AstMemberDType($<fl>1, *$1, VFlagChildDType(),
AstNodeDType::cloneTreeNull(GRAMMARP->m_memDTypep, true));
PARSEP->tagNodep($$);
}
| id variable_dimensionListE '=' variable_declExpr
@ -2102,10 +2103,12 @@ instnameList<nodep>:
instnameParen<cellp>:
// // Must clone m_instParamp as may be comma'ed list of instances
id instRangeE '(' cellpinList ')' { $$ = new AstCell($<fl>1,*$1,GRAMMARP->m_instModule,$4, GRAMMARP->m_instParamp->cloneTree(true),
id instRangeE '(' cellpinList ')' { $$ = new AstCell($<fl>1, *$1, GRAMMARP->m_instModule, $4,
AstPin::cloneTreeNull(GRAMMARP->m_instParamp, true),
GRAMMARP->scrubRange($2));
$$->trace(GRAMMARP->allTracingOn($<fl>1)); }
| id instRangeE { $$ = new AstCell($<fl>1,*$1,GRAMMARP->m_instModule,NULL,GRAMMARP->m_instParamp->cloneTree(true),
| id instRangeE { $$ = new AstCell($<fl>1, *$1, GRAMMARP->m_instModule, NULL,
AstPin::cloneTreeNull(GRAMMARP->m_instParamp, true),
GRAMMARP->scrubRange($2));
$$->trace(GRAMMARP->allTracingOn($<fl>1)); }
//UNSUP instRangeE '(' cellpinList ')' { UNSUP } // UDP
@ -2375,7 +2378,11 @@ statement_item<nodep>: // IEEE: statement_item
// // for's first ';' is in for_initalization
| yFOR '(' for_initialization expr ';' for_stepE ')' stmtBlock
{ $$ = new AstBegin($1,"",$3); $3->addNext(new AstWhile($1, $4,$8,$6)); }
| yDO stmtBlock yWHILE '(' expr ')' ';' { $$ = $2->cloneTree(true); $$->addNext(new AstWhile($1,$5,$2));}
| yDO stmtBlock yWHILE '(' expr ')' ';' { if ($2) {
$$ = $2->cloneTree(true);
$$->addNext(new AstWhile($1,$5,$2));
}
else $$ = new AstWhile($1,$5,NULL); }
// // IEEE says array_identifier here, but dotted accepted in VMM and 1800-2009
| yFOREACH '(' idClassForeach '[' loop_variables ']' ')' stmtBlock { $$ = new AstForeach($1,$3,$5,$8); }
//