Add UNUSEDLOOP when unused loop is removed (#4926)

This commit is contained in:
Bartłomiej Chmiel
2024-03-07 08:33:49 -05:00
committed by GitHub
parent 6db149c588
commit 32f288084a
11 changed files with 396 additions and 21 deletions
+5
View File
@@ -34,6 +34,7 @@
#include "V3LinkJump.h"
#include "V3AstUserAllocator.h"
#include "V3Error.h"
#include <vector>
@@ -228,6 +229,8 @@ class LinkJumpVisitor final : public VNVisitor {
void visit(AstWhile* nodep) override {
// Don't need to track AstRepeat/AstFor as they have already been converted
if (!m_unrollFull.isDefault()) nodep->unrollFull(m_unrollFull);
if (m_modp->hasParameterList() || m_modp->hasGParam())
nodep->fileline()->modifyWarnOff(V3ErrorCode::UNUSEDLOOP, true);
m_unrollFull = VOptionBool::OPT_DEFAULT_FALSE;
VL_RESTORER(m_loopp);
VL_RESTORER(m_loopInc);
@@ -254,6 +257,8 @@ class LinkJumpVisitor final : public VNVisitor {
AstWhile* const whilep = new AstWhile{nodep->fileline(), condp, bodyp};
if (!m_unrollFull.isDefault()) whilep->unrollFull(m_unrollFull);
m_unrollFull = VOptionBool::OPT_DEFAULT_FALSE;
// No unused warning for converted AstDoWhile, as body always executes once
nodep->fileline()->modifyWarnOff(V3ErrorCode::UNUSEDLOOP, true);
nodep->replaceWith(whilep);
VL_DO_DANGLING(nodep->deleteTree(), nodep);
if (bodyp) {