]> granicus.if.org Git - clang/commitdiff
stringref'ize API
authorChris Lattner <sabre@nondot.org>
Tue, 23 Nov 2010 04:45:28 +0000 (04:45 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 23 Nov 2010 04:45:28 +0000 (04:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119997 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/FileManager.h
lib/Basic/FileManager.cpp

index 7fd19d929690173933d3b3f770a42393a98351e9..3ee7d40c1e256f9c6c4bee23045dd1c5f4467648 100644 (file)
@@ -222,15 +222,6 @@ public:
                             ErrorStr, Entry->getSize(), FileInfo);
   }
   llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename,
-                                       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,
@@ -241,7 +232,7 @@ public:
   /// working directory.
   static void FixupRelativePath(llvm::sys::Path &path,
                                 const FileSystemOptions &FSOpts);
-
+  
   void PrintStats() const;
 };
 
index ff07c79cdf8d81507d14c5453519031fcdb437cd..e5ec545f16a9532151a2e6d145dd5b77656f8de4 100644 (file)
@@ -385,20 +385,27 @@ FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size,
   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 @@ int FileManager::stat_cached(const char *path, struct stat *buf,
                          : 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, "