diff options
author | Chris Lattner <sabre@nondot.org> | 2010-11-23 04:45:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-11-23 04:45:28 +0000 |
commit | 6e6409989ff954a0a33339f64234e27987e3f603 (patch) | |
tree | c92f41638104302a95956d1a9865f27a8dbc539c /clang/lib/Basic/FileManager.cpp | |
parent | 7c434b69376b77d730eefb01f87519fe83497c41 (diff) | |
download | bcm5719-llvm-6e6409989ff954a0a33339f64234e27987e3f603.tar.gz bcm5719-llvm-6e6409989ff954a0a33339f64234e27987e3f603.zip |
stringref'ize API
llvm-svn: 119997
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index ff07c79cdf8..e5ec545f16a 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/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, " |