-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[clang] Use the VFS in ModuleDependencyCollector
#160944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-clang-modules Author: Jan Svoboda (jansvoboda11) ChangesThis PR starts using the correct VFS in Full diff: https://github.com/llvm/llvm-project/pull/160944.diff 2 Files Affected:
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index 3b363f948a3a8..dad39df59ad45 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -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;
@@ -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;
}
@@ -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.
diff --git a/llvm/include/llvm/Support/FileCollector.h b/llvm/include/llvm/Support/FileCollector.h
index 9cc6776b948ba..9fa11ba362241 100644
--- a/llvm/include/llvm/Support/FileCollector.h
+++ b/llvm/include/llvm/Support/FileCollector.h
@@ -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)) {}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/16765 Here is the relevant piece of the build log for the reference
|
This PR starts using the correct VFS in `ModuleDependencyCollector` instead of using the real FS directly. This matches compiler's behavior for other input files.
This PR starts using the correct VFS in `ModuleDependencyCollector` instead of using the real FS directly. This matches compiler's behavior for other input files.
This PR starts using the correct VFS in
ModuleDependencyCollector
instead of using the real FS directly. This matches compiler's behavior for other input files.