[lld] r213821 - Change the signature of insertElementAt and rename addInputElementFront

Rui Ueyama ruiu at google.com
Wed Jul 23 17:08:22 PDT 2014


Author: ruiu
Date: Wed Jul 23 19:08:22 2014
New Revision: 213821

URL: http://llvm.org/viewvc/llvm-project?rev=213821&view=rev
Log:
Change the signature of insertElementAt and rename addInputElementFront

insertElementAt(x, END) does the identical thing as addInputElement(x),
so the only reasonable use of insertElementAt is to call it with the
other possible argument, BEGIN. That means the second parameter of the
function is just redundant. This patch is to remove the second
parameter and rename the function accordingly.

Modified:
    lld/trunk/include/lld/Core/InputGraph.h
    lld/trunk/lib/Core/InputGraph.cpp
    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=213821&r1=213820&r2=213821&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Wed Jul 23 19:08:22 2014
@@ -49,10 +49,6 @@ public:
   typedef std::vector<std::unique_ptr<File> > FileVectorT;
   typedef FileVectorT::iterator FileIterT;
 
-  /// Where do we want to insert the input element when calling the
-  /// insertElementAt.
-  enum Position : uint8_t { BEGIN, END };
-
   /// \brief Initialize the inputgraph
   InputGraph() : _nextElementIndex(0), _currentInputElement(nullptr) {}
 
@@ -77,6 +73,9 @@ public:
   /// \brief Adds a node into the InputGraph
   void addInputElement(std::unique_ptr<InputElement>);
 
+  /// \brief Adds a node at the beginning of the InputGraph
+  void addInputElementFront(std::unique_ptr<InputElement>);
+
   /// Normalize the InputGraph. It calls expand() on each node and then replace
   /// it with getReplacements() results.
   void normalize();
@@ -91,9 +90,6 @@ public:
   /// \brief Dump the input Graph
   bool dump(raw_ostream &diagnostics = llvm::errs());
 
-  /// \brief Insert an element into the input graph at position.
-  void insertElementAt(std::unique_ptr<InputElement>, Position position);
-
 protected:
   // Input arguments
   InputElementVectorT _inputArgs;

Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=213821&r1=213820&r2=213821&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Wed Jul 23 19:08:22 2014
@@ -46,6 +46,10 @@ void InputGraph::addInputElement(std::un
   _inputArgs.push_back(std::move(ie));
 }
 
+void InputGraph::addInputElementFront(std::unique_ptr<InputElement> ie) {
+  _inputArgs.insert(_inputArgs.begin(), std::move(ie));
+}
+
 bool InputGraph::dump(raw_ostream &diagnostics) {
   for (std::unique_ptr<InputElement> &ie : _inputArgs)
     if (!ie->dump(diagnostics))
@@ -53,17 +57,6 @@ bool InputGraph::dump(raw_ostream &diagn
   return true;
 }
 
-/// \brief Insert element at position
-void InputGraph::insertElementAt(std::unique_ptr<InputElement> element,
-                                 Position position) {
-  if (position == InputGraph::Position::BEGIN) {
-    _inputArgs.insert(_inputArgs.begin(), std::move(element));
-    return;
-  }
-  assert(position == InputGraph::Position::END);
-  _inputArgs.push_back(std::move(element));
-}
-
 /// \brief Helper functions for the resolver
 ErrorOr<InputElement *> InputGraph::getNextInputElement() {
   if (_nextElementIndex >= _inputArgs.size())

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=213821&r1=213820&r2=213821&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Wed Jul 23 19:08:22 2014
@@ -101,8 +101,7 @@ bool Driver::link(LinkingContext &contex
   context.createImplicitFiles(implicitFiles);
   if (implicitFiles.size())
     fileNode->addFiles(std::move(implicitFiles));
-  context.getInputGraph().insertElementAt(std::move(fileNode),
-                                          InputGraph::Position::BEGIN);
+  context.getInputGraph().addInputElementFront(std::move(fileNode));
 
   // Do core linking.
   ScopedTask resolveTask(getDefaultDomain(), "Resolve");





More information about the llvm-commits mailing list