Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions clang/lib/Frontend/ModuleDependencyCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ void ModuleDependencyCollector::attachToPreprocessor(Preprocessor &PP) {
std::make_unique<ModuleDependencyMMCallbacks>(*this));
}

static bool isCaseSensitivePath(StringRef Path) {
static bool isCaseSensitivePath(llvm::vfs::FileSystem &VFS, StringRef Path) {
SmallString<256> TmpDest = Path, UpperDest, RealDest;
// Remove component traversals, links, etc.
if (llvm::sys::fs::real_path(Path, TmpDest))
if (VFS.getRealPath(Path, TmpDest))
return true; // Current default value in vfs.yaml
Path = TmpDest;

Expand All @@ -104,7 +104,7 @@ static bool isCaseSensitivePath(StringRef Path) {
// already expects when sensitivity isn't setup.
for (auto &C : Path)
UpperDest.push_back(toUppercase(C));
if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path == RealDest)
if (!VFS.getRealPath(UpperDest, RealDest) && Path == RealDest)
return false;
return true;
}
Expand All @@ -121,7 +121,8 @@ void ModuleDependencyCollector::writeFileMap() {

// Explicitly set case sensitivity for the YAML writer. For that, find out
// the sensitivity at the path where the headers all collected to.
VFSWriter.setCaseSensitivity(isCaseSensitivePath(VFSDir));
VFSWriter.setCaseSensitivity(
isCaseSensitivePath(Canonicalizer.getFileSystem(), VFSDir));

// Do not rely on real path names when executing the crash reproducer scripts
// since we only want to actually use the files we have on the VFS cache.
Expand Down Expand Up @@ -153,7 +154,7 @@ std::error_code ModuleDependencyCollector::copyToRoot(StringRef Src,
} else {
// When collecting entries from input vfsoverlays, copy the external
// contents into the cache but still map from the source.
if (!fs::exists(Dst))
if (!Canonicalizer.getFileSystem().exists(Dst))
return std::error_code();
path::append(CacheDst, Dst);
Paths.CopyFrom = Dst;
Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/Support/FileCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class LLVM_ABI FileCollector : public FileCollectorBase {
/// Canonicalize a pair of virtual and real paths.
LLVM_ABI PathStorage canonicalize(StringRef SrcPath);

/// Return the underlying file system.
vfs::FileSystem &getFileSystem() const { return *VFS; };

explicit PathCanonicalizer(IntrusiveRefCntPtr<vfs::FileSystem> VFS)
: VFS(std::move(VFS)) {}

Expand Down