[llvm-bugs] [Bug 45300] New: llvm-cov: Regression: switch-case often leads to uncoverable regions

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 25 03:33:50 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45300

            Bug ID: 45300
           Summary: llvm-cov: Regression: switch-case often leads to
                    uncoverable regions
           Product: new-bugs
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dennis.felsing at sap.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

$ cat x.cpp
#include <iostream>

void f(int argc)
{
    switch (argc) {
        case 1: {
            std::cout << "1" << std::endl;
            return;
        }
    }
}

int main(int argc, char** /*argv*/)
{
    f(argc);
    f(argc+1);
}
$ clang++ --version
clang version 10.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ clang++ -fprofile-instr-generate -fcoverage-mapping x.cpp -o x
$ ./x
1
$ llvm-profdata merge default.profraw -o default.profdata
$ llvm-cov show ./x -instr-profile=default.profdata
    1|       |#include <iostream>
    2|       |
    3|       |void f(int argc)
    4|      2|{
    5|      2|    switch (argc) {
    6|      1|        case 1: {
    7|      1|            std::cout << "1" << std::endl;
    8|      1|            return;
    9|      0|        }
   10|      2|    }
   11|      2|}
   12|       |
   13|       |int main(int argc, char** /*argv*/)
   14|      1|{
   15|      1|    f(argc);
   16|      1|    f(argc+1);
   17|      1|}

Note that line 9 is uncovered and impossible to cover.

With LLVM 9.0.0 this worked fine:

    1|       |#include <iostream>
    2|       |
    3|       |void f(int argc)
    4|      2|{
    5|      2|    switch (argc) {
    6|      2|        case 1: {
    7|      1|            std::cout << "1" << std::endl;
    8|      1|            return;
    9|      2|        }
   10|      2|    }
   11|      2|}
   12|       |
   13|       |int main(int argc, char** /*argv*/)
   14|      1|{
   15|      1|    f(argc);
   16|      1|    f(argc+1);
   17|      1|}

Best regards
Dennis

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200325/ad8d5e6c/attachment.html>


More information about the llvm-bugs mailing list