> It's possible to have a line of code that has a non-zero coverage.
> However, it can contain unexecuted blocks and I hope adding a
> notification can be usefull. LLVM also does that:
>
> -: 0:Source:ternary.c
> -: 0:Graph:ternary.gcno
> -: 0:Data:ternary.gcda
> -: 0:Runs:1
> -: 0:Programs:1
> -: 1:int b, c, d, e;
> -: 2:
> 1: 3:int main()
> -: 4:{
> 1*: 5: int a = b < 1 ? (c < 3 ? d : c) : e;
> 1: 6: return a;
> -: 7:}
That can be annoying for languages more expressive than C's family though.
For example Ada has built-in overflow checking for addition, which means that:
function Add (I1, I2 : Integer) return Integer is
begin
return I1 + I2;
end;
will now have the '*' symbol:
1: 3: function Add (I1, I2 : Integer) return Integer is
-: 4: begin
1*: 5: return I1 + I2;
-: 6: end;
which doesn't really make sense from the user's viewpoint. How does LLVM deal
with that (assuming it does)?
Testcase attached, compile with gnatmake p -fprofile-arcs -ftest-coverage.
--
Eric Botcazou
procedure P is
function Add (I1, I2 : Integer) return Integer is
begin
return I1 + I2;
end;
begin
if Add (1, 2) /= 3 then
raise Program_Error;
end if;
end;