Description
Myself, multiple other maintainers and users got confused about what SanitizerCoverage
is and how it works.
Its documentation simply states
LLVM has a simple code coverage instrumentation built in (SanitizerCoverage). It inserts calls to user-defined functions on function-, basic-block-, and edge- levels. Default implementations of those callbacks are provided and implement simple coverage reporting and visualization, however if you need just coverage visualization you may want to use SourceBasedCodeCoverage instead.
This does not make it clear that the intent is that this coverage tool is meant to be used alongside other sanitizers, which immediately brings a few questions
- Why is this related to other sanitizers at all?
- Can this be used independently of any other sanitizer?
- Which sanitizer can this be used with?
The names of the options (-fsanitize-coverage-xxx
) and related tools (sanconv
) are also misleading and inconsistent.
There is better documentation in SourceBasedCodeCoverage which explains
This document explains how to use Clang’s source-based code coverage feature. It’s called “source-based” because it operates on AST and preprocessor information directly. This allows it to generate very precise coverage data.
Clang ships two other code coverage implementations:
- SanitizerCoverage - A low-overhead tool meant for use alongside the various sanitizers. It can provide up to edge-level coverage.
- gcov - A GCC-compatible coverage implementation which operates on DebugInfo. This is enabled by -ftest-coverage or --coverage.
But this is less visible.
It would be great to find ways to make all of that clearer. Possible options include
- Finding a better name (instrumented coverage?)
- Group the documentation of all 3 kinds of sanitizers under the same section (but still in different subpages)
- Add a better introductory description to the
SanitizerCoverage
page