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

Chris Lattner sabre at nondot.org
Mon Nov 22 20:45:28 PST 2010


Author: lattner
Date: Mon Nov 22 22:45:28 2010
New Revision: 119997

URL: http://llvm.org/viewvc/llvm-project?rev=119997&view=rev
Log:
stringref'ize API

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

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=119997&r1=119996&r2=119997&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Mon Nov 22 22:45:28 2010
@@ -225,15 +225,6 @@
                                        const FileSystemOptions &FileSystemOpts,
                                        std::string *ErrorStr = 0,
                                        int64_t FileSize = -1,
-                                       struct stat *FileInfo = 0) {
-    return getBufferForFile(Filename.begin(), Filename.end(), FileSystemOpts,
-                            ErrorStr, FileSize, FileInfo);
-  }
-  llvm::MemoryBuffer *getBufferForFile(const char *FilenameStart,
-                                       const char *FilenameEnd,
-                                       const FileSystemOptions &FileSystemOpts,
-                                       std::string *ErrorStr = 0,
-                                       int64_t FileSize = -1,
                                        struct stat *FileInfo = 0);
 
   /// \brief If path is not absolute and FileSystemOptions set the working
@@ -241,7 +232,7 @@
   /// working directory.
   static void FixupRelativePath(llvm::sys::Path &path,
                                 const FileSystemOptions &FSOpts);
-
+  
   void PrintStats() const;
 };
 

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=119997&r1=119996&r2=119997&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Mon Nov 22 22:45:28 2010
@@ -385,20 +385,27 @@
   return UFE;
 }
 
+void FileManager::FixupRelativePath(llvm::sys::Path &path,
+                                    const FileSystemOptions &FSOpts) {
+  if (FSOpts.WorkingDir.empty() || path.isAbsolute()) return;
+  
+  llvm::sys::Path NewPath(FSOpts.WorkingDir);
+  NewPath.appendComponent(path.str());
+  path = NewPath;
+}
+
+
+
 llvm::MemoryBuffer *FileManager::
-getBufferForFile(const char *FilenameStart, const char *FilenameEnd,
+getBufferForFile(llvm::StringRef Filename,
                  const FileSystemOptions &FileSystemOpts,
-                 std::string *ErrorStr,
-                 int64_t FileSize,
+                 std::string *ErrorStr, int64_t FileSize,
                  struct stat *FileInfo) {
-  assert(FilenameEnd[0] == 0);
   if (FileSystemOpts.WorkingDir.empty())
-    return llvm::MemoryBuffer::getFile(FilenameStart, ErrorStr,
-                                       FileSize, FileInfo);
-  llvm::sys::Path FilePath(llvm::StringRef(FilenameStart,
-                                           FilenameEnd-FilenameStart));
+    return llvm::MemoryBuffer::getFile(Filename, ErrorStr, FileSize, FileInfo);
+  
+  llvm::sys::Path FilePath(Filename);
   FixupRelativePath(FilePath, FileSystemOpts);
-
   return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr,
                                      FileSize, FileInfo);
 }
@@ -415,15 +422,6 @@
                          : stat(FilePath.c_str(), buf);
 }
 
-void FileManager::FixupRelativePath(llvm::sys::Path &path,
-                                    const FileSystemOptions &FSOpts) {
-  if (!FSOpts.WorkingDir.empty() && !path.isAbsolute()) {
-    llvm::sys::Path NewPath(FSOpts.WorkingDir);
-    NewPath.appendComponent(path.str());
-    path = NewPath;
-  }
-}
-
 void FileManager::PrintStats() const {
   llvm::errs() << "\n*** File Manager Stats:\n";
   llvm::errs() << UniqueFiles.size() << " files found, "





More information about the cfe-commits mailing list