diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Basic/FileManager.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/contrib/llvm/tools/clang/lib/Basic/FileManager.cpp b/contrib/llvm/tools/clang/lib/Basic/FileManager.cpp index c1f715e..fd6d334 100644 --- a/contrib/llvm/tools/clang/lib/Basic/FileManager.cpp +++ b/contrib/llvm/tools/clang/lib/Basic/FileManager.cpp @@ -20,13 +20,12 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemStatCache.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Path.h" #include "llvm/Support/system_error.h" -#include "llvm/Config/config.h" +#include "llvm/Config/llvm-config.h" #include <map> #include <set> #include <string> @@ -106,8 +105,8 @@ public: FileEntry &getFile(const char *Name, const struct stat & /*StatBuf*/) { std::string FullPath(GetFullPath(Name)); - // LowercaseString because Windows filesystem is case insensitive. - FullPath = llvm::LowercaseString(FullPath); + // Lowercase string because Windows filesystem is case insensitive. + FullPath = StringRef(FullPath).lower(); return UniqueFiles.GetOrCreateValue(FullPath).getValue(); } @@ -266,6 +265,12 @@ void FileManager::addAncestorsAsVirtualDirs(StringRef Path) { /// const DirectoryEntry *FileManager::getDirectory(StringRef DirName, bool CacheFailure) { + // stat doesn't like trailing separators. + // At least, on Win32 MSVCRT, stat() cannot strip trailing '/'. + // (though it can strip '\\') + if (DirName.size() > 1 && llvm::sys::path::is_separator(DirName.back())) + DirName = DirName.substr(0, DirName.size()-1); + ++NumDirLookups; llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt = SeenDirEntries.GetOrCreateValue(DirName); @@ -472,14 +477,14 @@ void FileManager::FixupRelativePath(SmallVectorImpl<char> &path) const { || llvm::sys::path::is_absolute(pathRef)) return; - llvm::SmallString<128> NewPath(FileSystemOpts.WorkingDir); + SmallString<128> NewPath(FileSystemOpts.WorkingDir); llvm::sys::path::append(NewPath, pathRef); path = NewPath; } llvm::MemoryBuffer *FileManager:: getBufferForFile(const FileEntry *Entry, std::string *ErrorStr) { - llvm::OwningPtr<llvm::MemoryBuffer> Result; + OwningPtr<llvm::MemoryBuffer> Result; llvm::error_code ec; const char *Filename = Entry->getName(); @@ -504,7 +509,7 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr) { return Result.take(); } - llvm::SmallString<128> FilePath(Entry->getName()); + SmallString<128> FilePath(Entry->getName()); FixupRelativePath(FilePath); ec = llvm::MemoryBuffer::getFile(FilePath.str(), Result, Entry->getSize()); if (ec && ErrorStr) @@ -514,7 +519,7 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr) { llvm::MemoryBuffer *FileManager:: getBufferForFile(StringRef Filename, std::string *ErrorStr) { - llvm::OwningPtr<llvm::MemoryBuffer> Result; + OwningPtr<llvm::MemoryBuffer> Result; llvm::error_code ec; if (FileSystemOpts.WorkingDir.empty()) { ec = llvm::MemoryBuffer::getFile(Filename, Result); @@ -523,7 +528,7 @@ getBufferForFile(StringRef Filename, std::string *ErrorStr) { return Result.take(); } - llvm::SmallString<128> FilePath(Filename); + SmallString<128> FilePath(Filename); FixupRelativePath(FilePath); ec = llvm::MemoryBuffer::getFile(FilePath.c_str(), Result); if (ec && ErrorStr) @@ -544,7 +549,7 @@ bool FileManager::getStatValue(const char *Path, struct stat &StatBuf, return FileSystemStatCache::get(Path, StatBuf, FileDescriptor, StatCache.get()); - llvm::SmallString<128> FilePath(Path); + SmallString<128> FilePath(Path); FixupRelativePath(FilePath); return FileSystemStatCache::get(FilePath.c_str(), StatBuf, FileDescriptor, @@ -553,7 +558,7 @@ bool FileManager::getStatValue(const char *Path, struct stat &StatBuf, bool FileManager::getNoncachedStatValue(StringRef Path, struct stat &StatBuf) { - llvm::SmallString<128> FilePath(Path); + SmallString<128> FilePath(Path); FixupRelativePath(FilePath); return ::stat(FilePath.c_str(), &StatBuf) != 0; |