diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-23 02:59:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-23 02:59:41 +0000 |
commit | 92bcc27ada5788c5f5057fa051b2600ec27c7e17 (patch) | |
tree | 28d91d27b87af4f2f0e4fc90e2bf69f61cbffb3c | |
parent | 70d488e6d0d3127aa53bee57ab9e746943ed47c3 (diff) |
adjust for raw_fd_ostream api change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79809 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/InheritViz.cpp | 3 | ||||
-rw-r--r-- | lib/Frontend/AnalysisConsumer.cpp | 4 | ||||
-rw-r--r-- | lib/Frontend/FixItRewriter.cpp | 16 | ||||
-rw-r--r-- | lib/Frontend/PlistDiagnostics.cpp | 3 | ||||
-rw-r--r-- | tools/clang-cc/clang-cc.cpp | 56 |
5 files changed, 38 insertions, 44 deletions
diff --git a/lib/AST/InheritViz.cpp b/lib/AST/InheritViz.cpp index 3e5dd1a53f..bf429674ff 100644 --- a/lib/AST/InheritViz.cpp +++ b/lib/AST/InheritViz.cpp @@ -149,7 +149,8 @@ void CXXRecordDecl::viewInheritance(ASTContext& Context) const { llvm::errs() << "Writing '" << Filename.c_str() << "'... "; - llvm::raw_fd_ostream O(Filename.c_str(), false, /*Force=*/true, ErrMsg); + llvm::raw_fd_ostream O(Filename.c_str(), ErrMsg, + raw_fd_ostream::F_Force); if (ErrMsg.empty()) { InheritanceHierarchyWriter Writer(Context, O); diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp index 2b718d56fc..9e6bf0b1a8 100644 --- a/lib/Frontend/AnalysisConsumer.cpp +++ b/lib/Frontend/AnalysisConsumer.cpp @@ -480,8 +480,8 @@ static ExplodedNode::Auditor* CreateUbiViz() { llvm::OwningPtr<llvm::raw_fd_ostream> Stream; std::string filename = Filename.toString(); - Stream.reset(new llvm::raw_fd_ostream(filename.c_str(), false, - /*Force=*/true, ErrMsg)); + Stream.reset(new llvm::raw_fd_ostream(filename.c_str(), ErrMsg, + llvm::raw_fd_ostream::F_Force)); if (!ErrMsg.empty()) return 0; diff --git a/lib/Frontend/FixItRewriter.cpp b/lib/Frontend/FixItRewriter.cpp index 399ad1c2cd..317693323f 100644 --- a/lib/Frontend/FixItRewriter.cpp +++ b/lib/Frontend/FixItRewriter.cpp @@ -44,11 +44,9 @@ bool FixItRewriter::WriteFixedFile(const std::string &InFileName, llvm::raw_ostream *OutFile; if (!OutFileName.empty()) { std::string Err; - OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(), - // set binary mode (critical for Windoze) - true, - /*Force=*/true, - Err); + OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(), Err, + llvm::raw_fd_ostream::F_Binary | + llvm::raw_fd_ostream::F_Force); OwnedStream.reset(OutFile); } else if (InFileName == "-") { OutFile = &llvm::outs(); @@ -58,11 +56,9 @@ bool FixItRewriter::WriteFixedFile(const std::string &InFileName, Path.eraseSuffix(); Path.appendSuffix("fixit." + Suffix); std::string Err; - OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), - // set binary mode (critical for Windoze) - true, - /*Force=*/true, - Err); + OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), Err, + llvm::raw_fd_ostream::F_Binary | + llvm::raw_fd_ostream::F_Force); OwnedStream.reset(OutFile); } diff --git a/lib/Frontend/PlistDiagnostics.cpp b/lib/Frontend/PlistDiagnostics.cpp index 827b9681d9..0b92ece52d 100644 --- a/lib/Frontend/PlistDiagnostics.cpp +++ b/lib/Frontend/PlistDiagnostics.cpp @@ -337,7 +337,8 @@ PlistDiagnostics::~PlistDiagnostics() { // Open the file. std::string ErrMsg; - llvm::raw_fd_ostream o(OutputFile.c_str(), false, /*Force=*/true, ErrMsg); + llvm::raw_fd_ostream o(OutputFile.c_str(), ErrMsg, + llvm::raw_fd_ostream::F_Force); if (!ErrMsg.empty()) { llvm::errs() << "warning: could not creat file: " << OutputFile << '\n'; return; diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index 847826cc77..e388231cb6 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -63,7 +63,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PluginLoader.h" #include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/Streams.h" #include "llvm/Support/Timer.h" #include "llvm/System/Host.h" #include "llvm/System/Path.h" @@ -1701,8 +1700,9 @@ static void SetUpBuildDumpLog(unsigned argc, char **argv, llvm::OwningPtr<DiagnosticClient> &DiagClient) { std::string ErrorInfo; - BuildLogFile = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(), false, - /*Force=*/true, ErrorInfo); + BuildLogFile = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(), + ErrorInfo, + llvm::raw_fd_ostream::F_Force); if (!ErrorInfo.empty()) { llvm::errs() << "error opening -dump-build-information file '" @@ -1729,41 +1729,37 @@ static void SetUpBuildDumpLog(unsigned argc, char **argv, // Main driver //===----------------------------------------------------------------------===// -static llvm::raw_ostream* ComputeOutFile(const std::string& InFile, - const char* Extension, +static llvm::raw_ostream *ComputeOutFile(const std::string &InFile, + const char *Extension, bool Binary, llvm::sys::Path& OutPath) { - llvm::raw_ostream* Ret; - bool UseStdout = false; + llvm::raw_ostream *Ret; std::string OutFile; - if (OutputFile == "-" || (OutputFile.empty() && InFile == "-")) { - UseStdout = true; - } else if (!OutputFile.empty()) { + if (!OutputFile.empty()) OutFile = OutputFile; + else if (InFile == "-") { + OutFile = "-"; } else if (Extension) { llvm::sys::Path Path(InFile); Path.eraseSuffix(); Path.appendSuffix(Extension); OutFile = Path.toString(); } else { - UseStdout = true; + OutFile = "-"; } - if (UseStdout) { - Ret = new llvm::raw_stdout_ostream(); - if (Binary) - llvm::sys::Program::ChangeStdoutToBinary(); - } else { - std::string 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"; - ::exit(1); - } - OutPath = OutFile; + std::string Error; + Ret = new llvm::raw_fd_ostream(OutFile.c_str(), Error, + (Binary ? llvm::raw_fd_ostream::F_Binary : 0) | + llvm::raw_fd_ostream::F_Force); + if (!Error.empty()) { + // FIXME: Don't fail this way. + llvm::errs() << "ERROR: " << Error << "\n"; + ::exit(1); } + + if (OutFile != "-") + OutPath = OutFile; return Ret; } @@ -1915,7 +1911,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, if (OutputFile.empty() || OutputFile == "-") { // FIXME: Don't fail this way. // FIXME: Verify that we can actually seek in the given file. - llvm::cerr << "ERROR: PTH requires an seekable file for output!\n"; + llvm::errs() << "ERROR: PTH requires an seekable file for output!\n"; ::exit(1); } OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); @@ -2307,17 +2303,17 @@ int main(int argc, char **argv) { llvm::raw_ostream *DependencyOS; if (DependencyTargets.empty()) { // FIXME: Use a proper diagnostic - llvm::cerr << "-dependency-file requires at least one -MT option\n"; + llvm::errs() << "-dependency-file requires at least one -MT option\n"; HadErrors = true; continue; } std::string ErrStr; DependencyOS = - new llvm::raw_fd_ostream(DependencyFile.c_str(), false, - /*Force=*/true, ErrStr); + new llvm::raw_fd_ostream(DependencyFile.c_str(), ErrStr, + llvm::raw_fd_ostream::F_Force); if (!ErrStr.empty()) { // FIXME: Use a proper diagnostic - llvm::cerr << "unable to open dependency file: " + ErrStr; + llvm::errs() << "unable to open dependency file: " + ErrStr; HadErrors = true; continue; } |