[LTO] Add error message on IO error in compileOptimizedToFile.

(No testcase because it's difficult to force an error here.)

Differential Revision: https://reviews.llvm.org/D26371



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286177 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Friedman 2016-11-07 23:43:07 +00:00
parent a5af556e61
commit a19c76d93d

View File

@ -257,6 +257,8 @@ bool LTOCodeGenerator::compileOptimizedToFile(const char **Name) {
bool genResult = compileOptimized(&objFile.os());
objFile.os().close();
if (objFile.os().has_error()) {
Twine ErrMsg = "could not write object file: " + Filename.str();
emitError(ErrMsg.str());
objFile.os().clear_error();
sys::fs::remove(Twine(Filename));
return false;