[lld] r226144 - Remove FileNode::parse.

Rui Ueyama ruiu at google.com
Wed Jan 14 23:56:14 PST 2015


Author: ruiu
Date: Thu Jan 15 01:56:14 2015
New Revision: 226144

URL: http://llvm.org/viewvc/llvm-project?rev=226144&view=rev
Log:
Remove FileNode::parse.

FileNode::parse was just a forwarder to File::parse so we could remove that.
Also removed dead code.

Removed:
    lld/trunk/lib/Core/InputGraph.cpp
Modified:
    lld/trunk/include/lld/Core/InputGraph.h
    lld/trunk/lib/Core/CMakeLists.txt
    lld/trunk/lib/Driver/Driver.cpp

Modified: lld/trunk/include/lld/Core/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=226144&r1=226143&r2=226144&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Thu Jan 15 01:56:14 2015
@@ -33,24 +33,8 @@ namespace lld {
 class InputElement;
 class LinkingContext;
 
-/// \brief The inputs to the linker are represented by an InputGraph. The
-/// nodes in the input graph contains Input elements. The InputElements are
-/// either Input Files or Control Options. The Input Files represent each Input
-/// File to the linker and the control option specify what the linker needs
-/// to do when it processes the option.
-/// Each InputElement that is part of the Graph has an Ordinal value
-/// associated with it. The ordinal value is needed for the Writer to figure out
-/// the relative position of the arguments that appeared in the Command Line.
 class InputGraph {
 public:
-  typedef std::vector<std::unique_ptr<InputElement> > InputElementVectorT;
-  typedef InputElementVectorT::iterator InputElementIterT;
-  typedef std::vector<std::unique_ptr<File> > FileVectorT;
-  typedef FileVectorT::iterator FileIterT;
-
-  /// \brief Initialize the inputgraph
-  InputGraph() : _index(0) {}
-
   /// \brief Adds a node into the InputGraph
   void addInputElement(std::unique_ptr<InputElement> ie) {
     _members.push_back(std::move(ie));
@@ -61,13 +45,12 @@ public:
     _members.insert(_members.begin(), std::move(ie));
   }
 
-  InputElementVectorT &members() { return _members; }
+  std::vector<std::unique_ptr<InputElement>> &members() {
+    return _members;
+  }
 
 protected:
-  // Input arguments
-  InputElementVectorT _members;
-  // Index of the next element to be processed
-  size_t _index;
+  std::vector<std::unique_ptr<InputElement>> _members;
 };
 
 /// \brief This describes each element in the InputGraph. The Kind
@@ -86,9 +69,6 @@ public:
   /// Return the Element Type for an Input Element
   virtual Kind kind() const { return _kind; }
 
-  /// \brief parse the input element
-  virtual std::error_code parse(const LinkingContext &, raw_ostream &) = 0;
-
 protected:
   Kind _kind; // The type of the Element
 };
@@ -105,50 +85,26 @@ public:
     return a->kind() == Kind::GroupEnd;
   }
 
-  /// \brief Parse the group members.
-  std::error_code parse(const LinkingContext &ctx, raw_ostream &diag) override {
-    return std::error_code();
-  }
-
 private:
   int _size;
 };
 
-/// \brief Represents an Input file in the graph
-///
-/// This class represents an input to the linker. It create the MemoryBuffer
-/// lazily when needed based on the file path. It can also take a MemoryBuffer
-/// directly.
+// A container of File.
 class FileNode : public InputElement {
 public:
   explicit FileNode(std::unique_ptr<File> f)
-      : InputElement(InputElement::Kind::File), _file(std::move(f)),
-        _done(false) {}
+      : InputElement(InputElement::Kind::File), _file(std::move(f)) {}
 
   virtual ~FileNode() {}
 
-  /// \brief Casting support
   static inline bool classof(const InputElement *a) {
     return a->kind() == InputElement::Kind::File;
   }
 
-  /// \brief Get the list of files
   File *getFile() { return _file.get(); }
 
-  /// \brief add a file to the list of files
-  virtual void addFiles(InputGraph::FileVectorT files) {
-    assert(files.size() == 1);
-    assert(!_file);
-    _file = std::move(files[0]);
-  }
-
-  std::error_code parse(const LinkingContext &, raw_ostream &) override;
-
 protected:
-  std::unique_ptr<File> _file;           // An lld File object
-
-  // The next file that would be processed by the resolver
-  bool _done;
+  std::unique_ptr<File> _file;
 };
 
 } // namespace lld

Modified: lld/trunk/lib/Core/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/CMakeLists.txt?rev=226144&r1=226143&r2=226144&view=diff
==============================================================================
--- lld/trunk/lib/Core/CMakeLists.txt (original)
+++ lld/trunk/lib/Core/CMakeLists.txt Thu Jan 15 01:56:14 2015
@@ -4,7 +4,6 @@ add_lld_library(lldCore
   DefinedAtom.cpp
   Error.cpp
   File.cpp
-  InputGraph.cpp
   LinkingContext.cpp
   Resolver.cpp
   SymbolTable.cpp

Removed: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=226143&view=auto
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp (removed)
@@ -1,21 +0,0 @@
-//===- lib/Core/InputGraph.cpp --------------------------------------------===//
-//
-//                             The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lld/Core/InputGraph.h"
-#include "lld/Core/Resolver.h"
-#include <memory>
-
-using namespace lld;
-
-std::error_code FileNode::parse(const LinkingContext &, raw_ostream &) {
-  if (_file)
-    if (std::error_code ec = _file->parse())
-      return ec;
-  return std::error_code();
-}

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=226144&r1=226143&r2=226144&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Thu Jan 15 01:56:14 2015
@@ -93,14 +93,14 @@ bool Driver::link(LinkingContext &contex
       std::string buf;
       llvm::raw_string_ostream stream(buf);
 
-      if (std::error_code ec = ie->parse(context, stream)) {
-        if (FileNode *fileNode = dyn_cast<FileNode>(ie.get())) {
-          stream << "Cannot open " + fileNode->getFile()->path()
-                 << ": " << ec.message() << "\n";
-        } else {
-          llvm_unreachable("Unknown type of input element");
-        }
-        fail = true;
+      if (FileNode *node = dyn_cast<FileNode>(ie.get())) {
+	if (File *file = node->getFile()) {
+	  if (std::error_code ec = file->parse()) {
+	    stream << "Cannot open " + file->path()
+		   << ": " << ec.message() << "\n";
+	    fail = true;
+	  }
+	}
       }
 
       stream.flush();
@@ -116,7 +116,7 @@ bool Driver::link(LinkingContext &contex
   if (fail)
     return false;
 
-  InputGraph::FileVectorT internalFiles;
+  std::vector<std::unique_ptr<File>> internalFiles;
   context.createInternalFiles(internalFiles);
   for (auto i = internalFiles.rbegin(), e = internalFiles.rend(); i != e; ++i) {
     context.getInputGraph().addInputElementFront(
@@ -124,7 +124,7 @@ bool Driver::link(LinkingContext &contex
   }
 
   // Give target a chance to add files.
-  InputGraph::FileVectorT implicitFiles;
+  std::vector<std::unique_ptr<File>> implicitFiles;
   context.createImplicitFiles(implicitFiles);
   for (auto i = implicitFiles.rbegin(), e = implicitFiles.rend(); i != e; ++i) {
     context.getInputGraph().addInputElementFront(





More information about the llvm-commits mailing list