diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-20 16:59:15 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-20 16:59:15 +0000 |
commit | f29140106f74d15ba357aa0a7f109adc939c3104 (patch) | |
tree | 770be753408ca9fefa28ec3a13ef8f45e00cba3a /tools/lto | |
parent | e7b67d0e94df497791207618194e1db545ac3721 (diff) |
Convert tools to use tool_output_file, and introduce error
checking to places which previously lacked it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111651 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/LTOCodeGenerator.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index b69bcc35a7..67b1765787 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -155,8 +155,8 @@ bool LTOCodeGenerator::writeMergedModules(const char *path, // create output file std::string ErrInfo; - raw_fd_ostream Out(path, ErrInfo, - raw_fd_ostream::F_Binary); + tool_output_file Out(path, ErrInfo, + raw_fd_ostream::F_Binary); if (!ErrInfo.empty()) { errMsg = "could not open bitcode file for writing: "; errMsg += path; @@ -174,6 +174,7 @@ bool LTOCodeGenerator::writeMergedModules(const char *path, return true; } + Out.keep(); return false; } @@ -189,11 +190,17 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) // generate assembly code bool genResult = false; { - raw_fd_ostream asmFD(uniqueAsmPath.c_str(), errMsg); - formatted_raw_ostream asmFile(asmFD); + tool_output_file asmFD(uniqueAsmPath.c_str(), errMsg); + formatted_tool_output_file asmFile(asmFD); if (!errMsg.empty()) return NULL; genResult = this->generateAssemblyCode(asmFile, errMsg); + asmFile.close(); + if (asmFile.has_error()) { + asmFile.clear_error(); + return NULL; + } + asmFile.keep(); } if ( genResult ) { uniqueAsmPath.eraseFromDisk(); |