[lld] r205558 - Add empty() to atom_collection.

Rui Ueyama ruiu at google.com
Thu Apr 3 12:51:15 PDT 2014


Author: ruiu
Date: Thu Apr  3 14:51:14 2014
New Revision: 205558

URL: http://llvm.org/viewvc/llvm-project?rev=205558&view=rev
Log:
Add empty() to atom_collection.

"x.empty()" is more idiomatic than "x.size() == 0". This patch is to
add such method and use it in LLD.

Differential Revision: http://llvm-reviews.chandlerc.com/D3279

Modified:
    lld/trunk/include/lld/Core/File.h
    lld/trunk/lib/Core/Resolver.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp

Modified: lld/trunk/include/lld/Core/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/File.h?rev=205558&r1=205557&r2=205558&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/File.h (original)
+++ lld/trunk/include/lld/Core/File.h Thu Apr  3 14:51:14 2014
@@ -105,6 +105,7 @@ public:
     virtual const T *deref(const void *it) const = 0;
     virtual void next(const void *&it) const = 0;
     virtual uint64_t size() const = 0;
+    bool empty() const { return size() == 0; }
   };
 
   /// \brief The class is the iterator type used to iterate through a File's

Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=205558&r1=205557&r2=205558&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Apr  3 14:51:14 2014
@@ -78,7 +78,7 @@ void Resolver::handleFile(const File &fi
 
   if (!sharedLibraryFile ||
       _context.addUndefinedAtomsFromSharedLibrary(sharedLibraryFile)) {
-    progress = (file.undefined().size() > 0);
+    progress = !file.undefined().empty();
 
     for (const UndefinedAtom *undefAtom : file.undefined()) {
       doUndefinedAtom(*undefAtom);
@@ -101,8 +101,8 @@ void Resolver::handleFile(const File &fi
 
   // If we make some progress on linking, notify that fact to the input file
   // manager, because it may want to know that for --start-group/end-group.
-  progress = progress || file.sharedLibrary().size() ||
-             file.absolute().size() || file.defined().size();
+  progress = progress || !file.sharedLibrary().empty() ||
+             !file.absolute().empty() || !file.defined().empty();
   if (progress) {
     _context.inputGraph().notifyProgress();
   }

Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp?rev=205558&r1=205557&r2=205558&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp Thu Apr  3 14:51:14 2014
@@ -111,7 +111,7 @@ std::vector<ImportTableEntryAtom *> Impo
 } // namespace idata
 
 void IdataPass::perform(std::unique_ptr<MutableFile> &file) {
-  if (file->sharedLibrary().size() == 0)
+  if (file->sharedLibrary().empty())
     return;
 
   idata::Context context(*file, _dummyFile);





More information about the llvm-commits mailing list