diff options
author | Kevin Enderby <enderby@apple.com> | 2015-10-13 20:48:04 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2015-10-13 20:48:04 +0000 |
commit | 1c1add44b6114270214c117c2991360f3b8a726a (patch) | |
tree | 61766aee0351924dc443dc343ce861f3a978976d /llvm/lib/Object/Archive.cpp | |
parent | a742b84e5d7f5b4d3da098c03ffd893e711cc0c1 (diff) | |
download | bcm5719-llvm-1c1add44b6114270214c117c2991360f3b8a726a.tar.gz bcm5719-llvm-1c1add44b6114270214c117c2991360f3b8a726a.zip |
Tweak to r250117 and change to use ErrorOr and drop isSizeValid for
ArchiveMemberHeader, suggestion by Rafael EspĂndola.
Also The clang-x86-win2008-selfhost bot still does not like the
malformed-machos 00000031.a test, so removing it for now. All
the other bots are fine with it however.
llvm-svn: 250222
Diffstat (limited to 'llvm/lib/Object/Archive.cpp')
-rw-r--r-- | llvm/lib/Object/Archive.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp index b0e0881c789..667732baa27 100644 --- a/llvm/lib/Object/Archive.cpp +++ b/llvm/lib/Object/Archive.cpp @@ -43,20 +43,13 @@ StringRef ArchiveMemberHeader::getName() const { return llvm::StringRef(Name, end); } -uint32_t ArchiveMemberHeader::getSize() const { +ErrorOr<uint32_t> ArchiveMemberHeader::getSize() const { uint32_t Ret; if (llvm::StringRef(Size, sizeof(Size)).rtrim(" ").getAsInteger(10, Ret)) - llvm_unreachable("Size is not a decimal number."); + return object_error::parse_failed; return Ret; } -bool ArchiveMemberHeader::isSizeValid() const { - uint32_t Ret; - if (llvm::StringRef(Size, sizeof(Size)).rtrim(" ").getAsInteger(10, Ret)) - return false; - return true; -} - sys::fs::perms ArchiveMemberHeader::getAccessMode() const { unsigned Ret; if (StringRef(AccessMode, sizeof(AccessMode)).rtrim(" ").getAsInteger(8, Ret)) @@ -96,11 +89,6 @@ Archive::Child::Child(const Archive *Parent, const char *Start) uint64_t Size = sizeof(ArchiveMemberHeader); Data = StringRef(Start, Size); - // Check to make sure the size is valid. - const ArchiveMemberHeader *Header = - reinterpret_cast<const ArchiveMemberHeader *>(Data.data()); - if (!Header->isSizeValid()) - return; if (!isThinMember()) { Size += getRawSize(); Data = StringRef(Start, Size); @@ -119,13 +107,20 @@ Archive::Child::Child(const Archive *Parent, const char *Start) } uint64_t Archive::Child::getSize() const { - if (Parent->IsThin) - return getHeader()->getSize(); + if (Parent->IsThin) { + ErrorOr<uint32_t> Size = getHeader()->getSize(); + if (Size.getError()) + return 0; + return Size.get(); + } return Data.size() - StartOfFile; } uint64_t Archive::Child::getRawSize() const { - return getHeader()->getSize(); + ErrorOr<uint32_t> Size = getHeader()->getSize(); + if (Size.getError()) + return 0; + return Size.get(); } bool Archive::Child::isThinMember() const { |