Skip to content

Commit

Permalink
Revert changes done to comments of nodes different than variables
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
  • Loading branch information
RRozak committed Jan 28, 2025
1 parent 32f84cf commit f4489f0
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/V3Coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ class CoverageVisitor final : public VNVisitor {
if (!nodep->dpiImport()) iterateProcedure(nodep);
}
void iterateProcedure(AstNode* nodep) {
char comment[100];
snprintf(comment, 100, "block_%p=", m_modp);
VL_RESTORER(m_state);
VL_RESTORER(m_inToggleOff);
m_inToggleOff = true;
Expand All @@ -244,7 +242,7 @@ class CoverageVisitor final : public VNVisitor {
if (m_state.lineCoverageOn(nodep)) {
lineTrack(nodep);
AstNode* const newp
= newCoverInc(nodep->fileline(), "", "v_line", comment, linesCov(m_state, nodep),
= newCoverInc(nodep->fileline(), "", "v_line", "block", linesCov(m_state, nodep),
0, traceNameForLine(nodep, "block"));
if (AstNodeProcedure* const itemp = VN_CAST(nodep, NodeProcedure)) {
itemp->addStmtsp(newp);
Expand Down Expand Up @@ -439,12 +437,6 @@ class CoverageVisitor final : public VNVisitor {
// Note not AstNodeIf; other types don't get covered
void visit(AstIf* nodep) override {
UINFO(4, " IF: " << nodep << endl);
char comment_if[100];
snprintf(comment_if, 100, "if_%p=", m_modp);
char comment_else[100];
snprintf(comment_else, 100, "else_%p=", m_modp);
char comment_elsif[100];
snprintf(comment_elsif, 100, "elsif_%p=", m_modp);
if (m_state.m_on) {
// An else-if. When we iterate the if, use "elsif" marking
const bool elsif
Expand Down Expand Up @@ -482,21 +474,21 @@ class CoverageVisitor final : public VNVisitor {
// Normal if. Linecov shows what's inside the if (not condition that is
// always executed)
UINFO(4, " COVER-branch: " << nodep << endl);
nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_branch", comment_if,
nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_branch", "if",
linesCov(ifState, nodep), 0,
traceNameForLine(nodep, "if")));
// The else has a column offset of 1 to uniquify it relative to the if
// As "if" and "else" are more than one character wide, this won't overlap
// another token
nodep->addElsesp(newCoverInc(nodep->fileline(), "", "v_branch", comment_else,
nodep->addElsesp(newCoverInc(nodep->fileline(), "", "v_branch", "else",
linesCov(elseState, nodep), 1,
traceNameForLine(nodep, "else")));
}
// If/else attributes to each block as non-branch coverage
else if (first_elsif || cont_elsif) {
UINFO(4, " COVER-elsif: " << nodep << endl);
if (ifState.lineCoverageOn(nodep)) {
nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_line", comment_elsif,
nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_line", "elsif",
linesCov(ifState, nodep), 0,
traceNameForLine(nodep, "elsif")));
}
Expand All @@ -505,13 +497,13 @@ class CoverageVisitor final : public VNVisitor {
// Cover as separate blocks (not a branch as is not two-legged)
if (ifState.lineCoverageOn(nodep)) {
UINFO(4, " COVER-half-if: " << nodep << endl);
nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_line", comment_if,
nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_line", "if",
linesCov(ifState, nodep), 0,
traceNameForLine(nodep, "if")));
}
if (elseState.lineCoverageOn(nodep)) {
UINFO(4, " COVER-half-el: " << nodep << endl);
nodep->addElsesp(newCoverInc(nodep->fileline(), "", "v_line", comment_else,
nodep->addElsesp(newCoverInc(nodep->fileline(), "", "v_line", "else",
linesCov(elseState, nodep), 1,
traceNameForLine(nodep, "else")));
}
Expand All @@ -523,8 +515,6 @@ class CoverageVisitor final : public VNVisitor {
void visit(AstCaseItem* nodep) override {
// We don't add an explicit "default" coverage if not provided,
// as we already have a warning when there is no default.
char comment[100];
snprintf(comment, 100, "case_%p=", m_modp);
UINFO(4, " CASEI: " << nodep << endl);
if (m_state.lineCoverageOn(nodep)) {
VL_RESTORER(m_state);
Expand All @@ -533,24 +523,22 @@ class CoverageVisitor final : public VNVisitor {
if (m_state.lineCoverageOn(nodep)) { // if the case body didn't disable it
lineTrack(nodep);
UINFO(4, " COVER: " << nodep << endl);
nodep->addStmtsp(newCoverInc(nodep->fileline(), "", "v_line", comment,
nodep->addStmtsp(newCoverInc(nodep->fileline(), "", "v_line", "case",
linesCov(m_state, nodep), 0,
traceNameForLine(nodep, "case")));
}
}
}
void visit(AstCover* nodep) override {
UINFO(4, " COVER: " << nodep << endl);
char comment[100];
snprintf(comment, 100, "cover_%p=", m_modp);
VL_RESTORER(m_state);
m_state.m_on = true; // Always do cover blocks, even if there's a $stop
createHandle(nodep);
iterateChildren(nodep);
if (!nodep->coverincsp() && v3Global.opt.coverageUser()) {
// Note the name may be overridden by V3Assert processing
lineTrack(nodep);
nodep->addCoverincsp(newCoverInc(nodep->fileline(), m_beginHier, "v_user", comment,
nodep->addCoverincsp(newCoverInc(nodep->fileline(), m_beginHier, "v_user", "cover",
linesCov(m_state, nodep), 0,
m_beginHier + "_vlCoverageUserTrace"));
}
Expand Down

0 comments on commit f4489f0

Please sign in to comment.