[llvm-commits] [lld] r154302 - in /lld/trunk: include/lld/Core/File.h lib/Core/YamlReader.cpp lib/Core/YamlWriter.cpp tools/lld-core/lld-core.cpp

Nick Kledzik kledzik at apple.com
Sun Apr 8 17:58:21 PDT 2012


Author: kledzik
Date: Sun Apr  8 19:58:21 2012
New Revision: 154302

URL: http://llvm.org/viewvc/llvm-project?rev=154302&view=rev
Log:
Remove definedAtomsBegin() and co. so that C++11 range based for loops can be used

Modified:
    lld/trunk/include/lld/Core/File.h
    lld/trunk/lib/Core/YamlReader.cpp
    lld/trunk/lib/Core/YamlWriter.cpp
    lld/trunk/tools/lld-core/lld-core.cpp

Modified: lld/trunk/include/lld/Core/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/File.h?rev=154302&r1=154301&r2=154302&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/File.h (original)
+++ lld/trunk/include/lld/Core/File.h Sun Apr  8 19:58:21 2012
@@ -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

Modified: lld/trunk/lib/Core/YamlReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlReader.cpp?rev=154302&r1=154301&r2=154302&view=diff
==============================================================================
--- lld/trunk/lib/Core/YamlReader.cpp (original)
+++ lld/trunk/lib/Core/YamlReader.cpp Sun Apr  8 19:58:21 2012
@@ -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();
     }
 }

Modified: lld/trunk/lib/Core/YamlWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlWriter.cpp?rev=154302&r1=154301&r2=154302&view=diff
==============================================================================
--- lld/trunk/lib/Core/YamlWriter.cpp (original)
+++ lld/trunk/lib/Core/YamlWriter.cpp Sun Apr  8 19:58:21 2012
@@ -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(File::shared_library_iterator it=file.sharedLibraryAtomsBegin(),
-                              end=file.sharedLibraryAtomsEnd();
-                               it != end; ++it) {
-      buildDuplicateNameMap(**it);
-    }
-    for(File::absolute_iterator it=file.absoluteAtomsBegin(),
-                              end=file.absoluteAtomsEnd();
-                               it != end; ++it) {
-      buildDuplicateNameMap(**it);
+    for( const UndefinedAtom *undefAtom : file.undefined() ) {
+      buildDuplicateNameMap(*undefAtom);
+    }
+    for( const SharedLibraryAtom *shlibAtom : file.sharedLibrary() ) {
+      buildDuplicateNameMap(*shlibAtom);
+    }
+    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(File::undefined_iterator it=_file.undefinedAtomsBegin(),
-                              end=_file.undefinedAtomsEnd();
-                               it != end; ++it) {
-      writeUndefinedAtom(**it, out);
-    }
-    for(File::shared_library_iterator it=_file.sharedLibraryAtomsBegin(),
-                              end=_file.sharedLibraryAtomsEnd();
-                               it != end; ++it) {
-      writeSharedLibraryAtom(**it, out);
-    }
-    for(File::absolute_iterator it=_file.absoluteAtomsBegin(),
-                              end=_file.absoluteAtomsEnd();
-                               it != end; ++it) {
-      writeAbsoluteAtom(**it, out);
+    for( const DefinedAtom *atom : _file.defined() ) {
+      writeDefinedAtom(*atom, out);
+    }
+    for( const UndefinedAtom *undefAtom : _file.undefined() ) {
+      writeUndefinedAtom(*undefAtom, out);
+    }
+    for( const SharedLibraryAtom *shlibAtom : _file.sharedLibrary() ) {
+      writeSharedLibraryAtom(*shlibAtom, out);
+    }
+    for( const AbsoluteAtom *absAtom : _file.absolute() ) {
+      writeAbsoluteAtom(*absAtom, out);
     }
 
     out << "...\n";

Modified: lld/trunk/tools/lld-core/lld-core.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld-core/lld-core.cpp?rev=154302&r1=154301&r2=154302&view=diff
==============================================================================
--- lld/trunk/tools/lld-core/lld-core.cpp (original)
+++ lld/trunk/tools/lld-core/lld-core.cpp Sun Apr  8 19:58:21 2012
@@ -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);
       }
     }
   }





More information about the llvm-commits mailing list