Detecting if code coverage is enabled

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Detecting if code coverage is enabled

Eric Fiselier via cfe-dev
I want to add a call to __llvm_profile_dump() to customize code coverage recording.

Is there a way to detect if code coverage is enabled at compile time? I wasn't able to find any __has_feature/__has_extension/macro for this in the documentation.

Currently, I solved this by adding custom preprocessor defines for the configurations that are used for running code with code coverage, but IMO it would be more reliable and convenient if there would be something built-in into compiler itself.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Detecting if code coverage is enabled

Eric Fiselier via cfe-dev

> On Oct 30, 2017, at 5:19 AM, Nickolas Pohilets via cfe-dev <[hidden email]> wrote:
>
> I want to add a call to __llvm_profile_dump() to customize code coverage recording.
>
> Is there a way to detect if code coverage is enabled at compile time? I wasn't able to find any __has_feature/__has_extension/macro for this in the documentation.
>
> Currently, I solved this by adding custom preprocessor defines for the configurations that are used for running code with code coverage, but IMO it would be more reliable and convenient if there would be something built-in into compiler itself.

There isn't a preprocessor define or compiler feature you can check at compile-time to determine whether coverage is enabled. We've held off on doing this to avoid creating situations where users #ifdef out code to change coverage results. Is there something about passing a custom define that's problematic?

vedant


>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev