[llvm] r251758 - Use Child instead of child_iterator in the archive writer.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 31 17:10:37 PDT 2015


Author: rafael
Date: Sat Oct 31 19:10:37 2015
New Revision: 251758

URL: http://llvm.org/viewvc/llvm-project?rev=251758&view=rev
Log:
Use Child instead of child_iterator in the archive writer.

We never need to pass end(). This will also remove some complication
once we start adding error checking.

Modified:
    llvm/trunk/include/llvm/Object/ArchiveWriter.h
    llvm/trunk/lib/Object/ArchiveWriter.cpp
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp

Modified: llvm/trunk/include/llvm/Object/ArchiveWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ArchiveWriter.h?rev=251758&r1=251757&r2=251758&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ArchiveWriter.h (original)
+++ llvm/trunk/include/llvm/Object/ArchiveWriter.h Sat Oct 31 19:10:37 2015
@@ -24,15 +24,15 @@ class NewArchiveIterator {
   bool IsNewMember;
   StringRef Name;
 
-  object::Archive::child_iterator OldI;
+  object::Archive::Child OldMember;
 
 public:
-  NewArchiveIterator(object::Archive::child_iterator I, StringRef Name);
+  NewArchiveIterator(const object::Archive::Child &OldMember, StringRef Name);
   NewArchiveIterator(StringRef FileName);
   bool isNewMember() const;
   StringRef getName() const;
 
-  object::Archive::child_iterator getOld() const;
+  const object::Archive::Child &getOld() const;
 
   StringRef getNew() const;
   llvm::ErrorOr<int> getFD(sys::fs::file_status &NewStatus) const;

Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=251758&r1=251757&r2=251758&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Sat Oct 31 19:10:37 2015
@@ -34,20 +34,20 @@
 
 using namespace llvm;
 
-NewArchiveIterator::NewArchiveIterator(object::Archive::child_iterator I,
+NewArchiveIterator::NewArchiveIterator(const object::Archive::Child &OldMember,
                                        StringRef Name)
-    : IsNewMember(false), Name(Name), OldI(I) {}
+    : IsNewMember(false), Name(Name), OldMember(OldMember) {}
 
 NewArchiveIterator::NewArchiveIterator(StringRef FileName)
-    : IsNewMember(true), Name(FileName) {}
+    : IsNewMember(true), Name(FileName), OldMember(nullptr, nullptr) {}
 
 StringRef NewArchiveIterator::getName() const { return Name; }
 
 bool NewArchiveIterator::isNewMember() const { return IsNewMember; }
 
-object::Archive::child_iterator NewArchiveIterator::getOld() const {
+const object::Archive::Child &NewArchiveIterator::getOld() const {
   assert(!IsNewMember);
-  return OldI;
+  return OldMember;
 }
 
 StringRef NewArchiveIterator::getNew() const {

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=251758&r1=251757&r2=251758&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Sat Oct 31 19:10:37 2015
@@ -446,11 +446,10 @@ void addMember(std::vector<NewArchiveIte
 }
 
 void addMember(std::vector<NewArchiveIterator> &Members,
-               object::Archive::child_iterator I, StringRef Name,
-               int Pos = -1) {
-  if (Thin && !I->getParent()->isThin())
+               const object::Archive::Child &M, StringRef Name, int Pos = -1) {
+  if (Thin && !M.getParent()->isThin())
     fail("Cannot convert a regular archive to a thin one");
-  NewArchiveIterator NI(I, Name);
+  NewArchiveIterator NI(M, Name);
   if (Pos == -1)
     Members.push_back(NI);
   else




More information about the llvm-commits mailing list