Code coverage issue - unreachable code is incorrectly being marked as hit by code coverage tool
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
llvm-cov code coverage tool incorrectly marks the following code as reachable.
This example illustrates the issue: https://godbolt.org/z/ha8PMGGG9
```
#include
#include
void good() {
exit(0);
puts("never get here"); // Code coverage correctly says this is not reached
}
void inner() {
exit(0);
}
void bad() {
inner();
puts("never get here"); // Code coverage says we reach this
}
```
This commit terminates region when noreturn funtion is hit: https://github.com/llvm/llvm-project/commit/181dfe4c92ad2671a4ff5c2d91d927dd5a9958b8
Additional instructions to reproduce this issue in a local workspace:
o clang -c code-cov-issue.c -fprofile-instr-generate -fcoverage-mapping
o clang -o app.exe code-cov-issue.o -fprofile-instr-generate
o ./app.exe
o llvm-profdata merge -o app.profdata *.profraw
o llvm-cov show --instr-profile=app.profdata ./app.exe
Contributor guide
Assessment
This issue has not been assessed yet.