aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-04-17 07:58:05 +0000
committerFangrui Song <maskray@google.com>2019-04-17 07:58:05 +0000
commitc82e92bca89f3b9740e8c66afae0298965c3183a (patch)
tree7731c7923970f33e032136221a4ea177659a7ccf /llvm/tools/llvm-objdump/llvm-objdump.cpp
parentb0b65cae592206d49e155bfc6ed0cbcf368061f4 (diff)
downloadllvm-c82e92bca89f3b9740e8c66afae0298965c3183a.zip
llvm-c82e92bca89f3b9740e8c66afae0298965c3183a.tar.gz
llvm-c82e92bca89f3b9740e8c66afae0298965c3183a.tar.bz2
Change some llvm::{lower,upper}_bound to llvm::bsearch. NFC
llvm-svn: 358564
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 9568d34..db8bfe3 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1045,10 +1045,9 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
error(ExportEntry.getExportRVA(RVA));
uint64_t VA = COFFObj->getImageBase() + RVA;
- auto Sec = llvm::upper_bound(
- SectionAddresses, VA,
- [](uint64_t LHS, const std::pair<uint64_t, SectionRef> &RHS) {
- return LHS < RHS.first;
+ auto Sec = llvm::bsearch(
+ SectionAddresses, [VA](const std::pair<uint64_t, SectionRef> &RHS) {
+ return VA < RHS.first;
});
if (Sec != SectionAddresses.begin()) {
--Sec;
@@ -1302,35 +1301,33 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
// N.B. We don't walk the relocations in the relocatable case yet.
auto *TargetSectionSymbols = &Symbols;
if (!Obj->isRelocatableObject()) {
- auto SectionAddress = llvm::upper_bound(
- SectionAddresses, Target,
- [](uint64_t LHS, const std::pair<uint64_t, SectionRef> &RHS) {
- return LHS < RHS.first;
+ auto It = llvm::bsearch(
+ SectionAddresses,
+ [=](const std::pair<uint64_t, SectionRef> &RHS) {
+ return Target < RHS.first;
});
- if (SectionAddress != SectionAddresses.begin()) {
- --SectionAddress;
- TargetSectionSymbols = &AllSymbols[SectionAddress->second];
+ if (It != SectionAddresses.begin()) {
+ --It;
+ TargetSectionSymbols = &AllSymbols[It->second];
} else {
TargetSectionSymbols = &AbsoluteSymbols;
}
}
- // Find the first symbol in the section whose offset is less than
+ // Find the last symbol in the section whose offset is less than
// or equal to the target. If there isn't a section that contains
// the target, find the nearest preceding absolute symbol.
- auto TargetSym = llvm::upper_bound(
- *TargetSectionSymbols, Target,
- [](uint64_t LHS,
- const std::tuple<uint64_t, StringRef, uint8_t> &RHS) {
- return LHS < std::get<0>(RHS);
+ auto TargetSym = llvm::bsearch(
+ *TargetSectionSymbols,
+ [=](const std::tuple<uint64_t, StringRef, uint8_t> &RHS) {
+ return Target < std::get<0>(RHS);
});
if (TargetSym == TargetSectionSymbols->begin()) {
TargetSectionSymbols = &AbsoluteSymbols;
- TargetSym = llvm::upper_bound(
- AbsoluteSymbols, Target,
- [](uint64_t LHS,
- const std::tuple<uint64_t, StringRef, uint8_t> &RHS) {
- return LHS < std::get<0>(RHS);
+ TargetSym = llvm::bsearch(
+ AbsoluteSymbols,
+ [=](const std::tuple<uint64_t, StringRef, uint8_t> &RHS) {
+ return Target < std::get<0>(RHS);
});
}
if (TargetSym != TargetSectionSymbols->begin()) {