diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-07-06 17:43:13 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-07-06 17:43:13 +0000 |
commit | 7cba2a973f79861d810a8bf927fd78b352fb712f (patch) | |
tree | cb3f17e431dac861411e8d485448b9b7cfc1168f /tools/llvm-ar | |
parent | 04e43e64a9e179d707f16cd09ccad4c135d82d6e (diff) |
Update the MemoryBuffer API to use ErrorOr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212405 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-ar')
-rw-r--r-- | tools/llvm-ar/llvm-ar.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 4bd586be451..f638e55c5c7 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -770,10 +770,10 @@ static void performWriteOperation(ArchiveOperation Operation, const char *Filename = Member.getNew(); int FD = Member.getFD(); const sys::fs::file_status &Status = Member.getStatus(); - failIfError(MemoryBuffer::getOpenFile(FD, Filename, MemberBuffer, - Status.getSize(), false), - Filename); - + ErrorOr<std::unique_ptr<MemoryBuffer>> MemberBufferOrErr = + MemoryBuffer::getOpenFile(FD, Filename, Status.getSize(), false); + failIfError(MemberBufferOrErr.getError(), Filename); + MemberBuffer = std::move(MemberBufferOrErr.get()); } else { object::Archive::child_iterator OldMember = Member.getOld(); ErrorOr<std::unique_ptr<MemoryBuffer>> MemberBufferOrErr = @@ -934,8 +934,9 @@ int ar_main(char **argv) { static int performOperation(ArchiveOperation Operation) { // Create or open the archive object. - std::unique_ptr<MemoryBuffer> Buf; - std::error_code EC = MemoryBuffer::getFile(ArchiveName, Buf, -1, false); + ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = + MemoryBuffer::getFile(ArchiveName, -1, false); + std::error_code EC = Buf.getError(); if (EC && EC != errc::no_such_file_or_directory) { errs() << ToolName << ": error opening '" << ArchiveName << "': " << EC.message() << "!\n"; @@ -943,7 +944,7 @@ static int performOperation(ArchiveOperation Operation) { } if (!EC) { - object::Archive Archive(std::move(Buf), EC); + object::Archive Archive(std::move(Buf.get()), EC); if (EC) { errs() << ToolName << ": error loading '" << ArchiveName |