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) {}
/// \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();
/// \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;
_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))
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())
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");