diff options
| author | Jan Svoboda <jan_svoboda@apple.com> | 2025-09-30 10:36:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-30 10:36:21 -0700 |
| commit | 6399d4792d127520ed7281229755d18ff54da297 (patch) | |
| tree | 420eef1893fe476839220f581e998d23952816d7 /llvm/lib/Support/VirtualFileSystem.cpp | |
| parent | 10a9ec88501fa260002245fcd4d0c6f6ccae4e17 (diff) | |
| download | llvm-6399d4792d127520ed7281229755d18ff54da297.zip llvm-6399d4792d127520ed7281229755d18ff54da297.tar.gz llvm-6399d4792d127520ed7281229755d18ff54da297.tar.bz2 | |
[llvm] Use the VFS to make path absolute (#161271)
For the redirecting VFS, the `'overlay-relative'` option controls
whether external paths should be appended to the overlay directory. This
didn't always work as expected: when the overlay file path itself was
relative, its absolute path was decided by the real FS, not the
underlying VFS, and the resulting external path didn't exist in the
underlying VFS. This PR fixes this issue.
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
| -rw-r--r-- | llvm/lib/Support/VirtualFileSystem.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 7ff62d4..44d2ee7 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -1908,7 +1908,12 @@ private: FullPath = FS->getOverlayFileDir(); assert(!FullPath.empty() && "External contents prefix directory must exist"); - llvm::sys::path::append(FullPath, Value); + SmallString<256> AbsFullPath = Value; + if (FS->makeAbsolute(FullPath, AbsFullPath)) { + error(N, "failed to make 'external-contents' absolute"); + return nullptr; + } + FullPath = AbsFullPath; } else { FullPath = Value; } @@ -2204,7 +2209,7 @@ RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer, // FS->OverlayFileDir => /<absolute_path_to>/dummy.cache/vfs // SmallString<256> OverlayAbsDir = sys::path::parent_path(YAMLFilePath); - std::error_code EC = llvm::sys::fs::make_absolute(OverlayAbsDir); + std::error_code EC = FS->makeAbsolute(OverlayAbsDir); assert(!EC && "Overlay dir final path must be absolute"); (void)EC; FS->setOverlayFileDir(OverlayAbsDir); |
