Skip to content

Commit e61a51d

Browse files
[llvm] Use llvm::find_if and llvm::is_contained (NFC) (#167166)
Identified with llvm-use-ranges.
1 parent 3b219cf commit e61a51d

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

llvm/include/llvm/Option/OptTable.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,13 @@ class LLVM_ABI OptTable {
148148
StringRef SubCommand) const {
149149
assert(!SubCommand.empty() &&
150150
"This helper is only for valid registered subcommands.");
151-
auto SCIT =
152-
std::find_if(SubCommands.begin(), SubCommands.end(),
153-
[&](const auto &C) { return SubCommand == C.Name; });
151+
auto SCIT = llvm::find_if(
152+
SubCommands, [&](const auto &C) { return SubCommand == C.Name; });
154153
assert(SCIT != SubCommands.end() &&
155154
"This helper is only for valid registered subcommands.");
156155
auto SubCommandIDs = CandidateInfo->getSubCommandIDs(SubCommandIDsTable);
157156
unsigned CurrentSubCommandID = SCIT - &SubCommands[0];
158-
return std::find(SubCommandIDs.begin(), SubCommandIDs.end(),
159-
CurrentSubCommandID) != SubCommandIDs.end();
157+
return llvm::is_contained(SubCommandIDs, CurrentSubCommandID);
160158
}
161159

162160
private:

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -917,11 +917,10 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
917917
}
918918

919919
// Check if the offset matches any of the sequence offset.
920-
auto It =
921-
std::find_if(LineTable->Sequences.begin(), LineTable->Sequences.end(),
922-
[SectionOffset](const auto &Sequence) {
923-
return Sequence.StmtSeqOffset == *SectionOffset;
924-
});
920+
auto It = llvm::find_if(LineTable->Sequences,
921+
[SectionOffset](const auto &Sequence) {
922+
return Sequence.StmtSeqOffset == *SectionOffset;
923+
});
925924

926925
if (It == LineTable->Sequences.end())
927926
ReportError(

llvm/lib/Option/OptTable.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,8 @@ void OptTable::internalPrintHelp(
756756
// pairs.
757757
std::map<std::string, std::vector<OptionInfo>> GroupedOptionHelp;
758758

759-
auto ActiveSubCommand =
760-
std::find_if(SubCommands.begin(), SubCommands.end(),
761-
[&](const auto &C) { return SubCommand == C.Name; });
759+
auto ActiveSubCommand = llvm::find_if(
760+
SubCommands, [&](const auto &C) { return SubCommand == C.Name; });
762761
if (!SubCommand.empty()) {
763762
assert(ActiveSubCommand != SubCommands.end() &&
764763
"Not a valid registered subcommand.");

llvm/unittests/Transforms/Utils/SSAUpdaterBulkTest.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,8 @@ static void RunEliminateNewDuplicatePHINode(
393393
}
394394

395395
Function *F = M->getFunction("main");
396-
auto BBIt = std::find_if(F->begin(), F->end(), [](const BasicBlock &Block) {
397-
return Block.getName() == "testbb";
398-
});
396+
auto BBIt = llvm::find_if(
397+
*F, [](const BasicBlock &Block) { return Block.getName() == "testbb"; });
399398
ASSERT_NE(BBIt, F->end());
400399
Check(*BBIt, EliminateNewDuplicatePHINodes);
401400
}

llvm/utils/TableGen/OptionParserEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ static void emitOptionParser(const RecordKeeper &Records, raw_ostream &OS) {
378378
assert((CurIndex == 0 || !SubCommand.empty()) &&
379379
"Only first subcommand set should be empty!");
380380
for (const auto &SubCommandKey : SubCommand) {
381-
auto It = std::find_if(
382-
SubCommands.begin(), SubCommands.end(),
383-
[&](const Record *R) { return R->getName() == SubCommandKey; });
381+
auto It = llvm::find_if(SubCommands, [&](const Record *R) {
382+
return R->getName() == SubCommandKey;
383+
});
384384
assert(It != SubCommands.end() && "SubCommand not found");
385385
OS << ", " << std::distance(SubCommands.begin(), It) << " /* '"
386386
<< SubCommandKey << "' */";

0 commit comments

Comments
 (0)