scripted-diff: Drop IWYU pragma: keep from build config includes

bitcoin/bitcoin: PR #36875

2 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · Header-wide IWYU exemption lacks its configuration rationale

The bare always_keep pragma leaves readers without the platform-dependent reason for retaining includes or the lint check that handles missing and redundant includes instead.

Location: cmake/bitcoin-build-config.h.in:5 (head).

Details and suggested fix

Configuration macros may be absent on the platform IWYU analyzes, so an apparently unused include can still be necessary on another configuration. Add a short comment above the pragma explaining this and pointing to lint_includes_build_config for missing and redundant direct-include checks. This documents why the broad exemption is intentional, consistent with the nearby-comment guidance in doc/developer-notes.md:559.

Avoid the lowercase substring define in the comment, including in undefined: the lint extracts macro names by running grep define over this template and taking each matching line's second whitespace token. Wording such as “configuration macros may be absent on some platforms” avoids adding a bogus macro name.


Link

[suggestion] · Lint follow-up leaves its broader acceptance rule unexplained

The follow-up commit combines stale-diagnostic cleanup with a broader missing-include match, leaving the separate acceptance change unexplained.

Location: test/lint/test_runner/src/lint_cpp.rs:53 at 53561d803747 (commit) (commit).

Details and suggested fix

The scripted commit 04108a0dbb4633a861232238a53008f15906b953 removes the per-include pragma while retaining ^#include <bitcoin-build-config.h>$ for the missing-include check. Its direct successor, 53561d803747567fc01ca1513ecfb280a01aa5a9, removes the stale pragma diagnostic but also replaces that pattern with an unanchored substring. A file referencing a configuration macro can therefore satisfy this check with // #include <bitcoin-build-config.h>; the redundant-include pass examines the complementary file set. No currently affected source file was identified.

Add a short body to the follow-up commit distinguishing the diagnostic cleanup from the matching change and explaining whether the broader acceptance is intentional. If it is not intentional, retain the start-of-line anchor there. Neither correction requires reordering or squashing the mechanical change and its follow-up.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

The original keep requirement protected includes that IWYU could incorrectly consider unused when configuration macros were undefined on the platform being analyzed.

PR #29494 explicitly says that configuration symbols may be defined or undefined and that keep preserves the include when a symbol is undefined. The preceding discussion cites macros commented out in CI and proposes keep everywhere because IWYU's behavior appeared fragile. This explains the retention requirement being moved from individual includes to the generated header; it does not document a requirement specific to older IWYU versions or generated-file processing.

Source 1 · Source 2 · Source 3

Configuration-header inclusion was checked separately because a missing include could silently change feature selection without causing compilation to fail.

The original lint proposal gives selection of a slower fallback despite an available faster feature as an example. In the pinned base, lint_includes_build_config checks macro references and requires an annotated direct include. Its diagnostic repeats this rationale. The supplied change retains the inclusion check while removing its requirement for the per-include annotation.

Source 1 · Source 2 · Source 3

Ralph's inferences

The inspected history supports a platform-configuration rationale, not a demonstrated compatibility reason why per-include keep must be used instead of header-level always_keep.

The historical concern is preserving a needed include even when the analyzed configuration exposes no macro dependency. The pinned head places always_keep in cmake/bitcoin-build-config.h.in, whereas the base enforces keep at each include. Nothing inspected identifies an additional generated-header handling constraint or a supported-version limitation that distinguishes those annotation locations. This is a bounded historical conclusion, not verification of their equivalence across IWYU versions.

Source 1 · Source 2 · Source 3