[cfe-dev] probable bug in clang source based coverage

Michał Pszona via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 20 05:37:35 PDT 2017


All,

I am parsing llvm-cov exports (json files) and I was surprised by some
of the outputs.
I was able to narrow it to the below example:

the source file:

int main (int argc, char* argv[])
{
   if ((argc > 1) && (argc < 10))
   {
   }
}

the output:
https://gist.github.com/meahow/84f39ed625d138b42ee1b9cde7613b6a

The confusing part is in segments section:

"segments": [
   [2,1,1,1,1],
   [3,8,1,1,1],
   [3,22,0,1,1],
   [3,33,1,1,0],
   [4,4,0,1,1],
   [5,5,1,1,0],
   [6,2,0,0,0]
],


It looks like there is unclosed region produced.
There are two opening marks in line 3 (cols 8 and 22) and one closing.
I believe that there should be another closing one in col 17.

It looks like this behavior is easily reproducible with multi
statement conditions in if expression like this:

if ( (a > 1) && (a < 5))
{}

Can someone confirm that this is a bug or if I'm not getting it right ?


regards,
Michał Pszona



More information about the cfe-dev mailing list