-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-tools-extra] Use llvm::find_if (NFC) #140411
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
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_llvm_find_if_clang_tools
May 18, 2025
Merged
[clang-tools-extra] Use llvm::find_if (NFC) #140411
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_llvm_find_if_clang_tools
May 18, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-clang-tidy @llvm/pr-subscribers-clang-tools-extra Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/140411.diff 2 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp b/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
index 32ea0c0cdf48c..40808aaf7c3da 100644
--- a/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
@@ -168,22 +168,21 @@ void NewDeleteOverloadsCheck::onEndOfTranslationUnit() {
// complexity when searching for corresponding free store functions.
for (const auto *Overload : RP.second) {
const auto *Match =
- std::find_if(RP.second.begin(), RP.second.end(),
- [&Overload](const FunctionDecl *FD) {
- if (FD == Overload)
- return false;
- // If the declaration contexts don't match, we don't
- // need to check any further.
- if (FD->getDeclContext() != Overload->getDeclContext())
- return false;
-
- // Since the declaration contexts match, see whether
- // the current element is the corresponding operator.
- if (!areCorrespondingOverloads(Overload, FD))
- return false;
-
- return true;
- });
+ llvm::find_if(RP.second, [&Overload](const FunctionDecl *FD) {
+ if (FD == Overload)
+ return false;
+ // If the declaration contexts don't match, we don't
+ // need to check any further.
+ if (FD->getDeclContext() != Overload->getDeclContext())
+ return false;
+
+ // Since the declaration contexts match, see whether
+ // the current element is the corresponding operator.
+ if (!areCorrespondingOverloads(Overload, FD))
+ return false;
+
+ return true;
+ });
if (Match == RP.second.end()) {
// Check to see if there is a corresponding overload in a base class
diff --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp
index e464f1ad45c52..d9b73b83e902a 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -185,9 +185,8 @@ void filterRenameTargets(llvm::DenseSet<const NamedDecl *> &Decls) {
// For renaming, we're only interested in foo's declaration, so drop the other
// one. There should never be more than one UsingDecl here, otherwise the
// rename would be ambiguos anyway.
- auto UD = std::find_if(Decls.begin(), Decls.end(), [](const NamedDecl *D) {
- return llvm::isa<UsingDecl>(D);
- });
+ auto UD = llvm::find_if(
+ Decls, [](const NamedDecl *D) { return llvm::isa<UsingDecl>(D); });
if (UD != Decls.end()) {
Decls.erase(UD);
}
|
@llvm/pr-subscribers-clangd Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/140411.diff 2 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp b/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
index 32ea0c0cdf48c..40808aaf7c3da 100644
--- a/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
@@ -168,22 +168,21 @@ void NewDeleteOverloadsCheck::onEndOfTranslationUnit() {
// complexity when searching for corresponding free store functions.
for (const auto *Overload : RP.second) {
const auto *Match =
- std::find_if(RP.second.begin(), RP.second.end(),
- [&Overload](const FunctionDecl *FD) {
- if (FD == Overload)
- return false;
- // If the declaration contexts don't match, we don't
- // need to check any further.
- if (FD->getDeclContext() != Overload->getDeclContext())
- return false;
-
- // Since the declaration contexts match, see whether
- // the current element is the corresponding operator.
- if (!areCorrespondingOverloads(Overload, FD))
- return false;
-
- return true;
- });
+ llvm::find_if(RP.second, [&Overload](const FunctionDecl *FD) {
+ if (FD == Overload)
+ return false;
+ // If the declaration contexts don't match, we don't
+ // need to check any further.
+ if (FD->getDeclContext() != Overload->getDeclContext())
+ return false;
+
+ // Since the declaration contexts match, see whether
+ // the current element is the corresponding operator.
+ if (!areCorrespondingOverloads(Overload, FD))
+ return false;
+
+ return true;
+ });
if (Match == RP.second.end()) {
// Check to see if there is a corresponding overload in a base class
diff --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp
index e464f1ad45c52..d9b73b83e902a 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -185,9 +185,8 @@ void filterRenameTargets(llvm::DenseSet<const NamedDecl *> &Decls) {
// For renaming, we're only interested in foo's declaration, so drop the other
// one. There should never be more than one UsingDecl here, otherwise the
// rename would be ambiguos anyway.
- auto UD = std::find_if(Decls.begin(), Decls.end(), [](const NamedDecl *D) {
- return llvm::isa<UsingDecl>(D);
- });
+ auto UD = llvm::find_if(
+ Decls, [](const NamedDecl *D) { return llvm::isa<UsingDecl>(D); });
if (UD != Decls.end()) {
Decls.erase(UD);
}
|
shiltian
approved these changes
May 17, 2025
ajaden-codes
pushed a commit
to Jaddyen/llvm-project
that referenced
this pull request
Jun 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.