<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 - line coverage shows coverage of comments"
   href="https://bugs.llvm.org/show_bug.cgi?id=45757">45757</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>line coverage shows coverage of comments
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hans@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk, vsk@apple.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For example:

$ cat /tmp/a.c
int f(int x) {
  if (x == 42) {
    // <a href="show_bug.cgi?id=45757#c1">Comment 1</a>.
    return 1;
  }
  // <a href="show_bug.cgi?id=45757#c2">Comment 2</a>.
  return 0;
}

int main() {
  f(1);
  return 0;
}
$ bin/clang -fcoverage-mapping -fprofile-instr-generate /tmp/a.c
$ ./a.out
$ bin/llvm-profdata merge default.profraw -o default.profdata
$ bin/llvm-cov show a.out -instr-profile=default.profdata
    1|      1|int f(int x) {
    2|      1|  if (x == 42) {
    3|      0|    // <a href="show_bug.cgi?id=45757#c1">Comment 1</a>.
    4|      0|    return 1;
    5|      0|  }
    6|      1|  // <a href="show_bug.cgi?id=45757#c2">Comment 2</a>.
    7|      1|  return 0;
    8|      1|}
    9|       |
   10|      1|int main() {
   11|      1|  f(1);
   12|      1|  return 0;
   13|      1|}

<a href="show_bug.cgi?id=45757#c1">Comment 1</a> gets an execution count of 0 (and shows on red background in the
console) but <a href="show_bug.cgi?id=45757#c2">Comment 2</a> is marked executed.

Does it make sense to have counters for comments, since they can't really be
executed?

(This was reported by Chromium's code coverage folks in
<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1074518">https://bugs.chromium.org/p/chromium/issues/detail?id=1074518</a>)


It seems gcc/gcov doesn't count the comment lines (gcc -fprofile-arcs
-ftest-coverage /tmp/a.c && ./a.out && gcov a.c && cat a.c.gcov).</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>