stringref'ize API


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119997 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h
index 7fd19d9..3ee7d40 100644
--- a/include/clang/Basic/FileManager.h
+++ b/include/clang/Basic/FileManager.h
@@ -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;
 };
 
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index ff07c79..e5ec545 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -385,20 +385,27 @@
   return UFE;
 }
 
-llvm::MemoryBuffer *FileManager::
-getBufferForFile(const char *FilenameStart, const char *FilenameEnd,
-                 const FileSystemOptions &FileSystemOpts,
-                 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));
-  FixupRelativePath(FilePath, FileSystemOpts);
+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(llvm::StringRef Filename,
+                 const FileSystemOptions &FileSystemOpts,
+                 std::string *ErrorStr, int64_t FileSize,
+                 struct stat *FileInfo) {
+  if (FileSystemOpts.WorkingDir.empty())
+    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, "