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 | 8525fe7155a34f9e3fad0ea1012542453e803153 (patch) | |
tree | 0e892b7149ebade5cee7d020dd1afca7fbc3a443 /llvm/tools/bugpoint/OptimizerDriver.cpp | |
parent | e3b3464d4e525c4ba1ff07329bfc7d0e2cc4f684 (diff) | |
download | bcm5719-llvm-8525fe7155a34f9e3fad0ea1012542453e803153.tar.gz bcm5719-llvm-8525fe7155a34f9e3fad0ea1012542453e803153.zip |
Convert tools to use tool_output_file, and introduce error
checking to places which previously lacked it.
llvm-svn: 111651
Diffstat (limited to 'llvm/tools/bugpoint/OptimizerDriver.cpp')
-rw-r--r-- | llvm/tools/bugpoint/OptimizerDriver.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp index ffd40997fc5..6d37761bcde 100644 --- a/llvm/tools/bugpoint/OptimizerDriver.cpp +++ b/llvm/tools/bugpoint/OptimizerDriver.cpp @@ -54,12 +54,18 @@ namespace { bool BugDriver::writeProgramToFile(const std::string &Filename, const Module *M) const { std::string ErrInfo; - raw_fd_ostream Out(Filename.c_str(), ErrInfo, - raw_fd_ostream::F_Binary); - if (!ErrInfo.empty()) return true; - - WriteBitcodeToFile(M, Out); - return false; + tool_output_file Out(Filename.c_str(), ErrInfo, + raw_fd_ostream::F_Binary); + if (ErrInfo.empty()) { + WriteBitcodeToFile(M, Out); + Out.close(); + if (!Out.has_error()) { + Out.keep(); + return false; + } + } + Out.clear_error(); + return true; } @@ -125,8 +131,8 @@ bool BugDriver::runPasses(Module *Program, } std::string ErrInfo; - raw_fd_ostream InFile(inputFilename.c_str(), ErrInfo, - raw_fd_ostream::F_Binary); + tool_output_file InFile(inputFilename.c_str(), ErrInfo, + raw_fd_ostream::F_Binary); if (!ErrInfo.empty()) { @@ -135,6 +141,12 @@ bool BugDriver::runPasses(Module *Program, } WriteBitcodeToFile(Program, InFile); InFile.close(); + if (InFile.has_error()) { + errs() << "Error writing bitcode file: " << inputFilename.str() << "\n"; + InFile.clear_error(); + return 1; + } + InFile.keep(); // setup the child process' arguments SmallVector<const char*, 8> Args; |