diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index 45caf53bdb22..2fdd578aa894 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -49,11 +49,7 @@ public: /// Where do we want to insert the input element when calling the /// insertElementAt. - enum Position : uint8_t { - ANY, - BEGIN, - END - }; + enum Position : uint8_t { BEGIN, END }; /// \brief Initialize the inputgraph InputGraph() : _ordinal(0), _nextElementIndex(0) {} @@ -91,8 +87,7 @@ public: } /// \brief Insert an element into the input graph at position. - void insertElementAt(std::unique_ptr, Position position, - size_t pos = 0); + void insertElementAt(std::unique_ptr, Position position); /// \brief Helper functions for the resolver ErrorOr getNextInputElement(); diff --git a/lld/lib/Core/InputGraph.cpp b/lld/lib/Core/InputGraph.cpp index 80f8d6923ec8..ad9779e19740 100644 --- a/lld/lib/Core/InputGraph.cpp +++ b/lld/lib/Core/InputGraph.cpp @@ -44,12 +44,13 @@ bool InputGraph::dump(raw_ostream &diagnostics) { /// \brief Insert element at position void InputGraph::insertElementAt(std::unique_ptr element, - Position position, size_t pos) { - if (position == InputGraph::Position::BEGIN) - pos = 0; - else if (position == InputGraph::Position::END) - pos = _inputArgs.size(); - _inputArgs.insert(_inputArgs.begin() + pos, std::move(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