[cfe-commits] r127133 - in /cfe/trunk: include/clang/Basic/FileManager.h lib/Basic/FileManager.cpp lib/Frontend/CompilerInstance.cpp

Anders Carlsson andersca at mac.com
Sun Mar 6 14:25:35 PST 2011


Author: andersca
Date: Sun Mar  6 16:25:35 2011
New Revision: 127133

URL: http://llvm.org/viewvc/llvm-project?rev=127133&view=rev
Log:
Convert FileManager::FixupRelativePath over to using PathV2.

Modified:
    cfe/trunk/include/clang/Basic/FileManager.h
    cfe/trunk/lib/Basic/FileManager.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=127133&r1=127132&r2=127133&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Sun Mar  6 16:25:35 2011
@@ -197,10 +197,9 @@
   /// \brief If path is not absolute and FileSystemOptions set the working
   /// directory, the path is modified to be relative to the given
   /// working directory.
-  static void FixupRelativePath(llvm::sys::Path &path,
+  static void FixupRelativePath(llvm::SmallVectorImpl<char> &path,
                                 const FileSystemOptions &FSOpts);
 
-  
   /// \brief Produce an array mapping from the unique IDs assigned to each
   /// file to the corresponding FileEntry pointer.
   void GetUniqueIDMapping(

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=127133&r1=127132&r2=127133&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Sun Mar  6 16:25:35 2011
@@ -450,13 +450,15 @@
   return UFE;
 }
 
-void FileManager::FixupRelativePath(llvm::sys::Path &path,
+void FileManager::FixupRelativePath(llvm::SmallVectorImpl<char> &path,
                                     const FileSystemOptions &FSOpts) {
-  if (FSOpts.WorkingDir.empty() || llvm::sys::path::is_absolute(path.str()))
+  llvm::StringRef pathRef(path.data(), path.size());
+
+  if (FSOpts.WorkingDir.empty() || llvm::sys::path::is_absolute(pathRef))
     return;
 
   llvm::SmallString<128> NewPath(FSOpts.WorkingDir);
-  llvm::sys::path::append(NewPath, path.str());
+  llvm::sys::path::append(NewPath, pathRef);
   path = NewPath;
 }
 
@@ -484,10 +486,10 @@
       *ErrorStr = ec.message();
     return Result.take();
   }
-  
-  llvm::sys::Path FilePath(Entry->getName());
+
+  llvm::SmallString<128> FilePath(Entry->getName());
   FixupRelativePath(FilePath, FileSystemOpts);
-  ec = llvm::MemoryBuffer::getFile(FilePath.c_str(), Result, Entry->getSize());
+  ec = llvm::MemoryBuffer::getFile(FilePath.str(), Result, Entry->getSize());
   if (ec && ErrorStr)
     *ErrorStr = ec.message();
   return Result.take();
@@ -504,7 +506,7 @@
     return Result.take();
   }
 
-  llvm::sys::Path FilePath(Filename);
+  llvm::SmallString<128> FilePath(Filename);
   FixupRelativePath(FilePath, FileSystemOpts);
   ec = llvm::MemoryBuffer::getFile(FilePath.c_str(), Result);
   if (ec && ErrorStr)
@@ -525,7 +527,7 @@
     return FileSystemStatCache::get(Path, StatBuf, FileDescriptor,
                                     StatCache.get());
 
-  llvm::sys::Path FilePath(Path);
+  llvm::SmallString<128> FilePath(Path);
   FixupRelativePath(FilePath, FileSystemOpts);
 
   return FileSystemStatCache::get(FilePath.c_str(), StatBuf, FileDescriptor,

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=127133&r1=127132&r2=127133&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Sun Mar  6 16:25:35 2011
@@ -362,19 +362,22 @@
          it = OutputFiles.begin(), ie = OutputFiles.end(); it != ie; ++it) {
     delete it->OS;
     if (!it->TempFilename.empty()) {
-      llvm::sys::Path TempPath(it->TempFilename);
-      if (EraseFiles)
-        TempPath.eraseFromDisk();
-      else {
-        std::string Error;
-        llvm::sys::Path NewOutFile(it->Filename);
+      if (EraseFiles) {
+        bool existed;
+        llvm::sys::fs::remove(it->TempFilename, existed);
+      } else {
+        llvm::SmallString<128> NewOutFile(it->Filename);
+
         // If '-working-directory' was passed, the output filename should be
         // relative to that.
         FileManager::FixupRelativePath(NewOutFile, getFileSystemOpts());
-        if (TempPath.renamePathOnDisk(NewOutFile, &Error)) {
+        if (llvm::error_code ec = llvm::sys::fs::rename(it->TempFilename,
+                                                        NewOutFile.str())) {
           getDiagnostics().Report(diag::err_fe_unable_to_rename_temp)
-            << it->TempFilename << it->Filename << Error;
-          TempPath.eraseFromDisk();
+            << it->TempFilename << it->Filename << ec.message();
+
+          bool existed;
+          llvm::sys::fs::remove(it->TempFilename, existed);
         }
       }
     } else if (!it->Filename.empty() && EraseFiles)





More information about the cfe-commits mailing list