Fix debug crash when no std:: used

This commit is contained in:
Wilson Snyder 2023-04-06 21:43:39 -04:00
parent 38000a3da0
commit 2530cda507
3 changed files with 12 additions and 8 deletions

View File

@ -77,14 +77,6 @@ void V3Global::readFiles() {
"Cannot find file containing library module: "); "Cannot find file containing library module: ");
} }
// Delete the std package if unused
if (!usesStdPackage()) {
if (AstNodeModule* stdp = v3Global.rootp()->stdPackagep()) {
v3Global.rootp()->stdPackagep(nullptr);
VL_DO_DANGLING(stdp->unlinkFrBack()->deleteTree(), stdp);
}
}
// v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("parse.tree")); // v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("parse.tree"));
V3Error::abortIfErrors(); V3Error::abortIfErrors();
@ -94,6 +86,16 @@ void V3Global::readFiles() {
} }
} }
void V3Global::removeStd() {
// Delete the std package if unused
if (!usesStdPackage()) {
if (AstNodeModule* stdp = v3Global.rootp()->stdPackagep()) {
v3Global.rootp()->stdPackagep(nullptr);
VL_DO_DANGLING(stdp->unlinkFrBack()->deleteTree(), stdp);
}
}
}
string V3Global::debugFilename(const string& nameComment, int newNumber) { string V3Global::debugFilename(const string& nameComment, int newNumber) {
++m_debugFileNumber; ++m_debugFileNumber;
if (newNumber) m_debugFileNumber = newNumber; if (newNumber) m_debugFileNumber = newNumber;

View File

@ -135,6 +135,7 @@ public:
// METHODS // METHODS
void readFiles(); void readFiles();
void removeStd();
void checkTree() const; void checkTree() const;
static void dumpCheckGlobalTree(const string& stagename, int newNumber = 0, static void dumpCheckGlobalTree(const string& stagename, int newNumber = 0,
bool doDump = true); bool doDump = true);

View File

@ -618,6 +618,7 @@ static void verilate(const string& argString) {
// Read first filename // Read first filename
v3Global.readFiles(); v3Global.readFiles();
v3Global.removeStd();
// Link, etc, if needed // Link, etc, if needed
if (!v3Global.opt.preprocOnly()) { // if (!v3Global.opt.preprocOnly()) { //