Remove a comparator from header and instead use lambdas for simplicity. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@354052 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/ELF/InputSection.cpp b/ELF/InputSection.cpp
index 03326ff..6f05fde 100644
--- a/ELF/InputSection.cpp
+++ b/ELF/InputSection.cpp
@@ -557,10 +557,16 @@
// Relocations are sorted by offset, so we can use std::equal_range to do
// binary search.
- auto Range = std::equal_range(IS->Relocations.begin(), IS->Relocations.end(),
- D->Value, RelocationOffsetComparator{});
- for (auto It = std::get<0>(Range); It != std::get<1>(Range); ++It)
- if (isRelExprOneOf<R_PC>(It->Expr))
+ Relocation R;
+ R.Offset = D->Value;
+ auto Range =
+ std::equal_range(IS->Relocations.begin(), IS->Relocations.end(), R,
+ [](const Relocation &LHS, const Relocation &RHS) {
+ return LHS.Offset < RHS.Offset;
+ });
+
+ for (auto It = Range.first; It != Range.second; ++It)
+ if (It->Expr == R_PC)
return &*It;
error("R_RISCV_PCREL_LO12 relocation points to " + IS->getObjMsg(D->Value) +
diff --git a/ELF/Relocations.cpp b/ELF/Relocations.cpp
index 668db47..ab2113b 100644
--- a/ELF/Relocations.cpp
+++ b/ELF/Relocations.cpp
@@ -1196,7 +1196,9 @@
// Sort relocations by offset to binary search for R_RISCV_PCREL_HI20
if (Config->EMachine == EM_RISCV)
std::stable_sort(Sec.Relocations.begin(), Sec.Relocations.end(),
- RelocationOffsetComparator{});
+ [](const Relocation &LHS, const Relocation &RHS) {
+ return LHS.Offset < RHS.Offset;
+ });
}
template <class ELFT> void elf::scanRelocations(InputSectionBase &S) {
diff --git a/ELF/Relocations.h b/ELF/Relocations.h
index 954885e..3298bfc 100644
--- a/ELF/Relocations.h
+++ b/ELF/Relocations.h
@@ -134,21 +134,6 @@
Symbol *Sym;
};
-struct RelocationOffsetComparator {
- bool operator()(const Relocation &Lhs, const Relocation &Rhs) {
- return Lhs.Offset < Rhs.Offset;
- }
-
- // For std::lower_bound, std::upper_bound, std::equal_range.
- bool operator()(const Relocation &Rel, uint64_t Val) {
- return Rel.Offset < Val;
- }
-
- bool operator()(uint64_t Val, const Relocation &Rel) {
- return Val < Rel.Offset;
- }
-};
-
template <class ELFT> void scanRelocations(InputSectionBase &);
void addIRelativeRelocs();