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.

llvm-svn: 251758
This commit is contained in:
Rafael Espindola 2015-11-01 00:10:37 +00:00
parent cd97667400
commit 38d8e625e7
3 changed files with 11 additions and 12 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -446,11 +446,10 @@ void addMember(std::vector<NewArchiveIterator> &Members, StringRef FileName,
}
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