[lld] r224206 - Remove code duplication.

Rui Ueyama ruiu at google.com
Sat Dec 13 18:03:49 PST 2014


Author: ruiu
Date: Sat Dec 13 20:03:47 2014
New Revision: 224206

URL: http://llvm.org/viewvc/llvm-project?rev=224206&view=rev
Log:
Remove code duplication.

Modified:
    lld/trunk/include/lld/Core/InputGraph.h
    lld/trunk/include/lld/Driver/CoreInputGraph.h
    lld/trunk/include/lld/Driver/DarwinInputGraph.h
    lld/trunk/include/lld/Driver/GnuLdInputGraph.h
    lld/trunk/include/lld/Driver/WinLinkInputGraph.h
    lld/trunk/lib/Driver/WinLinkInputGraph.cpp

Modified: lld/trunk/include/lld/Core/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=224206&r1=224205&r2=224206&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Sat Dec 13 20:03:47 2014
@@ -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
 

Modified: lld/trunk/include/lld/Driver/CoreInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/CoreInputGraph.h?rev=224206&r1=224205&r2=224206&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/CoreInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/CoreInputGraph.h Sat Dec 13 20:03:47 2014
@@ -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

Modified: lld/trunk/include/lld/Driver/DarwinInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=224206&r1=224205&r2=224206&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/DarwinInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/DarwinInputGraph.h Sat Dec 13 20:03:47 2014
@@ -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;
   }

Modified: lld/trunk/include/lld/Driver/GnuLdInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/GnuLdInputGraph.h?rev=224206&r1=224205&r2=224206&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/GnuLdInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/GnuLdInputGraph.h Sat Dec 13 20:03:47 2014
@@ -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.

Modified: lld/trunk/include/lld/Driver/WinLinkInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=224206&r1=224205&r2=224206&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/WinLinkInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/WinLinkInputGraph.h Sat Dec 13 20:03:47 2014
@@ -37,8 +37,6 @@ public:
   std::error_code parse(const LinkingContext &ctx,
                         raw_ostream &diagnostics) override;
 
-  ErrorOr<File &> getNextFile() override;
-
 protected:
   const PECOFFLinkingContext &_ctx;
 

Modified: lld/trunk/lib/Driver/WinLinkInputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkInputGraph.cpp?rev=224206&r1=224205&r2=224206&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkInputGraph.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkInputGraph.cpp Sat Dec 13 20:03:47 2014
@@ -40,12 +40,6 @@ std::error_code PECOFFFileNode::parse(co
   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);





More information about the llvm-commits mailing list