Skip to content

Commit d94a632

Browse files
committed
[llvm] Use the VFS to make path absolute
1 parent 0fc972d commit d94a632

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer,
22042204
// FS->OverlayFileDir => /<absolute_path_to>/dummy.cache/vfs
22052205
//
22062206
SmallString<256> OverlayAbsDir = sys::path::parent_path(YAMLFilePath);
2207-
std::error_code EC = llvm::sys::fs::make_absolute(OverlayAbsDir);
2207+
std::error_code EC = ExternalFS->makeAbsolute(OverlayAbsDir);
22082208
assert(!EC && "Overlay dir final path must be absolute");
22092209
(void)EC;
22102210
FS->setOverlayFileDir(OverlayAbsDir);

llvm/unittests/Support/VirtualFileSystemTest.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,29 @@ TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
19411941
EXPECT_EQ(0, NumDiagnostics);
19421942
}
19431943

1944+
TEST_F(VFSFromYAMLTest, RelativeFileDirWithOverlayRelativeSetting) {
1945+
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
1946+
Lower->addDirectory("//root/foo/bar");
1947+
Lower->addRegularFile("//root/foo/bar/a");
1948+
Lower->setCurrentWorkingDirectory("//root/foo");
1949+
IntrusiveRefCntPtr<vfs::FileSystem> FS =
1950+
getFromYAMLString("{\n"
1951+
" 'case-sensitive': false,\n"
1952+
" 'overlay-relative': true,\n"
1953+
" 'roots': [\n"
1954+
" { 'name': '//root/foo/bar/b', 'type': 'file',\n"
1955+
" 'external-contents': 'a'\n"
1956+
" }\n"
1957+
" ]\n"
1958+
"}",
1959+
Lower, "bar/overlay");
1960+
1961+
ASSERT_NE(FS.get(), nullptr);
1962+
ErrorOr<vfs::Status> S = FS->status("//root/foo/bar/b");
1963+
ASSERT_FALSE(S.getError());
1964+
EXPECT_EQ("//root/foo/bar/a", S->getName());
1965+
}
1966+
19441967
TEST_F(VFSFromYAMLTest, RootRelativeToOverlayDirTest) {
19451968
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
19461969
Lower->addDirectory("//root/foo/bar");

0 commit comments

Comments
 (0)