summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core/LinkingContext.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2013-10-08 00:43:53 +0000
committerRui Ueyama <ruiu@google.com>2013-10-08 00:43:53 +0000
commit094546836bed638d03e687d83b2682dfb3adf8f6 (patch)
tree286f473d44ecc18115c3e79ff953dec06690a2b8 /lld/lib/Core/LinkingContext.cpp
parentf8c54842d6d944c0d0aba8638b985f354ef32d6a (diff)
downloadbcm5719-llvm-094546836bed638d03e687d83b2682dfb3adf8f6.tar.gz
bcm5719-llvm-094546836bed638d03e687d83b2682dfb3adf8f6.zip
Add comments. Early return.
llvm-svn: 192149
Diffstat (limited to 'lld/lib/Core/LinkingContext.cpp')
-rw-r--r--lld/lib/Core/LinkingContext.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/lld/lib/Core/LinkingContext.cpp b/lld/lib/Core/LinkingContext.cpp
index 23ae0fbad91..0bfef16cc61 100644
--- a/lld/lib/Core/LinkingContext.cpp
+++ b/lld/lib/Core/LinkingContext.cpp
@@ -81,24 +81,30 @@ void LinkingContext::setResolverState(int32_t state) const {
}
ErrorOr<File &> LinkingContext::nextFile() const {
+ // When nextFile() is called for the first time, _currentInputElement is not
+ // initialized. Initialize it with the first element of the input graph.
if (_currentInputElement == nullptr) {
ErrorOr<InputElement *> elem = inputGraph().getNextInputElement();
if (error_code(elem) == input_graph_error::no_more_elements)
return make_error_code(input_graph_error::no_more_files);
_currentInputElement = *elem;
}
- do {
+
+ // Otherwise, 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 (;;) {
ErrorOr<File &> nextFile = _currentInputElement->getNextFile();
- if (error_code(nextFile) == input_graph_error::no_more_files) {
- ErrorOr<InputElement *> elem = inputGraph().getNextInputElement();
- if (error_code(elem) == input_graph_error::no_more_elements)
- return make_error_code(input_graph_error::no_more_files);
- _currentInputElement = *elem;
- } else {
+ if (error_code(nextFile) != input_graph_error::no_more_files)
return std::move(nextFile);
- }
- } while (_currentInputElement != nullptr);
- return make_error_code(input_graph_error::no_more_files);
+
+ ErrorOr<InputElement *> elem = inputGraph().getNextInputElement();
+ if (error_code(elem) == input_graph_error::no_more_elements ||
+ *elem == nullptr)
+ return make_error_code(input_graph_error::no_more_files);
+ _currentInputElement = *elem;
+ }
}
void LinkingContext::addPasses(PassManager &pm) const {}
OpenPOWER on IntegriCloud