From: Rui Ueyama Date: Thu, 15 Jan 2015 07:20:39 +0000 (+0000) Subject: Remove InputGraph::size(). X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cdb1071be52ac6991903075bf8563896eb9394a5;p=platform%2Fupstream%2Fllvm.git Remove InputGraph::size(). llvm-svn: 226140 --- diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index 1df63e1..0bbd2ee 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -52,19 +52,20 @@ public: InputGraph() : _index(0) {} /// \brief Adds a node into the InputGraph - void addInputElement(std::unique_ptr); + void addInputElement(std::unique_ptr ie) { + _members.push_back(std::move(ie)); + } /// \brief Adds a node at the beginning of the InputGraph - void addInputElementFront(std::unique_ptr); - - InputElementVectorT &inputElements() { return _inputArgs; } + void addInputElementFront(std::unique_ptr 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; }; diff --git a/lld/lib/Core/InputGraph.cpp b/lld/lib/Core/InputGraph.cpp index 2041ba5..b5b68da 100644 --- a/lld/lib/Core/InputGraph.cpp +++ b/lld/lib/Core/InputGraph.cpp @@ -13,14 +13,6 @@ using namespace lld; -void InputGraph::addInputElement(std::unique_ptr ie) { - _inputArgs.push_back(std::move(ie)); -} - -void InputGraph::addInputElementFront(std::unique_ptr 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()) diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 49d3f61..ce398ff 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -233,7 +233,7 @@ void Resolver::addAtoms(const std::vector &newAtoms) { // undefined symbol. bool Resolver::undefinesAdded(int begin, int end) { std::vector> &inputs = - _context.getInputGraph().inputElements(); + _context.getInputGraph().members(); for (int i = begin; i < end; ++i) if (FileNode *node = dyn_cast(inputs[i].get())) if (_newUndefinesAdded[node->getFile()]) @@ -243,7 +243,7 @@ bool Resolver::undefinesAdded(int begin, int end) { File *Resolver::getFile(int &index, int &groupLevel) { std::vector> &inputs - = _context.getInputGraph().inputElements(); + = _context.getInputGraph().members(); if ((size_t)index >= inputs.size()) return nullptr; if (GroupEnd *group = dyn_cast(inputs[index].get())) { diff --git a/lld/lib/Driver/CoreDriver.cpp b/lld/lib/Driver/CoreDriver.cpp index f6d077c..1ecd147 100644 --- a/lld/lib/Driver/CoreDriver.cpp +++ b/lld/lib/Driver/CoreDriver.cpp @@ -165,7 +165,7 @@ bool CoreDriver::parse(int argc, const char *argv[], CoreLinkingContext &ctx, } } - if (!inputGraph->size()) { + if (inputGraph->members().empty()) { diagnostics << "No input files\n"; return false; } diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp index 6912cd4..1695812 100644 --- a/lld/lib/Driver/DarwinLdDriver.cpp +++ b/lld/lib/Driver/DarwinLdDriver.cpp @@ -843,7 +843,7 @@ bool DarwinLdDriver::parse(int argc, const char *argv[], } } - if (!inputGraph->size()) { + if (inputGraph->members().empty()) { diagnostics << "No input files\n"; return false; } diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp index f059c0e..9882b55 100644 --- a/lld/lib/Driver/Driver.cpp +++ b/lld/lib/Driver/Driver.cpp @@ -76,7 +76,7 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) { llvm::cl::ParseCommandLineOptions(numArgs + 1, args); } InputGraph &inputGraph = context.getInputGraph(); - if (!inputGraph.size()) + if (inputGraph.members().empty()) return false; bool fail = false; @@ -85,7 +85,7 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) { ScopedTask readTask(getDefaultDomain(), "Read Args"); TaskGroup tg; std::mutex diagnosticsMutex; - for (std::unique_ptr &ie : inputGraph.inputElements()) { + for (std::unique_ptr &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 diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp index c6e8a92..871c5c9 100644 --- a/lld/lib/Driver/GnuLdDriver.cpp +++ b/lld/lib/Driver/GnuLdDriver.cpp @@ -668,7 +668,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[], } // end switch on option ID } // end for - if (!inputGraph->size()) { + if (inputGraph->members().empty()) { diagnostics << "No input files\n"; return false; } diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 29e5edc..cc2722d 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -802,7 +802,7 @@ parseArgs(int argc, const char **argv, PECOFFLinkingContext &ctx, // graph. static bool hasLibrary(const PECOFFLinkingContext &ctx, File *file) { StringRef path = file->path(); - for (std::unique_ptr &p : ctx.getInputGraph().inputElements()) + for (std::unique_ptr &p : ctx.getInputGraph().members()) if (auto *f = dyn_cast(p.get())) if (*f->getPath(ctx) == path) return true; diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp index bdfe1a1..ca1e11a 100644 --- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp +++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp @@ -947,7 +947,7 @@ static bool isLibrary(const std::unique_ptr &elem) { // new undefines from libraries. void MachOLinkingContext::maybeSortInputFiles() { std::vector> &elements - = getInputGraph().inputElements(); + = getInputGraph().members(); std::stable_sort(elements.begin(), elements.end(), [](const std::unique_ptr &a, const std::unique_ptr &b) { diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp index aa53816..5fa53fd 100644 --- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp @@ -92,7 +92,7 @@ void PECOFFLinkingContext::addLibraryFile(std::unique_ptr file) { GroupEnd *currentGroupEnd; int pos = -1; std::vector> &elements - = getInputGraph().inputElements(); + = getInputGraph().members(); for (int i = 0, e = elements.size(); i < e; ++i) { if ((currentGroupEnd = dyn_cast(elements[i].get()))) { pos = i; diff --git a/lld/unittests/DriverTests/DriverTest.h b/lld/unittests/DriverTests/DriverTest.h index b5edbcb..83e25c8 100644 --- a/lld/unittests/DriverTests/DriverTest.h +++ b/lld/unittests/DriverTests/DriverTest.h @@ -26,12 +26,14 @@ protected: 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(&inputElement)->getPath(*linkingContext()); llvm_unreachable("not handling other types of input files");