<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/82356>82356</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            llvm-cov: wrong line coverage of 0 for closing brace after statement after return.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ManuelvOK
      </td>
    </tr>
</table>

<pre>
    Having an empty statement after a return statement leads to the line count of a following closing brace being 0:
(I am building all these examples with `-fprofile-instr-generate -fcoverage-mapping`, run them once and create reports with `llvm-cov show`)

```
    1|      1|int main() {
    2|      1|    return 0;;
    3|      0|}
```
The second semicolon in line 2 as well as the closing brace in line 3 have a red background.

Omitting the empty statement leads to line 3 having an execution count of 1:
```
    1| 1|int main() {
    2|      1|    return 0;
    3| 1|}
```

Putting the second semicolon on a dedicated line has the noncovered brace again:
```
    1|      1|int main() {
    2| 1|    return 0;
    3|      0|    ;
    4|      0|}
```

Any statement in line 3 also leads to the brace not being covered:
```
 1|      1|int main() {
    2|      1|    return 0;
    3|      0| int x = 0;
    4|      0|}
```

A second return statement, though:
```
    1|      1|int main() {
    2|      1|    return 0;
    3|      0|    return 0;
    4|      1|}
```

Here is an example with a condition that is run twice, once executing the body and once jumping over it:
```
    1|      2|int foo (int i) {
    2|      2| if (i) {
    3|      1|        return 0;;
    4|      0|    }
 5|      1|    return 1;
    6|      2|}
    7|       |
    8| 1|int main() {
    9|      1|    foo(0);
   10|      1|    foo(1);
 11|      1|    return 0;
   12|      1|}
```

The coverage of closing braces should at least be consistent.
I would expect it to be covered if something inside the enclosed code block is executed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVs2OozgQfhrnUkpkDCFw4NA_ima0Ws0e9gUMFOAZY0e2SXrefmVDQpNsetKakSLsbpfL9X31y60VrUIsyPaZbF9XfHCdNsXfX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