Skip to content

Commit

Permalink
[clang-tidy] Fix cppcoreguidelines-missing-std-forward false positi…
Browse files Browse the repository at this point in the history
…ve for deleted functions (#83055)

Improved check by no longer giving false positives for deleted functions.
  • Loading branch information
AMS21 committed Feb 27, 2024
1 parent 2d704f4 commit 7b11e2e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
hasAncestor(functionDecl().bind("func")),
hasAncestor(functionDecl(
isDefinition(), equalsBoundNode("func"), ToParam,
unless(hasDescendant(std::move(ForwardCallMatcher)))))),
unless(anyOf(isDeleted(), hasDescendant(std::move(
ForwardCallMatcher))))))),
this);
}

Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ Changes in existing checks
<clang-tidy/checks/bugprone/unused-local-non-trivial-variable>` check by
ignoring local variable with ``[maybe_unused]`` attribute.

- Improved :doc:`cppcoreguidelines-missing-std-forward
<clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by no longer
giving false positives for deleted functions.

- Cleaned up :doc:`cppcoreguidelines-prefer-member-initializer
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>`
by removing enforcement of rule `C.48
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,18 @@ void lambda_value_reference_auxiliary_var(T&& t) {
}

} // namespace negative_cases

namespace deleted_functions {

template <typename T>
void f(T &&) = delete;

struct S {
template <typename T>
S(T &&) = delete;

template <typename T>
void operator&(T &&) = delete;
};

} // namespace deleted_functions

0 comments on commit 7b11e2e

Please sign in to comment.