-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[clang-tidy] Ignore deleted ctor in bugprone-forwarding-reference-overload
#88138
[clang-tidy] Ignore deleted ctor in bugprone-forwarding-reference-overload
#88138
Conversation
Fixes #88128 |
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
bugprone-forwarding-reference-overload
bugprone-forwarding-reference-overload
clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp
Show resolved
Hide resolved
Please mention changes in Release Notes. |
6c188e7
to
4cb9527
Compare
@llvm/pr-subscribers-clang-tidy Author: Mike Weller (MikeWeller) ChangesFix Full diff: https://github.com/llvm/llvm-project/pull/88138.diff 2 Files Affected:
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;
+};
|
@llvm/pr-subscribers-clang-tools-extra Author: Mike Weller (MikeWeller) ChangesFix Full diff: https://github.com/llvm/llvm-project/pull/88138.diff 2 Files Affected:
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;
+};
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing release notes entry, except that looks fine.
Sorry, didn't realize there are release notes I can updated in the change itself. Will do this Monday. |
…rload` Fix `bugprone-forwarding-reference-overload` so it doesn't report a constructor that is deleted.
5f4f9c9
to
483bd05
Compare
Given the small size of the change I just did a rebase and force push to resolve conflicts with the release notes. |
@PiotrZSL apologies, have put it in the correct location. Is there a way to preview/check the |
@@ -287,6 +286,10 @@ Changes in existing checks | |||
check by resolving fix-it overlaps in template code by disregarding implicit | |||
instances. | |||
|
|||
- Improved :doc:`bugprone-forwarding-reference-overload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it to line 149, to keep checks in alphabetical order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in source code part.
@@ -286,6 +286,10 @@ Changes in existing checks | |||
check by resolving fix-it overlaps in template code by disregarding implicit | |||
instances. | |||
|
|||
- Improved :doc:`bugprone-forwarding-reference-overload | |||
<clang-tidy/checks/bugprone/forwarding-reference-overload>` | |||
check to not flag deleted constructors which are unable to hide anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use more clear description in release note.
e.g. by ignoring deleted ctor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in bab66e1, let me know if you have a better suggestion
FYI I don't have merge privs, not sure if I need to ping anybody. Then again I still see "This workflow requires approval from a maintainer", possibly because this is my first contribution? |
I can help you to merge it. 😄 |
✅ With the latest revision this PR passed the C/C++ code formatter. |
please fix format issue. |
…nce-overload` formatting
@MikeWeller Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Fix
bugprone-forwarding-reference-overload
so it doesn't report a constructor that is deleted.