It caused PR10331. MSVCRT stat() cannot strip trailing '/'. (can '\')
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144884
91177308-0d34-0410-b5e6-
96231b3b80d8
///
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);