Protect doParse() because that's not a public interface.

llvm-svn: 224235
This commit is contained in:
Rui Ueyama 2014-12-15 07:14:32 +00:00
parent 51eb1308bd
commit 0a2c2dbfc2
6 changed files with 21 additions and 17 deletions

View File

@ -154,10 +154,6 @@ public:
/// all AbsoluteAtoms in this File.
virtual const atom_collection<AbsoluteAtom> &absolute() const = 0;
/// \brief Subclasses should override this method to parse the
/// memory buffer passed to this file's constructor.
virtual std::error_code doParse() { return std::error_code(); }
/// \brief If a file is parsed using a different method than doParse(),
/// one must use this method to set the last error status, so that
/// doParse will not be called twice. Only YAML reader uses this
@ -184,6 +180,10 @@ protected:
File(StringRef p, Kind kind)
: _path(p), _kind(kind), _ordinal(UINT64_MAX) {}
/// \brief Subclasses should override this method to parse the
/// memory buffer passed to this file's constructor.
virtual std::error_code doParse() { return std::error_code(); }
/// \brief This is a convenience class for File subclasses which manage their
/// atoms as a simple std::vector<>.
template <typename T>

View File

@ -55,6 +55,7 @@ public:
*this, name, _soname, sym->second._symbol);
}
protected:
std::error_code doParse() override {
std::error_code ec;
_objFile.reset(

View File

@ -122,8 +122,6 @@ public:
: File(mb->getBufferIdentifier(), kindObject), _mb(std::move(mb)),
_ordinal(0), _doStringsMerge(atomizeStrings) {}
virtual std::error_code doParse() override;
static ErrorOr<std::unique_ptr<ELFFile>>
create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings);
@ -171,6 +169,8 @@ protected:
const Elf_Shdr *section, ArrayRef<uint8_t> symContent,
ArrayRef<uint8_t> secContent);
std::error_code doParse() override;
/// \brief Iterate over Elf_Rela relocations list and create references.
virtual void createRelocationReferences(const Elf_Sym &symbol,
ArrayRef<uint8_t> content,

View File

@ -100,6 +100,7 @@ public:
uint64_t getTPOffset() const { return *_tpOff; }
uint64_t getDTPOffset() const { return *_dtpOff; }
protected:
std::error_code doParse() override {
if (std::error_code ec = ELFFile<ELFT>::doParse())
return ec;

View File

@ -39,17 +39,6 @@ public:
: ArchiveLibraryFile(path), _mb(std::shared_ptr<MemoryBuffer>(mb.release())),
_registry(reg), _logLoading(logLoading) {}
std::error_code doParse() override {
// Make Archive object which will be owned by FileArchive object.
std::error_code ec;
_archive.reset(new Archive(_mb->getMemBufferRef(), ec));
if (ec)
return ec;
if ((ec = buildTableOfContents()))
return ec;
return std::error_code();
}
virtual ~FileArchive() {}
/// \brief Check if any member of the archive contains an Atom with the
@ -136,6 +125,18 @@ public:
return ret;
}
protected:
std::error_code doParse() override {
// Make Archive object which will be owned by FileArchive object.
std::error_code ec;
_archive.reset(new Archive(_mb->getMemBufferRef(), ec));
if (ec)
return ec;
if ((ec = buildTableOfContents()))
return ec;
return std::error_code();
}
private:
std::error_code
instantiateMember(Archive::child_iterator member,

View File

@ -175,6 +175,7 @@ public:
visitor(offAndAtom.atom, offAndAtom.offset);
}
protected:
std::error_code doParse() override {
// Convert binary file to normalized mach-o.
auto normFile = normalized::readBinary(_mb, _ctx->arch());