Change the signature of insertElementAt and rename addInputElementFront
authorRui Ueyama <ruiu@google.com>
Thu, 24 Jul 2014 00:08:22 +0000 (00:08 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 24 Jul 2014 00:08:22 +0000 (00:08 +0000)
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.

llvm-svn: 213821

lld/include/lld/Core/InputGraph.h
lld/lib/Core/InputGraph.cpp
lld/lib/Driver/Driver.cpp

index 1b357a2..6c63d5c 100644 (file)
@@ -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;
index 9a76e93..bdef8c3 100644 (file)
@@ -46,6 +46,10 @@ void InputGraph::addInputElement(std::unique_ptr<InputElement> ie) {
   _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 &diagnostics) {
   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())
index e8567ed..9e57ed7 100644 (file)
@@ -101,8 +101,7 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
   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");