forked from github/verilator
Fix leak issues, bug521
This commit is contained in:
parent
4cc5943f90
commit
1b439703ff
@ -56,7 +56,7 @@ public:
|
||||
// METHODS
|
||||
static void deleted(const AstNode* nodep) {
|
||||
// Called by operator delete on any node - only if VL_LEAK_CHECKS
|
||||
if (debug()) cout<<"-nodeDel: "<<(void*)(nodep)<<endl;
|
||||
if (debug()>=9) cout<<"-nodeDel: "<<(void*)(nodep)<<endl;
|
||||
NodeMap::iterator iter = s_nodes.find(nodep);
|
||||
if (iter==s_nodes.end() || !(iter->second & FLAG_ALLOCATED)) {
|
||||
((AstNode*)(nodep))->v3fatalSrc("Deleting AstNode object that was never tracked or already deleted\n");
|
||||
@ -65,7 +65,7 @@ public:
|
||||
}
|
||||
static void addNewed(const AstNode* nodep) {
|
||||
// Called by operator new on any node - only if VL_LEAK_CHECKS
|
||||
if (debug()) cout<<"-nodeNew: "<<(void*)(nodep)<<endl;
|
||||
if (debug()>=9) cout<<"-nodeNew: "<<(void*)(nodep)<<endl;
|
||||
NodeMap::iterator iter = s_nodes.find(nodep);
|
||||
if (iter!=s_nodes.end() || (iter->second & FLAG_ALLOCATED)) {
|
||||
((AstNode*)(nodep))->v3fatalSrc("Newing AstNode object that is already allocated\n");
|
||||
@ -146,7 +146,7 @@ public:
|
||||
&& (it->first->backp() ? backs==1 : backs==0)) {
|
||||
// Use only AstNode::dump instead of the virtual one, as there
|
||||
// may be varp() and other cross links that are bad.
|
||||
if (debug()) {
|
||||
if (v3Global.opt.debugCheck()) {
|
||||
cerr<<"%Error: LeakedNode"<<(it->first->backp()?"Back: ":": ");
|
||||
((AstNode*)(it->first))->AstNode::dump(cerr);
|
||||
cerr<<endl;
|
||||
|
@ -1204,7 +1204,7 @@ private:
|
||||
AstNode* bilhsp = fromp->lhsp()->unlinkFrBack();
|
||||
//
|
||||
fromp->lhsp(new AstSel(nodep->fileline(),
|
||||
bilhsp, lsbp->cloneTree(true), widthp->cloneTree(true)));
|
||||
bilhsp, lsbp, widthp));
|
||||
fromp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(fromp); nodep->deleteTree(); nodep=NULL;
|
||||
}
|
||||
|
@ -609,6 +609,8 @@ class TristateVisitor : public TristateBaseVisitor {
|
||||
undrivenp = new AstAnd(nodep->fileline(), undrivenp,
|
||||
new AstConst(nodep->fileline(), pull));
|
||||
orp = new AstOr(nodep->fileline(), orp, undrivenp);
|
||||
} else {
|
||||
undrivenp->deleteTree(); undrivenp=NULL;
|
||||
}
|
||||
if (envarp) {
|
||||
nodep->addStmtp(new AstAssignW(enp->fileline(),
|
||||
|
@ -310,6 +310,7 @@ private:
|
||||
if (bodysp) { pushDeletep(bodysp); bodysp=NULL; }
|
||||
if (precondsp) { pushDeletep(precondsp); precondsp=NULL; }
|
||||
if (initp) { pushDeletep(initp); initp=NULL; }
|
||||
if (incp && !incp->backp()) { pushDeletep(incp); incp=NULL; }
|
||||
if (debug()>=9) newbodysp->dumpTree(cout,"- _new: ");
|
||||
}
|
||||
|
||||
|
@ -1301,6 +1301,7 @@ private:
|
||||
string format;
|
||||
if (pinp->castConst()) format = pinp->castConst()->num().toString();
|
||||
else pinp->v3error("Format to $display-like function must have constant format string");
|
||||
pushDeletep(pinp); pinp=NULL;
|
||||
AstSFormatF* newp = new AstSFormatF(nodep->fileline(), format, false, argsp);
|
||||
if (!newp->scopeNamep() && newp->formatScopeTracking()) {
|
||||
newp->scopeNamep(new AstScopeName(newp->fileline()));
|
||||
@ -1749,7 +1750,7 @@ private:
|
||||
num.isSigned(expDTypep->isSigned());
|
||||
AstNode* newp = new AstConst(nodep->fileline(), num);
|
||||
constp->replaceWith(newp);
|
||||
pushDeletep(constp); constp=NULL;
|
||||
pushDeletep(constp); constp=NULL; nodep=NULL;
|
||||
nodep=newp;
|
||||
} else if (expWidth<nodep->width()) {
|
||||
// Trunc - Extract
|
||||
@ -1787,6 +1788,7 @@ private:
|
||||
num.isSigned(expSigned);
|
||||
AstNode* newp = new AstConst(nodep->fileline(), num);
|
||||
constp->replaceWith(newp);
|
||||
constp->deleteTree(); constp=NULL; nodep=NULL;
|
||||
nodep=newp;
|
||||
} else {
|
||||
AstNRelinker linker;
|
||||
|
@ -235,6 +235,7 @@ private:
|
||||
// How to recover? We'll strip a dimension.
|
||||
nodep->replaceWith(fromp); pushDeletep(nodep); nodep=NULL;
|
||||
}
|
||||
if (!bitp->backp()) pushDeletep(bitp); bitp=NULL;
|
||||
}
|
||||
|
||||
virtual void visit(AstSelExtract* nodep, AstNUser*) {
|
||||
@ -285,13 +286,16 @@ private:
|
||||
UINFO(6," new "<<newp<<endl);
|
||||
//if (debug()>=9) newp->dumpTree(cout,"--SLEXnew: ");
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(msbp); msbp=NULL;
|
||||
}
|
||||
else { // NULL=bad extract, or unknown node type
|
||||
nodep->v3error("Illegal range select; variable already selected, or bad dimension");
|
||||
// How to recover? We'll strip a dimension.
|
||||
nodep->replaceWith(fromp); pushDeletep(nodep); nodep=NULL;
|
||||
}
|
||||
// delete whataver we didn't use in reconstruction
|
||||
if (!fromp->backp()) pushDeletep(fromp); fromp=NULL;
|
||||
if (!msbp->backp()) pushDeletep(msbp); msbp=NULL;
|
||||
if (!lsbp->backp()) pushDeletep(lsbp); lsbp=NULL;
|
||||
}
|
||||
|
||||
void replaceSelPlusMinus(AstNodePreSel* nodep) {
|
||||
|
@ -178,6 +178,8 @@ const AstBasicDTypeKwd LOGIC_IMPLICIT = AstBasicDTypeKwd::LOGIC_IMPLICIT;
|
||||
|
||||
#define INSTPREP(modname,paramsp) { GRAMMARP->m_impliedDecl = true; GRAMMARP->m_instModule = modname; GRAMMARP->m_instParamp = paramsp; }
|
||||
|
||||
#define DEL(nodep) { if (nodep) nodep->deleteTree(); }
|
||||
|
||||
static void ERRSVKWD(FileLine* fileline, const string& tokname) {
|
||||
static int toldonce = 0;
|
||||
fileline->v3error((string)"Unexpected \""+tokname+"\": \""+tokname+"\" is a SystemVerilog keyword misused as an identifier.");
|
||||
@ -1586,7 +1588,7 @@ delay_value: // ==IEEE:delay_value
|
||||
;
|
||||
|
||||
delayExpr:
|
||||
expr { }
|
||||
expr { DEL($1); }
|
||||
// // Verilator doesn't support yaTIMENUM, so not in expr
|
||||
| yaTIMENUM { }
|
||||
;
|
||||
@ -2165,9 +2167,9 @@ system_t_call<nodep>: // IEEE: system_tf_call (as task)
|
||||
| yD_FFLUSH parenE { $1->v3error("Unsupported: $fflush of all handles does not map to C++."); }
|
||||
| yD_FFLUSH '(' idClassSel ')' { $$ = new AstFFlush($1, $3); }
|
||||
| yD_FINISH parenE { $$ = new AstFinish($1); }
|
||||
| yD_FINISH '(' expr ')' { $$ = new AstFinish($1); }
|
||||
| yD_FINISH '(' expr ')' { $$ = new AstFinish($1); DEL($3); }
|
||||
| yD_STOP parenE { $$ = new AstStop($1); }
|
||||
| yD_STOP '(' expr ')' { $$ = new AstStop($1); }
|
||||
| yD_STOP '(' expr ')' { $$ = new AstStop($1); DEL($3); }
|
||||
//
|
||||
| yD_SFORMAT '(' expr ',' str commaEListE ')' { $$ = new AstSFormat($1,$3,*$5,$6); }
|
||||
| yD_SWRITE '(' expr ',' str commaEListE ')' { $$ = new AstSFormat($1,$3,*$5,$6); }
|
||||
@ -2187,8 +2189,8 @@ system_t_call<nodep>: // IEEE: system_tf_call (as task)
|
||||
| yD_ERROR parenE { $$ = GRAMMARP->createDisplayError($1); }
|
||||
| yD_ERROR '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_ERROR, *$3,NULL,$4); $$->addNext(new AstStop($1)); }
|
||||
| yD_FATAL parenE { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); }
|
||||
| yD_FATAL '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); if ($3) $3->deleteTree(); }
|
||||
| yD_FATAL '(' expr ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, *$5,NULL,$6); $$->addNext(new AstStop($1)); if ($3) $3->deleteTree(); }
|
||||
| yD_FATAL '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); DEL($3); }
|
||||
| yD_FATAL '(' expr ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, *$5,NULL,$6); $$->addNext(new AstStop($1)); DEL($3); }
|
||||
//
|
||||
| yD_READMEMB '(' expr ',' varRefMem ')' { $$ = new AstReadMem($1,false,$3,$5,NULL,NULL); }
|
||||
| yD_READMEMB '(' expr ',' varRefMem ',' expr ')' { $$ = new AstReadMem($1,false,$3,$5,$7,NULL); }
|
||||
@ -2792,60 +2794,60 @@ gateUnsupList<nodep>:
|
||||
|
||||
gateBuf<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' expr ')'
|
||||
{ $$ = new AstAssignW ($3,$4,$6); }
|
||||
{ $$ = new AstAssignW ($3,$4,$6); DEL($2); }
|
||||
;
|
||||
gateBufif0<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' expr ',' expr ')'
|
||||
{ $$ = new AstAssignW ($3,$4,new AstBufIf1($3,new AstNot($3,$8),$6)); }
|
||||
{ $$ = new AstAssignW ($3,$4,new AstBufIf1($3,new AstNot($3,$8),$6)); DEL($2); }
|
||||
;
|
||||
gateBufif1<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' expr ',' expr ')'
|
||||
{ $$ = new AstAssignW ($3,$4,new AstBufIf1($3,$8,$6)); }
|
||||
{ $$ = new AstAssignW ($3,$4,new AstBufIf1($3,$8,$6)); DEL($2); }
|
||||
;
|
||||
gateNot<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' expr ')'
|
||||
{ $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); }
|
||||
{ $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); DEL($2); }
|
||||
;
|
||||
gateNotif0<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' expr ',' expr ')'
|
||||
{ $$ = new AstAssignW ($3,$4,new AstBufIf1($3,new AstNot($3,$8), new AstNot($3, $6))); }
|
||||
{ $$ = new AstAssignW ($3,$4,new AstBufIf1($3,new AstNot($3,$8), new AstNot($3, $6))); DEL($2); }
|
||||
;
|
||||
gateNotif1<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' expr ',' expr ')'
|
||||
{ $$ = new AstAssignW ($3,$4,new AstBufIf1($3,$8, new AstNot($3,$6))); }
|
||||
{ $$ = new AstAssignW ($3,$4,new AstBufIf1($3,$8, new AstNot($3,$6))); DEL($2); }
|
||||
;
|
||||
gateAnd<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' gateAndPinList ')'
|
||||
{ $$ = new AstAssignW ($3,$4,$6); }
|
||||
{ $$ = new AstAssignW ($3,$4,$6); DEL($2); }
|
||||
;
|
||||
gateNand<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' gateAndPinList ')'
|
||||
{ $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); }
|
||||
{ $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); DEL($2); }
|
||||
;
|
||||
gateOr<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' gateOrPinList ')'
|
||||
{ $$ = new AstAssignW ($3,$4,$6); }
|
||||
{ $$ = new AstAssignW ($3,$4,$6); DEL($2); }
|
||||
;
|
||||
gateNor<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' gateOrPinList ')'
|
||||
{ $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); }
|
||||
{ $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); DEL($2); }
|
||||
;
|
||||
gateXor<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' gateXorPinList ')'
|
||||
{ $$ = new AstAssignW ($3,$4,$6); }
|
||||
{ $$ = new AstAssignW ($3,$4,$6); DEL($2); }
|
||||
;
|
||||
gateXnor<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ',' gateXorPinList ')'
|
||||
{ $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); }
|
||||
{ $$ = new AstAssignW ($3,$4,new AstNot($5,$6)); DEL($2); }
|
||||
;
|
||||
gatePullup<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ')' { $$ = new AstPull ($3, $4, true); }
|
||||
gateIdE instRangeE '(' variable_lvalue ')' { $$ = new AstPull ($3, $4, true); DEL($2); }
|
||||
;
|
||||
gatePulldown<nodep>:
|
||||
gateIdE instRangeE '(' variable_lvalue ')' { $$ = new AstPull ($3, $4, false); }
|
||||
gateIdE instRangeE '(' variable_lvalue ')' { $$ = new AstPull ($3, $4, false); DEL($2); }
|
||||
;
|
||||
gateUnsup<nodep>:
|
||||
gateIdE instRangeE '(' gateUnsupPinList ')' { $$ = new AstImplicit ($3,$4); }
|
||||
gateIdE instRangeE '(' gateUnsupPinList ')' { $$ = new AstImplicit ($3,$4); DEL($2); }
|
||||
;
|
||||
|
||||
gateIdE:
|
||||
|
Loading…
Reference in New Issue
Block a user