[lld] r226140 - Remove InputGraph::size().

Rui Ueyama ruiu at google.com
Wed Jan 14 23:20:40 PST 2015


Author: ruiu
Date: Thu Jan 15 01:20:39 2015
New Revision: 226140

URL: http://llvm.org/viewvc/llvm-project?rev=226140&view=rev
Log:
Remove InputGraph::size().

Modified:
    lld/trunk/include/lld/Core/InputGraph.h
    lld/trunk/lib/Core/InputGraph.cpp
    lld/trunk/lib/Core/Resolver.cpp
    lld/trunk/lib/Driver/CoreDriver.cpp
    lld/trunk/lib/Driver/DarwinLdDriver.cpp
    lld/trunk/lib/Driver/Driver.cpp
    lld/trunk/lib/Driver/GnuLdDriver.cpp
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
    lld/trunk/unittests/DriverTests/DriverTest.h

Modified: lld/trunk/include/lld/Core/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Thu Jan 15 01:20:39 2015
@@ -52,19 +52,20 @@ public:
   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>);
+  void addInputElementFront(std::unique_ptr<InputElement> ie) {
+    _members.insert(_members.begin(), std::move(ie));
+  }
 
-  InputElementVectorT &inputElements() { return _inputArgs; }
-
-  // \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;
 };

Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Thu Jan 15 01:20:39 2015
@@ -13,14 +13,6 @@
 
 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())

Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Jan 15 01:20:39 2015
@@ -233,7 +233,7 @@ void Resolver::addAtoms(const std::vecto
 // 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()])
@@ -243,7 +243,7 @@ bool Resolver::undefinesAdded(int begin,
 
 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())) {

Modified: lld/trunk/lib/Driver/CoreDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CoreDriver.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CoreDriver.cpp (original)
+++ lld/trunk/lib/Driver/CoreDriver.cpp Thu Jan 15 01:20:39 2015
@@ -165,7 +165,7 @@ bool CoreDriver::parse(int argc, const c
     }
   }
 
-  if (!inputGraph->size()) {
+  if (inputGraph->members().empty()) {
     diagnostics << "No input files\n";
     return false;
   }

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Thu Jan 15 01:20:39 2015
@@ -843,7 +843,7 @@ bool DarwinLdDriver::parse(int argc, con
     }
   }
 
-  if (!inputGraph->size()) {
+  if (inputGraph->members().empty()) {
     diagnostics << "No input files\n";
     return false;
   }

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Thu Jan 15 01:20:39 2015
@@ -76,7 +76,7 @@ bool Driver::link(LinkingContext &contex
     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 &contex
   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

Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Thu Jan 15 01:20:39 2015
@@ -668,7 +668,7 @@ bool GnuLdDriver::parse(int argc, const
     } // end switch on option ID
   }   // end for
 
-  if (!inputGraph->size()) {
+  if (inputGraph->members().empty()) {
     diagnostics << "No input files\n";
     return false;
   }

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Jan 15 01:20:39 2015
@@ -802,7 +802,7 @@ parseArgs(int argc, const char **argv, P
 // 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;

Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Thu Jan 15 01:20:39 2015
@@ -947,7 +947,7 @@ static bool isLibrary(const std::unique_
 // 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) {

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Thu Jan 15 01:20:39 2015
@@ -92,7 +92,7 @@ void PECOFFLinkingContext::addLibraryFil
   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;

Modified: lld/trunk/unittests/DriverTests/DriverTest.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/DriverTest.h?rev=226140&r1=226139&r2=226140&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/DriverTest.h (original)
+++ lld/trunk/unittests/DriverTests/DriverTest.h Thu Jan 15 01:20:39 2015
@@ -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<FileNode>(&inputElement)->getPath(*linkingContext());
     llvm_unreachable("not handling other types of input files");





More information about the llvm-commits mailing list