[llvm] e61a51d - [llvm] Use llvm::find_if and llvm::is_contained (NFC) (#167166)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 8 14:44:30 PST 2025
Author: Kazu Hirata
Date: 2025-11-08T14:44:25-08:00
New Revision: e61a51d0d620bf013173930749d760ad6cb788ed
URL: https://github.com/llvm/llvm-project/commit/e61a51d0d620bf013173930749d760ad6cb788ed
DIFF: https://github.com/llvm/llvm-project/commit/e61a51d0d620bf013173930749d760ad6cb788ed.diff
LOG: [llvm] Use llvm::find_if and llvm::is_contained (NFC) (#167166)
Identified with llvm-use-ranges.
Added:
Modified:
llvm/include/llvm/Option/OptTable.h
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/lib/Option/OptTable.cpp
llvm/unittests/Transforms/Utils/SSAUpdaterBulkTest.cpp
llvm/utils/TableGen/OptionParserEmitter.cpp
Removed:
################################################################################
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 e2440c110f9f4..45edde3546f6f 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 << "' */";
More information about the llvm-commits
mailing list