[llvm] r282884 - [Object] Define Archive::isEmpty().

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 10:54:31 PDT 2016


Author: ruiu
Date: Fri Sep 30 12:54:31 2016
New Revision: 282884

URL: http://llvm.org/viewvc/llvm-project?rev=282884&view=rev
Log:
[Object] Define Archive::isEmpty().

Modified:
    llvm/trunk/include/llvm/Object/Archive.h
    llvm/trunk/lib/Object/Archive.cpp

Modified: llvm/trunk/include/llvm/Object/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Archive.h?rev=282884&r1=282883&r2=282884&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Archive.h (original)
+++ llvm/trunk/include/llvm/Object/Archive.h Fri Sep 30 12:54:31 2016
@@ -239,6 +239,7 @@ public:
   // check if a symbol is in the archive
   Expected<Optional<Child>> findSym(StringRef name) const;
 
+  bool isEmpty() const;
   bool hasSymbolTable() const;
   StringRef getSymbolTable() const { return SymbolTable; }
   StringRef getStringTable() const { return StringTable; }

Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=282884&r1=282883&r2=282884&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Fri Sep 30 12:54:31 2016
@@ -752,7 +752,7 @@ Archive::Archive(MemoryBufferRef Source,
 
 Archive::child_iterator Archive::child_begin(Error &Err,
                                              bool SkipInternal) const {
-  if (Data.getBufferSize() == 8) // empty archive.
+  if (isEmpty())
     return child_end();
 
   if (SkipInternal)
@@ -968,4 +968,7 @@ Expected<Optional<Archive::Child>> Archi
   return Optional<Child>();
 }
 
+// Returns true if archive file contains no member file.
+bool Archive::isEmpty() const { return Data.getBufferSize() == 8; }
+
 bool Archive::hasSymbolTable() const { return !SymbolTable.empty(); }




More information about the llvm-commits mailing list