From 9664135d17b589bd54bb46a349e3209c4c0f8768 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 23 Sep 2025 22:14:02 +0100 Subject: [PATCH 1/2] ci: Update Clang in "tidy" job This change updates to IWYU 0.25, which is compatible with Clang 21. Fixes new "modernize-use-default-member-init" warnings. The warning in `interpreter.cpp` is a false positive, so it has been suppressed. --- ci/test/00_setup_env_native_tidy.sh | 2 +- src/qt/recentrequeststablemodel.h | 4 ++-- src/qt/transactionfilterproxy.cpp | 4 +--- src/qt/transactionfilterproxy.h | 2 +- src/script/interpreter.cpp | 4 ++++ src/txdb.cpp | 4 ++-- src/zmq/zmqabstractnotifier.h | 3 +-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ci/test/00_setup_env_native_tidy.sh b/ci/test/00_setup_env_native_tidy.sh index c14e59b7289..5a2fa300998 100755 --- a/ci/test/00_setup_env_native_tidy.sh +++ b/ci/test/00_setup_env_native_tidy.sh @@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8 export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04" export CONTAINER_NAME=ci_native_tidy -export TIDY_LLVM_V="20" +export TIDY_LLVM_V="21" export APT_LLVM_V="${TIDY_LLVM_V}" export PACKAGES="clang-${TIDY_LLVM_V} libclang-${TIDY_LLVM_V}-dev llvm-${TIDY_LLVM_V}-dev libomp-${TIDY_LLVM_V}-dev clang-tidy-${TIDY_LLVM_V} jq libevent-dev libboost-dev libzmq3-dev systemtap-sdt-dev qt6-base-dev qt6-tools-dev qt6-l10n-tools libqrencode-dev libsqlite3-dev libcapnp-dev capnproto" export NO_DEPENDS=1 diff --git a/src/qt/recentrequeststablemodel.h b/src/qt/recentrequeststablemodel.h index 151f8322a8a..7a5b71c932e 100644 --- a/src/qt/recentrequeststablemodel.h +++ b/src/qt/recentrequeststablemodel.h @@ -18,10 +18,10 @@ class WalletModel; class RecentRequestEntry { public: - RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION) {} + RecentRequestEntry() = default; static const int CURRENT_VERSION = 1; - int nVersion; + int nVersion{RecentRequestEntry::CURRENT_VERSION}; int64_t id{0}; QDateTime date; SendCoinsRecipient recipient; diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp index 1ad77fd767f..1f455576f7f 100644 --- a/src/qt/transactionfilterproxy.cpp +++ b/src/qt/transactionfilterproxy.cpp @@ -12,9 +12,7 @@ #include TransactionFilterProxy::TransactionFilterProxy(QObject* parent) - : QSortFilterProxyModel(parent), - m_search_string(), - typeFilter(ALL_TYPES) + : QSortFilterProxyModel(parent) { } diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h index d0f7031a331..a8570c5bcc1 100644 --- a/src/qt/transactionfilterproxy.h +++ b/src/qt/transactionfilterproxy.h @@ -44,7 +44,7 @@ private: std::optional dateFrom; std::optional dateTo; QString m_search_string; - quint32 typeFilter; + quint32 typeFilter{ALL_TYPES}; CAmount minAmount{0}; bool showInactive{true}; }; diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 07fda48c493..1070afbac68 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1253,8 +1253,12 @@ private: const CScript& scriptCode; //!< output script being consumed const unsigned int nIn; //!< input index of txTo being signed const bool fAnyoneCanPay; //!< whether the hashtype has the SIGHASH_ANYONECANPAY flag set + // Temporary workaround for a clang-tidy bug. + // See: https://github.com/llvm/llvm-project/issues/160394. + // NOLINTBEGIN(modernize-use-default-member-init) const bool fHashSingle; //!< whether the hashtype is SIGHASH_SINGLE const bool fHashNone; //!< whether the hashtype is SIGHASH_NONE + // NOLINTEND(modernize-use-default-member-init) public: CTransactionSignatureSerializer(const T& txToIn, const CScript& scriptCodeIn, unsigned int nInIn, int nHashTypeIn) : diff --git a/src/txdb.cpp b/src/txdb.cpp index bb6ee2eb524..93cd5948aec 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -38,8 +38,8 @@ namespace { struct CoinEntry { COutPoint* outpoint; - uint8_t key; - explicit CoinEntry(const COutPoint* ptr) : outpoint(const_cast(ptr)), key(DB_COIN) {} + uint8_t key{DB_COIN}; + explicit CoinEntry(const COutPoint* ptr) : outpoint(const_cast(ptr)) {} SERIALIZE_METHODS(CoinEntry, obj) { READWRITE(obj.key, obj.outpoint->hash, VARINT(obj.outpoint->n)); } }; diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h index 17fa7bbaa91..47132cd5704 100644 --- a/src/zmq/zmqabstractnotifier.h +++ b/src/zmq/zmqabstractnotifier.h @@ -21,7 +21,6 @@ class CZMQAbstractNotifier public: static const int DEFAULT_ZMQ_SNDHWM {1000}; - CZMQAbstractNotifier() : outbound_message_high_water_mark(DEFAULT_ZMQ_SNDHWM) {} virtual ~CZMQAbstractNotifier(); template @@ -61,7 +60,7 @@ protected: void* psocket{nullptr}; std::string type; std::string address; - int outbound_message_high_water_mark; // aka SNDHWM + int outbound_message_high_water_mark{DEFAULT_ZMQ_SNDHWM}; // aka SNDHWM }; #endif // BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H From 5b20d172ca2a46a2b525201b4ff2444f9d415d8c Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 23 Sep 2025 22:14:27 +0100 Subject: [PATCH 2/2] clang-tidy: Disable `ArrayBound` check in src/ipc and src/test --- src/ipc/.clang-tidy.in | 8 +++++--- src/test/.clang-tidy.in | 3 +++ src/test/CMakeLists.txt | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/test/.clang-tidy.in diff --git a/src/ipc/.clang-tidy.in b/src/ipc/.clang-tidy.in index 2fc880ed078..68dcb297959 100644 --- a/src/ipc/.clang-tidy.in +++ b/src/ipc/.clang-tidy.in @@ -1,3 +1,5 @@ -Checks: ' --clang-analyzer-core.UndefinedBinaryOperatorResult, -' +Checks: + # See: https://github.com/capnproto/capnproto/pull/2334. + - "-clang-analyzer-core.UndefinedBinaryOperatorResult" + # See: https://github.com/capnproto/capnproto/pull/2417. + - "-clang-analyzer-security.ArrayBound" diff --git a/src/test/.clang-tidy.in b/src/test/.clang-tidy.in new file mode 100644 index 00000000000..92d24f6f660 --- /dev/null +++ b/src/test/.clang-tidy.in @@ -0,0 +1,3 @@ +Checks: + # See: https://github.com/capnproto/capnproto/pull/2417. + - "-clang-analyzer-security.ArrayBound" diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index c963afff351..cadc1f29a63 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -177,6 +177,8 @@ if(ENABLE_IPC) ipc_tests.cpp ) target_link_libraries(test_bitcoin bitcoin_ipc_test bitcoin_ipc) + + configure_file(.clang-tidy.in .clang-tidy USE_SOURCE_PERMISSIONS COPYONLY) endif() function(add_boost_test source_file)