Remove definedAtomsBegin() and co. so that C++11 range based for loops can be used
llvm-svn: 154302
diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h
index 0f4de36..58de481 100644
--- a/lld/include/lld/Core/File.h
+++ b/lld/include/lld/Core/File.h
@@ -71,46 +71,8 @@
/// 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
diff --git a/lld/lib/Core/YamlReader.cpp b/lld/lib/Core/YamlReader.cpp
index 6d7c23c..6af7111 100644
--- a/lld/lib/Core/YamlReader.cpp
+++ b/lld/lib/Core/YamlReader.cpp
@@ -606,8 +606,9 @@
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();
}
}
diff --git a/lld/lib/Core/YamlWriter.cpp b/lld/lib/Core/YamlWriter.cpp
index db63b61..c5f45c9 100644
--- a/lld/lib/Core/YamlWriter.cpp
+++ b/lld/lib/Core/YamlWriter.cpp
@@ -48,10 +48,7 @@
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 @@
}
}
}
- 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 @@
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";
diff --git a/lld/tools/lld-core/lld-core.cpp b/lld/tools/lld-core/lld-core.cpp
index 69cd3d3..ef80507 100644
--- a/lld/tools/lld-core/lld-core.cpp
+++ b/lld/tools/lld-core/lld-core.cpp
@@ -451,21 +451,17 @@
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);
}
}
}