[cfe-dev] Detecting if code coverage is enabled

Vedant Kumar via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 30 14:10:18 PDT 2017

> On Oct 30, 2017, at 5:19 AM, Nickolas Pohilets via cfe-dev <cfe-dev at lists.llvm.org> 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?


> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list