diff options
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 342413d7da5..2599cee3ae5 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -450,13 +450,15 @@ FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size, return UFE; } -void FileManager::FixupRelativePath(llvm::sys::Path &path, +void FileManager::FixupRelativePath(llvm::SmallVectorImpl<char> &path, const FileSystemOptions &FSOpts) { - if (FSOpts.WorkingDir.empty() || llvm::sys::path::is_absolute(path.str())) + llvm::StringRef pathRef(path.data(), path.size()); + + if (FSOpts.WorkingDir.empty() || llvm::sys::path::is_absolute(pathRef)) return; llvm::SmallString<128> NewPath(FSOpts.WorkingDir); - llvm::sys::path::append(NewPath, path.str()); + llvm::sys::path::append(NewPath, pathRef); path = NewPath; } @@ -484,10 +486,10 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr) { *ErrorStr = ec.message(); return Result.take(); } - - llvm::sys::Path FilePath(Entry->getName()); + + llvm::SmallString<128> FilePath(Entry->getName()); FixupRelativePath(FilePath, FileSystemOpts); - ec = llvm::MemoryBuffer::getFile(FilePath.c_str(), Result, Entry->getSize()); + ec = llvm::MemoryBuffer::getFile(FilePath.str(), Result, Entry->getSize()); if (ec && ErrorStr) *ErrorStr = ec.message(); return Result.take(); @@ -504,7 +506,7 @@ getBufferForFile(llvm::StringRef Filename, std::string *ErrorStr) { return Result.take(); } - llvm::sys::Path FilePath(Filename); + llvm::SmallString<128> FilePath(Filename); FixupRelativePath(FilePath, FileSystemOpts); ec = llvm::MemoryBuffer::getFile(FilePath.c_str(), Result); if (ec && ErrorStr) @@ -525,7 +527,7 @@ bool FileManager::getStatValue(const char *Path, struct stat &StatBuf, return FileSystemStatCache::get(Path, StatBuf, FileDescriptor, StatCache.get()); - llvm::sys::Path FilePath(Path); + llvm::SmallString<128> FilePath(Path); FixupRelativePath(FilePath, FileSystemOpts); return FileSystemStatCache::get(FilePath.c_str(), StatBuf, FileDescriptor, |