forked from OSchip/llvm-project
Rename referencesBegin() to begin() so that C++11 range based for loops can be used
llvm-svn: 154301
This commit is contained in:
parent
6148fe65e8
commit
062a98cff0
|
@ -279,14 +279,10 @@ public:
|
|||
};
|
||||
|
||||
/// Returns an iterator to the beginning of this Atom's References
|
||||
virtual reference_iterator referencesBegin() const = 0;
|
||||
virtual reference_iterator begin() const = 0;
|
||||
|
||||
/// Returns an iterator to the end of this Atom's References
|
||||
virtual reference_iterator referencesEnd() const = 0;
|
||||
|
||||
reference_iterator begin() const { return referencesBegin(); }
|
||||
reference_iterator end() const { return referencesEnd(); }
|
||||
|
||||
virtual reference_iterator end() const = 0;
|
||||
|
||||
static inline bool classof(const Atom *a) {
|
||||
return a->definition() == definitionRegular;
|
||||
|
|
|
@ -92,9 +92,9 @@ public:
|
|||
|
||||
virtual ArrayRef<uint8_t> rawContent() const;
|
||||
|
||||
virtual reference_iterator referencesBegin() const;
|
||||
virtual reference_iterator begin() const;
|
||||
|
||||
virtual reference_iterator referencesEnd() const;
|
||||
virtual reference_iterator end() const;
|
||||
|
||||
virtual const Reference* derefIterator(const void*) const;
|
||||
|
||||
|
@ -731,13 +731,13 @@ inline StringRef NativeDefinedAtomV1::customSectionName() const {
|
|||
return _file->string(offset);
|
||||
}
|
||||
|
||||
DefinedAtom::reference_iterator NativeDefinedAtomV1::referencesBegin() const {
|
||||
DefinedAtom::reference_iterator NativeDefinedAtomV1::begin() const {
|
||||
uintptr_t index = _ivarData->referencesStartIndex;
|
||||
const void* it = reinterpret_cast<const void*>(index);
|
||||
return reference_iterator(*this, it);
|
||||
}
|
||||
|
||||
DefinedAtom::reference_iterator NativeDefinedAtomV1::referencesEnd() const {
|
||||
DefinedAtom::reference_iterator NativeDefinedAtomV1::end() const {
|
||||
uintptr_t index = _ivarData->referencesStartIndex+_ivarData->referencesCount;
|
||||
const void* it = reinterpret_cast<const void*>(index);
|
||||
return reference_iterator(*this, it);
|
||||
|
|
|
@ -30,25 +30,17 @@ public:
|
|||
// reserve first byte for unnamed atoms
|
||||
_stringPool.push_back('\0');
|
||||
// visit all atoms
|
||||
for(File::defined_iterator it=file.definedAtomsBegin(),
|
||||
end=file.definedAtomsEnd();
|
||||
it != end; ++it) {
|
||||
this->addIVarsForDefinedAtom(**it);
|
||||
for ( const DefinedAtom *defAtom : file.defined() ) {
|
||||
this->addIVarsForDefinedAtom(*defAtom);
|
||||
}
|
||||
for(File::undefined_iterator it=file.undefinedAtomsBegin(),
|
||||
end=file.undefinedAtomsEnd();
|
||||
it != end; ++it) {
|
||||
this->addIVarsForUndefinedAtom(**it);
|
||||
for ( const UndefinedAtom *undefAtom : file.undefined() ) {
|
||||
this->addIVarsForUndefinedAtom(*undefAtom);
|
||||
}
|
||||
for(File::shared_library_iterator it=file.sharedLibraryAtomsBegin(),
|
||||
end=file.sharedLibraryAtomsEnd();
|
||||
it != end; ++it) {
|
||||
this->addIVarsForSharedLibraryAtom(**it);
|
||||
for ( const SharedLibraryAtom *shlibAtom : file.sharedLibrary() ) {
|
||||
this->addIVarsForSharedLibraryAtom(*shlibAtom);
|
||||
}
|
||||
for(File::absolute_iterator it=file.absoluteAtomsBegin(),
|
||||
end=file.absoluteAtomsEnd();
|
||||
it != end; ++it) {
|
||||
this->addIVarsForAbsoluteAtom(**it);
|
||||
for ( const AbsoluteAtom *absAtom : file.absolute() ) {
|
||||
this->addIVarsForAbsoluteAtom(*absAtom);
|
||||
}
|
||||
|
||||
|
||||
|
@ -412,9 +404,7 @@ private:
|
|||
count = 0;
|
||||
size_t startRefSize = _references.size();
|
||||
uint32_t result = startRefSize;
|
||||
for (auto it=atom.referencesBegin(), end=atom.referencesEnd();
|
||||
it != end; ++it) {
|
||||
const Reference* ref = *it;
|
||||
for (const Reference *ref : atom) {
|
||||
NativeReferenceIvarsV1 nref;
|
||||
nref.offsetInAtom = ref->offsetInAtom();
|
||||
nref.kind = ref->kind();
|
||||
|
|
|
@ -175,9 +175,8 @@ void Resolver::resolveUndefines() {
|
|||
undefineGenCount = _symbolTable.size();
|
||||
std::vector<const Atom *> undefines;
|
||||
_symbolTable.undefines(undefines);
|
||||
for (std::vector<const Atom *>::iterator it = undefines.begin();
|
||||
it != undefines.end(); ++it) {
|
||||
StringRef undefName = (*it)->name();
|
||||
for ( const Atom *undefAtom : undefines ) {
|
||||
StringRef undefName = undefAtom->name();
|
||||
// load for previous undefine may also have loaded this undefine
|
||||
if (!_symbolTable.isDefined(undefName)) {
|
||||
_inputFiles.searchLibraries(undefName, true, true, false, *this);
|
||||
|
@ -194,18 +193,16 @@ void Resolver::resolveUndefines() {
|
|||
// search libraries for overrides of common symbols
|
||||
if (searchArchives || searchDylibs) {
|
||||
std::vector<const Atom *> tents;
|
||||
for (std::vector<const Atom *>::iterator ait = _atoms.begin();
|
||||
ait != _atoms.end(); ++ait) {
|
||||
if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(*ait)) {
|
||||
for ( const Atom *tent : tents ) {
|
||||
if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(tent)) {
|
||||
if ( defAtom->merge() == DefinedAtom::mergeAsTentative )
|
||||
tents.push_back(defAtom);
|
||||
}
|
||||
}
|
||||
for (std::vector<const Atom *>::iterator dit = tents.begin();
|
||||
dit != tents.end(); ++dit) {
|
||||
for ( const Atom *tent : tents ) {
|
||||
// load for previous tentative may also have loaded
|
||||
// this tentative, so check again
|
||||
StringRef tentName = (*dit)->name();
|
||||
StringRef tentName = tent->name();
|
||||
const Atom *curAtom = _symbolTable.findByName(tentName);
|
||||
assert(curAtom != nullptr);
|
||||
if (const DefinedAtom* curDefAtom = dyn_cast<DefinedAtom>(curAtom)) {
|
||||
|
@ -222,11 +219,9 @@ void Resolver::resolveUndefines() {
|
|||
// switch all references to undefined or coalesced away atoms
|
||||
// to the new defined atom
|
||||
void Resolver::updateReferences() {
|
||||
for (auto ait = _atoms.begin(); ait != _atoms.end(); ++ait) {
|
||||
if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(*ait)) {
|
||||
for (auto rit=defAtom->referencesBegin(), end=defAtom->referencesEnd();
|
||||
rit != end; ++rit) {
|
||||
const Reference* ref = *rit;
|
||||
for(const Atom *atom : _atoms) {
|
||||
if (const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(atom)) {
|
||||
for (const Reference *ref : *defAtom) {
|
||||
const Atom* newTarget = _symbolTable.replacement(ref->target());
|
||||
(const_cast<Reference*>(ref))->setTarget(newTarget);
|
||||
}
|
||||
|
@ -262,9 +257,7 @@ void Resolver::markLive(const Atom &atom, WhyLiveBackChain *previous) {
|
|||
thisChain.previous = previous;
|
||||
thisChain.referer = &atom;
|
||||
if ( const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(&atom)) {
|
||||
for (auto rit=defAtom->referencesBegin(), end=defAtom->referencesEnd();
|
||||
rit != end; ++rit) {
|
||||
const Reference* ref = *rit;
|
||||
for (const Reference *ref : *defAtom) {
|
||||
this->markLive(*ref->target(), &thisChain);
|
||||
}
|
||||
}
|
||||
|
@ -299,12 +292,11 @@ void Resolver::deadStripOptimize() {
|
|||
this->addAtoms(platRootAtoms);
|
||||
|
||||
// mark all roots as live, and recursively all atoms they reference
|
||||
for (std::set<const Atom *>::iterator it = _deadStripRoots.begin();
|
||||
it != _deadStripRoots.end(); ++it) {
|
||||
for ( const Atom *dsrAtom : _deadStripRoots) {
|
||||
WhyLiveBackChain rootChain;
|
||||
rootChain.previous = nullptr;
|
||||
rootChain.referer = *it;
|
||||
this->markLive(**it, &rootChain);
|
||||
rootChain.referer = dsrAtom;
|
||||
this->markLive(*dsrAtom, &rootChain);
|
||||
}
|
||||
|
||||
// now remove all non-live atoms from _atoms
|
||||
|
@ -342,9 +334,8 @@ void Resolver::removeCoalescedAwayAtoms() {
|
|||
// check for interactions between symbols defined in this linkage unit
|
||||
// and same symbol name in linked dynamic shared libraries
|
||||
void Resolver::checkDylibSymbolCollisions() {
|
||||
for (std::vector<const Atom *>::const_iterator it = _atoms.begin();
|
||||
it != _atoms.end(); ++it) {
|
||||
const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(*it);
|
||||
for ( const Atom *atom : _atoms ) {
|
||||
const DefinedAtom* defAtom = dyn_cast<DefinedAtom>(atom);
|
||||
if (defAtom == nullptr)
|
||||
continue;
|
||||
if ( defAtom->merge() != DefinedAtom::mergeAsTentative )
|
||||
|
@ -407,8 +398,8 @@ void Resolver::MergedFile::addAtom(const Atom& atom) {
|
|||
}
|
||||
|
||||
void Resolver::MergedFile::addAtoms(std::vector<const Atom*>& all) {
|
||||
for(std::vector<const Atom*>::iterator it=all.begin(); it != all.end(); ++it){
|
||||
this->addAtom(**it);
|
||||
for ( const Atom *atom : all ) {
|
||||
this->addAtom(*atom);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -456,13 +456,13 @@ public:
|
|||
return _ord;
|
||||
}
|
||||
|
||||
DefinedAtom::reference_iterator referencesBegin() const {
|
||||
DefinedAtom::reference_iterator begin() const {
|
||||
uintptr_t index = _refStartIndex;
|
||||
const void* it = reinterpret_cast<const void*>(index);
|
||||
return reference_iterator(*this, it);
|
||||
}
|
||||
|
||||
DefinedAtom::reference_iterator referencesEnd() const {
|
||||
DefinedAtom::reference_iterator end() const {
|
||||
uintptr_t index = _refEndIndex;
|
||||
const void* it = reinterpret_cast<const void*>(index);
|
||||
return reference_iterator(*this, it);
|
||||
|
|
|
@ -57,9 +57,7 @@ public:
|
|||
buildDuplicateNameMap(*atom);
|
||||
|
||||
// Find references to unnamed atoms and create ref-names for them.
|
||||
for (auto rit=atom->referencesBegin(), rend=atom->referencesEnd();
|
||||
rit != rend; ++rit) {
|
||||
const Reference* ref = *rit;
|
||||
for (const Reference *ref : *atom) {
|
||||
// create refname for any unnamed reference target
|
||||
if ( ref->target()->name().empty() ) {
|
||||
std::string Storage;
|
||||
|
@ -313,9 +311,7 @@ public:
|
|||
}
|
||||
|
||||
bool wroteFirstFixup = false;
|
||||
for (auto it=atom.referencesBegin(), end=atom.referencesEnd();
|
||||
it != end; ++it) {
|
||||
const Reference* ref = *it;
|
||||
for (const Reference *ref : atom) {
|
||||
if ( !wroteFirstFixup ) {
|
||||
out << " fixups:\n";
|
||||
wroteFirstFixup = true;
|
||||
|
|
|
@ -47,12 +47,8 @@ void GOTPass::perform() {
|
|||
llvm::DenseMap<const Atom*, const DefinedAtom*> targetToGOT;
|
||||
|
||||
// Scan all references in all atoms.
|
||||
for(auto ait=_file.definedAtomsBegin(), aend=_file.definedAtomsEnd();
|
||||
ait != aend; ++ait) {
|
||||
const DefinedAtom* atom = *ait;
|
||||
for (auto rit=atom->referencesBegin(), rend=atom->referencesEnd();
|
||||
rit != rend; ++rit) {
|
||||
const Reference* ref = *rit;
|
||||
for(const DefinedAtom *atom : _file.defined()) {
|
||||
for (const Reference *ref : *atom) {
|
||||
// Look at instructions accessing the GOT.
|
||||
bool canBypassGOT;
|
||||
if ( _platform.isGOTAccess(ref->kind(), canBypassGOT) ) {
|
||||
|
|
|
@ -31,12 +31,8 @@ void StubsPass::perform() {
|
|||
return;
|
||||
|
||||
// Scan all references in all atoms.
|
||||
for(auto ait=_file.definedAtomsBegin(), aend=_file.definedAtomsEnd();
|
||||
ait != aend; ++ait) {
|
||||
const DefinedAtom* atom = *ait;
|
||||
for (auto rit=atom->referencesBegin(), rend=atom->referencesEnd();
|
||||
rit != rend; ++rit) {
|
||||
const Reference* ref = *rit;
|
||||
for(const DefinedAtom *atom : _file.defined()) {
|
||||
for (const Reference *ref : *atom) {
|
||||
// Look at call-sites.
|
||||
if ( _platform.isCallSite(ref->kind()) ) {
|
||||
const Atom* target = ref->target();
|
||||
|
|
|
@ -556,9 +556,7 @@ void SectionChunk::write(raw_ostream &out) {
|
|||
ArrayRef<uint8_t> content = atomInfo.atom->rawContent();
|
||||
buffer.resize(content.size());
|
||||
::memcpy(buffer.data(), content.data(), content.size());
|
||||
for (auto rit=atomInfo.atom->referencesBegin(),
|
||||
rend=atomInfo.atom->referencesEnd(); rit != rend; ++rit) {
|
||||
const Reference* ref = *rit;
|
||||
for (const Reference *ref : *atomInfo.atom) {
|
||||
uint32_t offset = ref->offsetInAtom();
|
||||
uint64_t targetAddress = 0;
|
||||
if ( ref->target() != nullptr )
|
||||
|
|
|
@ -126,13 +126,13 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual DefinedAtom::reference_iterator referencesBegin() const {
|
||||
virtual DefinedAtom::reference_iterator begin() const {
|
||||
uintptr_t index = 0;
|
||||
const void* it = reinterpret_cast<const void*>(index);
|
||||
return reference_iterator(*this, it);
|
||||
}
|
||||
|
||||
virtual DefinedAtom::reference_iterator referencesEnd() const {
|
||||
virtual DefinedAtom::reference_iterator end() const {
|
||||
uintptr_t index = _references.size();
|
||||
const void* it = reinterpret_cast<const void*>(index);
|
||||
return reference_iterator(*this, it);
|
||||
|
|
|
@ -119,11 +119,11 @@ public:
|
|||
return ArrayRef<uint8_t>();
|
||||
}
|
||||
|
||||
virtual reference_iterator referencesBegin() const {
|
||||
virtual reference_iterator begin() const {
|
||||
return reference_iterator(*this, nullptr);
|
||||
}
|
||||
|
||||
virtual reference_iterator referencesEnd() const {
|
||||
virtual reference_iterator end() const {
|
||||
return reference_iterator(*this, nullptr);
|
||||
}
|
||||
|
||||
|
@ -218,11 +218,11 @@ public:
|
|||
return ArrayRef<uint8_t>();
|
||||
}
|
||||
|
||||
virtual reference_iterator referencesBegin() const {
|
||||
virtual reference_iterator begin() const {
|
||||
return reference_iterator(*this, nullptr);
|
||||
}
|
||||
|
||||
virtual reference_iterator referencesEnd() const {
|
||||
virtual reference_iterator end() const {
|
||||
return reference_iterator(*this, nullptr);
|
||||
}
|
||||
|
||||
|
@ -449,9 +449,7 @@ public:
|
|||
|
||||
// InputFiles interface
|
||||
virtual void forEachInitialAtom(InputFiles::Handler& handler) const {
|
||||
for (std::vector<const File *>::iterator fit = _files.begin();
|
||||
fit != _files.end(); ++fit) {
|
||||
const File* file = *fit;
|
||||
for ( const File *file : _files ) {
|
||||
handler.doFile(*file);
|
||||
for(auto it=file->definedAtomsBegin(),end=file->definedAtomsEnd();
|
||||
it != end; ++it) {
|
||||
|
|
Loading…
Reference in New Issue