Skip to content

[Coverage] Add a field in Coverage Mapping header for tracking coverage capabilities #158027

@RenjiSann

Description

@RenjiSann

(This issue is related to this Discourse discussion)

Problem

Code coverage consists in several strategies (namely statement, branch, and MC/DC for clang) which require specific code instrumentation to work.

To instrument code for simple statement and branch coverage, we need to pass -fprofile-instr-generate and -fcoverage-mapping.
The -fcoverage-mcdc option enables further instrumentation for the MC/DC coverage.

When it comes to generating coverage reports, we use the -show-mcdc option.

However, using this option when the analyzed code was not instrumented for MC/DC is a no-op.
This is problematic, because it means that we can't know for sure that there is no MC/DC report because we forgot to instrument for it, or because there is no code region of interest for MC/DC.

In safety-critical tooling, this is problematic, as it is a behavior that is prone to false-positives.

Proposed solution

The goal is to have a way to determine if an instrumented code has capabilities to provide specific coverage information.

As discussed on Discourse, this could be done through the coverage mapping header, that could be set by clang and read by llvm-cov.

The discussed solution would be to add a bitset field in the coverage header, where each bit represents a capability. For now, 3 bits would be used (for statement, branch and MCDC) but could be extended in the future

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions