aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2013-07-04 23:20:12 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2013-07-04 23:20:12 +0000
commit5679d7da014e415237a4a4f7d61a119a8c84cfd9 (patch)
tree73cd29653f0f8a0e9852e1e32233175db0675ddb /lib
parent09bb56f0a0bb098faf076e54ee84221c1fd9fefa (diff)
downloadexternal_llvm-5679d7da014e415237a4a4f7d61a119a8c84cfd9.tar.gz
external_llvm-5679d7da014e415237a4a4f7d61a119a8c84cfd9.tar.bz2
external_llvm-5679d7da014e415237a4a4f7d61a119a8c84cfd9.zip
Remove use of asymmetric std::lower_bound comparator.
VS 2008 doesn't like it when in debug mode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCModule.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/MC/MCModule.cpp b/lib/MC/MCModule.cpp
index 5890b4bd02..b09fbb51c8 100644
--- a/lib/MC/MCModule.cpp
+++ b/lib/MC/MCModule.cpp
@@ -14,8 +14,19 @@
using namespace llvm;
-static bool AtomComp(const MCAtom *L, uint64_t Addr) {
- return L->getEndAddr() < Addr;
+static bool AtomComp(const MCAtom *LHS, const MCAtom *RHS) {
+ return LHS->getEndAddr() < RHS->getEndAddr();
+}
+
+MCModule::const_atom_iterator MCModule::atom_lower_bound(uint64_t Addr) const {
+ // This is a dummy atom, because VS 2008 doesn't like asymmetric comparators.
+ MCDataAtom AddrAtom(0, Addr, Addr);
+ return std::lower_bound(atom_begin(), atom_end(), &AddrAtom, AtomComp);
+}
+
+MCModule::atom_iterator MCModule::atom_lower_bound(uint64_t Addr) {
+ MCDataAtom AddrAtom(0, Addr, Addr);
+ return std::lower_bound(atom_begin(), atom_end(), &AddrAtom, AtomComp);
}
void MCModule::map(MCAtom *NewAtom) {
@@ -24,8 +35,7 @@ void MCModule::map(MCAtom *NewAtom) {
assert(Begin <= NewAtom->End && "Creating MCAtom with endpoints reversed?");
// Check for atoms already covering this range.
- AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
- Begin, AtomComp);
+ AtomListTy::iterator I = atom_lower_bound(Begin);
assert((I == atom_end() || (*I)->getBeginAddr() > NewAtom->End)
&& "Offset range already occupied!");
@@ -48,15 +58,13 @@ MCDataAtom *MCModule::createDataAtom(uint64_t Begin, uint64_t End) {
// remap - Update the interval mapping for an atom.
void MCModule::remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd) {
// Find and erase the old mapping.
- AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
- Atom->Begin, AtomComp);
+ AtomListTy::iterator I = atom_lower_bound(Atom->Begin);
assert(I != atom_end() && "Atom offset not found in module!");
assert(*I == Atom && "Previous atom mapping was invalid!");
Atoms.erase(I);
// Insert the new mapping.
- AtomListTy::iterator NewI = std::lower_bound(atom_begin(), atom_end(),
- NewBegin, AtomComp);
+ AtomListTy::iterator NewI = atom_lower_bound(NewBegin);
Atoms.insert(NewI, Atom);
// Update the atom internal bounds.
@@ -65,16 +73,14 @@ void MCModule::remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd) {
}
const MCAtom *MCModule::findAtomContaining(uint64_t Addr) const {
- AtomListTy::const_iterator I = std::lower_bound(atom_begin(), atom_end(),
- Addr, AtomComp);
+ AtomListTy::const_iterator I = atom_lower_bound(Addr);
if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
return *I;
return 0;
}
MCAtom *MCModule::findAtomContaining(uint64_t Addr) {
- AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
- Addr, AtomComp);
+ AtomListTy::iterator I = atom_lower_bound(Addr);
if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
return *I;
return 0;