WIP: iwyu: Fix warnings in src/test/fuzz and treat them as errors

bitcoin/bitcoin: PR #36808

2 suggestions

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

Optional improvements

Link

[suggestion] · test/fuzz/util/wallet.h remains outside IWYU enforcement

The new --check_also checks test/fuzz/util/wallet.h only in the warnings pass, so suggested rewrites do not fail CI; IWYU was not run to determine whether it currently reports any.

Location: ci/test/03_test_script.sh:271 (head).

Details and suggested fix

The only tracked includer is src/wallet/test/fuzz/spend.cpp, whose /src/wallet/ path does not match FILES_WITH_ENFORCED_IWYU. Adding --check_also makes the header reportable while processing that translation unit, but does not move it into compile_commands_iwyu_errors.json. The warnings pass applies fix_includes.py and prints the diff without checking --exit-code. To include this header in the enforced fuzz scope, add its includer to the enforced set once it is IWYU-clean. If reporting alone is intentional, mark this option as report-only.


Link

[suggestion] · Shared-header changes are buried in 08d7d419's fuzz cleanup

The fuzz-cleanup commit also changes shared production headers, adds the IWYU workaround, and removes bitdeque declarations, making those separate review decisions harder to inspect; this is a review-flow concern, not a head defect.

Location: src/private_broadcast.h:21 at 08d7d419348c (commit) (commit).

Details and suggested fix

The series separates the CI-list refactor in 645271533b2e7869f4a984c4897a12b2408254e8 from the production-module cleanup in a960fe3705fed4abe223247400fa366e30387db4, but 08d7d419348ce979fddacf790f1b8a5d36444107 bundles the remaining shared-header changes with the large fuzz-include cleanup and enforcement. Changes such as replacing <net.h> in shared headers, adding the private_broadcast.h suppressions, and removing the Iterator forward and friend declarations from util/bitdeque.h deserve inspection separately from mechanical fuzz includes.

Move the production-header and mapping changes into a preparatory commit after a960fe3705fed4abe223247400fa366e30387db4, carrying the source include additions needed to keep those changes buildable, as that earlier commit already does. Leave the remaining fuzz cleanup and CI enforcement afterward. Keep dependent header and includer fixes together rather than making a header-only split. The exact dependency-preserving partition has not been worked out or built.


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

IWYU can mistake a valid use of a nested type during implicit member destruction for a use occurring before that type's definition, then suggest an invalid namespace-scope declaration such as struct A::B;. Upstream #2142 explains that scanning an instantiated member destructor failed to mark the use as inside a C++ method body; the use was attributed to the enclosing class's location, before the nested definition.

Both base and head define CTransactionRefHash and CTransactionRefComp inside PrivateBroadcast and use them as template arguments of the m_transactions unordered_map member. The head adds only targeted no_forward_declare pragmas for these two names. This is the relevant class of false suggestion: the helper types already have definitions inside their enclosing class, rather than needing the qualified top-level declarations IWYU proposes.

Source 1 · Source 2

The limitation is version-sensitive, not a universal inability to handle nested types. Upstream #2145 identifies a specific regression introduced by 4966ff6: traversing a constructor or destructor declaration name can rescan a template specialization's members and report nested-type uses at the enclosing class. Its author reports that the reduced example works before that change. Separately, #1707 originally reported invalid nested declarations with IWYU 0.23 based on Clang 19.1.1; #2145 explicitly cautions that this older report predates the identified regression and may have another cause.

The head comment links #2142, but that link alone does not establish whether the same mechanism exists in the CI build. The inspected ci/test/01_base_install.sh selects an IWYU clang-version branch and applies a local patch. Determining applicability therefore requires identifying that selected revision and patch contents, rather than assuming that an upstream-master reproducer applies to every IWYU release.

Source 1 · Source 2 · Source 3

Ralph's inferences

The suppressions are best understood as narrowly disabling erroneous declaration advice, not as satisfying a missing C++ declaration requirement. The historical evidence explains the symptom, but does not conclusively establish that the pinned CI build needs this workaround.

The base already contains the two complete nested helper definitions and their unordered_map use; the head retains that structure and adds the two suppressions. This matches the documented symptom structurally. However, neither the exact CI version nor the precise triggering path for this unordered_map instantiation was verified, so a definitive yes or no on version applicability would exceed the inspected evidence.

Source 1 · Source 2