================
@@ -658,6 +658,109 @@ directory_iterator OverlayFileSystem::dir_begin(const
Twine &Dir,
void ProxyFileSystem::anchor() {}
+//===-----------------------------------------------------------------------===/
+// CaseInsensitiveFileSystem implementation
+//===-----------------------------------------------------------------------===/
+
+bool CaseInsensitiveFileSystem::exclude(StringRef Dir, uint32_t DirHash,
+ StringRef File) {
+ if (auto I = Maps.find(Dir, DirHash); I != Maps.end())
+ return !I->second.contains(File.lower());
+ // We have no map for this Dir, but see if we can exclude the file by
+ // excluding Dir from its parent.
+ StringRef Parent = llvm::sys::path::parent_path(Dir);
+ return (!Parent.empty() &&
+ exclude(Parent, Maps.hash(Parent), llvm::sys::path::filename(Dir)));
+}
+
+std::error_code CaseInsensitiveFileSystem::findCaseInsensitivePath(
+ StringRef Path, SmallVectorImpl<char> &FoundPath) {
+ StringRef FileName = llvm::sys::path::filename(Path);
+ StringRef Dir = llvm::sys::path::parent_path(Path);
+
+ if (Dir.empty())
+ Dir = ".";
+
+ auto DirHash = Maps.hash(Dir);
+ if (exclude(Dir, DirHash, FileName))
+ return llvm::errc::no_such_file_or_directory;
+
+ if (auto It = Maps.find(Dir, DirHash); It != Maps.end()) {
+ // If we have a map for this Dir and File wasn't excluded above, it must
+ // exist.
+ llvm::sys::path::append(FoundPath, Dir, It->second.at(FileName.lower()));
+ return {};
+ }
+
+ std::error_code EC;
+ directory_iterator I = FS->dir_begin(Dir, EC);
----------------
grqz wrote:
perhaps we could try the original path first, and index the directory only if
that fails
https://github.com/llvm/llvm-project/pull/178585
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits