-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[llvm] Use llvm::find_if and llvm::is_contained (NFC) #167166
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
Open
kazutakahirata
wants to merge
1
commit into
llvm:main
Choose a base branch
from
kazutakahirata:cleanup_20251108a_clang_tidy_llvm-use-ranges
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[llvm] Use llvm::find_if and llvm::is_contained (NFC) #167166
kazutakahirata
wants to merge
1
commit into
llvm:main
from
kazutakahirata:cleanup_20251108a_clang_tidy_llvm-use-ranges
+14
−19
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
Identified with llvm-use-ranges.
Member
|
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesIdentified with llvm-use-ranges. Full diff: https://github.com/llvm/llvm-project/pull/167166.diff 5 Files Affected:
diff --git a/llvm/include/llvm/Option/OptTable.h b/llvm/include/llvm/Option/OptTable.h
index f641ca4ac08d3..45083b31c11f4 100644
--- a/llvm/include/llvm/Option/OptTable.h
+++ b/llvm/include/llvm/Option/OptTable.h
@@ -148,15 +148,13 @@ class LLVM_ABI OptTable {
StringRef SubCommand) const {
assert(!SubCommand.empty() &&
"This helper is only for valid registered subcommands.");
- auto SCIT =
- std::find_if(SubCommands.begin(), SubCommands.end(),
- [&](const auto &C) { return SubCommand == C.Name; });
+ auto SCIT = llvm::find_if(
+ SubCommands, [&](const auto &C) { return SubCommand == C.Name; });
assert(SCIT != SubCommands.end() &&
"This helper is only for valid registered subcommands.");
auto SubCommandIDs = CandidateInfo->getSubCommandIDs(SubCommandIDsTable);
unsigned CurrentSubCommandID = SCIT - &SubCommands[0];
- return std::find(SubCommandIDs.begin(), SubCommandIDs.end(),
- CurrentSubCommandID) != SubCommandIDs.end();
+ return llvm::is_contained(SubCommandIDs, CurrentSubCommandID);
}
private:
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 5ab80e339a1ad..693454e249945 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -917,11 +917,10 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
}
// Check if the offset matches any of the sequence offset.
- auto It =
- std::find_if(LineTable->Sequences.begin(), LineTable->Sequences.end(),
- [SectionOffset](const auto &Sequence) {
- return Sequence.StmtSeqOffset == *SectionOffset;
- });
+ auto It = llvm::find_if(LineTable->Sequences,
+ [SectionOffset](const auto &Sequence) {
+ return Sequence.StmtSeqOffset == *SectionOffset;
+ });
if (It == LineTable->Sequences.end())
ReportError(
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index 14e3b0d60886d..0450b2fd172ef 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -756,9 +756,8 @@ void OptTable::internalPrintHelp(
// pairs.
std::map<std::string, std::vector<OptionInfo>> GroupedOptionHelp;
- auto ActiveSubCommand =
- std::find_if(SubCommands.begin(), SubCommands.end(),
- [&](const auto &C) { return SubCommand == C.Name; });
+ auto ActiveSubCommand = llvm::find_if(
+ SubCommands, [&](const auto &C) { return SubCommand == C.Name; });
if (!SubCommand.empty()) {
assert(ActiveSubCommand != SubCommands.end() &&
"Not a valid registered subcommand.");
diff --git a/llvm/unittests/Transforms/Utils/SSAUpdaterBulkTest.cpp b/llvm/unittests/Transforms/Utils/SSAUpdaterBulkTest.cpp
index 716f5f21302a8..13cfaf3a0345e 100644
--- a/llvm/unittests/Transforms/Utils/SSAUpdaterBulkTest.cpp
+++ b/llvm/unittests/Transforms/Utils/SSAUpdaterBulkTest.cpp
@@ -393,9 +393,8 @@ static void RunEliminateNewDuplicatePHINode(
}
Function *F = M->getFunction("main");
- auto BBIt = std::find_if(F->begin(), F->end(), [](const BasicBlock &Block) {
- return Block.getName() == "testbb";
- });
+ auto BBIt = llvm::find_if(
+ *F, [](const BasicBlock &Block) { return Block.getName() == "testbb"; });
ASSERT_NE(BBIt, F->end());
Check(*BBIt, EliminateNewDuplicatePHINodes);
}
diff --git a/llvm/utils/TableGen/OptionParserEmitter.cpp b/llvm/utils/TableGen/OptionParserEmitter.cpp
index 48ae1a0a92b1c..04fb720b0504b 100644
--- a/llvm/utils/TableGen/OptionParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptionParserEmitter.cpp
@@ -378,9 +378,9 @@ static void emitOptionParser(const RecordKeeper &Records, raw_ostream &OS) {
assert((CurIndex == 0 || !SubCommand.empty()) &&
"Only first subcommand set should be empty!");
for (const auto &SubCommandKey : SubCommand) {
- auto It = std::find_if(
- SubCommands.begin(), SubCommands.end(),
- [&](const Record *R) { return R->getName() == SubCommandKey; });
+ auto It = llvm::find_if(SubCommands, [&](const Record *R) {
+ return R->getName() == SubCommandKey;
+ });
assert(It != SubCommands.end() && "SubCommand not found");
OS << ", " << std::distance(SubCommands.begin(), It) << " /* '"
<< SubCommandKey << "' */";
|
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.
Identified with llvm-use-ranges.