From 25569fdcdab032ffe42f3595ae69b934247f3bbc Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 1 Nov 2015 00:10:37 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251758 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ArchiveWriter.h | 6 +++--- lib/Object/ArchiveWriter.cpp | 10 +++++----- tools/llvm-ar/llvm-ar.cpp | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/llvm/Object/ArchiveWriter.h b/include/llvm/Object/ArchiveWriter.h index fc4669de1ba..b5d2ba35808 100644 --- a/include/llvm/Object/ArchiveWriter.h +++ b/include/llvm/Object/ArchiveWriter.h @@ -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 getFD(sys::fs::file_status &NewStatus) const; diff --git a/lib/Object/ArchiveWriter.cpp b/lib/Object/ArchiveWriter.cpp index dae0188a21e..f14cbc0d657 100644 --- a/lib/Object/ArchiveWriter.cpp +++ b/lib/Object/ArchiveWriter.cpp @@ -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 { diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index c8ff53b58b2..b63856b9f7f 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -446,11 +446,10 @@ void addMember(std::vector &Members, StringRef FileName, } void addMember(std::vector &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 -- 2.34.1