[Object] Define Archive::isEmpty().
authorRui Ueyama <ruiu@google.com>
Fri, 30 Sep 2016 17:54:31 +0000 (17:54 +0000)
committerRui Ueyama <ruiu@google.com>
Fri, 30 Sep 2016 17:54:31 +0000 (17:54 +0000)
llvm-svn: 282884

llvm/include/llvm/Object/Archive.h
llvm/lib/Object/Archive.cpp

index 555900f..14195f8 100644 (file)
@@ -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; }
index 2870584..73761fa 100644 (file)
@@ -752,7 +752,7 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
 
 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>> Archive::findSym(StringRef name) const {
   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(); }