Skip to content

Commit

Permalink
Add initial ternary operator branch coverage support
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gorochowik <[email protected]>
  • Loading branch information
tgorochowik committed Dec 27, 2024
1 parent ce29be4 commit 232f465
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/V3Coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,22 @@ class CoverageVisitor final : public VNVisitor {
}

// VISITORS - LINE COVERAGE
void visit(AstCond* nodep) override {
UINFO(4, " COND: " << nodep << endl);

// Current method cannot run coverage for impure statements
if (!nodep->condp()->isPure()) {
return;
}

auto fake_if = new AstIf(nodep->fileline(), nodep->condp()->cloneTree(true));
FileLine* newFl = new FileLine{nodep->fileline()};
auto always = new AstAlways{newFl, VAlwaysKwd::ALWAYS, nullptr, fake_if};
// Disable coverage for this fake always block
newFl->coverageOn(false);
nodep->addNextStmt(always, nodep);

}
// Note not AstNodeIf; other types don't get covered
void visit(AstIf* nodep) override {
UINFO(4, " IF: " << nodep << endl);
Expand Down

0 comments on commit 232f465

Please sign in to comment.