diff options
author | Kevin Enderby <enderby@apple.com> | 2016-06-27 21:39:39 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2016-06-27 21:39:39 +0000 |
commit | 054620884ae562e844ed0a411c0e5d36efed0da0 (patch) | |
tree | d9df4c86a7d00282d81ffae3fa3cc2824a044cda /tools/dsymutil/BinaryHolder.cpp | |
parent | aac123825eb12a40393679bf9ed9c3e3106f2640 (diff) |
Change all but the last ErrorOr<...> use for MachOUniversalBinary to Expected<...> to
allow a good error message to be produced.
I added the one test case that the object file tools could produce an error
message. The other two errors can’t be triggered if the input file is passed
through sys::fs::identify_magic(). But the malformedError("bad magic number")
does get triggered by the logic in llvm-dsymutil when dealing with a normal
Mach-O file. The other "File too small ..." error would take a logic error
currently to produce and is not tested for.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/dsymutil/BinaryHolder.cpp')
-rw-r--r-- | tools/dsymutil/BinaryHolder.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/dsymutil/BinaryHolder.cpp b/tools/dsymutil/BinaryHolder.cpp index 32d176645bf..8f33657dd55 100644 --- a/tools/dsymutil/BinaryHolder.cpp +++ b/tools/dsymutil/BinaryHolder.cpp @@ -73,7 +73,8 @@ BinaryHolder::GetMemoryBuffersForFile(StringRef Filename, auto ErrOrFat = object::MachOUniversalBinary::create( CurrentMemoryBuffer->getMemBufferRef()); - if (ErrOrFat.getError()) { + if (!ErrOrFat) { + consumeError(ErrOrFat.takeError()); // Not a fat binary must be a standard one. Return a one element vector. return std::vector<MemoryBufferRef>{CurrentMemoryBuffer->getMemBufferRef()}; } @@ -145,7 +146,8 @@ BinaryHolder::MapArchiveAndGetMemberBuffers(StringRef Filename, std::vector<MemoryBufferRef> ArchiveBuffers; auto ErrOrFat = object::MachOUniversalBinary::create( CurrentMemoryBuffer->getMemBufferRef()); - if (ErrOrFat.getError()) { + if (!ErrOrFat) { + consumeError(ErrOrFat.takeError()); // Not a fat binary must be a standard one. ArchiveBuffers.push_back(CurrentMemoryBuffer->getMemBufferRef()); } else { |