[clang-tools-extra] 7b11e2e - [clang-tidy] Fix `cppcoreguidelines-missing-std-forward` false positive for deleted functions (#83055)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 27 10:35:50 PST 2024
Author: AMS21
Date: 2024-02-27T19:35:11+01:00
New Revision: 7b11e2ec39ae01f53d53250551e207583bd51e80
URL: https://github.com/llvm/llvm-project/commit/7b11e2ec39ae01f53d53250551e207583bd51e80
DIFF: https://github.com/llvm/llvm-project/commit/7b11e2ec39ae01f53d53250551e207583bd51e80.diff
LOG: [clang-tidy] Fix `cppcoreguidelines-missing-std-forward` false positive for deleted functions (#83055)
Improved check by no longer giving false positives for deleted functions.
Added:
Modified:
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
index 370de12999aceb..c633683570f748 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
@@ -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);
}
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 69537964f9bce0..3f90e7d63d6b23 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -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
diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
index 443f338ba2046a..20e43f04180ff3 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
@@ -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
More information about the cfe-commits
mailing list