diff options
-rw-r--r-- | include/clang/Basic/FileManager.h | 11 | ||||
-rw-r--r-- | lib/Basic/FileManager.cpp | 34 |
2 files changed, 17 insertions, 28 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index 7fd19d9296..3ee7d40c1e 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -225,15 +225,6 @@ public: 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 @@ public: /// 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 ff07c79cdf..e5ec545f16 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -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, " |