1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Make sure an error is always handled.

llvm-svn: 317724
This commit is contained in:
Rafael Espindola 2017-11-08 21:15:21 +00:00
parent 1e5ce63ec5
commit 0b65b26f04
2 changed files with 15 additions and 3 deletions

View File

@ -0,0 +1,11 @@
# RUN: yaml2obj %s > %t
# RUN: not llvm-objcopy %t no/such/dir 2>&1 | FileCheck %s
# CHECK: failed to open no/such/dir
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64

View File

@ -116,10 +116,11 @@ void WriteObjectFile(const Object<ELFT> &Obj, StringRef File) {
Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
FileOutputBuffer::create(File, Obj.totalSize(),
FileOutputBuffer::F_executable);
if (BufferOrErr.takeError())
handleAllErrors(BufferOrErr.takeError(), [](const ErrorInfoBase &) {
error("failed to open " + OutputFilename);
else
Buffer = std::move(*BufferOrErr);
});
Buffer = std::move(*BufferOrErr);
Obj.write(*Buffer);
if (auto E = Buffer->commit())
reportError(File, errorToErrorCode(std::move(E)));