From 4726967a514bcf5c0b653247337b763a84bf6234 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 14 Dec 2014 02:03:47 +0000 Subject: [PATCH] Remove code duplication. llvm-svn: 224206 --- lld/include/lld/Core/InputGraph.h | 16 ++++++++-------- lld/include/lld/Driver/CoreInputGraph.h | 10 ---------- lld/include/lld/Driver/DarwinInputGraph.h | 10 ---------- lld/include/lld/Driver/GnuLdInputGraph.h | 15 --------------- lld/include/lld/Driver/WinLinkInputGraph.h | 2 -- lld/lib/Driver/WinLinkInputGraph.cpp | 6 ------ 6 files changed, 8 insertions(+), 51 deletions(-) diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index cf5969389426..c307153b7f9b 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -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 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 getNextFile() override { - if (_nextFileIndex == _files.size()) - return make_error_code(InputGraphError::no_more_files); - return *_files[_nextFileIndex++]; - } }; } // namespace lld diff --git a/lld/include/lld/Driver/CoreInputGraph.h b/lld/include/lld/Driver/CoreInputGraph.h index a68b01a93913..ade6f490e359 100644 --- a/lld/include/lld/Driver/CoreInputGraph.h +++ b/lld/include/lld/Driver/CoreInputGraph.h @@ -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 getNextFile() override { - if (_files.size() == _nextFileIndex) - return make_error_code(InputGraphError::no_more_files); - return *_files[_nextFileIndex++]; - } }; } // namespace lld diff --git a/lld/include/lld/Driver/DarwinInputGraph.h b/lld/include/lld/Driver/DarwinInputGraph.h index b2b8cabcbf86..8d41135412fb 100644 --- a/lld/include/lld/Driver/DarwinInputGraph.h +++ b/lld/include/lld/Driver/DarwinInputGraph.h @@ -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 getNextFile() override { - if (_files.size() == _nextFileIndex) - return make_error_code(InputGraphError::no_more_files); - return *_files[_nextFileIndex++]; - } - void setLoadWholeArchive(bool value=true) { _isWholeArchive = value; } diff --git a/lld/include/lld/Driver/GnuLdInputGraph.h b/lld/include/lld/Driver/GnuLdInputGraph.h index dfb61d2bd534..8d62bafadeba 100644 --- a/lld/include/lld/Driver/GnuLdInputGraph.h +++ b/lld/include/lld/Driver/GnuLdInputGraph.h @@ -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 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 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. diff --git a/lld/include/lld/Driver/WinLinkInputGraph.h b/lld/include/lld/Driver/WinLinkInputGraph.h index ddcabd277670..d9439659b332 100644 --- a/lld/include/lld/Driver/WinLinkInputGraph.h +++ b/lld/include/lld/Driver/WinLinkInputGraph.h @@ -37,8 +37,6 @@ public: std::error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override; - ErrorOr getNextFile() override; - protected: const PECOFFLinkingContext &_ctx; diff --git a/lld/lib/Driver/WinLinkInputGraph.cpp b/lld/lib/Driver/WinLinkInputGraph.cpp index e5a2733a8879..b3232a67a5e1 100644 --- a/lld/lib/Driver/WinLinkInputGraph.cpp +++ b/lld/lib/Driver/WinLinkInputGraph.cpp @@ -40,12 +40,6 @@ std::error_code PECOFFFileNode::parse(const LinkingContext &ctx, return ctx.registry().parseFile(std::move(mb.get()), _files); } -ErrorOr PECOFFFileNode::getNextFile() { - if (_nextFileIndex == _files.size()) - return make_error_code(InputGraphError::no_more_files); - return *_files[_nextFileIndex++]; -} - ErrorOr PECOFFFileNode::getPath(const LinkingContext &) const { if (isCOFFLibraryFileExtension(_path)) return _ctx.searchLibraryFile(_path);