]> granicus.if.org Git - clang/commitdiff
Update for llvm API change.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 16 Jul 2013 19:44:23 +0000 (19:44 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 16 Jul 2013 19:44:23 +0000 (19:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186448 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ARCMigrate/FileRemapper.cpp
lib/Basic/FileSystemStatCache.cpp
lib/Driver/Compilation.cpp
lib/Driver/Driver.cpp
lib/Frontend/CompilerInstance.cpp
lib/Frontend/HeaderIncludeGen.cpp
lib/Rewrite/Frontend/FixItRewriter.cpp
lib/Tooling/Refactoring.cpp
tools/clang-format/ClangFormat.cpp
tools/driver/cc1as_main.cpp

index 159ab79b54377fa04cabfbba070376b60e750ad3..2eadd8ed0444aae63b69b37ba21a22c1d5a024ef 100644 (file)
@@ -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);
 
index 38c46299018ce8c1f399e21e515deabe2f3cb1c4..b71259e0d5c2b6456dab88ea82acf8f81c1cf04c 100644 (file)
@@ -12,8 +12,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Basic/FileSystemStatCache.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include <fcntl.h>
 
 // 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 {
index fedd16d0395d073f094004530a7ca85570951fe2..b1dd37d6cdf40fbc942555a2bbd3781d6d848359 100644 (file)
@@ -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;
index 1daabcb3fbaadb961f17bae5c2cda1d186af058f..41b6387437f1a338f9b3ae2377e93508928b56c3 100644 (file)
@@ -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;
index 6d6c805c1118597a8c9c48b86135f71a522995fd..44d9ec22ed04ebffeca691ef308e302fb91db12e 100644 (file)
@@ -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<llvm::raw_fd_ostream> 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
index 79920df20af75746106ec0752153d4e4c8cc27a6..4d8a05cfbc15b01c2af70a6d4262c5272559caca 100644 (file)
@@ -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;
index 166c607d020e0f5a8da78eb1e4bb84071176ac7f..8930c35d06c4395c6f700806200cf8631bce718e 100644 (file)
@@ -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)
index db68f42725a6a734d51a72cd8de162a69fdb221b..843e4bb192449bda6f43ec11101e86079949653f 100644 (file)
@@ -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);
index 2aa43259ed97242554306efd1cfb5ecec8578fc9..7f0fb501b40a40087f9f3accb1f7c4c22ecc2288 100644 (file)
@@ -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;
index 1f3c1d653ea98133a39e848212d87d2fdea97779..eec33d8f171d2ef21e0f09f4a5cd7e72b757a4ab 100644 (file)
@@ -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;