| Issue |
114622
|
| Summary |
[line coverage] macros from system headers after `break` have wrong execution count
|
| Labels |
tools:llvm-cov
|
| Assignees |
|
| Reporter |
whentojump
|
How to reproduce it (Compiler explorer [link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:1,endLineNumber:22,positionColumn:1,positionLineNumber:22,selectionStartColumn:1,selectionStartLineNumber:22,startColumn:1,startLineNumber:22),source:'%23ifdef+HEADER%0A++%23define+FOO+x%2B%2B%0A%23else%0A%0A%23define+HEADER%0A++%23include+%3Cexample.cpp%3E%0A%23undef+HEADER%0A%0Aint+main(void)%0A%7B%0A++++int+x%3B%0A++++for+(int+i%3D0%3B+i%3C10%3B+i%2B%2B)+%7B%0A++++++++if+(i%3D%3D5)%0A++++++++++++break%3B%0A++++++++FOO%3B%0A++++++++x%2B%2B%3B%0A++++%7D%0A++++return+0%3B%0A%7D%0A%0A%23endif%0A'),l:'5',n:'1',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'1',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-fprofile-instr-generate+-fcoverage-mapping+-isystem.+',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(trunk)+(Editor+%231)',t:'0')),k:50,l:'4',m:50,n:'0',o:'',s:0,t:'0'),(g:!((h:tool,i:(args:'',argsPanelShown:'0',compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:1,monacoEditorHasBeenAutoOpened:'1',monacoEditorOpen:'1',monacoStdin:'1',stdin:'',stdinPanelShown:'1',toolId:llvm-covtrunk,treeid:0,wrap:'1'),l:'5',n:'0',o:'llvm-cov+(clang-only)+x86-64+clang+(trunk)+(Editor+%231,+Compiler+%231)',t:'0')),header:(),l:'4',m:50,n:'0',o:'',s:0,t:'0')),k:50,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)):
```shell
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.
```c
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: https://github.com/llvm/llvm-project/issues/78920
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs