Remove use of std::ofstream in HTMLDiagnostics.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83560 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/HTMLDiagnostics.cpp b/lib/Frontend/HTMLDiagnostics.cpp
index f8bca23..9d6f96c 100644
--- a/lib/Frontend/HTMLDiagnostics.cpp
+++ b/lib/Frontend/HTMLDiagnostics.cpp
@@ -25,7 +25,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Path.h"
-#include <fstream>
+
 using namespace clang;
 
 //===----------------------------------------------------------------------===//
@@ -316,30 +316,27 @@
     return;
   }
 
-  // Create the stream to write out the HTML.
-  std::ofstream os;
+  // Create a path for the target HTML file.
+  llvm::sys::Path F(FilePrefix);
+  F.makeUnique(false, NULL);
 
-  {
-    // Create a path for the target HTML file.
-    llvm::sys::Path F(FilePrefix);
-    F.makeUnique(false, NULL);
+  // Rename the file with an HTML extension.
+  llvm::sys::Path H(F);
+  H.appendSuffix("html");
+  F.renamePathOnDisk(H, NULL);
 
-    // Rename the file with an HTML extension.
-    llvm::sys::Path H(F);
-    H.appendSuffix("html");
-    F.renamePathOnDisk(H, NULL);
+  std::string ErrorMsg;
+  llvm::raw_fd_ostream os(H.c_str(), ErrorMsg);
 
-    os.open(H.c_str());
-
-    if (!os) {
-      llvm::errs() << "warning: could not create file '" << F.str() << "'\n";
-      return;
-    }
-
-    if (FilesMade)
-      FilesMade->push_back(H.getLast());
+  if (!ErrorMsg.empty()) {
+    (llvm::errs() << "warning: could not create file '" << F.str() 
+                  << "'\n").flush();
+    return;
   }
 
+  if (FilesMade)
+    FilesMade->push_back(H.getLast());
+
   // Emit the HTML to disk.
   for (RewriteBuffer::iterator I = Buf->begin(), E = Buf->end(); I!=E; ++I)
       os << *I;