Skip to content

[line coverage] macros from system headers after break have wrong execution count #114622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
whentojump opened this issue Nov 1, 2024 · 0 comments

Comments

@whentojump
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant