Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit eabc8ab

Browse files
committed
[Object] Define Archive::isEmpty().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282884 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 937044f commit eabc8ab

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

include/llvm/Object/Archive.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class Archive : public Binary {
239239
// check if a symbol is in the archive
240240
Expected<Optional<Child>> findSym(StringRef name) const;
241241

242+
bool isEmpty() const;
242243
bool hasSymbolTable() const;
243244
StringRef getSymbolTable() const { return SymbolTable; }
244245
StringRef getStringTable() const { return StringTable; }

lib/Object/Archive.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
752752

753753
Archive::child_iterator Archive::child_begin(Error &Err,
754754
bool SkipInternal) const {
755-
if (Data.getBufferSize() == 8) // empty archive.
755+
if (isEmpty())
756756
return child_end();
757757

758758
if (SkipInternal)
@@ -968,4 +968,7 @@ Expected<Optional<Archive::Child>> Archive::findSym(StringRef name) const {
968968
return Optional<Child>();
969969
}
970970

971+
// Returns true if archive file contains no member file.
972+
bool Archive::isEmpty() const { return Data.getBufferSize() == 8; }
973+
971974
bool Archive::hasSymbolTable() const { return !SymbolTable.empty(); }

0 commit comments

Comments
 (0)