-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang-tidy] Add flag to specify an alternative to std::move in cppcoreguidelines-rvalue-reference-param-not-moved #138757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vbvictor
merged 5 commits into
llvm:main
from
DimitrijeDobrota:cppcoreguidelines-rvalue-reference-param-not-moved
Jun 30, 2025
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
28723cc
Add flag to specify an alternative to std::move
DimitrijeDobrota 648995c
Fix alphabetical order in ReleaseNotes
DimitrijeDobrota 07873f2
Add test
DimitrijeDobrota 33aeee4
Update clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rva…
DimitrijeDobrota 4ed8042
Merge branch 'main' into cppcoreguidelines-rvalue-reference-param-not…
DimitrijeDobrota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...lang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved-custom-function.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \ | ||
| // RUN: -config="{CheckOptions: {cppcoreguidelines-rvalue-reference-param-not-moved.AllowPartialMove: true, cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams: true, cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreNonDeducedTemplateTypes: true, cppcoreguidelines-rvalue-reference-param-not-moved.MoveFunction: custom_move}}" -- -fno-delayed-template-parsing | ||
|
|
||
| // NOLINTBEGIN | ||
| namespace std { | ||
| template <typename> | ||
| struct remove_reference; | ||
|
|
||
| template <typename _Tp> struct remove_reference { typedef _Tp type; }; | ||
| template <typename _Tp> struct remove_reference<_Tp&> { typedef _Tp type; }; | ||
| template <typename _Tp> struct remove_reference<_Tp&&> { typedef _Tp type; }; | ||
|
|
||
| template <typename _Tp> | ||
| constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept; | ||
|
|
||
| template <typename _Tp> | ||
| constexpr _Tp && | ||
| forward(typename remove_reference<_Tp>::type &__t) noexcept; | ||
|
|
||
| } | ||
| // NOLINTEND | ||
|
|
||
|
|
||
| struct Obj { | ||
| Obj(); | ||
| Obj(const Obj&); | ||
| Obj& operator=(const Obj&); | ||
| Obj(Obj&&); | ||
| Obj& operator=(Obj&&); | ||
| void member() const; | ||
| }; | ||
|
|
||
| template<class T> | ||
| constexpr typename std::remove_reference<T>::type&& custom_move(T&& x) noexcept | ||
| { | ||
| return static_cast<typename std::remove_reference<T>::type&&>(x); | ||
| } | ||
|
|
||
| void move_with_std(Obj&& o) { | ||
| // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved] | ||
| Obj other{std::move(o)}; | ||
| } | ||
|
|
||
| void move_with_custom(Obj&& o) { | ||
| Obj other{custom_move(o)}; | ||
| } | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.