From 1275ab1620b665eb06231ce3c4e5068c97d9b618 Mon Sep 17 00:00:00 2001 From: Adrian McCarthy Date: Thu, 7 Nov 2019 10:50:33 -0800 Subject: Improve VFS compatibility on Windows Keys in a virtual file system can be in Posix or Windows form or even a combination of the two. Many VFS tests (and a few Clang tests) were XFAILed on Windows because of false negatives when comparing paths. First, we default CaseSenstive to false on Windows. This allows drive letters like "D:" to match "d:". Windows filesystems are, by default, case insensitive, so this makes sense even beyond the drive letter. Second, we allow slashes to match backslashes when they're used as the root component of a path. Both of these changes are limited to RedirectingFileSystems, so there's little chance of affecting other path handling. These changes allow eleven of the VFS tests to pass on Windows as well as three other Clang tests, so they have re-enabled. This solves the majority of PR43272. Additional VFS test failures will be fixed in separate patches. Differential Revision: https://reviews.llvm.org/D69958 --- llvm/lib/Support/VirtualFileSystem.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Support/VirtualFileSystem.cpp') diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 40b748eab18..2d5c04baa57 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -1671,9 +1671,7 @@ RedirectingFileSystem::lookupPath(sys::path::const_iterator Start, // Forward the search to the next component in case this is an empty one. if (!FromName.empty()) { - if (CaseSensitive ? !Start->equals(FromName) - : !Start->equals_lower(FromName)) - // failure to match + if (!pathComponentMatches(*Start, FromName)) return make_error_code(llvm::errc::no_such_file_or_directory); ++Start; @@ -1695,6 +1693,7 @@ RedirectingFileSystem::lookupPath(sys::path::const_iterator Start, if (Result || Result.getError() != llvm::errc::no_such_file_or_directory) return Result; } + return make_error_code(llvm::errc::no_such_file_or_directory); } -- cgit v1.2.3