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
This commit is contained in:
Dan Gohman
2010-08-20 16:59:15 +00:00
parent e7b67d0e94
commit f29140106f
6 changed files with 68 additions and 24 deletions

View File

@ -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();