diff options
author | Kevin Enderby <enderby@apple.com> | 2016-05-31 20:35:34 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2016-05-31 20:35:34 +0000 |
commit | 9acb109930dd2584438f0d985a964ac3924faf0e (patch) | |
tree | e89a92630b53f358afe577b135a911fb57f315bd /llvm/lib/Object/MachOUniversal.cpp | |
parent | 87ea3b05b9d1cc1f7512b53b191f265a93b1ec01 (diff) | |
download | bcm5719-llvm-9acb109930dd2584438f0d985a964ac3924faf0e.tar.gz bcm5719-llvm-9acb109930dd2584438f0d985a964ac3924faf0e.zip |
Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error
when the object is from a slice of a Mach-O Universal Binary use something like
"foo.o (for architecture i386)" as part of the error message when expected.
Also fixed places in these tools that were ignoring object file errors from
MachOUniversalBinary::getAsObjectFile() when the code moved on to see if
the slice was an archive.
To do this MachOUniversalBinary::getAsObjectFile() and
MachOUniversalBinary::getObjectForArch() were changed from returning
ErrorOr<...> to Expected<...> then that was threaded up to its users.
Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now the use of
errorToErrorCode() is still used in two places yet to be fully converted.
llvm-svn: 271332
Diffstat (limited to 'llvm/lib/Object/MachOUniversal.cpp')
-rw-r--r-- | llvm/lib/Object/MachOUniversal.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Object/MachOUniversal.cpp b/llvm/lib/Object/MachOUniversal.cpp index df25f7416b3..2d0ddd93f0b 100644 --- a/llvm/lib/Object/MachOUniversal.cpp +++ b/llvm/lib/Object/MachOUniversal.cpp @@ -67,16 +67,16 @@ MachOUniversalBinary::ObjectForArch::ObjectForArch( } } -ErrorOr<std::unique_ptr<MachOObjectFile>> +Expected<std::unique_ptr<MachOObjectFile>> MachOUniversalBinary::ObjectForArch::getAsObjectFile() const { if (!Parent) - return object_error::parse_failed; + return errorCodeToError(object_error::parse_failed); StringRef ParentData = Parent->getData(); StringRef ObjectData = ParentData.substr(Header.offset, Header.size); StringRef ObjectName = Parent->getFileName(); MemoryBufferRef ObjBuffer(ObjectData, ObjectName); - return expectedToErrorOr(ObjectFile::createMachOObjectFile(ObjBuffer)); + return ObjectFile::createMachOObjectFile(ObjBuffer); } ErrorOr<std::unique_ptr<Archive>> @@ -123,14 +123,14 @@ MachOUniversalBinary::MachOUniversalBinary(MemoryBufferRef Source, ec = std::error_code(); } -ErrorOr<std::unique_ptr<MachOObjectFile>> +Expected<std::unique_ptr<MachOObjectFile>> MachOUniversalBinary::getObjectForArch(StringRef ArchName) const { if (Triple(ArchName).getArch() == Triple::ArchType::UnknownArch) - return object_error::arch_not_found; + return errorCodeToError(object_error::arch_not_found); for (object_iterator I = begin_objects(), E = end_objects(); I != E; ++I) { if (I->getArchTypeName() == ArchName) return I->getAsObjectFile(); } - return object_error::arch_not_found; + return errorCodeToError(object_error::arch_not_found); } |