Skip to content

Commit 7b11e2e

Browse files
authored
[clang-tidy] Fix cppcoreguidelines-missing-std-forward false positive for deleted functions (llvm#83055)
Improved check by no longer giving false positives for deleted functions.
1 parent 2d704f4 commit 7b11e2e

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
127127
hasAncestor(functionDecl().bind("func")),
128128
hasAncestor(functionDecl(
129129
isDefinition(), equalsBoundNode("func"), ToParam,
130-
unless(hasDescendant(std::move(ForwardCallMatcher)))))),
130+
unless(anyOf(isDeleted(), hasDescendant(std::move(
131+
ForwardCallMatcher))))))),
131132
this);
132133
}
133134

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ Changes in existing checks
134134
<clang-tidy/checks/bugprone/unused-local-non-trivial-variable>` check by
135135
ignoring local variable with ``[maybe_unused]`` attribute.
136136

137+
- Improved :doc:`cppcoreguidelines-missing-std-forward
138+
<clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by no longer
139+
giving false positives for deleted functions.
140+
137141
- Cleaned up :doc:`cppcoreguidelines-prefer-member-initializer
138142
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>`
139143
by removing enforcement of rule `C.48

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,18 @@ void lambda_value_reference_auxiliary_var(T&& t) {
173173
}
174174

175175
} // namespace negative_cases
176+
177+
namespace deleted_functions {
178+
179+
template <typename T>
180+
void f(T &&) = delete;
181+
182+
struct S {
183+
template <typename T>
184+
S(T &&) = delete;
185+
186+
template <typename T>
187+
void operator&(T &&) = delete;
188+
};
189+
190+
} // namespace deleted_functions

0 commit comments

Comments
 (0)