Remove code duplication.

llvm-svn: 224206
This commit is contained in:
Rui Ueyama 2014-12-14 02:03:47 +00:00
parent 578a1f8c6d
commit 4726967a51
6 changed files with 8 additions and 51 deletions

View File

@ -213,6 +213,14 @@ public:
bool getReplacements(InputGraph::InputElementVectorT &result) override;
/// \brief Return the next File thats part of this node to the
/// resolver.
ErrorOr<File &> getNextFile() override {
if (_nextFileIndex == _files.size())
return make_error_code(InputGraphError::no_more_files);
return *_files[_nextFileIndex++];
}
protected:
StringRef _path; // The path of the Input file
InputGraph::FileVectorT _files; // A vector of lld File objects
@ -241,14 +249,6 @@ public:
std::error_code parse(const LinkingContext &, raw_ostream &) override {
return std::error_code();
}
/// \brief Return the next File thats part of this node to the
/// resolver.
ErrorOr<File &> getNextFile() override {
if (_nextFileIndex == _files.size())
return make_error_code(InputGraphError::no_more_files);
return *_files[_nextFileIndex++];
}
};
} // namespace lld

View File

@ -46,16 +46,6 @@ public:
return ctx.registry().parseFile(std::move(mb.get()), _files);
}
/// \brief Return the file that has to be processed by the resolver
/// to resolve atoms. This iterates over all the files thats part
/// of this node. Returns no_more_files when there are no files to be
/// processed
ErrorOr<File &> getNextFile() override {
if (_files.size() == _nextFileIndex)
return make_error_code(InputGraphError::no_more_files);
return *_files[_nextFileIndex++];
}
};
} // namespace lld

View File

@ -34,16 +34,6 @@ public:
std::error_code parse(const LinkingContext &ctx,
raw_ostream &diagnostics) override;
/// \brief Return the file that has to be processed by the resolver
/// to resolve atoms. This iterates over all the files thats part
/// of this node. Returns no_more_files when there are no files to be
/// processed
ErrorOr<File &> getNextFile() override {
if (_files.size() == _nextFileIndex)
return make_error_code(InputGraphError::no_more_files);
return *_files[_nextFileIndex++];
}
void setLoadWholeArchive(bool value=true) {
_isWholeArchive = value;
}

View File

@ -87,16 +87,6 @@ public:
}
}
/// \brief Return the file that has to be processed by the resolver
/// to resolve atoms. This iterates over all the files thats part
/// of this node. Returns no_more_files when there are no files to be
/// processed
ErrorOr<File &> getNextFile() override {
if (_nextFileIndex == _files.size())
return make_error_code(InputGraphError::no_more_files);
return *_files[_nextFileIndex++];
}
private:
llvm::BumpPtrAllocator _alloc;
const ELFLinkingContext &_elfLinkingContext;
@ -135,11 +125,6 @@ public:
return true;
}
/// Unused functions for ELFGNULdScript Nodes.
ErrorOr<File &> getNextFile() override {
return make_error_code(InputGraphError::no_more_files);
}
// Linker Script will be expanded and replaced with other elements
// by InputGraph::normalize(), so at link time it does not exist in
// the tree. No need to handle this message.

View File

@ -37,8 +37,6 @@ public:
std::error_code parse(const LinkingContext &ctx,
raw_ostream &diagnostics) override;
ErrorOr<File &> getNextFile() override;
protected:
const PECOFFLinkingContext &_ctx;

View File

@ -40,12 +40,6 @@ std::error_code PECOFFFileNode::parse(const LinkingContext &ctx,
return ctx.registry().parseFile(std::move(mb.get()), _files);
}
ErrorOr<File &> PECOFFFileNode::getNextFile() {
if (_nextFileIndex == _files.size())
return make_error_code(InputGraphError::no_more_files);
return *_files[_nextFileIndex++];
}
ErrorOr<StringRef> PECOFFFileNode::getPath(const LinkingContext &) const {
if (isCOFFLibraryFileExtension(_path))
return _ctx.searchLibraryFile(_path);