using namespace llvm;
-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);
+static bool AtomComp(const MCAtom *L, uint64_t Addr) {
+ return L->getEndAddr() < Addr;
}
void MCModule::map(MCAtom *NewAtom) {
assert(Begin <= NewAtom->End && "Creating MCAtom with endpoints reversed?");
// Check for atoms already covering this range.
- AtomListTy::iterator I = atom_lower_bound(Begin);
+ AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
+ Begin, AtomComp);
assert((I == atom_end() || (*I)->getBeginAddr() > NewAtom->End)
&& "Offset range already occupied!");
// 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 = atom_lower_bound(Atom->Begin);
+ AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
+ Atom->Begin, AtomComp);
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 = atom_lower_bound(NewBegin);
+ AtomListTy::iterator NewI = std::lower_bound(atom_begin(), atom_end(),
+ NewBegin, AtomComp);
Atoms.insert(NewI, Atom);
// Update the atom internal bounds.
}
const MCAtom *MCModule::findAtomContaining(uint64_t Addr) const {
- AtomListTy::const_iterator I = atom_lower_bound(Addr);
+ AtomListTy::const_iterator I = std::lower_bound(atom_begin(), atom_end(),
+ Addr, AtomComp);
if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
return *I;
return 0;
}
MCAtom *MCModule::findAtomContaining(uint64_t Addr) {
- AtomListTy::iterator I = atom_lower_bound(Addr);
+ AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
+ Addr, AtomComp);
if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
return *I;
return 0;