<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - llvm-cov: Regression: switch-case often leads to uncoverable regions"
   href="https://bugs.llvm.org/show_bug.cgi?id=45300">45300</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm-cov: Regression: switch-case often leads to uncoverable regions
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dennis.felsing@sap.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ 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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>