When handling raw_ostream errors manually, use clear_error() so that
authorDan Gohman <gohman@apple.com>
Thu, 27 May 2010 20:19:47 +0000 (20:19 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 27 May 2010 20:19:47 +0000 (20:19 +0000)
raw_ostream doesn't try to do its own error handling.

Also, close the raw_ostream before checking for errors so that any
errors that occur during closing are caught by the manual check.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104882 91177308-0d34-0410-b5e6-96231b3b80d8

tools/lto/LTOCodeGenerator.cpp

index 59e8405e7ec2b15e01400a7cf1b0f597795923e4..c4d7e8abe72ca13a38a50e75582d58a2ba0f5b43 100644 (file)
@@ -152,10 +152,12 @@ bool LTOCodeGenerator::writeMergedModules(const char *path,
     
   // write bitcode to it
   WriteBitcodeToFile(_linker.getModule(), Out);
-  
+  Out.close();
+
   if (Out.has_error()) {
     errMsg = "could not write bitcode file: ";
     errMsg += path;
+    Out.clear_error();
     return true;
   }