-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[llvm] Use the underlying VFS when constructing RedirectingFileSystem
#160942
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
Merged
jansvoboda11
merged 3 commits into
llvm:main
from
jansvoboda11:overlay-vfs-use-underlying-vfs
Sep 29, 2025
Merged
[llvm] Use the underlying VFS when constructing RedirectingFileSystem
#160942
jansvoboda11
merged 3 commits into
llvm:main
from
jansvoboda11:overlay-vfs-use-underlying-vfs
Sep 29, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-llvm-support Author: Jan Svoboda (jansvoboda11) ChangesWhen the root node of the Full diff: https://github.com/llvm/llvm-project/pull/160942.diff 2 Files Affected:
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index cf784595c2f1c..7ff62d43ba205 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -1973,7 +1973,7 @@ class llvm::vfs::RedirectingFileSystemParser {
EC = FS->makeAbsolute(FullPath, Name);
Name = canonicalize(Name);
} else {
- EC = sys::fs::make_absolute(Name);
+ EC = FS->makeAbsolute(Name);
}
if (EC) {
assert(NameValueNode && "Name presence should be checked earlier");
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index 6228de8aa897a..e6c75a60a6a80 100644
--- a/llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1941,7 +1941,7 @@ TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
EXPECT_EQ(0, NumDiagnostics);
}
-TEST_F(VFSFromYAMLTest, RootRelativeTest) {
+TEST_F(VFSFromYAMLTest, RootRelativeToOverlayDirTest) {
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
Lower->addDirectory("//root/foo/bar");
Lower->addRegularFile("//root/foo/bar/a");
@@ -2004,6 +2004,35 @@ TEST_F(VFSFromYAMLTest, RootRelativeTest) {
#endif
}
+TEST_F(VFSFromYAMLTest, RootRelativeToCWDTest) {
+ auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
+ Lower->addDirectory("//root/foo/bar");
+ Lower->addRegularFile("//root/foo/bar/a");
+ Lower->addDirectory("//root/foo/bar/cwd");
+ Lower->addRegularFile("//root/foo/bar/cwd/a");
+ Lower->setCurrentWorkingDirectory("//root/foo/bar/cwd");
+ IntrusiveRefCntPtr<vfs::FileSystem> FS =
+ getFromYAMLString("{\n"
+ " 'case-sensitive': false,\n"
+ " 'root-relative': 'cwd',\n"
+ " 'roots': [\n"
+ " { 'name': 'b', 'type': 'file',\n"
+ " 'external-contents': '//root/foo/bar/a'\n"
+ " }\n"
+ " ]\n"
+ "}",
+ Lower, "//root/foo/bar/overlay");
+
+ ASSERT_NE(FS.get(), nullptr);
+
+ ErrorOr<vfs::Status> S1 = FS->status("//root/foo/bar/b");
+ ASSERT_TRUE(S1.getError());
+
+ ErrorOr<vfs::Status> S2 = FS->status("//root/foo/bar/cwd/b");
+ ASSERT_FALSE(S2.getError());
+ EXPECT_EQ("//root/foo/bar/a", S2->getName());
+}
+
TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
auto BaseFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
BaseFS->addFile("//root/foo/realname", 0,
|
benlangmuir
approved these changes
Sep 26, 2025
mahesh-attarde
pushed a commit
to mahesh-attarde/llvm-project
that referenced
this pull request
Oct 3, 2025
…m` (llvm#160942) When the root node of the `RedirectingFileSystem` is to be resolved to the current working directory, we previously consulted the real FS instead of the provided underlying VFS. This PR fixes that issue.
jansvoboda11
added a commit
to swiftlang/llvm-project
that referenced
this pull request
Oct 18, 2025
…m` (llvm#160942) When the root node of the `RedirectingFileSystem` is to be resolved to the current working directory, we previously consulted the real FS instead of the provided underlying VFS. This PR fixes that issue.
jansvoboda11
added a commit
to swiftlang/llvm-project
that referenced
this pull request
Oct 23, 2025
…m` (llvm#160942) When the root node of the `RedirectingFileSystem` is to be resolved to the current working directory, we previously consulted the real FS instead of the provided underlying VFS. This PR fixes that issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the root node of the
RedirectingFileSystemis to be resolved to the current working directory, we previously consulted the real FS instead of the provided underlying VFS. This PR fixes that issue.