diff options
Diffstat (limited to 'lib/Object/MachOUniversal.cpp')
-rw-r--r-- | lib/Object/MachOUniversal.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/Object/MachOUniversal.cpp b/lib/Object/MachOUniversal.cpp index 77aeb63..a01c838 100644 --- a/lib/Object/MachOUniversal.cpp +++ b/lib/Object/MachOUniversal.cpp @@ -12,9 +12,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Object/MachOUniversal.h" +#include "llvm/Object/Archive.h" #include "llvm/Object/MachO.h" #include "llvm/Object/ObjectFile.h" -#include "llvm/Object/Archive.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Host.h" #include "llvm/Support/MemoryBuffer.h" @@ -79,20 +79,16 @@ MachOUniversalBinary::ObjectForArch::getAsObjectFile() const { return object_error::parse_failed; } -std::error_code MachOUniversalBinary::ObjectForArch::getAsArchive( - std::unique_ptr<Archive> &Result) const { - if (Parent) { - StringRef ParentData = Parent->getData(); - StringRef ObjectData = ParentData.substr(Header.offset, Header.size); - StringRef ObjectName = Parent->getFileName(); - MemoryBufferRef ObjBuffer(ObjectData, ObjectName); - ErrorOr<std::unique_ptr<Archive>> Obj = Archive::create(ObjBuffer); - if (std::error_code EC = Obj.getError()) - return EC; - Result = std::move(Obj.get()); - return object_error::success; - } - return object_error::parse_failed; +ErrorOr<std::unique_ptr<Archive>> +MachOUniversalBinary::ObjectForArch::getAsArchive() const { + if (!Parent) + return 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 Archive::create(ObjBuffer); } void MachOUniversalBinary::anchor() { } |