-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Open
Labels
Description
Hit the issue when measuring coverage for the following Debian package lines:
- distro-info-1.5+deb12u1/distro-info-util.c:759
- distro-info-1.5+deb12u1/distro-info-util.c:875
- mawk,mawk-1.3.4.20200120/print.c:58
- mawk,mawk-1.3.4.20200120/rexp0.c:233
How to reproduce it (Compiler explorer link):
cat > test.c << EOF
int main(int argc, char** argv) {
switch(0) {
case 0:
if (argc > 2)
break;
break;
case 1:
break;
}
return 0;
}
EOF
clang -fprofile-instr-generate -fcoverage-mapping test.c -o test
./test
llvm-profdata merge default.profraw -o default.profdata
llvm-cov show -instr-profile default.profdata testCoverage report where line 7 is incorrectly marked as covered:
1| 1|int main(int argc, char** argv) {
2| 1| switch(0) {
3| 1| case 0:
4| 1| if (argc > 2)
5| 0| break;
6| 1| break;
7| 1| case 1:
8| 0| break;
9| 1| }
10| 1| return 0;
11| 1|}
The necessary condition to trigger this bug:
- An
ifstatement containing a control-flow change statement inside aswitch. - A control-flow change statement immediately following the
ifstatement.
Tests done with
clang --version
Ubuntu clang version 20.1.8 (++20250708082409+6fb913d3e2ec-1~exp1~20250708202428.132)
Target: x86_64-pc-linux-gnu
Thread model: posix