How to reproduce it (Compiler explorer link):
cat > test.h << EOF
#define FOO x++
EOF
cat > test.c << EOF
#include <test.h>
int main(void)
{
int x;
for (int i=0; i<10; i++) {
if (i==5)
break;
FOO;
x++;
}
return 0;
}
EOF
clang -fprofile-instr-generate -fcoverage-mapping -isystem. test.c -o test
./test
llvm-profdata merge default.profraw -o default.profdata
llvm-cov show -instr-profile default.profdata test
Coverage report where line 8 and 9 are self-contradictory.
1| |#include <test.h>
2| |int main(void)
3| 1|{
4| 1| int x;
5| 6| for (int i=0; i<10; i++) {
6| 6| if (i==5)
7| 1| break;
8| 6| FOO;
9| 5| x++;
10| 5| }
11| 1| return 0;
12| 1|}
(Example reduced from https://github.com/mtoyoda/sl/blob/5.02/sl.c#L108 where getch is from #include <curses.h>)
Related: #78920