aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-11-08 14:44:25 -0800
committerGitHub <noreply@github.com>2025-11-08 14:44:25 -0800
commite61a51d0d620bf013173930749d760ad6cb788ed (patch)
treea1b5e70fbc439ea1256ab9176bfe3f94a34861a4 /llvm
parent3b219cf42ac4970fc01a4e9d4b428d9689e13f78 (diff)
downloadllvm-e61a51d0d620bf013173930749d760ad6cb788ed.zip
llvm-e61a51d0d620bf013173930749d760ad6cb788ed.tar.gz
llvm-e61a51d0d620bf013173930749d760ad6cb788ed.tar.bz2
[llvm] Use llvm::find_if and llvm::is_contained (NFC) (#167166)
Identified with llvm-use-ranges.
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Option/OptTable.h8
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp9
-rw-r--r--llvm/lib/Option/OptTable.cpp5
-rw-r--r--llvm/unittests/Transforms/Utils/SSAUpdaterBulkTest.cpp5
-rw-r--r--llvm/utils/TableGen/OptionParserEmitter.cpp6
5 files changed, 14 insertions, 19 deletions
diff --git a/llvm/include/llvm/Option/OptTable.h b/llvm/include/llvm/Option/OptTable.h
index f641ca4..45083b3 100644
--- a/llvm/include/llvm/Option/OptTable.h
+++ b/llvm/include/llvm/Option/OptTable.h
@@ -148,15 +148,13 @@ public:
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 5ab80e33..693454e 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 14e3b0d..0450b2f 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 716f5f2..13cfaf3 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 e2440c1..45edde3 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 << "' */";