virtual void anchor();
public:
class Child {
+ friend Archive;
const Archive *Parent;
/// \brief Includes header but not padding byte.
StringRef Data;
public:
Child(const Archive *Parent, const char *Start);
+ Child(const Archive *Parent, StringRef Data, uint16_t StartOfFile);
bool operator ==(const Child &other) const {
assert(Parent == other.Parent);
private:
StringRef SymbolTable;
StringRef StringTable;
- child_iterator FirstRegular;
+
+ StringRef FirstRegularData;
+ uint16_t FirstRegularStartOfFile = -1;
+ void setFirstRegular(const Child &C);
+
unsigned Format : 2;
unsigned IsThin : 1;
mutable std::vector<std::unique_ptr<MemoryBuffer>> ThinBuffers;
return Ret;
}
+Archive::Child::Child(const Archive *Parent, StringRef Data,
+ uint16_t StartOfFile)
+ : Parent(Parent), Data(Data), StartOfFile(StartOfFile) {}
+
Archive::Child::Child(const Archive *Parent, const char *Start)
: Parent(Parent) {
if (!Start)
return std::move(Ret);
}
+void Archive::setFirstRegular(const Child &C) {
+ FirstRegularData = C.Data;
+ FirstRegularStartOfFile = C.StartOfFile;
+}
+
Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
- : Binary(Binary::ID_Archive, Source), FirstRegular(child_end()) {
+ : Binary(Binary::ID_Archive, Source) {
StringRef Buffer = Data.getBuffer();
// Check for sufficient magic.
if (Buffer.startswith(ThinMagic)) {
// there is no error.
SymbolTable = *i->getBuffer();
++i;
- FirstRegular = i;
+ setFirstRegular(*i);
ec = std::error_code();
return;
}
SymbolTable = *i->getBuffer();
++i;
}
- FirstRegular = i;
+ setFirstRegular(*i);
return;
}
// ErrorOr.
StringTable = *i->getBuffer();
++i;
- FirstRegular = i;
+ setFirstRegular(*i);
ec = std::error_code();
return;
}
if (Name[0] != '/') {
Format = has64SymTable ? K_MIPS64 : K_GNU;
- FirstRegular = i;
+ setFirstRegular(*i);
ec = std::error_code();
return;
}
++i;
if (i == e) {
- FirstRegular = i;
+ setFirstRegular(*i);
ec = std::error_code();
return;
}
++i;
}
- FirstRegular = i;
+ setFirstRegular(*i);
ec = std::error_code();
}
return child_end();
if (SkipInternal)
- return FirstRegular;
+ return Child(this, FirstRegularData, FirstRegularStartOfFile);
const char *Loc = Data.getBufferStart() + strlen(Magic);
Child c(this, Loc);