diff options
Diffstat (limited to 'lld/lib/Driver/InputGraph.cpp')
-rw-r--r-- | lld/lib/Driver/InputGraph.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lld/lib/Driver/InputGraph.cpp b/lld/lib/Driver/InputGraph.cpp new file mode 100644 index 00000000000..001cfed4e27 --- /dev/null +++ b/lld/lib/Driver/InputGraph.cpp @@ -0,0 +1,56 @@ +//===- lib/Driver/InputGraph.cpp ------------------------------------------===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include "lld/Driver/InputGraph.h" + +using namespace lld; + +namespace { +bool sortInputElements(const std::unique_ptr<InputElement> &a, + const std::unique_ptr<InputElement> &b) { + return a->getOrdinal() < b->getOrdinal(); +} +} + +bool InputGraph::addInputElement(std::unique_ptr<InputElement> ie) { + switch (ie->kind()) { + case InputElement::Kind::Control: + ++_numElements; + break; + case InputElement::Kind::File: + ++_numElements; + ++_numFiles; + break; + } + _inputArgs.push_back(std::move(ie)); + return true; +} + +bool InputGraph::assignOrdinals() { + for (auto &ie : _inputArgs) + ie->setOrdinal(++_ordinal); + return true; +} + +void InputGraph::doPostProcess() { + std::stable_sort(_inputArgs.begin(), _inputArgs.end(), sortInputElements); +} + +bool InputGraph::validate() { + for (auto &ie : _inputArgs) + if (!ie->validate()) + return false; + return true; +} + +bool InputGraph::dump(raw_ostream &diagnostics) { + for (auto &ie : _inputArgs) + if (!ie->dump(diagnostics)) + return false; + return true; +} |