summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Object/Archive.h1
-rw-r--r--llvm/lib/Object/Archive.cpp5
2 files changed, 5 insertions, 1 deletions
diff --git a/llvm/include/llvm/Object/Archive.h b/llvm/include/llvm/Object/Archive.h
index 555900f98e3..14195f869a0 100644
--- a/llvm/include/llvm/Object/Archive.h
+++ b/llvm/include/llvm/Object/Archive.h
@@ -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; }
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 2870584cdcf..73761fa73db 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -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(); }
OpenPOWER on IntegriCloud