[lld] r225816 - Simplify.

Rui Ueyama ruiu at google.com
Tue Jan 13 10:51:10 PST 2015


Author: ruiu
Date: Tue Jan 13 12:51:09 2015
New Revision: 225816

URL: http://llvm.org/viewvc/llvm-project?rev=225816&view=rev
Log:
Simplify.

We can remove these methods because every InputElement has
only one File.

Modified:
    lld/trunk/include/lld/Core/InputGraph.h
    lld/trunk/lib/Core/InputGraph.cpp

Modified: lld/trunk/include/lld/Core/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=225816&r1=225815&r2=225816&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Tue Jan 13 12:51:09 2015
@@ -49,7 +49,7 @@ public:
   typedef FileVectorT::iterator FileIterT;
 
   /// \brief Initialize the inputgraph
-  InputGraph() : _nextElementIndex(0), _currentInputElement(nullptr) {}
+  InputGraph() : _index(0) {}
   virtual ~InputGraph();
 
   /// getNextFile returns the next file that needs to be processed by
@@ -79,11 +79,7 @@ protected:
   // Input arguments
   InputElementVectorT _inputArgs;
   // Index of the next element to be processed
-  uint32_t _nextElementIndex;
-  InputElement *_currentInputElement;
-
-private:
-  InputElement *getNextInputElement();
+  size_t _index;
 };
 
 /// \brief This describes each element in the InputGraph. The Kind

Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=225816&r1=225815&r2=225816&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Tue Jan 13 12:51:09 2015
@@ -16,18 +16,11 @@ using namespace lld;
 InputGraph::~InputGraph() { }
 
 File *InputGraph::getNextFile() {
-  // Try to get the next file of _currentInputElement. If the current input
-  // element points to an archive file, and there's a file left in the archive,
-  // it will succeed. If not, try to get the next file in the input graph.
   for (;;) {
-    if (_currentInputElement)
-      if (File *next = _currentInputElement->getNextFile())
-        return next;
-
-    InputElement *elt = getNextInputElement();
-    if (!elt)
+    if (_index >= _inputArgs.size())
       return nullptr;
-    _currentInputElement = elt;
+    if (FileNode *node = dyn_cast<FileNode>(_inputArgs[_index++].get()))
+      return node->getFile();
   }
 }
 
@@ -39,33 +32,23 @@ void InputGraph::addInputElementFront(st
   _inputArgs.insert(_inputArgs.begin(), std::move(ie));
 }
 
-/// \brief Helper functions for the resolver
-InputElement *InputGraph::getNextInputElement() {
-  if (_nextElementIndex >= _inputArgs.size())
-    return nullptr;
-  InputElement *elem = _inputArgs[_nextElementIndex++].get();
-  if (isa<GroupEnd>(elem))
-    return getNextInputElement();
-  return elem;
-}
-
 // If we are at the end of a group, return its size (which indicates
 // how many files we need to go back in the command line).
 // Returns 0 if we are not at the end of a group.
 int InputGraph::getGroupSize() {
-  if (_nextElementIndex >= _inputArgs.size())
+  if (_index >= _inputArgs.size())
     return 0;
-  InputElement *elem = _inputArgs[_nextElementIndex].get();
+  InputElement *elem = _inputArgs[_index].get();
   if (const GroupEnd *group = dyn_cast<GroupEnd>(elem))
     return group->getSize();
   return 0;
 }
 
 void InputGraph::skipGroup() {
-  if (_nextElementIndex >= _inputArgs.size())
+  if (_index >= _inputArgs.size())
     return;
-  if (isa<GroupEnd>(_inputArgs[_nextElementIndex].get()))
-    _nextElementIndex++;
+  if (isa<GroupEnd>(_inputArgs[_index].get()))
+    _index++;
 }
 
 std::error_code FileNode::parse(const LinkingContext &, raw_ostream &) {





More information about the llvm-commits mailing list