summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-10-08 17:44:41 +0000
committerTed Kremenek <kremenek@apple.com>2009-10-08 17:44:41 +0000
commit490b8c0f5baaa216cf0757c5c2ac6881a752062e (patch)
tree0d56416aa6e8818bb1c16c1ebc75692cc68093e2 /clang/lib/Frontend
parenta18ed9b11310391004867b7d0bc50551d2024efd (diff)
downloadbcm5719-llvm-490b8c0f5baaa216cf0757c5c2ac6881a752062e.tar.gz
bcm5719-llvm-490b8c0f5baaa216cf0757c5c2ac6881a752062e.zip
Remove use of std::ofstream in HTMLDiagnostics.cpp.
llvm-svn: 83560
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/HTMLDiagnostics.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/clang/lib/Frontend/HTMLDiagnostics.cpp b/clang/lib/Frontend/HTMLDiagnostics.cpp
index f8bca235bd5..9d6f96c69f5 100644
--- a/clang/lib/Frontend/HTMLDiagnostics.cpp
+++ b/clang/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 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
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);
-
- // Rename the file with an HTML extension.
- llvm::sys::Path H(F);
- H.appendSuffix("html");
- F.renamePathOnDisk(H, NULL);
+ // Create a path for the target HTML file.
+ llvm::sys::Path F(FilePrefix);
+ F.makeUnique(false, NULL);
- os.open(H.c_str());
+ // Rename the file with an HTML extension.
+ llvm::sys::Path H(F);
+ H.appendSuffix("html");
+ F.renamePathOnDisk(H, NULL);
- if (!os) {
- llvm::errs() << "warning: could not create file '" << F.str() << "'\n";
- return;
- }
+ std::string ErrorMsg;
+ llvm::raw_fd_ostream os(H.c_str(), ErrorMsg);
- 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;
OpenPOWER on IntegriCloud