[cfe-commits] r83560 - /cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp
Ted Kremenek
kremenek at apple.com
Thu Oct 8 10:44:41 PDT 2009
Author: kremenek
Date: Thu Oct 8 12:44:41 2009
New Revision: 83560
URL: http://llvm.org/viewvc/llvm-project?rev=83560&view=rev
Log:
Remove use of std::ofstream in HTMLDiagnostics.cpp.
Modified:
cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp
Modified: cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp?rev=83560&r1=83559&r2=83560&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp Thu Oct 8 12:44:41 2009
@@ -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);
-
- // Rename the file with an HTML extension.
- llvm::sys::Path H(F);
- H.appendSuffix("html");
- F.renamePathOnDisk(H, NULL);
-
- 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());
+ // 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);
+
+ std::string ErrorMsg;
+ llvm::raw_fd_ostream os(H.c_str(), ErrorMsg);
+
+ 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;
More information about the cfe-commits
mailing list