Skip to content

Commit 0514237

Browse files
MacroFakeknst
authored andcommitted
Merge bitcoin#25733: tidy: enable bugprone-use-after-move
f345dc3 tidy: enable bugprone-use-after-move (fanquake) 94f2235 test: work around bugprone-use-after-move warnings in util tests (fanquake) Pull request description: Would have caught bitcoin#25640. Currently `// NOLINT`s around: ```bash test/util_tests.cpp:2513:34: error: 't2' used after it was moved [bugprone-use-after-move,-warnings-as-errors] BOOST_CHECK(v2[0].origin == &t2); ^ test/util_tests.cpp:2511:15: note: move occurred here auto v2 = Vector(std::move(t2)); ^ test/util_tests.cpp:2519:34: error: 't2' used after it was moved [bugprone-use-after-move,-warnings-as-errors] BOOST_CHECK(v3[1].origin == &t2); ^ test/util_tests.cpp:2516:15: note: move occurred here auto v3 = Vector(t1, std::move(t2)); ^ test/util_tests.cpp:2527:34: error: 't3' used after it was moved [bugprone-use-after-move,-warnings-as-errors] BOOST_CHECK(v4[2].origin == &t3); ^ test/util_tests.cpp:2523:15: note: move occurred here auto v4 = Vector(std::move(v3[0]), v3[1], std::move(t3)); ``` See: https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/bugprone-use-after-move.html ACKs for top commit: ryanofsky: Code review ACK f345dc3. Only change since last review is switching to NOLINT directives Tree-SHA512: afadecbaf1069653f4be5d6e66a5800ffd975c0b1a960057abc6367b616c181cd518897a874a8f3fd5e5e1f45fcc165f7a9a3171136cd4deee641214c4b765b8
1 parent 7b3a8ae commit 0514237

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Checks: '
22
-*,
33
bugprone-argument-comment,
4+
bugprone-use-after-move,
45
misc-unused-using-decls,
56
modernize-use-default-member-init,
67
modernize-use-nullptr,
@@ -10,6 +11,7 @@ readability-redundant-string-init,
1011
'
1112
WarningsAsErrors: '
1213
bugprone-argument-comment,
14+
bugprone-use-after-move,
1315
misc-unused-using-decls,
1416
modernize-use-default-member-init,
1517
modernize-use-nullptr,

src/test/util_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,21 +1304,21 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector)
13041304

13051305
auto v2 = Vector(std::move(t2));
13061306
BOOST_CHECK_EQUAL(v2.size(), 1U);
1307-
BOOST_CHECK(v2[0].origin == &t2);
1307+
BOOST_CHECK(v2[0].origin == &t2); // NOLINT(*-use-after-move)
13081308
BOOST_CHECK_EQUAL(v2[0].copies, 0);
13091309

13101310
auto v3 = Vector(t1, std::move(t2));
13111311
BOOST_CHECK_EQUAL(v3.size(), 2U);
13121312
BOOST_CHECK(v3[0].origin == &t1);
1313-
BOOST_CHECK(v3[1].origin == &t2);
1313+
BOOST_CHECK(v3[1].origin == &t2); // NOLINT(*-use-after-move)
13141314
BOOST_CHECK_EQUAL(v3[0].copies, 1);
13151315
BOOST_CHECK_EQUAL(v3[1].copies, 0);
13161316

13171317
auto v4 = Vector(std::move(v3[0]), v3[1], std::move(t3));
13181318
BOOST_CHECK_EQUAL(v4.size(), 3U);
13191319
BOOST_CHECK(v4[0].origin == &t1);
13201320
BOOST_CHECK(v4[1].origin == &t2);
1321-
BOOST_CHECK(v4[2].origin == &t3);
1321+
BOOST_CHECK(v4[2].origin == &t3); // NOLINT(*-use-after-move)
13221322
BOOST_CHECK_EQUAL(v4[0].copies, 1);
13231323
BOOST_CHECK_EQUAL(v4[1].copies, 1);
13241324
BOOST_CHECK_EQUAL(v4[2].copies, 0);

0 commit comments

Comments
 (0)