<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/116884>116884</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Line Coverage] for loop which has empty predicate or true from <stdbool.h> as the predicate has wrong execution counters
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          manvik99
      </td>
    </tr>
</table>

<pre>
    How to reproduce the bug ( Compiler explorer link: [link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:2,endLineNumber:11,positionColumn:2,positionLineNumber:11,selectionStartColumn:2,selectionStartLineNumber:11,startColumn:2,startLineNumber:11),source:'int+main()%7B%0A++++int+x+%3D+0%3B%0A++++for+(int+i%3D0%3B+%3B+i%2B%2B)%0A++++%7B%0A++++++++if+(x+%3D%3D2)%7B%0A++++++++++++break%3B%0A++++++++%7D%0A++++++++x%2B%2B%3B%0A++++%7D%0A++++return+0%3B+%0A%7D'),l:'5',n:'0',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:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'',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:'1',compilerName:'x86-64+clang+19.1.0',editorid:1,fontScale:14,fontUsePx:'0',j:1,monacoEditorHasBeenAutoOpened:'1',monacoEditorOpen:'1',monacoStdin:'1',stdin:'',stdinPanelShown:'1',toolId:llvm-covtrunk,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) )
```
cat > test.c << EOF
int main(){
    int x = 0;
    for (int i=0; ; i++)
    {
        if (x == 2){
            break;
 }
        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
```

which would produce:


```
    1|      1|int main(){
    2|      1|    int x = 0;           // N1
    3|      2| for (int i=0; ; i++) // N2-N1
    4|      3|    {                    // N2
    5|      3|        if (x == 2){
    6|      1| break;
    7|      1|        }
    8|      2|        x++;
    9| 2|    }
   10|      1|    return 0;
   11|      1|}
```

The line before 'for' (Line number 2) has counter value N1.
The line after 'for' ( Line number 4) has counter value N2.
The line counter for 'for' ( Line number 3) is (N2-N1), which is hard to interpret.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysWN9voz4S_2ucFysRGCjhIQ8N2WpPOrUr9e5eTwYmxFtjI9sk7X__lW1IICTd7mqrNMHz4zPj8czYhmrNagGwQckWJbsF7cxBqk1DxZG9ZdmikNXH5rs8YSOxglbJqisBmwPgoqsxImucy6ZlHBSG95ZLBQpzJt5Q9IhRsnWPyQ6R9cGYVqPoEZEnRJ5qWRWSm5VUtSNEtWOFiKwRWd8fHFD0WMoKvlXMSIVIzhx3vWccBG3AjdIQkRSRfC-FeS0pt9Qw7gn_1fDj3YsFXuynZSOScyqsrRKRhGz7r1wDh9Iw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