From 7fb9fa4b9aba2a54e076c6f905b39dbcb421a2bf Mon Sep 17 00:00:00 2001 From: Tomasz Gorochowik Date: Fri, 27 Dec 2024 19:29:06 +0100 Subject: [PATCH] Skip branch coverage inside functions --- src/V3Coverage.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 87c26d9b5d..257b85771d 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -220,6 +220,11 @@ class CoverageVisitor final : public VNVisitor { } iterateChildren(nodep); } + void visit(AstFunc* nodep) override { + VL_RESTORER(m_state); + m_state.m_on = false; + iterateChildren(nodep); + } void visit(AstNodeProcedure* nodep) override { iterateProcedure(nodep); } void visit(AstWhile* nodep) override { iterateProcedure(nodep); } @@ -405,6 +410,10 @@ class CoverageVisitor final : public VNVisitor { void visit(AstCond* nodep) override { UINFO(4, " COND: " << nodep << endl); + if (!m_state.m_on) { + return; + } + // Current method cannot run coverage for impure statements if (!nodep->condp()->isPure()) { return;