CTFE in coverage reports - I finally fixed it

Bruce Carneal bcarneal at gmail.com
Mon Jun 15 16:49:16 UTC 2020


On Monday, 15 June 2020 at 15:02:04 UTC, Stefan Koch wrote:
> Hi Guys,
>
> CTFE not being in coverage reports has made 100% coverage 
> unattainable
> for code which has if (__ctfe) branches.
>
> Well fret no more.

[snip of code demonstrating the improvement, better coverage 
stats]

>
>
> The way it works is quite simple.
> During CTFE we keep an array which counts the lines we hit.
> When it comes time to do codegen we simply initialize the 
> hidden __coverge symbol.
> Which is a uint[]  representing the coverage counts for line 
> numbers with that information rather than filling it with zeros.
>
> Therefore no modification to the runtime is necessary at all.
>
> It's open as DMD pr: https://github.com/dlang/dmd/pull/11279
>
> and hopefully passing on all platforms.
>
> Cheers,
>
> Stefan

Thanks for this Stefan.  Another nice step towards "it all just 
works" and a commendably simple implementation.







More information about the Digitalmars-d mailing list