llvm / llvm/llvm-project

[llvm-cov] catch after uncovered catch is considered uncovered

Open
#164,414 4 comments 0 reactions 1 assignee Claimed by @aaronpuchert View on GitHub
clang:codegen debuginfo
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Hi!
In our tests we have code with chained catch statements where only one of them is actually executed. If this is the first catch, everything is fine, but if the catch block that's followed by an uncovered catch block is executed, the first line (the catch itself) is considered as uncovered. I see this pattern in multiple locations, so this seems to be a general issue with llvm-cov. When using gcov everything is marked correctly as covered and uncovered.

My example code looks like this:

```c++
try {
throw SomeException(__FILE__, __LINE__, "...");
} catch (const SpecialException&) { // uncovered
x = 0;
} catch (const SomeException&) { // executed
x = 1;
}
```

We verify by checking the value of x that indeed the second catch is executed. But still, llvm-cov marks the catch as uncovered:

```
110 : try {
111 2 : throw SomeException(__FILE__, __LINE__, "...");
112 0 : } catch (const SpecialException&) {
113 0 : x = 0;
114 0 : } catch (const SomeException&) {
115 2 : x = 1;
116 : }
```

Is this a known issue, or are we using llvm-cov or interpreting the results in a wrong way?

Sorry for the formatting, for some reason formatting as code doesn't work as expected...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.