llvm.org GIT mirror llvm / bf4296f
Disallow Archive::child_iterator that don't point to an archive. NFC, just less error prone. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241747 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
5 changed file(s) with 6 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
108108 Child child;
109109
110110 public:
111 child_iterator() : child(Child(nullptr, nullptr)) {}
112111 child_iterator(const Child &c) : child(c) {}
113112 const Child *operator->() const { return &child; }
114113 const Child &operator*() const { return child; }
2323 bool IsNewMember;
2424 StringRef Name;
2525
26 union {
2627 object::Archive::child_iterator OldI;
27
2828 StringRef NewFilename;
29 };
2930
3031 public:
3132 NewArchiveIterator(object::Archive::child_iterator I, StringRef Name);
3233 NewArchiveIterator(StringRef I, StringRef Name);
33 NewArchiveIterator();
3434 bool isNewMember() const;
3535 StringRef getName() const;
3636
206206 }
207207
208208 Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
209 : Binary(Binary::ID_Archive, Source), SymbolTable(child_end()) {
209 : Binary(Binary::ID_Archive, Source), SymbolTable(child_end()),
210 StringTable(child_end()), FirstRegular(child_end()) {
210211 StringRef Buffer = Data.getBuffer();
211212 // Check for sufficient magic.
212213 if (Buffer.startswith(ThinMagic)) {
3232 #endif
3333
3434 using namespace llvm;
35
36 NewArchiveIterator::NewArchiveIterator() {}
3735
3836 NewArchiveIterator::NewArchiveIterator(object::Archive::child_iterator I,
3937 StringRef Name)
534534 assert(unsigned(InsertPos) <= Ret.size());
535535 Ret.insert(Ret.begin() + InsertPos, Moved.begin(), Moved.end());
536536
537 Ret.insert(Ret.begin() + InsertPos, Members.size(), NewArchiveIterator());
537 Ret.insert(Ret.begin() + InsertPos, Members.size(),
538 NewArchiveIterator("", ""));
538539 int Pos = InsertPos;
539540 for (auto &Member : Members) {
540541 StringRef Name = sys::path::filename(Member);