aboutsummaryrefslogtreecommitdiff
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
commitb8fc325f00a85a4101958e6df873cf7eb5a5f84d (patch)
tree31294b0901ea0fe26616bf62c6e9ae54568612bd
parent74d644abe56809d9bcea7311f37aa9063ab9e064 (diff)
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
-rw-r--r--lib/Frontend/HTMLDiagnostics.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/lib/Frontend/HTMLDiagnostics.cpp b/lib/Frontend/HTMLDiagnostics.cpp
index f8bca235bd..9d6f96c69f 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 @@ 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;