Internals: Fix some object-less asserts

This commit is contained in:
Wilson Snyder 2025-09-20 17:40:50 -04:00
parent 580a843474
commit a4db488b02
8 changed files with 16 additions and 14 deletions

View File

@ -61,7 +61,7 @@ class CUseVisitor final : public VNVisitorConst {
}
void visit(AstCCall* nodep) override { return; }
void visit(AstCReturn* nodep) override {
UASSERT(!nodep->user1SetOnce(), "Visited same return twice.");
UASSERT_OBJ(!nodep->user1SetOnce(), nodep, "Visited same return twice");
iterateConst(nodep->lhsp()->dtypep());
}
void visit(AstNodeDType* nodep) override {

View File

@ -308,7 +308,7 @@ class CaseVisitor final : public VNVisitor {
for (uint32_t i = 0; i < numCases; ++i) {
if (AstNode* const condp = m_valueItem[i]) {
const AstCaseItem* const caseItemp = caseItemMap[condp];
UASSERT(caseItemp, "caseItemp should exist");
UASSERT_OBJ(caseItemp, condp, "caseItemp should exist");
m_valueItem[i] = caseItemp->stmtsp();
}
}

View File

@ -574,7 +574,7 @@ class ConstBitOpTreeVisitor final : public VNVisitorConst {
// Reach past a cast then add to frozen nodes to be added to final reduction
if (const AstCCast* const castp = VN_CAST(opp, CCast)) opp = castp->lhsp();
const bool pol = isXorTree() || m_polarity; // Only AND/OR tree needs polarity
UASSERT(pol, "AND/OR tree expects m_polarity==true");
UASSERT_OBJ(pol, nodep, "AND/OR tree expects m_polarity==true");
m_frozenNodes.emplace_back(opp, FrozenNodeInfo{pol, m_lsb});
m_failed = origFailed;
continue;
@ -2274,7 +2274,8 @@ class ConstVisitor final : public VNVisitor {
if (VN_IS(dstDTypep, UnpackArrayDType)) {
streamp = new AstCvtPackedToArray{nodep->fileline(), streamp, dstDTypep};
} else {
UASSERT(sWidth >= dWidth, "sWidth >= dWidth should have caused an error earlier");
UASSERT_OBJ(sWidth >= dWidth, nodep,
"sWidth >= dWidth should have caused an error earlier");
if (dWidth == 0) {
streamp = new AstCvtPackedToArray{nodep->fileline(), streamp, dstDTypep};
} else if (sWidth >= dWidth) {
@ -2307,7 +2308,8 @@ class ConstVisitor final : public VNVisitor {
}
srcp = new AstCvtPackedToArray{nodep->fileline(), srcp, dstDTypep};
} else {
UASSERT(sWidth >= dWidth, "sWidth >= dWidth should have caused an error earlier");
UASSERT_OBJ(sWidth >= dWidth, nodep,
"sWidth >= dWidth should have caused an error earlier");
if (dWidth == 0) {
srcp = new AstCvtPackedToArray{nodep->fileline(), srcp, dstDTypep};
} else if (sWidth >= dWidth) {

View File

@ -575,7 +575,7 @@ class ForkVisitor final : public VNVisitor {
if (!m_newProcess || nodep->user1()) {
VL_RESTORER(m_forkDepth);
if (nodep->user1()) {
UASSERT(m_forkDepth > 0, "Wrong fork depth!");
UASSERT_OBJ(m_forkDepth > 0, nodep, "Wrong fork depth");
--m_forkDepth;
}
iterateChildren(nodep);
@ -601,7 +601,7 @@ class ForkVisitor final : public VNVisitor {
AstTask* taskp = nullptr;
if (AstBegin* const beginp = VN_CAST(nodep, Begin)) {
UASSERT(beginp->stmtsp(), "No stmtsp\n");
UASSERT_OBJ(beginp->stmtsp(), beginp, "No stmtsp");
const string taskName = generateTaskName(beginp, "fork_begin");
taskp
= makeTask(beginp->fileline(), beginp->stmtsp()->unlinkFrBackWithNext(), taskName);

View File

@ -69,7 +69,7 @@ class LinkIncVisitor final : public VNVisitor {
} else if (m_modp) {
stmtsp = m_modp->stmtsp();
}
UASSERT(stmtsp, "Variable not under FTASK/MODULE");
UASSERT_OBJ(stmtsp, newp, "Variable not under FTASK/MODULE");
newp->addNext(stmtsp->unlinkFrBackWithNext());
if (m_ftaskp) {
m_ftaskp->addStmtsp(newp);

View File

@ -136,7 +136,7 @@ public:
}
AstNodeModule* findByParams(const string& origName, AstPin* firstPinp,
const AstNodeModule* modp) {
UASSERT(isHierBlock(origName), origName << " is not hierarchical block\n");
UASSERT(isHierBlock(origName), origName << " is not hierarchical block");
// This module is a hierarchical block. Need to replace it by the --lib-create wrapper.
const std::pair<HierMapIt, HierMapIt> candidates
= m_hierBlockOptsByOrigName.equal_range(origName);

View File

@ -1154,7 +1154,7 @@ int V3PreProcImp::getStateToken() {
m_lexp->pushStateDefForm();
goto next_tok;
} else { // LCOV_EXCL_LINE
v3fatalSrc("Bad case\n");
v3fatalSrc("Bad case");
}
goto next_tok;
} else if (tok == VP_TEXT) {
@ -1521,7 +1521,7 @@ int V3PreProcImp::getStateToken() {
goto next_tok;
}
}
default: v3fatalSrc("Bad case\n");
default: v3fatalSrc("Bad case");
}
// Default is to do top level expansion of some tokens
switch (tok) {
@ -1637,7 +1637,7 @@ int V3PreProcImp::getStateToken() {
goto next_tok;
}
}
v3fatalSrc("Bad case\n"); // FALLTHRU
v3fatalSrc("Bad case"); // FALLTHRU
goto next_tok; // above fatal means unreachable, but fixes static analysis warning
}
case VP_ERROR: {

View File

@ -253,7 +253,7 @@ class TimingSuspendableVisitor final : public VNVisitor {
// VISITORS
void visit(AstClass* nodep) override {
UASSERT(!m_classp, "Class under class");
UASSERT_OBJ(!m_classp, nodep, "Class under class");
VL_RESTORER(m_classp);
m_classp = nodep;
iterateChildren(nodep);
@ -752,7 +752,7 @@ class TimingControlVisitor final : public VNVisitor {
// VISITORS
void visit(AstNodeModule* nodep) override {
UASSERT(!m_classp, "Module or class under class");
UASSERT_OBJ(!m_classp, nodep, "Module or class under class");
VL_RESTORER(m_classp);
m_classp = VN_CAST(nodep, Class);
VL_RESTORER(m_forkCnt);