[PATCH] D138847: MC/DC in LLVM Source-Based Code Coverage: llvm-cov visualization

Fütő Gergely via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 4 02:46:08 PDT 2023


futogergely added a comment.

HI, I just started to look into MC/DC, and if I understand correctly, with the current implementation, you can have 100% MC/DC coverage in the following case:

  void test(bool a, bool b, bool c) {
  
    if (a && b)
      std::cout << "test_1 decision true\n";
  
    if (c)
      std::cout << "test_2 decision true\n";
  
  }
  
  int main() {
      test(true, false, false);
      test(true, true, false);
      test(false, true, false);
  }

This gives you 100% MC/DC coverage (with 2 MC/DC conditions considered). However, with the tests executed, 'c' did not meet the requirements imposed by MC/DC (for example the condition did not take every possible value)

If you change 'if (c)' to 'if (c && 1)' the MC/DC coverage changes to 66.67% (with 3 MC/DC conditions considered), which should be the result for the original use case I think.
Also if you consider branch coverage as well, it will show that the tests missed some spots.

As far as I understood, MC/DC coverage should be more strict than branch coverage, so 100% MC/CD coverage should imply 100% branch coverage. Or do I miss something here?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138847/new/

https://reviews.llvm.org/D138847



More information about the llvm-commits mailing list