InputGraph() : _index(0) {}
/// \brief Adds a node into the InputGraph
- void addInputElement(std::unique_ptr<InputElement>);
+ void addInputElement(std::unique_ptr<InputElement> ie) {
+ _members.push_back(std::move(ie));
+ }
/// \brief Adds a node at the beginning of the InputGraph
- void addInputElementFront(std::unique_ptr<InputElement>);
-
- InputElementVectorT &inputElements() { return _inputArgs; }
+ void addInputElementFront(std::unique_ptr<InputElement> ie) {
+ _members.insert(_members.begin(), std::move(ie));
+ }
- // \brief Returns the number of input files.
- size_t size() const { return _inputArgs.size(); }
+ InputElementVectorT &members() { return _members; }
protected:
// Input arguments
- InputElementVectorT _inputArgs;
+ InputElementVectorT _members;
// Index of the next element to be processed
size_t _index;
};
using namespace lld;
-void InputGraph::addInputElement(std::unique_ptr<InputElement> ie) {
- _inputArgs.push_back(std::move(ie));
-}
-
-void InputGraph::addInputElementFront(std::unique_ptr<InputElement> ie) {
- _inputArgs.insert(_inputArgs.begin(), std::move(ie));
-}
-
std::error_code FileNode::parse(const LinkingContext &, raw_ostream &) {
if (_file)
if (std::error_code ec = _file->parse())
// undefined symbol.
bool Resolver::undefinesAdded(int begin, int end) {
std::vector<std::unique_ptr<InputElement>> &inputs =
- _context.getInputGraph().inputElements();
+ _context.getInputGraph().members();
for (int i = begin; i < end; ++i)
if (FileNode *node = dyn_cast<FileNode>(inputs[i].get()))
if (_newUndefinesAdded[node->getFile()])
File *Resolver::getFile(int &index, int &groupLevel) {
std::vector<std::unique_ptr<InputElement>> &inputs
- = _context.getInputGraph().inputElements();
+ = _context.getInputGraph().members();
if ((size_t)index >= inputs.size())
return nullptr;
if (GroupEnd *group = dyn_cast<GroupEnd>(inputs[index].get())) {
}
}
- if (!inputGraph->size()) {
+ if (inputGraph->members().empty()) {
diagnostics << "No input files\n";
return false;
}
}
}
- if (!inputGraph->size()) {
+ if (inputGraph->members().empty()) {
diagnostics << "No input files\n";
return false;
}
llvm::cl::ParseCommandLineOptions(numArgs + 1, args);
}
InputGraph &inputGraph = context.getInputGraph();
- if (!inputGraph.size())
+ if (inputGraph.members().empty())
return false;
bool fail = false;
ScopedTask readTask(getDefaultDomain(), "Read Args");
TaskGroup tg;
std::mutex diagnosticsMutex;
- for (std::unique_ptr<InputElement> &ie : inputGraph.inputElements()) {
+ for (std::unique_ptr<InputElement> &ie : inputGraph.members()) {
tg.spawn([&] {
// Writes to the same output stream is not guaranteed to be thread-safe.
// We buffer the diagnostics output to a separate string-backed output
} // end switch on option ID
} // end for
- if (!inputGraph->size()) {
+ if (inputGraph->members().empty()) {
diagnostics << "No input files\n";
return false;
}
// graph.
static bool hasLibrary(const PECOFFLinkingContext &ctx, File *file) {
StringRef path = file->path();
- for (std::unique_ptr<InputElement> &p : ctx.getInputGraph().inputElements())
+ for (std::unique_ptr<InputElement> &p : ctx.getInputGraph().members())
if (auto *f = dyn_cast<FileNode>(p.get()))
if (*f->getPath(ctx) == path)
return true;
// new undefines from libraries.
void MachOLinkingContext::maybeSortInputFiles() {
std::vector<std::unique_ptr<InputElement>> &elements
- = getInputGraph().inputElements();
+ = getInputGraph().members();
std::stable_sort(elements.begin(), elements.end(),
[](const std::unique_ptr<InputElement> &a,
const std::unique_ptr<InputElement> &b) {
GroupEnd *currentGroupEnd;
int pos = -1;
std::vector<std::unique_ptr<InputElement>> &elements
- = getInputGraph().inputElements();
+ = getInputGraph().members();
for (int i = 0, e = elements.size(); i < e; ++i) {
if ((currentGroupEnd = dyn_cast<GroupEnd>(elements[i].get()))) {
pos = i;
std::string &errorMessage() { return _errorMessage; }
// Convenience method for getting number of input files.
- int inputFileCount() { return linkingContext()->getInputGraph().size(); }
+ int inputFileCount() {
+ return linkingContext()->getInputGraph().members().size();
+ }
// Convenience method for getting i'th input files name.
std::string inputFile(int index) {
const InputElement &inputElement =
- *linkingContext()->getInputGraph().inputElements()[index];
+ *linkingContext()->getInputGraph().members()[index];
if (inputElement.kind() == InputElement::Kind::File)
return *cast<FileNode>(&inputElement)->getPath(*linkingContext());
llvm_unreachable("not handling other types of input files");