Skip to content

Classify included headers without executable code as declaration-only, not no-data #43

Open

Description

@dcalavrezo-qorix

Observation

unmapped_files.txt lists score/launch_manager/src/daemon/src/watchdog/details/Watchdog.hpp (lifecycle) as no-data, although WatchdogImpl_UT.cpp includes it and its tests run. The header holds only constexpr constants and includes, no function, so clang emits no coverage region for it and llvm-cov cannot list it. There is nothing to measure; the file belongs in the harmless declaration-only category.

Not a bug in the measurement: no coverage is lost. The category is wrong.

Why

select_files in reporter.py recognises declaration-only by a naming rule: a header without data whose same-stem source has data (foo.h next to a compiled foo.cpp). A header with no companion source, such as a constants-only or interface-only header, cannot be told apart from a header nothing includes, because a header without functions leaves no trace in the objects. It falls into no-data, the category that is meant to flag real gaps.

Proposal

Use the compiler's own knowledge of which headers were included:

  • With -MD/.d dependency files (Bazel's .d outputs of CppCompile actions) or the showIncludes-style data, the scope aspect can record the set of headers each translation unit included.
  • The reporter then classifies an unmapped header that appears in any compiled unit's include set as declaration-only (included, nothing executable), and leaves no-data for headers no unit included.

Alternative, cheaper but weaker: scan the header text for function definitions ({ bodies outside class/namespace declarations) and classify headers without any as declaration-only. Heuristic and fragile with templates and macros; the dependency-file route is exact.

Acceptance

  • Watchdog.hpp-style headers (included, no functions, no same-stem source) are reported as declaration-only.
  • no-data keeps only files no translation unit in the run compiled or included.
  • Unit test for both cases; end-to-end workspace gets one constants-only header without a companion source.
  • Manual's unmapped-files section describes the rule.

Activity

  1. dcalavrezo-qorix commented on Nov 17, 2026

    @dcalavrezo-qorix
    ContributorAuthor

    not urgent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions