aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-01-13 18:51:09 +0000
committerRui Ueyama <ruiu@google.com>2015-01-13 18:51:09 +0000
commit8e91899882c023ee06e5493d027da8c2c80b2427 (patch)
treec9de71443370176be3fa1e86aa9deca8e7153410
parent29a7e2ef252347a9a5bc04ed00e701aec840ba01 (diff)
Simplify.
We can remove these methods because every InputElement has only one File. git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@225816 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/lld/Core/InputGraph.h8
-rw-r--r--lib/Core/InputGraph.cpp33
2 files changed, 10 insertions, 31 deletions
diff --git a/include/lld/Core/InputGraph.h b/include/lld/Core/InputGraph.h
index 8ccb4438b..bf88e87c5 100644
--- a/include/lld/Core/InputGraph.h
+++ b/include/lld/Core/InputGraph.h
@@ -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
diff --git a/lib/Core/InputGraph.cpp b/lib/Core/InputGraph.cpp
index 1fad72764..0c86bdf2d 100644
--- a/lib/Core/InputGraph.cpp
+++ b/lib/Core/InputGraph.cpp
@@ -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(std::unique_ptr<InputElement> ie) {
_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 &) {