Skip to content

Commit 3b9c29d

Browse files
001493a fix: more fixes for performance-move-const-arg clang-tidy (Konstantin Akimov) 245d1b1 fix: more fixes for bugprone-use-after-move clang-tidy (Konstantin Akimov) 022896e fix: more fixes for performance-unnecessary-copy-initialization due to newer clang 19 (Konstantin Akimov) 36d589a partial Merge bitcoin#31306: ci: Update Clang in "tidy" job (merge-script) 828b9bc Merge bitcoin#31051: test: remove unused code from `script_tests` (merge-script) b33214c Merge bitcoin#31305: refactor: Fix remaining clang-tidy performance-inefficient-vector errors (Ava Chow) 4734a59 Merge bitcoin#31364: refactor: Fix remaining clang-tidy performance-unnecessary-copy-initialization errors (Ava Chow) fdddfc1 Merge bitcoin#25872: Fix issues when calling std::move(const&) (fanquake) 887d7b3 Merge bitcoin#25701: fix comment spellings from the codespell lint (fanquake) 0e7d0e2 partial Merge bitcoin#25707: refactor: Make const references to avoid unnecessarily copying objects and enable two clang-tidy checks (MacroFake) 03a8a7e Merge bitcoin#25733: tidy: enable bugprone-use-after-move (MacroFake) 3538700 Merge bitcoin#25466: ci: add unused-using-decls to clang-tidy (MacroFake) f89f8a1 Merge bitcoin#25351: rpc, wallet: Scan mempool after import* - Second attempt (Andrew Chow) b78bf3e Merge bitcoin#24419: lint: remove no-longer used exceptions from lint-format-strings.py (MarcoFalke) Pull request description: ## What was done? Some more regular backports from Bitcoin Core v24; some extra backports have been pulled from Bitcoin Core v29 to fix clang-tidy for newer clang-19 ## How Has This Been Tested? Run unit & functional tests ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: UdjinM6: utACK 001493a kwvg: utACK 001493a Tree-SHA512: 39927ecc4008aa7602947e3cdb018ba141e0dae3e9f6f7f983411dc24cb6300c0d27e4f5a9128e292a184ef18841f6da640479c78cc8e0c1d1816dc405bc850f
2 parents aa4e582 + 001493a commit 3b9c29d

File tree

82 files changed

+241
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+241
-163
lines changed

ci/dash/lint-tidy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ iwyu_tool.py \
4444
"src/util/moneystr.cpp" \
4545
"src/util/serfloat.cpp" \
4646
"src/util/spanparsing.cpp" \
47+
"src/util/string.cpp" \
4748
"src/util/strencodings.cpp" \
4849
"src/util/syserror.cpp" \
4950
"src/util/url.cpp" \
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Fixups / upstreamed changes
1+
# Nothing for now.
22
[
33
]

src/.clang-tidy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
Checks: '
22
-*,
33
bugprone-argument-comment,
4+
bugprone-use-after-move,
5+
misc-unused-using-decls,
46
modernize-use-default-member-init,
57
modernize-use-nullptr,
8+
performance-for-range-copy,
9+
performance-move-const-arg,
10+
performance-unnecessary-copy-initialization,
611
readability-const-return-type,
712
readability-redundant-declaration,
813
readability-redundant-string-init,
914
'
1015
WarningsAsErrors: '
1116
bugprone-argument-comment,
17+
bugprone-use-after-move,
18+
misc-unused-using-decls,
1219
modernize-use-default-member-init,
1320
modernize-use-nullptr,
21+
performance-move-const-arg,
22+
performance-unnecessary-copy-initialization,
1423
readability-redundant-declaration,
1524
readability-redundant-string-init,
1625
'
26+
CheckOptions:
27+
- key: performance-move-const-arg.CheckTriviallyCopyableMove
28+
value: false

src/bench/load_external.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void LoadExternalBlockFile(benchmark::Bench& bench)
2828
// block data) as a stream object.
2929
const fs::path blkfile{testing_setup.get()->m_path_root / "blk.dat"};
3030
CDataStream ss(SER_DISK, 0);
31-
auto params{Params()};
31+
const auto& params{Params()};
3232
ss << params.MessageStart();
3333
ss << static_cast<uint32_t>(benchmark::data::block813851.size());
3434
// We can't use the streaming serialization (ss << benchmark::data::block813851)

