Skip to content

Commit be09694

Browse files
author
git apple-llvm automerger
committed
Merge commit '6399d4792d12' from llvm.org/main into next
2 parents b287511 + 6399d47 commit be09694

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,12 @@ class llvm::vfs::RedirectingFileSystemParser {
19091909
FullPath = FS->getOverlayFileDir();
19101910
assert(!FullPath.empty() &&
19111911
"External contents prefix directory must exist");
1912-
llvm::sys::path::append(FullPath, Value);
1912+
SmallString<256> AbsFullPath = Value;
1913+
if (FS->makeAbsolute(FullPath, AbsFullPath)) {
1914+
error(N, "failed to make 'external-contents' absolute");
1915+
return nullptr;
1916+
}
1917+
FullPath = AbsFullPath;
19131918
} else {
19141919
FullPath = Value;
19151920
}
@@ -2205,7 +2210,7 @@ RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer,
22052210
// FS->OverlayFileDir => /<absolute_path_to>/dummy.cache/vfs
22062211
//
22072212
SmallString<256> OverlayAbsDir = sys::path::parent_path(YAMLFilePath);
2208-
std::error_code EC = llvm::sys::fs::make_absolute(OverlayAbsDir);
2213+
std::error_code EC = FS->makeAbsolute(OverlayAbsDir);
22092214
assert(!EC && "Overlay dir final path must be absolute");
22102215
(void)EC;
22112216
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)