From 40bceea68aeca0c1bfcc86c6cc2b5e1d9b8dabcc Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 29 Mar 2014 11:04:13 -0400 Subject: [PATCH] Fix missing coverage line on else-if, bug727. --- Changes | 2 ++ src/V3Coverage.cpp | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index 9c6352cd3..c8f2d9b2a 100644 --- a/Changes +++ b/Changes @@ -17,6 +17,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix tracing of package variables and real arrays. +**** Fix missing coverage line on else-if, bug727. [Sharad Bagri] + **** Fix Mac OS-X test issues. [Holger Waechtler] **** Fix C++-2011 warnings. diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 4fc52469a..3582aa449 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -60,9 +60,14 @@ private: } }; + // NODE STATE + // Entire netlist: + // AstIf::user1() -> bool. True indicates ifelse processed + AstUser1InUse m_inuser1; + // STATE - bool m_checkBlock; // Should this block get covered? - AstNodeModule* m_modp; // Current module to add statement to + bool m_checkBlock; // Should this block get covered? + AstNodeModule* m_modp; // Current module to add statement to bool m_inToggleOff; // In function/task etc bool m_inModOff; // In module with no coverage FileMap m_fileps; // Column counts for each fileline @@ -277,12 +282,18 @@ private: virtual void visit(AstIf* nodep, AstNUser*) { // Note not AstNodeIf; other types don't get covered UINFO(4," IF: "<elsesp()->castIf() + && !nodep->elsesp()->castIf()->nextp()); + if (elsif) nodep->elsesp()->castIf()->user1(true); + // nodep->ifsp()->iterateAndNext(*this); if (m_checkBlock && !m_inModOff && nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) { // if a "if" branch didn't disable it - if (!nodep->backp()->castIf() - || nodep->backp()->castIf()->elsesp()!=nodep) { // Ignore if else; did earlier - UINFO(4," COVER: "<user1()) { + nodep->addIfsp(newCoverInc(nodep->fileline(), "", "v_line", "elsif")); + } else { nodep->addIfsp(newCoverInc(nodep->fileline(), "", "v_line", "if")); } } @@ -293,9 +304,7 @@ private: if (m_checkBlock && !m_inModOff && nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) { // if a "else" branch didn't disable it UINFO(4," COVER: "<elsesp()->castIf()) { - nodep->addElsesp(newCoverInc(nodep->elsesp()->fileline(), "", "v_line", "elsif")); - } else { + if (!elsif) { // elsif done inside if() nodep->addElsesp(newCoverInc(nodep->elsesp()->fileline(), "", "v_line", "else")); } }