[clang-tools-extra] [clang-tidy] Ignore deleted ctor in `bugprone-forwarding-reference-overload` (PR #88138)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 9 08:51:26 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Mike Weller (MikeWeller)
<details>
<summary>Changes</summary>
Fix `bugprone-forwarding-reference-overload` so it doesn't report a constructor that is deleted.
---
Full diff: https://github.com/llvm/llvm-project/pull/88138.diff
2 Files Affected:
- (modified) clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp (+1)
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp (+10)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
index c608fe713f9f5b..e42b40d7b6690e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
@@ -73,6 +73,7 @@ void ForwardingReferenceOverloadCheck::registerMatchers(MatchFinder *Finder) {
DeclarationMatcher FindOverload =
cxxConstructorDecl(
hasParameter(0, ForwardingRefParm),
+ unless(isDeleted()),
unless(hasAnyParameter(
// No warning: enable_if as constructor parameter.
parmVarDecl(hasType(isEnableIf())))),
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp
index 38b0691bc9f1ec..92dfb718bb51b7 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp
@@ -251,3 +251,13 @@ class Test10 {
Test10(T &&Item, E e)
: e(e){}
};
+
+// A deleted ctor cannot hide anything
+class Test11 {
+public:
+ template <typename T>
+ Test11(T&&) = delete;
+
+ Test11(const Test11 &) = default;
+ Test11(Test11 &&) = default;
+};
``````````
</details>
https://github.com/llvm/llvm-project/pull/88138
More information about the cfe-commits
mailing list