Reland "[llvm-cov] Add support for baseline coverage" (#144130)

When no profile is provided, but the new --empty-profile option is
specified, the export/report/show commands now emit coverage data
equivalent to that obtained from a profile with all zero counters
("baseline coverage").

This is useful for build systems (e.g. Bazel) that can track coverage
information for each build target, even those that are never linked into
tests and thus don't have runtime coverage data recorded. By merging in
baseline coverage, lines in files that aren't linked into tests are
correctly reported as uncovered.

Reland with fixes to `CoverageMappingTest.cpp`.

Reverts llvm/llvm-project#144121
This commit is contained in:
Fabian Meumertzheim
2025-06-13 21:09:58 +02:00
committed by GitHub
parent 90d98a38b2
commit 83f215b035
6 changed files with 195 additions and 86 deletions

View File

@@ -380,6 +380,11 @@ OPTIONS
Fail if an object file cannot be found for a binary ID present in the profile,
neither on the command line nor via binary ID lookup.
.. option:: -empty-profile
Display the baseline coverage of the binaries with all zero execution counts.
Mutually exclusive with -instr-profile.
.. program:: llvm-cov report
.. _llvm-cov-report:
@@ -470,6 +475,11 @@ OPTIONS
Fail if an object file cannot be found for a binary ID present in the profile,
neither on the command line nor via binary ID lookup.
.. option:: -empty-profile
Display the baseline coverage of the binaries with all zero execution counts.
Mutually exclusive with -instr-profile.
.. program:: llvm-cov export
.. _llvm-cov-export:
@@ -562,6 +572,11 @@ OPTIONS
Fail if an object file cannot be found for a binary ID present in the profile,
neither on the command line nor via binary ID lookup.
.. option:: -empty-profile
Export the baseline coverage of the binaries with all zero execution counts.
Mutually exclusive with -instr-profile.
CONVERT-FOR-TESTING COMMAND
---------------------------