Rename referencesBegin() to begin() so that C++11 range based for loops can be used

llvm-svn: 154301
diff --git a/lld/lib/Core/NativeReader.cpp b/lld/lib/Core/NativeReader.cpp
index 01466d3..2908614 100644
--- a/lld/lib/Core/NativeReader.cpp
+++ b/lld/lib/Core/NativeReader.cpp
@@ -92,9 +92,9 @@
 
   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 @@
   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);
diff --git a/lld/lib/Core/NativeWriter.cpp b/lld/lib/Core/NativeWriter.cpp
index 09e0d9a..5c7fc05 100644
--- a/lld/lib/Core/NativeWriter.cpp
+++ b/lld/lib/Core/NativeWriter.cpp
@@ -30,25 +30,17 @@
     // 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 @@
     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();
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index f0742a2..0cf5838 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -175,9 +175,8 @@
     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 @@
     // 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 @@
 // 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 @@
   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 @@
     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 @@
 // 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::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);
   }
 }
 
diff --git a/lld/lib/Core/YamlReader.cpp b/lld/lib/Core/YamlReader.cpp
index 8fc8f94..6d7c23c 100644
--- a/lld/lib/Core/YamlReader.cpp
+++ b/lld/lib/Core/YamlReader.cpp
@@ -456,13 +456,13 @@
     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);
diff --git a/lld/lib/Core/YamlWriter.cpp b/lld/lib/Core/YamlWriter.cpp
index c01bca5..db63b61 100644
--- a/lld/lib/Core/YamlWriter.cpp
+++ b/lld/lib/Core/YamlWriter.cpp
@@ -57,9 +57,7 @@
         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 @@
     }
 
     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;