[llvm] r241747 - Disallow Archive::child_iterator that don't point to an archive.

Rafael Espindola rafael.espindola at gmail.com
Wed Jul 8 15:15:08 PDT 2015


Author: rafael
Date: Wed Jul  8 17:15:07 2015
New Revision: 241747

URL: http://llvm.org/viewvc/llvm-project?rev=241747&view=rev
Log:
Disallow Archive::child_iterator that don't point to an archive.

NFC, just less error prone.

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

Modified: llvm/trunk/include/llvm/Object/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Archive.h?rev=241747&r1=241746&r2=241747&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Archive.h (original)
+++ llvm/trunk/include/llvm/Object/Archive.h Wed Jul  8 17:15:07 2015
@@ -109,7 +109,6 @@ public:
     Child child;
 
   public:
-    child_iterator() : child(Child(nullptr, nullptr)) {}
     child_iterator(const Child &c) : child(c) {}
     const Child *operator->() const { return &child; }
     const Child &operator*() const { return child; }

Modified: llvm/trunk/include/llvm/Object/ArchiveWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ArchiveWriter.h?rev=241747&r1=241746&r2=241747&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ArchiveWriter.h (original)
+++ llvm/trunk/include/llvm/Object/ArchiveWriter.h Wed Jul  8 17:15:07 2015
@@ -24,14 +24,14 @@ class NewArchiveIterator {
   bool IsNewMember;
   StringRef Name;
 
+  union {
   object::Archive::child_iterator OldI;
-
   StringRef NewFilename;
+  };
 
 public:
   NewArchiveIterator(object::Archive::child_iterator I, StringRef Name);
   NewArchiveIterator(StringRef I, StringRef Name);
-  NewArchiveIterator();
   bool isNewMember() const;
   StringRef getName() const;
 

Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=241747&r1=241746&r2=241747&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Wed Jul  8 17:15:07 2015
@@ -207,7 +207,8 @@ ErrorOr<std::unique_ptr<Archive>> Archiv
 }
 
 Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
-    : Binary(Binary::ID_Archive, Source), SymbolTable(child_end()) {
+    : Binary(Binary::ID_Archive, Source), SymbolTable(child_end()),
+      StringTable(child_end()), FirstRegular(child_end()) {
   StringRef Buffer = Data.getBuffer();
   // Check for sufficient magic.
   if (Buffer.startswith(ThinMagic)) {

Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=241747&r1=241746&r2=241747&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Wed Jul  8 17:15:07 2015
@@ -34,8 +34,6 @@
 
 using namespace llvm;
 
-NewArchiveIterator::NewArchiveIterator() {}
-
 NewArchiveIterator::NewArchiveIterator(object::Archive::child_iterator I,
                                        StringRef Name)
     : IsNewMember(false), Name(Name), OldI(I) {}

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=241747&r1=241746&r2=241747&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Wed Jul  8 17:15:07 2015
@@ -535,7 +535,8 @@ computeNewArchiveMembers(ArchiveOperatio
   assert(unsigned(InsertPos) <= Ret.size());
   Ret.insert(Ret.begin() + InsertPos, Moved.begin(), Moved.end());
 
-  Ret.insert(Ret.begin() + InsertPos, Members.size(), NewArchiveIterator());
+  Ret.insert(Ret.begin() + InsertPos, Members.size(),
+             NewArchiveIterator("", ""));
   int Pos = InsertPos;
   for (auto &Member : Members) {
     StringRef Name = sys::path::filename(Member);





More information about the llvm-commits mailing list