Internals: Fix VL_LEAK_CHECK (#2542).

This commit is contained in:
Wilson Snyder 2020-09-11 11:52:30 -04:00
parent d0819f156f
commit fac04521db
3 changed files with 7 additions and 2 deletions

View File

@ -35,6 +35,12 @@ AstNetlist* V3Global::makeNetlist() {
return newp;
}
void V3Global::clear() {
#ifdef VL_LEAK_CHECK
if (m_rootp) VL_DO_CLEAR(m_rootp->deleteTree(), m_rootp = nullptr);
#endif
}
void V3Global::shutdown() {
VL_DO_CLEAR(delete m_hierPlanp, m_hierPlanp = nullptr); // delete nullptr is safe
}

View File

@ -119,6 +119,7 @@ public:
UASSERT(!m_rootp, "call once");
m_rootp = makeNetlist();
}
void clear();
void shutdown(); // Release allocated resorces
// ACCESSORS (general)
AstNetlist* rootp() const { return m_rootp; }

View File

@ -623,10 +623,8 @@ static void verilate(const string& argString) {
// Final writing shouldn't throw warnings, but...
V3Error::abortIfWarnings();
#ifdef VL_LEAK_CHECKS
// Cleanup memory for valgrind leak analysis
v3Global.clear();
#endif
FileLine::deleteAllRemaining();
}