From ff2fe7b82974e01c61f4f7247be231182fb76591 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 3 Sep 2022 11:17:38 -0700 Subject: [PATCH] Use llvm::upper_bound (NFC) --- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 6 ++---- lldb/source/Symbol/ArmUnwindInfo.cpp | 4 ++-- lldb/source/Target/ThreadCollection.cpp | 8 ++++---- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 10 +++++----- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 82b1e8e..e50c7d8 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -2013,8 +2013,7 @@ uint32_t SymbolFilePDB::GetCompilandId(const llvm::pdb::PDBSymbolData &data) { auto &sec_cs = m_sec_contribs[sec]; auto offset = SectionContrib->getAddressOffset(); - auto it = - std::upper_bound(sec_cs.begin(), sec_cs.end(), offset, pred_upper); + auto it = llvm::upper_bound(sec_cs, offset, pred_upper); auto size = SectionContrib->getLength(); sec_cs.insert(it, {offset, size, comp_id}); @@ -2039,8 +2038,7 @@ uint32_t SymbolFilePDB::GetCompilandId(const llvm::pdb::PDBSymbolData &data) { if (DataSection) { // Search by section contributions auto &sec_cs = m_sec_contribs[DataSection]; - auto it = - std::upper_bound(sec_cs.begin(), sec_cs.end(), DataOffset, pred_upper); + auto it = llvm::upper_bound(sec_cs, DataOffset, pred_upper); if (it != sec_cs.begin()) { --it; if (DataOffset < it->Offset + it->Size) diff --git a/lldb/source/Symbol/ArmUnwindInfo.cpp b/lldb/source/Symbol/ArmUnwindInfo.cpp index ae6cddf..60935a3 100644 --- a/lldb/source/Symbol/ArmUnwindInfo.cpp +++ b/lldb/source/Symbol/ArmUnwindInfo.cpp @@ -352,8 +352,8 @@ bool ArmUnwindInfo::GetUnwindPlan(Target &target, const Address &addr, const uint8_t * ArmUnwindInfo::GetExceptionHandlingTableEntry(const Address &addr) { - auto it = std::upper_bound(m_exidx_entries.begin(), m_exidx_entries.end(), - ArmExidxEntry{0, addr.GetFileAddress(), 0}); + auto it = llvm::upper_bound(m_exidx_entries, + ArmExidxEntry{0, addr.GetFileAddress(), 0}); if (it == m_exidx_entries.begin()) return nullptr; --it; diff --git a/lldb/source/Target/ThreadCollection.cpp b/lldb/source/Target/ThreadCollection.cpp index 8c23097..45ce2fd 100644 --- a/lldb/source/Target/ThreadCollection.cpp +++ b/lldb/source/Target/ThreadCollection.cpp @@ -34,10 +34,10 @@ void ThreadCollection::AddThreadSortedByIndexID(const ThreadSP &thread_sp) { m_threads.push_back(thread_sp); else { m_threads.insert( - std::upper_bound(m_threads.begin(), m_threads.end(), thread_sp, - [](const ThreadSP &lhs, const ThreadSP &rhs) -> bool { - return lhs->GetIndexID() < rhs->GetIndexID(); - }), + llvm::upper_bound(m_threads, thread_sp, + [](const ThreadSP &lhs, const ThreadSP &rhs) -> bool { + return lhs->GetIndexID() < rhs->GetIndexID(); + }), thread_sp); } } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index d80008c..7f7581a 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -134,11 +134,11 @@ void DWARFUnitVector::addUnitsImpl( } DWARFUnit *DWARFUnitVector::addUnit(std::unique_ptr Unit) { - auto I = std::upper_bound(begin(), end(), Unit, - [](const std::unique_ptr &LHS, - const std::unique_ptr &RHS) { - return LHS->getOffset() < RHS->getOffset(); - }); + auto I = llvm::upper_bound(*this, Unit, + [](const std::unique_ptr &LHS, + const std::unique_ptr &RHS) { + return LHS->getOffset() < RHS->getOffset(); + }); return this->insert(I, std::move(Unit))->get(); } -- 2.7.4