From 14a5ca0498552a4ae3e9b99cb339dcffac6a5a12 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 30 Sep 2016 17:54:31 +0000 Subject: [PATCH] [Object] Define Archive::isEmpty(). llvm-svn: 282884 --- llvm/include/llvm/Object/Archive.h | 1 + llvm/lib/Object/Archive.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Object/Archive.h b/llvm/include/llvm/Object/Archive.h index 555900f..14195f8 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> 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 2870584..73761fa 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> Archive::findSym(StringRef name) const { return Optional(); } +// Returns true if archive file contains no member file. +bool Archive::isEmpty() const { return Data.getBufferSize() == 8; } + bool Archive::hasSymbolTable() const { return !SymbolTable.empty(); } -- 2.7.4