From fdc9fe2da6a8640b11a2871f8b653764652f8c1f Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 20 Jan 2026 14:46:00 +0000 Subject: [PATCH] ci, iwyu: Fix warnings in `src/primitives` and treat them as errors --- ci/test/03_test_script.sh | 3 ++- src/primitives/block.cpp | 4 ++++ src/primitives/block.h | 5 +++++ src/primitives/transaction.cpp | 2 +- src/primitives/transaction.h | 2 +- src/primitives/transaction_identifier.h | 7 +++++-- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index 050d9e6a599..7f605fb0319 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -215,7 +215,7 @@ fi if [[ "${RUN_IWYU}" == true ]]; then # TODO: Consider enforcing IWYU across the entire codebase. - FILES_WITH_ENFORCED_IWYU="/src/((crypto|index|kernel)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_io.cpp|signet.cpp)" + FILES_WITH_ENFORCED_IWYU="/src/((crypto|index|kernel|primitives)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_io.cpp|signet.cpp)" jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns)))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_errors.json" jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns) | not))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_warnings.json" @@ -227,6 +227,7 @@ if [[ "${RUN_IWYU}" == true ]]; then -p "${BASE_BUILD_DIR}" "${MAKEJOBS}" \ -- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \ -Xiwyu --max_line_length=160 \ + -Xiwyu --check_also="*/primitives/*.h" \ 2>&1 | tee /tmp/iwyu_ci.out python3 "/include-what-you-use/fix_includes.py" --nosafe_headers < /tmp/iwyu_ci.out git diff -U0 | ./contrib/devtools/clang-format-diff.py -binary="clang-format-${TIDY_LLVM_V}" -p1 -i -v diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index c390de3800b..dfeed29575c 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -8,6 +8,10 @@ #include #include +#include +#include +#include + uint256 CBlockHeader::GetHash() const { return (HashWriter{} << *this).GetHash(); diff --git a/src/primitives/block.h b/src/primitives/block.h index 3c22c0f6eb6..8ca4fb4800e 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -11,6 +11,11 @@ #include #include +#include +#include +#include +#include + /** Nodes collect new transactions into a block, hash them into a hash tree, * and scan through nonce values to make the block's hash satisfy proof-of-work * requirements. When they solve the proof-of-work, they broadcast the block diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index c8bbd9f821e..5d7cd52916e 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -12,10 +12,10 @@ #include