From: Rafael Espindola Date: Tue, 16 Jul 2013 19:44:23 +0000 (+0000) Subject: Update for llvm API change. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d965f95daa97097c8ddc5e1165ceae585a888719;p=clang Update for llvm API change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186448 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ARCMigrate/FileRemapper.cpp b/lib/ARCMigrate/FileRemapper.cpp index 159ab79b54..2eadd8ed04 100644 --- a/lib/ARCMigrate/FileRemapper.cpp +++ b/lib/ARCMigrate/FileRemapper.cpp @@ -126,7 +126,7 @@ bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) { std::string errMsg; std::string infoFile = outputPath; llvm::raw_fd_ostream infoOut(infoFile.c_str(), errMsg, - llvm::raw_fd_ostream::F_Binary); + llvm::sys::fs::F_Binary); if (!errMsg.empty()) return report(errMsg, Diag); @@ -189,7 +189,7 @@ bool FileRemapper::overwriteOriginal(DiagnosticsEngine &Diag, std::string errMsg; llvm::raw_fd_ostream Out(origFE->getName(), errMsg, - llvm::raw_fd_ostream::F_Binary); + llvm::sys::fs::F_Binary); if (!errMsg.empty()) return report(errMsg, Diag); diff --git a/lib/Basic/FileSystemStatCache.cpp b/lib/Basic/FileSystemStatCache.cpp index 38c4629901..b71259e0d5 100644 --- a/lib/Basic/FileSystemStatCache.cpp +++ b/lib/Basic/FileSystemStatCache.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "clang/Basic/FileSystemStatCache.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include // FIXME: This is terrible, we need this for ::close. #if !defined(_MSC_VER) && !defined(__MINGW32__) @@ -60,13 +60,9 @@ bool FileSystemStatCache::get(const char *Path, struct stat &StatBuf, // // Because of this, check to see if the file exists with 'open'. If the // open succeeds, use fstat to get the stat info. - int OpenFlags = O_RDONLY; -#ifdef O_BINARY - OpenFlags |= O_BINARY; // Open input file in binary mode on win32. -#endif - *FileDescriptor = ::open(Path, OpenFlags); - - if (*FileDescriptor == -1) { + llvm::error_code EC = llvm::sys::fs::openFileForRead(Path, *FileDescriptor); + + if (EC) { // If the open fails, our "stat" fails. R = CacheMissing; } else { diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index fedd16d039..b1dd37d6cd 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -274,9 +274,8 @@ int Compilation::ExecuteCommand(const Command &C, // output stream. if (getDriver().CCPrintOptions && getDriver().CCPrintOptionsFilename) { std::string Error; - OS = new llvm::raw_fd_ostream(getDriver().CCPrintOptionsFilename, - Error, - llvm::raw_fd_ostream::F_Append); + OS = new llvm::raw_fd_ostream(getDriver().CCPrintOptionsFilename, Error, + llvm::sys::fs::F_Append); if (!Error.empty()) { getDriver().Diag(clang::diag::err_drv_cc_print_options_failure) << Error; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 1daabcb3fb..41b6387437 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -467,9 +467,8 @@ void Driver::generateCompilationDiagnostics(Compilation &C, std::string Err; std::string Script = StringRef(*it).rsplit('.').first; Script += ".sh"; - llvm::raw_fd_ostream ScriptOS(Script.c_str(), Err, - llvm::raw_fd_ostream::F_Excl | - llvm::raw_fd_ostream::F_Binary); + llvm::raw_fd_ostream ScriptOS( + Script.c_str(), Err, llvm::sys::fs::F_Excl | llvm::sys::fs::F_Binary); if (!Err.empty()) { Diag(clang::diag::note_drv_command_failed_diag_msg) << "Error generating run script: " + Script + " " + Err; diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 6d6c805c11..44d9ec22ed 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -111,8 +111,8 @@ static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts, if (DiagOpts->DiagnosticLogFile != "-") { // Create the output stream. llvm::raw_fd_ostream *FileOS( - new llvm::raw_fd_ostream(DiagOpts->DiagnosticLogFile.c_str(), - ErrorInfo, llvm::raw_fd_ostream::F_Append)); + new llvm::raw_fd_ostream(DiagOpts->DiagnosticLogFile.c_str(), ErrorInfo, + llvm::sys::fs::F_Append)); if (!ErrorInfo.empty()) { Diags.Report(diag::warn_fe_cc_log_diagnostics_failure) << DiagOpts->DiagnosticLogFile << ErrorInfo; @@ -138,8 +138,8 @@ static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts, std::string ErrorInfo; OwningPtr OS; OS.reset(new llvm::raw_fd_ostream(OutputFile.str().c_str(), ErrorInfo, - llvm::raw_fd_ostream::F_Binary)); - + llvm::sys::fs::F_Binary)); + if (!ErrorInfo.empty()) { Diags.Report(diag::warn_fe_serialized_diag_failure) << OutputFile << ErrorInfo; @@ -567,9 +567,9 @@ CompilerInstance::createOutputFile(StringRef OutputPath, if (!OS) { OSFile = OutFile; - OS.reset( - new llvm::raw_fd_ostream(OSFile.c_str(), Error, - (Binary ? llvm::raw_fd_ostream::F_Binary : 0))); + OS.reset(new llvm::raw_fd_ostream( + OSFile.c_str(), Error, + (Binary ? llvm::sys::fs::F_Binary : llvm::sys::fs::F_None))); if (!Error.empty()) return 0; } @@ -1011,7 +1011,7 @@ static void checkConfigMacro(Preprocessor &PP, StringRef ConfigMacro, static void writeTimestampFile(StringRef TimestampFile) { std::string ErrorInfo; llvm::raw_fd_ostream Out(TimestampFile.str().c_str(), ErrorInfo, - llvm::raw_fd_ostream::F_Binary); + llvm::sys::fs::F_Binary); } /// \brief Prune the module cache of modules that haven't been accessed in diff --git a/lib/Frontend/HeaderIncludeGen.cpp b/lib/Frontend/HeaderIncludeGen.cpp index 79920df20a..4d8a05cfbc 100644 --- a/lib/Frontend/HeaderIncludeGen.cpp +++ b/lib/Frontend/HeaderIncludeGen.cpp @@ -54,7 +54,7 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders, if (!OutputPath.empty()) { std::string Error; llvm::raw_fd_ostream *OS = new llvm::raw_fd_ostream( - OutputPath.str().c_str(), Error, llvm::raw_fd_ostream::F_Append); + OutputPath.str().c_str(), Error, llvm::sys::fs::F_Append); if (!Error.empty()) { PP.getDiagnostics().Report( clang::diag::warn_fe_cc_print_header_failure) << Error; diff --git a/lib/Rewrite/Frontend/FixItRewriter.cpp b/lib/Rewrite/Frontend/FixItRewriter.cpp index 166c607d02..8930c35d06 100644 --- a/lib/Rewrite/Frontend/FixItRewriter.cpp +++ b/lib/Rewrite/Frontend/FixItRewriter.cpp @@ -92,7 +92,7 @@ bool FixItRewriter::WriteFixedFiles( OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true)); } else { OS.reset(new llvm::raw_fd_ostream(Filename.c_str(), Err, - llvm::raw_fd_ostream::F_Binary)); + llvm::sys::fs::F_Binary)); } if (!Err.empty()) { Diags.Report(clang::diag::err_fe_unable_to_open_output) diff --git a/lib/Tooling/Refactoring.cpp b/lib/Tooling/Refactoring.cpp index db68f42725..843e4bb192 100644 --- a/lib/Tooling/Refactoring.cpp +++ b/lib/Tooling/Refactoring.cpp @@ -220,8 +220,8 @@ int RefactoringTool::saveRewrittenFiles(Rewriter &Rewrite) { const FileEntry *Entry = Rewrite.getSourceMgr().getFileEntryForID(I->first); std::string ErrorInfo; - llvm::raw_fd_ostream FileStream( - Entry->getName(), ErrorInfo, llvm::raw_fd_ostream::F_Binary); + llvm::raw_fd_ostream FileStream(Entry->getName(), ErrorInfo, + llvm::sys::fs::F_Binary); if (!ErrorInfo.empty()) return 1; I->second.write(FileStream); diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp index 2aa43259ed..7f0fb501b4 100644 --- a/tools/clang-format/ClangFormat.cpp +++ b/tools/clang-format/ClangFormat.cpp @@ -221,7 +221,7 @@ static bool format(std::string FileName) { std::string ErrorInfo; llvm::raw_fd_ostream FileStream(FileName.c_str(), ErrorInfo, - llvm::raw_fd_ostream::F_Binary); + llvm::sys::fs::F_Binary); if (!ErrorInfo.empty()) { llvm::errs() << "Error while writing file: " << ErrorInfo << "\n"; return true; diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index 1f3c1d653e..eec33d8f17 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -252,8 +252,8 @@ static formatted_raw_ostream *GetOutputStream(AssemblerInvocation &Opts, std::string Error; raw_fd_ostream *Out = - new raw_fd_ostream(Opts.OutputPath.c_str(), Error, - (Binary ? raw_fd_ostream::F_Binary : 0)); + new raw_fd_ostream(Opts.OutputPath.c_str(), Error, + (Binary ? sys::fs::F_Binary : sys::fs::F_None)); if (!Error.empty()) { Diags.Report(diag::err_fe_unable_to_open_output) << Opts.OutputPath << Error;