From 74e3eb49eaa394cb7decdbd7ecf40c2a632ab396 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 15 Jul 2009 17:32:18 +0000 Subject: [PATCH] Update for raw_fd_ostream API changes. raw_fd_ostream now has a Force flag to control whether the case of opening an existing file is considered an error. llvm-svn: 75802 --- clang/lib/AST/InheritViz.cpp | 2 +- clang/lib/Frontend/AnalysisConsumer.cpp | 3 ++- clang/lib/Frontend/FixItRewriter.cpp | 2 ++ clang/lib/Frontend/PlistDiagnostics.cpp | 2 +- clang/tools/clang-cc/clang-cc.cpp | 8 +++++--- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/clang/lib/AST/InheritViz.cpp b/clang/lib/AST/InheritViz.cpp index dd2fc14ab2a4..1188ba5860b4 100644 --- a/clang/lib/AST/InheritViz.cpp +++ b/clang/lib/AST/InheritViz.cpp @@ -149,7 +149,7 @@ void CXXRecordDecl::viewInheritance(ASTContext& Context) const { llvm::errs() << "Writing '" << Filename.c_str() << "'... "; - llvm::raw_fd_ostream O(Filename.c_str(), false, ErrMsg); + llvm::raw_fd_ostream O(Filename.c_str(), false, /*Force=*/true, ErrMsg); if (ErrMsg.empty()) { InheritanceHierarchyWriter Writer(Context, O); diff --git a/clang/lib/Frontend/AnalysisConsumer.cpp b/clang/lib/Frontend/AnalysisConsumer.cpp index 06af2d9a4e58..6433bdf7a49d 100644 --- a/clang/lib/Frontend/AnalysisConsumer.cpp +++ b/clang/lib/Frontend/AnalysisConsumer.cpp @@ -587,7 +587,8 @@ static ExplodedNodeImpl::Auditor* CreateUbiViz() { llvm::OwningPtr Stream; std::string filename = Filename.toString(); - Stream.reset(new llvm::raw_fd_ostream(filename.c_str(), false, ErrMsg)); + Stream.reset(new llvm::raw_fd_ostream(filename.c_str(), false, + /*Force=*/true, ErrMsg)); if (!ErrMsg.empty()) return 0; diff --git a/clang/lib/Frontend/FixItRewriter.cpp b/clang/lib/Frontend/FixItRewriter.cpp index 1ed89d75a9c9..cd7cee0f6847 100644 --- a/clang/lib/Frontend/FixItRewriter.cpp +++ b/clang/lib/Frontend/FixItRewriter.cpp @@ -47,6 +47,7 @@ bool FixItRewriter::WriteFixedFile(const std::string &InFileName, OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(), // set binary mode (critical for Windoze) true, + /*Force=*/true, Err); OwnedStream.reset(OutFile); } else if (InFileName == "-") { @@ -60,6 +61,7 @@ bool FixItRewriter::WriteFixedFile(const std::string &InFileName, OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), // set binary mode (critical for Windoze) true, + /*Force=*/true, Err); OwnedStream.reset(OutFile); } diff --git a/clang/lib/Frontend/PlistDiagnostics.cpp b/clang/lib/Frontend/PlistDiagnostics.cpp index 387ed45a9c71..f3a954358ec3 100644 --- a/clang/lib/Frontend/PlistDiagnostics.cpp +++ b/clang/lib/Frontend/PlistDiagnostics.cpp @@ -319,7 +319,7 @@ PlistDiagnostics::~PlistDiagnostics() { // Open the file. std::string ErrMsg; - llvm::raw_fd_ostream o(OutputFile.c_str(), false, ErrMsg); + llvm::raw_fd_ostream o(OutputFile.c_str(), false, /*Force=*/true, ErrMsg); if (!ErrMsg.empty()) { llvm::errs() << "warning: could not creat file: " << OutputFile << '\n'; return; diff --git a/clang/tools/clang-cc/clang-cc.cpp b/clang/tools/clang-cc/clang-cc.cpp index 18bd884f0d75..def46c2f7a1c 100644 --- a/clang/tools/clang-cc/clang-cc.cpp +++ b/clang/tools/clang-cc/clang-cc.cpp @@ -1682,7 +1682,7 @@ static void SetUpBuildDumpLog(unsigned argc, char **argv, std::string ErrorInfo; BuildLogFile = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(), false, - ErrorInfo); + /*Force=*/true, ErrorInfo); if (!ErrorInfo.empty()) { llvm::errs() << "error opening -dump-build-information file '" @@ -1735,7 +1735,8 @@ static llvm::raw_ostream* ComputeOutFile(const std::string& InFile, llvm::sys::Program::ChangeStdoutToBinary(); } else { std::string Error; - Ret = new llvm::raw_fd_ostream(OutFile.c_str(), Binary, Error); + Ret = new llvm::raw_fd_ostream(OutFile.c_str(), Binary, + /*Force=*/true, Error); if (!Error.empty()) { // FIXME: Don't fail this way. llvm::cerr << "ERROR: " << Error << "\n"; @@ -2276,7 +2277,8 @@ int main(int argc, char **argv) { } std::string ErrStr; DependencyOS = - new llvm::raw_fd_ostream(DependencyFile.c_str(), false, ErrStr); + new llvm::raw_fd_ostream(DependencyFile.c_str(), false, + /*Force=*/true, ErrStr); if (!ErrStr.empty()) { // FIXME: Use a proper diagnostic llvm::cerr << "unable to open dependency file: " + ErrStr;