Skip to content

[llvm] Use llvm::find_if (NFC) #140412

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace detail {
template <typename Container, typename Predicate>
typename std::remove_reference_t<Container>::iterator
find_unique(Container &&container, Predicate &&pred) {
auto first = std::find_if(container.begin(), container.end(), pred);
auto first = llvm::find_if(container, pred);
if (first == container.end())
return first;
auto second = std::find_if(std::next(first), container.end(), pred);
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,8 @@ void LVBinaryReader::processLines(LVLines *DebugLines,

// Find the indexes for the lines whose address is zero.
std::vector<size_t> AddressZero;
LVLines::iterator It =
std::find_if(std::begin(*DebugLines), std::end(*DebugLines),
[](LVLine *Line) { return !Line->getAddress(); });
LVLines::iterator It = llvm::find_if(
*DebugLines, [](LVLine *Line) { return !Line->getAddress(); });
while (It != std::end(*DebugLines)) {
AddressZero.emplace_back(std::distance(std::begin(*DebugLines), It));
It = std::find_if(std::next(It), std::end(*DebugLines),
Expand Down Expand Up @@ -930,8 +929,8 @@ void LVBinaryReader::includeInlineeLines(LVSectionIndex SectionIndex,
if (InlineeLines->size()) {
// First address of inlinee code.
uint64_t InlineeStart = (InlineeLines->front())->getAddress();
LVLines::iterator Iter = std::find_if(
CULines.begin(), CULines.end(), [&](LVLine *Item) -> bool {
LVLines::iterator Iter =
llvm::find_if(CULines, [&](LVLine *Item) -> bool {
return Item->getAddress() == InlineeStart;
});
if (Iter != CULines.end()) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3389,11 +3389,11 @@ bool AArch64FrameLowering::restoreCalleeSavedRegisters(

// For performance reasons restore SVE register in increasing order
auto IsPPR = [](const RegPairInfo &c) { return c.Type == RegPairInfo::PPR; };
auto PPRBegin = std::find_if(RegPairs.begin(), RegPairs.end(), IsPPR);
auto PPRBegin = llvm::find_if(RegPairs, IsPPR);
auto PPREnd = std::find_if_not(PPRBegin, RegPairs.end(), IsPPR);
std::reverse(PPRBegin, PPREnd);
auto IsZPR = [](const RegPairInfo &c) { return c.Type == RegPairInfo::ZPR; };
auto ZPRBegin = std::find_if(RegPairs.begin(), RegPairs.end(), IsZPR);
auto ZPRBegin = llvm::find_if(RegPairs, IsZPR);
auto ZPREnd = std::find_if_not(ZPRBegin, RegPairs.end(), IsZPR);
std::reverse(ZPRBegin, ZPREnd);

Expand Down
7 changes: 4 additions & 3 deletions llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3720,9 +3720,10 @@ SDValue SITargetLowering::LowerCall(CallLoweringInfo &CLI,
// followed by the flags and any other arguments with special meanings.
// Pop them out of CLI.Outs and CLI.OutVals before we do any processing so
// we don't treat them like the "real" arguments.
auto RequestedExecIt = std::find_if(
CLI.Outs.begin(), CLI.Outs.end(),
[](const ISD::OutputArg &Arg) { return Arg.OrigArgIndex == 2; });
auto RequestedExecIt =
llvm::find_if(CLI.Outs, [](const ISD::OutputArg &Arg) {
return Arg.OrigArgIndex == 2;
});
assert(RequestedExecIt != CLI.Outs.end() && "No node for EXEC");

size_t SpecialArgsBeginIdx = RequestedExecIt - CLI.Outs.begin();
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Target/Hexagon/HexagonOptAddrMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,9 @@ bool HexagonOptAddrMode::findFirstReachedInst(
for (auto &InstIter : *CurrentMBB) {
// If the instruction is an Addi and is in the AddiList
if (InstIter.getOpcode() == Hexagon::A2_addi) {
auto Iter = std::find_if(
AddiList.begin(), AddiList.end(), [&InstIter](const auto &SUPair) {
return SUPair.first.Addr->getCode() == &InstIter;
});
auto Iter = llvm::find_if(AddiList, [&InstIter](const auto &SUPair) {
return SUPair.first.Addr->getCode() == &InstIter;
});
if (Iter != AddiList.end()) {
UseSN = Iter->first;
return true;
Expand Down
7 changes: 3 additions & 4 deletions llvm/unittests/XRay/GraphTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ template <typename T> void graphVertexTester(T &G) {
EXPECT_EQ(1u, G.count(u));
EXPECT_EQ(VA[u], EVV->VA);
EXPECT_NE(G.vertices().end(),
std::find_if(G.vertices().begin(), G.vertices().end(),
[&](const VVT &VV) { return VV.first == u; }));
llvm::find_if(G.vertices(),
[&](const VVT &VV) { return VV.first == u; }));
consumeError(EVV.takeError());
}

Expand All @@ -98,8 +98,7 @@ template <typename T> void graphEdgeTester(T &G) {
EXPECT_EQ(VA[u.first] * VA[u.second] * ((u.first > u.second) ? 2 : 1),
EEV->EA);
auto Pred = [&](const EVT &EV) { return EV.first == u; };
EXPECT_NE(G.edges().end(),
std::find_if(G.edges().begin(), G.edges().end(), Pred));
EXPECT_NE(G.edges().end(), llvm::find_if(G.edges(), Pred));
consumeError(EEV.takeError());
}

Expand Down
Loading