-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Clang-Tidy][NFC] Simplify check cppcoreguidelines-missing-std-forward #138504
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][NFC] Simplify check cppcoreguidelines-missing-std-forward #138504
Conversation
@llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clang-tidy Author: Yanzuo Liu (zwuis) ChangesRemove No functional changes because implicit captures are not added to capture list until the function is instantiated (P0588R1 is not implemented currently), so that Full diff: https://github.com/llvm/llvm-project/pull/138504.diff 1 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
index bbb35228ce47f..2e8d4f7860021 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
@@ -98,13 +98,10 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
allOf(hasCaptureDefaultKind(LambdaCaptureDefault::LCD_ByRef),
unless(hasAnyCapture(
capturesVar(varDecl(hasSameNameAsBoundNode("param"))))));
- auto CaptureInCopy = allOf(
- hasCaptureDefaultKind(LambdaCaptureDefault::LCD_ByCopy), HasRefToParm);
auto CaptureByRefExplicit = hasAnyCapture(
allOf(hasCaptureKind(LambdaCaptureKind::LCK_ByRef), RefToParm));
- auto CapturedInBody =
- lambdaExpr(anyOf(CaptureInRef, CaptureInCopy, CaptureByRefExplicit));
+ auto CapturedInBody = lambdaExpr(anyOf(CaptureInRef, CaptureByRefExplicit));
auto CapturedInCaptureList = hasAnyCapture(capturesVar(
varDecl(hasInitializer(ignoringParenImpCasts(equalsBoundNode("call"))))));
|
Strange, can you explain why that's the case? Are we missing tests? |
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.
Strange, can you explain why that's the case?
CaptureInCopy
matches lambda expressions whose default capture kind is copy and which have an explicit capture referencing function parameter.
CaptureByRefExplicit
matches lambda expressions which have an explicit capture captured by reference and referencing function parameter, not requiring default capture kind.
Are we missing tests?
I don't think we miss tests.
Thank you for your review! I don't have commit access. Please help me merge this PR if it's ready. |
llvm#138504) Remove `CaptureInCopy` because the cases handled by it are covered by `CaptureByRefExplicit`.
Remove
CaptureInCopy
because the cases handled by it are covered byCaptureByRefExplicit
.