Use llvm::lower_bound (NFC)

This commit is contained in:
Kazu Hirata 2022-09-03 11:17:37 -07:00
parent 3850edd9e0
commit 89f1433225
16 changed files with 30 additions and 36 deletions

View File

@ -336,8 +336,8 @@ void FrameOptimizerPass::performShrinkWrapping(const RegAnalysis &RA,
std::vector<std::pair<uint64_t, const BinaryFunction *>> Top10Funcs;
auto LogFunc = [&](BinaryFunction &BF) {
auto Lower = std::lower_bound(
Top10Funcs.begin(), Top10Funcs.end(), BF.getKnownExecutionCount(),
auto Lower = llvm::lower_bound(
Top10Funcs, BF.getKnownExecutionCount(),
[](const std::pair<uint64_t, const BinaryFunction *> &Elmt,
uint64_t Value) { return Elmt.first > Value; });
if (Lower == Top10Funcs.end() && Top10Funcs.size() >= 10)

View File

@ -68,10 +68,9 @@ std::string ConfusableIdentifierCheck::skeleton(StringRef Name) {
}
StringRef Key(Prev, Curr - Prev);
auto Where = std::lower_bound(std::begin(ConfusableEntries),
std::end(ConfusableEntries), CodePoint,
[](decltype(ConfusableEntries[0]) x,
UTF32 y) { return x.codepoint < y; });
auto Where = llvm::lower_bound(ConfusableEntries, CodePoint,
[](decltype(ConfusableEntries[0]) x,
UTF32 y) { return x.codepoint < y; });
if (Where == std::end(ConfusableEntries) || CodePoint != Where->codepoint) {
Skeleton.append(Prev, Curr);
} else {

View File

@ -18924,8 +18924,7 @@ getIntrinsicForHexagonNonClangBuiltin(unsigned BuiltinID) {
static const bool SortOnce = (llvm::sort(Infos, CmpInfo), true);
(void)SortOnce;
const Info *F = std::lower_bound(std::begin(Infos), std::end(Infos),
Info{BuiltinID, 0, 0}, CmpInfo);
const Info *F = llvm::lower_bound(Infos, Info{BuiltinID, 0, 0}, CmpInfo);
if (F == std::end(Infos) || F->BuiltinID != BuiltinID)
return {Intrinsic::not_intrinsic, 0};

View File

@ -5542,9 +5542,10 @@ static bool ArmBuiltinAliasValid(unsigned BuiltinID, StringRef AliasName,
const char *IntrinNames) {
if (AliasName.startswith("__arm_"))
AliasName = AliasName.substr(6);
const IntrinToName *It = std::lower_bound(
Map.begin(), Map.end(), BuiltinID,
[](const IntrinToName &L, unsigned Id) { return L.Id < Id; });
const IntrinToName *It =
llvm::lower_bound(Map, BuiltinID, [](const IntrinToName &L, unsigned Id) {
return L.Id < Id;
});
if (It == Map.end() || It->Id != BuiltinID)
return false;
StringRef FullName(&IntrinNames[It->FullName]);

View File

@ -1015,8 +1015,7 @@ static const IntrinsicHandler *findIntrinsicHandler(llvm::StringRef name) {
auto compare = [](const IntrinsicHandler &handler, llvm::StringRef name) {
return name.compare(handler.name) > 0;
};
auto result =
std::lower_bound(std::begin(handlers), std::end(handlers), name, compare);
auto result = llvm::lower_bound(handlers, name, compare);
return result != std::end(handlers) && result->name == name ? result
: nullptr;
}

View File

@ -1094,8 +1094,7 @@ void TypeMerger::mergeTypesWithGHash() {
entries.size(), tableSize));
// Find out how many type and item indices there are.
auto mid =
std::lower_bound(entries.begin(), entries.end(), GHashCell(true, 0, 0));
auto mid = llvm::lower_bound(entries, GHashCell(true, 0, 0));
assert((mid == entries.end() || mid->isItem()) &&
(mid == entries.begin() || !std::prev(mid)->isItem()) &&
"midpoint is not midpoint");

View File

@ -618,11 +618,10 @@ public:
if (!m_entries.empty()) {
typename Collection::const_iterator begin = m_entries.begin();
typename Collection::const_iterator end = m_entries.end();
typename Collection::const_iterator pos =
std::lower_bound(m_entries.begin(), end, addr,
[](const Entry &lhs, B rhs_base) -> bool {
return lhs.GetRangeEnd() <= rhs_base;
});
typename Collection::const_iterator pos = llvm::lower_bound(
m_entries, addr, [](const Entry &lhs, B rhs_base) -> bool {
return lhs.GetRangeEnd() <= rhs_base;
});
while (pos != begin && pos[-1].Contains(addr))
--pos;
@ -794,7 +793,7 @@ public:
typename Collection::iterator begin = m_entries.begin();
typename Collection::iterator end = m_entries.end();
typename Collection::iterator pos =
std::lower_bound(begin, end, entry, BaseLessThan);
llvm::lower_bound(m_entries, entry, BaseLessThan);
while (pos != begin && pos[-1].addr == addr)
--pos;

View File

@ -69,7 +69,7 @@ BreakpointLocationList::FindByID(lldb::break_id_t break_id) const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::const_iterator end = m_locations.end();
collection::const_iterator pos =
std::lower_bound(m_locations.begin(), end, break_id, Compare);
llvm::lower_bound(m_locations, break_id, Compare);
if (pos != end && (*pos)->GetID() == break_id)
return *(pos);
else

View File

@ -474,9 +474,8 @@ static llvm::Optional<PublicSym32> FindPublicSym(const SegmentOffset &addr,
SymbolStream &syms,
PublicsStream &publics) {
llvm::FixedStreamArray<ulittle32_t> addr_map = publics.getAddressMap();
auto iter = std::lower_bound(
addr_map.begin(), addr_map.end(), addr,
[&](const ulittle32_t &x, const SegmentOffset &y) {
auto iter = llvm::lower_bound(
addr_map, addr, [&](const ulittle32_t &x, const SegmentOffset &y) {
CVSymbol s1 = syms.readRecord(x);
lldbassert(s1.kind() == S_PUB32);
PublicSym32 p1;

View File

@ -516,7 +516,7 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction(
key.function_offset = function_offset;
std::vector<UnwindIndex>::const_iterator it;
it = std::lower_bound(m_indexes.begin(), m_indexes.end(), key);
it = llvm::lower_bound(m_indexes, key);
if (it == m_indexes.end()) {
return false;
}

View File

@ -225,6 +225,6 @@ llvm::Error Loader::LoadIndex() {
bool Loader::HasFile(StringRef file) {
assert(m_loaded);
auto it = std::lower_bound(m_files.begin(), m_files.end(), file.str());
auto it = llvm::lower_bound(m_files, file.str());
return (it != m_files.end()) && (*it == file);
}

View File

@ -161,8 +161,8 @@ SymbolFileLoader::GetPaths(const UUID *uuid) const {
if (!uuid)
return {};
auto it = std::lower_bound(m_symbol_files.begin(), m_symbol_files.end(),
SymbolFileProvider::Entry(uuid->GetAsString()));
auto it = llvm::lower_bound(m_symbol_files,
SymbolFileProvider::Entry(uuid->GetAsString()));
if (it == m_symbol_files.end())
return {};
return std::make_pair<FileSpec, FileSpec>(FileSpec(it->module_path),

View File

@ -1430,8 +1430,7 @@ bool InstrRefBasedLDV::transferDebugInstrRef(MachineInstr &MI,
// Try to lookup the instruction number, and find the machine value number
// that it defines. It could be an instruction, or a PHI.
auto InstrIt = DebugInstrNumToInstr.find(InstNo);
auto PHIIt = std::lower_bound(DebugPHINumToValue.begin(),
DebugPHINumToValue.end(), InstNo);
auto PHIIt = llvm::lower_bound(DebugPHINumToValue, InstNo);
if (InstrIt != DebugInstrNumToInstr.end()) {
const MachineInstr &TargetInstr = *InstrIt->second.first;
uint64_t BlockNo = TargetInstr.getParent()->getNumber();

View File

@ -1482,8 +1482,8 @@ void JITDylib::dump(raw_ostream &OS) {
void JITDylib::MaterializingInfo::addQuery(
std::shared_ptr<AsynchronousSymbolQuery> Q) {
auto I = std::lower_bound(
PendingQueries.rbegin(), PendingQueries.rend(), Q->getRequiredState(),
auto I = llvm::lower_bound(
llvm::reverse(PendingQueries), Q->getRequiredState(),
[](const std::shared_ptr<AsynchronousSymbolQuery> &V, SymbolState S) {
return V->getRequiredState() <= S;
});

View File

@ -445,8 +445,8 @@ nearestMatchesForCodepointName(StringRef Pattern, std::size_t MaxMatchesCount) {
return Name;
};
auto It = std::lower_bound(
Matches.begin(), Matches.end(), Distance,
auto It = llvm::lower_bound(
Matches, Distance,
[&](const MatchForCodepointName &a, std::size_t Distance) {
if (Distance == a.Distance)
return a.Name < GetName();

View File

@ -435,7 +435,7 @@ void PerfScriptReader::updateBinaryAddress(const MMapEvent &Event) {
} else {
// Verify segments are loaded consecutively.
const auto &Offsets = Binary->getTextSegmentOffsets();
auto It = std::lower_bound(Offsets.begin(), Offsets.end(), Event.Offset);
auto It = llvm::lower_bound(Offsets, Event.Offset);
if (It != Offsets.end() && *It == Event.Offset) {
// The event is for loading a separate executable segment.
auto I = std::distance(Offsets.begin(), It);