Remove definedAtomsBegin() and co. so that C++11 range based for loops can be used

llvm-svn: 154302
This commit is contained in:
Nick Kledzik 2012-04-09 00:58:21 +00:00
parent 062a98cff0
commit 467209b1d4
4 changed files with 26 additions and 84 deletions

View File

@ -71,46 +71,8 @@ public:
/// For use interating over AbsoluteAtoms in this File.
typedef atom_iterator<AbsoluteAtom> absolute_iterator;
/// Returns an iterator to the beginning of this File's DefinedAtoms
defined_iterator definedAtomsBegin() const {
return defined().begin();
}
/// Returns an iterator to the end of this File's DefinedAtoms
defined_iterator definedAtomsEnd() const {
return defined().end();
}
/// Returns an iterator to the beginning of this File's DefinedAtoms
undefined_iterator undefinedAtomsBegin() const {
return undefined().begin();
}
/// Returns an iterator to the end of this File's UndefinedAtoms
undefined_iterator undefinedAtomsEnd() const {
return undefined().end();
}
/// Returns an iterator to the beginning of this File's SharedLibraryAtoms
shared_library_iterator sharedLibraryAtomsBegin() const {
return sharedLibrary().begin();
}
/// Returns an iterator to the end of this File's SharedLibraryAtoms
shared_library_iterator sharedLibraryAtomsEnd() const {
return sharedLibrary().end();
}
/// Returns an iterator to the beginning of this File's AbsoluteAtoms
absolute_iterator absoluteAtomsBegin() const {
return absolute().begin();
}
/// Returns an iterator to the end of this File's AbsoluteAtoms
absolute_iterator absoluteAtomsEnd() const {
return absolute().end();
}
/// Note: this method is not const. All File objects instantiated by reading
/// an object file from disk are "const File*" objects and cannot be
/// modified. This method can only be used with temporay File objects

View File

@ -606,8 +606,9 @@ private:
void YAMLFile::bindTargetReferences() {
for (defined_iterator it = definedAtomsBegin(); it != definedAtomsEnd(); ++it) {
const YAMLDefinedAtom* atom = reinterpret_cast<const YAMLDefinedAtom*>(*it);
for (const DefinedAtom *defAtom : _definedAtoms) {
const YAMLDefinedAtom* atom =
reinterpret_cast<const YAMLDefinedAtom*>(defAtom);
atom->bindTargetReferences();
}
}

View File

@ -48,10 +48,7 @@ public:
RefNameBuilder(const File& file)
: _collisionCount(0), _unnamedCounter(0) {
// visit all atoms
for(File::defined_iterator it=file.definedAtomsBegin(),
end=file.definedAtomsEnd();
it != end; ++it) {
const DefinedAtom* atom = *it;
for( const DefinedAtom *atom : file.defined() ) {
// Build map of atoms names to detect duplicates
if ( ! atom->name().empty() )
buildDuplicateNameMap(*atom);
@ -67,20 +64,14 @@ public:
}
}
}
for(File::undefined_iterator it=file.undefinedAtomsBegin(),
end=file.undefinedAtomsEnd();
it != end; ++it) {
buildDuplicateNameMap(**it);
for( const UndefinedAtom *undefAtom : file.undefined() ) {
buildDuplicateNameMap(*undefAtom);
}
for(File::shared_library_iterator it=file.sharedLibraryAtomsBegin(),
end=file.sharedLibraryAtomsEnd();
it != end; ++it) {
buildDuplicateNameMap(**it);
for( const SharedLibraryAtom *shlibAtom : file.sharedLibrary() ) {
buildDuplicateNameMap(*shlibAtom);
}
for(File::absolute_iterator it=file.absoluteAtomsBegin(),
end=file.absoluteAtomsEnd();
it != end; ++it) {
buildDuplicateNameMap(**it);
for( const AbsoluteAtom *absAtom : file.absolute() ) {
buildDuplicateNameMap(*absAtom);
}
@ -142,25 +133,17 @@ public:
out << "---\n";
// visit all atoms
for(File::defined_iterator it=_file.definedAtomsBegin(),
end=_file.definedAtomsEnd();
it != end; ++it) {
writeDefinedAtom(**it, out);
for( const DefinedAtom *atom : _file.defined() ) {
writeDefinedAtom(*atom, out);
}
for(File::undefined_iterator it=_file.undefinedAtomsBegin(),
end=_file.undefinedAtomsEnd();
it != end; ++it) {
writeUndefinedAtom(**it, out);
for( const UndefinedAtom *undefAtom : _file.undefined() ) {
writeUndefinedAtom(*undefAtom, out);
}
for(File::shared_library_iterator it=_file.sharedLibraryAtomsBegin(),
end=_file.sharedLibraryAtomsEnd();
it != end; ++it) {
writeSharedLibraryAtom(**it, out);
for( const SharedLibraryAtom *shlibAtom : _file.sharedLibrary() ) {
writeSharedLibraryAtom(*shlibAtom, out);
}
for(File::absolute_iterator it=_file.absoluteAtomsBegin(),
end=_file.absoluteAtomsEnd();
it != end; ++it) {
writeAbsoluteAtom(**it, out);
for( const AbsoluteAtom *absAtom : _file.absolute() ) {
writeAbsoluteAtom(*absAtom, out);
}
out << "...\n";

View File

@ -451,21 +451,17 @@ public:
virtual void forEachInitialAtom(InputFiles::Handler& handler) const {
for ( const File *file : _files ) {
handler.doFile(*file);
for(auto it=file->definedAtomsBegin(),end=file->definedAtomsEnd();
it != end; ++it) {
handler.doDefinedAtom(**it);
for( const DefinedAtom *atom : file->defined() ) {
handler.doDefinedAtom(*atom);
}
for(auto it=file->undefinedAtomsBegin(), end=file->undefinedAtomsEnd();
it != end; ++it) {
handler.doUndefinedAtom(**it);
for( const UndefinedAtom *undefAtom : file->undefined() ) {
handler.doUndefinedAtom(*undefAtom);
}
for(auto it=file->sharedLibraryAtomsBegin(), end=file->sharedLibraryAtomsEnd();
it != end; ++it) {
handler.doSharedLibraryAtom(**it);
for( const SharedLibraryAtom *shlibAtom : file->sharedLibrary() ) {
handler.doSharedLibraryAtom(*shlibAtom);
}
for(auto it=file->absoluteAtomsBegin(),end=file->absoluteAtomsEnd();
it != end; ++it) {
handler.doAbsoluteAtom(**it);
for( const AbsoluteAtom *absAtom : file->absolute() ) {
handler.doAbsoluteAtom(*absAtom);
}
}
}