src/bench/prevector.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static void PrevectorFillVectorDirect(benchmark::Bench& bench)
112112
{
113113
bench.run([&] {
114114
std::vector<prevector<28, T>> vec;
115+
vec.reserve(260);
115116
for (size_t i = 0; i < 260; ++i) {
116117
vec.emplace_back();
117118
}
@@ -124,6 +125,7 @@ static void PrevectorFillVectorIndirect(benchmark::Bench& bench)
124125
{
125126
bench.run([&] {
126127
std::vector<prevector<28, T>> vec;
128+
vec.reserve(260);
127129
for (size_t i = 0; i < 260; ++i) {
128130
// force allocation
129131
vec.emplace_back(29, T{});

src/bench/wallet_loading.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
using wallet::CWallet;
2020
using wallet::DatabaseFormat;
2121
using wallet::DatabaseOptions;
22-
using wallet::ISMINE_SPENDABLE;
23-
using wallet::MakeWalletDatabase;
2422
using wallet::TxStateInactive;
2523
using wallet::WALLET_FLAG_DESCRIPTORS;
2624
using wallet::WalletContext;

src/bitcoin-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ static void GetWalletBalances(UniValue& result)
948948

949949
UniValue balances(UniValue::VOBJ);
950950
for (const UniValue& wallet : wallets.getValues()) {
951-
const std::string wallet_name = wallet.get_str();
951+
const std::string& wallet_name = wallet.get_str();
952952
const UniValue getbalances = ConnectAndCallRPC(&rh, "getbalances", /* args=*/{}, wallet_name);
953953
const UniValue& balance = getbalances.find_value("result")["mine"]["trusted"];
954954
balances.pushKV(wallet_name, balance);

src/bitcoin-tx.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strIn
279279
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
280280

281281
// extract and validate ADDRESS
282-
std::string strAddr = vStrInputParts[1];
282+
const std::string& strAddr = vStrInputParts[1];
283283
CTxDestination destination = DecodeDestination(strAddr);
284284
if (!IsValidDestination(destination)) {
285285
throw std::runtime_error("invalid TX output address");
@@ -311,7 +311,7 @@ static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& str
311311
// Extract and validate FLAGS
312312
bool bScriptHash = false;
313313
if (vStrInputParts.size() == 3) {
314-
std::string flags = vStrInputParts[2];
314+
const std::string& flags = vStrInputParts[2];
315315
bScriptHash = (flags.find('S') != std::string::npos);
316316
}
317317

@@ -363,7 +363,7 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
363363
// Extract FLAGS
364364
bool bScriptHash = false;
365365
if (vStrInputParts.size() == numkeys + 4) {
366-
std::string flags = vStrInputParts.back();
366+
const std::string& flags = vStrInputParts.back();
367367
bScriptHash = (flags.find('S') != std::string::npos);
368368
}
369369
else if (vStrInputParts.size() > numkeys + 4) {
@@ -428,13 +428,13 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str
428428
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
429429

430430
// extract and validate script
431-
std::string strScript = vStrInputParts[1];
431+
const std::string& strScript = vStrInputParts[1];
432432
CScript scriptPubKey = ParseScript(strScript);
433433

434434
// Extract FLAGS
435435
bool bScriptHash = false;
436436
if (vStrInputParts.size() == 3) {
437-
std::string flags = vStrInputParts.back();
437+
const std::string& flags = vStrInputParts.back();
438438
bScriptHash = (flags.find('S') != std::string::npos);
439439
}
440440

@@ -555,7 +555,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
555555
UniValue prevtxsObj = registers["prevtxs"];
556556
{
557557
for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) {
558-
UniValue prevOut = prevtxsObj[previdx];
558+
const UniValue& prevOut = prevtxsObj[previdx];
559559
if (!prevOut.isObject())
560560
throw std::runtime_error("expected prevtxs internal object");
561561

src/blockfilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const std::set<BlockFilterType>& AllBlockFilterTypes()
170170

171171
static std::once_flag flag;
172172
std::call_once(flag, []() {
173-
for (auto entry : g_filter_types) {
173+
for (const auto& entry : g_filter_types) {
174174
types.insert(entry.first);
175175
}
176176
});

src/bls/bls_worker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ template <typename T>
1515
bool VerifyVectorHelper(Span<T> vec)
1616
{
1717
std::set<uint256> set;
18-
for (auto item : vec) {
18+
for (const auto& item : vec) {
1919
if (!item.IsValid())
2020
return false;
2121
// check duplicates

0 commit comments

Comments
 (0)