Skip to content

chore: Enable clang-tidy use-after-move check#6432

Open
kuznetsss wants to merge 3 commits intoXRPLF:developfrom
kuznetsss:Enable_clang-tidy_checks
Open

chore: Enable clang-tidy use-after-move check#6432
kuznetsss wants to merge 3 commits intoXRPLF:developfrom
kuznetsss:Enable_clang-tidy_checks

Conversation

@kuznetsss
Copy link
Collaborator

High Level Overview of Change

This PR enables use-after-move clang-tidy check. It also fixes all the places where use after move was found.

Context of Change

Use after move was found only in tests checking the state of object after it was moved.
The fix in SHAmap doesn't change much, because the pointer is already reset after move.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables the clang-tidy bugprone-use-after-move check and addresses all instances where use-after-move was detected. The changes are primarily test-related, where tests intentionally access moved-from objects to verify their post-move state. The production code change in SHAMap adds an explicit reset to prevent use-after-move, though this may be redundant.

Changes:

  • Enabled bugprone-use-after-move check in .clang-tidy configuration
  • Added NOLINT suppressions to test code where intentional use-after-move validates moved-from object state
  • Added explicit prevNode reset in SHAMap::delItem() to prevent use-after-move warning

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
.clang-tidy Enabled bugprone-use-after-move check
src/tests/libxrpl/json/Value.cpp Added NOLINT suppressions for intentional use-after-move in Json::Value move tests
src/test/protocol/STObject_test.cpp Added NOLINT suppressions for Buffer move verification tests
src/test/jtx/Env_test.cpp Added NOLINT suppressions for JTx move semantics tests
src/test/core/ClosureCounter_test.cpp Added NOLINT suppression for verifying moved string is empty
src/test/basics/Buffer_test.cpp Added NOLINT suppressions for comprehensive Buffer move operation tests
src/libxrpl/shamap/SHAMap.cpp Added explicit prevNode reset after move to prevent use-after-move; includes TODO noting potential redundancy

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.8%. Comparing base (404f35d) to head (1a7396d).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6432     +/-   ##
=========================================
- Coverage     79.8%   79.8%   -0.0%     
=========================================
  Files          848     848             
  Lines        67757   67758      +1     
  Branches      7558    7558             
=========================================
- Hits         54074   54065      -9     
- Misses       13683   13693     +10     
Files with missing lines Coverage Δ
src/libxrpl/shamap/SHAMap.cpp 91.4% <100.0%> (+<0.1%) ⬆️

... and 4 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings February 27, 2026 14:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 675 to +677
node = unshareNode(std::move(node), nodeID);
node->setChild(selectBranch(nodeID, id), std::move(prevNode));
prevNode = intr_ptr::SharedPtr<SHAMapTreeNode>{};
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reinitializes prevNode immediately after moving it into setChild. Consider using std::exchange(prevNode, {}) as the argument to setChild so the move-and-clear is a single, self-documenting operation and avoids the extra assignment line.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants