]> git.nickg.me.uk Git - nvc.git/commitdiff
Revert "If/case statements do not count for statement coverage" master github/master sr.ht/master
authorNick Gasson <nick@nickg.me.uk>
Thu, 18 Apr 2024 19:07:17 +0000 (20:07 +0100)
committerNick Gasson <nick@nickg.me.uk>
Thu, 18 Apr 2024 19:07:17 +0000 (20:07 +0100)
This reverts commit 575349b17bccb07eb104ac9c1287b21455107012.

src/cov/cov-export.c
src/lower.c
test/regress/gold/cover1.txt
test/regress/gold/cover15.txt
test/regress/gold/cover21.txt
test/regress/gold/cover5.txt
test/regress/gold/cover9.txt
test/test_lower.c

index 360c68ba7cc8607d17385b090f5f745a79bc42e3..0a66c7a3d5a92840acb17315a7bbe539825ac527 100644 (file)
@@ -126,7 +126,6 @@ static void cobertura_export_scope(cobertura_report_t *report,
          {
             cobertura_line_t *l = cobertura_get_line(class, &(t->loc));
             l->branch = true;
-            l->hits += t->data;
             if (t->data > 0)
                l->bflags |= t->flags;
          }
index da002bf7caeac6eb6ced5bd608a98a436200bfe6..e1e18a12627e31a826f0ccc2d02096d6d2dd6385 100644 (file)
@@ -6303,6 +6303,8 @@ static void lower_sequence(lower_unit_t *lu, tree_t block, loop_stack_t *loops)
 
 static void lower_if(lower_unit_t *lu, tree_t stmt, loop_stack_t *loops)
 {
+   lower_stmt_coverage(lu, stmt);
+
    vcode_block_t exit_bb = VCODE_INVALID_BLOCK;
    const bool want_coverage = cover_enabled(lu->cover, COVER_MASK_BRANCH);
 
@@ -7119,6 +7121,8 @@ static void lower_case_array(lower_unit_t *lu, tree_t stmt, loop_stack_t *loops)
 
 static void lower_case(lower_unit_t *lu, tree_t stmt, loop_stack_t *loops)
 {
+   lower_stmt_coverage(lu, stmt);
+
    if (type_is_scalar(tree_type(tree_value(stmt))))
       lower_case_scalar(lu, stmt, loops);
    else
index 539d8441c9d6c682207c7c0308eadb892152bab2..1ccf429dd162a064fca61e27104a32f5b6108680 100644 (file)
@@ -1,5 +1,5 @@
 ** Note: code coverage results for: WORK.COVER1
-** Note:      statement:     97.3 % (36/37)
+** Note:      statement:     97.7 % (42/43)
 ** Note:      branch:        N.A.
 ** Note:      toggle:        N.A.
 ** Note:      expression:    N.A.
index d9422e517da2949d1900f593c4b79c7efd639e06..6a4b32dd811e8225ab77ba0dd4ee4d48514d7a04 100644 (file)
@@ -1,7 +1,7 @@
 ** Note: Code coverage report folder: html.
 ** Note: Code coverage report contains: covered, uncovered, excluded coverage details.
 ** Note: code coverage results for: WORK.COVER15
-** Note:      statement:     84.6 % (11/13)
+** Note:      statement:     85.7 % (12/14)
 ** Note:      branch:        62.5 % (5/8)
 ** Note:      toggle:        N.A.
 ** Note:      expression:    N.A.
index 69a71bdf78c5d2dc35f4e87d9edb24c1d6df405a..2bdd845f54239161de5c6878f65a63bacc927ea1 100644 (file)
@@ -1,7 +1,7 @@
 ** Note: Code coverage report folder: html.
 ** Note: Code coverage report contains: covered, uncovered, excluded coverage details.
 ** Note: code coverage results for: WORK.COVER21
-** Note:      statement:     100.0 % (12/12)
+** Note:      statement:     100.0 % (13/13)
 ** Note:      branch:        100.0 % (2/2)
 ** Note:      toggle:        83.3 % (5/6)
 ** Note:      expression:    100.0 % (2/2)
index 7b1ede611c862165d4d47328e04af200e878ff70..40780314471284a2d522e11c63a8735304792e60 100644 (file)
@@ -1,7 +1,7 @@
 ** Note: Code coverage report folder: html.
 ** Note: Code coverage report contains: covered, uncovered, excluded coverage details.
 ** Note: code coverage results for: WORK.COVER5
-** Note:      statement:     36.8 % (7/19)
+** Note:      statement:     42.9 % (9/21)
 ** Note:      branch:        14.3 % (2/14)
 ** Note:      toggle:        3.1 % (1/32)
 ** Note:      expression:    14.3 % (2/14)
@@ -10,7 +10,7 @@
 ** Note: Code coverage report folder: html.
 ** Note: Code coverage report contains: covered, uncovered, excluded coverage details.
 ** Note: code coverage results for: WORK.COVER5
-** Note:      statement:     42.1 % (8/19)
+** Note:      statement:     47.6 % (10/21)
 ** Note:      branch:        28.6 % (4/14)
 ** Note:      toggle:        6.2 % (2/32)
 ** Note:      expression:    28.6 % (4/14)
@@ -19,7 +19,7 @@
 ** Note: Code coverage report folder: html.
 ** Note: Code coverage report contains: covered, uncovered, excluded coverage details.
 ** Note: code coverage results for: WORK.COVER5
-** Note:      statement:     47.4 % (9/19)
+** Note:      statement:     52.4 % (11/21)
 ** Note:      branch:        42.9 % (6/14)
 ** Note:      toggle:        9.4 % (3/32)
 ** Note:      expression:    42.9 % (6/14)
@@ -28,7 +28,7 @@
 ** Note: Code coverage report folder: html.
 ** Note: Code coverage report contains: covered, uncovered, excluded coverage details.
 ** Note: code coverage results for: WORK.COVER5
-** Note:      statement:     52.6 % (10/19)
+** Note:      statement:     57.1 % (12/21)
 ** Note:      branch:        50.0 % (7/14)
 ** Note:      toggle:        12.5 % (4/32)
 ** Note:      expression:    50.0 % (7/14)
@@ -37,7 +37,7 @@
 ** Note: Code coverage report folder: html.
 ** Note: Code coverage report contains: covered, uncovered, excluded coverage details.
 ** Note: code coverage results for: WORK.COVER5
-** Note:      statement:     100.0 % (19/19)
+** Note:      statement:     100.0 % (21/21)
 ** Note:      branch:        92.9 % (13/14)
 ** Note:      toggle:        28.1 % (9/32)
 ** Note:      expression:    92.9 % (13/14)
index 36c5d2e3bb6ef2c386687c996242cf37f9d64106..deff25a7f32dc81212c1f90f2d76547441b4ceb0 100644 (file)
    |
  5 | exclude WORK.COVER9.SUB_BLOCK_INST.*
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+** Note: excluding statement: 'WORK.COVER9.SUB_BLOCK_INST.AND_GATE._S0'
+   > data/cover9_ef1.txt:5
+   |
+ 5 | exclude WORK.COVER9.SUB_BLOCK_INST.*
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+** Warning: statement: 'WORK.COVER9.SUB_BLOCK_INST.AND_GATE._S0' already covered!
+   > data/cover9_ef1.txt:5
+   |
+ 5 | exclude WORK.COVER9.SUB_BLOCK_INST.*
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ** Note: excluding expression: 'WORK.COVER9.SUB_BLOCK_INST.AND_GATE._S0._B0._E0' bins: BIN_TRUE, BIN_FALSE
    > data/cover9_ef1.txt:5
    |
 ** Note: Code coverage report folder: html.
 ** Note: Code coverage report contains: covered, uncovered, excluded coverage details.
 ** Note: code coverage results for: WORK.COVER9
-** Note:      statement:     100.0 % (26/26)
+** Note:      statement:     100.0 % (29/29)
 ** Note:      branch:        100.0 % (10/10)
 ** Note:      toggle:        79.4 % (27/34)
 ** Note:      expression:    100.0 % (22/22)
index 5a2d0b399aba22711d01ae3e1e2729807bd787fe..e1aed4c2af82f8f80bef8938c3b1dd03bdc9085b 100644 (file)
@@ -1945,6 +1945,7 @@ START_TEST(test_cover)
       { VCODE_OP_COVER_STMT, .tag = 9 },
       { VCODE_OP_CONST, .value = 1 },
       { VCODE_OP_STORE, .name = "V" },
+      { VCODE_OP_COVER_STMT, .tag = 10 },
       { VCODE_OP_VAR_UPREF, .hops = 1, .name = "S" },
       { VCODE_OP_LOAD_INDIRECT },
       { VCODE_OP_RESOLVED },
@@ -1953,11 +1954,11 @@ START_TEST(test_cover)
       { VCODE_OP_CONST, .value = 1 },
       { VCODE_OP_CONST, .value = 2 },
       { VCODE_OP_SELECT },
-      { VCODE_OP_COVER_EXPR, .tag = 10 },
+      { VCODE_OP_COVER_EXPR, .tag = 11 },
       { VCODE_OP_CONST, .value = 10 },
       { VCODE_OP_CMP, .cmp = VCODE_CMP_GT },
       { VCODE_OP_SELECT },
-      { VCODE_OP_COVER_EXPR, .tag = 11 },
+      { VCODE_OP_COVER_EXPR, .tag = 12 },
       { VCODE_OP_OR },
       { VCODE_OP_NOT },
       { VCODE_OP_NOT },
@@ -1973,15 +1974,15 @@ START_TEST(test_cover)
       { VCODE_OP_CONST, .value = 32 },
       { VCODE_OP_SELECT },
       { VCODE_OP_ADD },
-      { VCODE_OP_COVER_EXPR, .tag = 12 },
+      { VCODE_OP_COVER_EXPR, .tag = 13 },
       { VCODE_OP_COND, .target = 2, .target_else = 3 }
    };
 
    CHECK_BB(1);
 
    EXPECT_BB(2) = {
-      { VCODE_OP_COVER_BRANCH, .tag = 13 },
-      { VCODE_OP_COVER_STMT, .tag = 15 },
+      { VCODE_OP_COVER_BRANCH, .tag = 14 },
+      { VCODE_OP_COVER_STMT, .tag = 16 },
       { VCODE_OP_CONST, .value = 2 },
       { VCODE_OP_STORE, .name = "V" },
       { VCODE_OP_JUMP, .target = 4 }
@@ -1990,7 +1991,7 @@ START_TEST(test_cover)
    CHECK_BB(2);
 
    EXPECT_BB(3) = {
-      { VCODE_OP_COVER_BRANCH, .tag = 14 },
+      { VCODE_OP_COVER_BRANCH, .tag = 15 },
       { VCODE_OP_JUMP, .target = 4 }
    };
 
@@ -2003,7 +2004,7 @@ START_TEST(test_cover)
       { VCODE_OP_CONST, .value = 0 },
       { VCODE_OP_CONST, .value = 1 },
       { VCODE_OP_SCHED_WAVEFORM },
-      { VCODE_OP_COVER_STMT, .tag = 16 },
+      { VCODE_OP_COVER_STMT, .tag = 17 },
       { VCODE_OP_WAIT, .target = 5 }
    };