Fix handling of "clang c:foo"
On windows, c:foo is a valid file path, but stat fails on just "c:". This causes a problem for clang since its file manager wants to cache data about the parent directory. There are refactorings to be done in here, but this gives clang the correct behavior and testing first. Patch by Yunzhong Gao! llvm-svn: 187359
This commit is contained in:
@@ -292,6 +292,16 @@ const DirectoryEntry *FileManager::getDirectory(StringRef DirName,
|
||||
DirName != llvm::sys::path::root_path(DirName) &&
|
||||
llvm::sys::path::is_separator(DirName.back()))
|
||||
DirName = DirName.substr(0, DirName.size()-1);
|
||||
#ifdef LLVM_ON_WIN32
|
||||
// Fixing a problem with "clang C:test.c" on Windows.
|
||||
// Stat("C:") does not recognize "C:" as a valid directory
|
||||
std::string DirNameStr;
|
||||
if (DirName.size() > 1 && DirName.back() == ':' &&
|
||||
DirName.equals_lower(llvm::sys::path::root_name(DirName))) {
|
||||
DirNameStr = DirName.str() + '.';
|
||||
DirName = DirNameStr;
|
||||
}
|
||||
#endif
|
||||
|
||||
++NumDirLookups;
|
||||
llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt =
|
||||
|
||||
Reference in New Issue
Block a user