diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2025-09-15 09:37:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-15 09:37:19 -0700 |
commit | 4957c473bc73a3a0bf1037adec770547c4a0aa02 (patch) | |
tree | a1e40ddddc3559d7c6de6ed7b8bd295124d65567 /llvm/lib/Support/VirtualFileSystem.cpp | |
parent | 985dc69a2def6812ba310c8fa431a0679f1b8163 (diff) | |
download | llvm-4957c473bc73a3a0bf1037adec770547c4a0aa02.zip llvm-4957c473bc73a3a0bf1037adec770547c4a0aa02.tar.gz llvm-4957c473bc73a3a0bf1037adec770547c4a0aa02.tar.bz2 |
[clang] Avoid reparsing VFS overlay files for module dep collector (#158372)
This PR uses the new-ish `llvm::vfs::FileSystem::visit()` interface to
collect VFS overlay entries from an existing `FileSystem` instance
rather than parsing the VFS YAML file anew. This prevents duplicate
diagnostics as observed by `clang/test/VFS/broken-vfs-module-dep.c`.
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r-- | llvm/lib/Support/VirtualFileSystem.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 5d42488..cf78459 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -2707,19 +2707,9 @@ static void getVFSEntries(RedirectingFileSystem::Entry *SrcE, Entries.push_back(YAMLVFSEntry(VPath.c_str(), FE->getExternalContentsPath())); } -void vfs::collectVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer, - SourceMgr::DiagHandlerTy DiagHandler, - StringRef YAMLFilePath, - SmallVectorImpl<YAMLVFSEntry> &CollectedEntries, - void *DiagContext, - IntrusiveRefCntPtr<FileSystem> ExternalFS) { - std::unique_ptr<RedirectingFileSystem> VFS = RedirectingFileSystem::create( - std::move(Buffer), DiagHandler, YAMLFilePath, DiagContext, - std::move(ExternalFS)); - if (!VFS) - return; - ErrorOr<RedirectingFileSystem::LookupResult> RootResult = - VFS->lookupPath("/"); +void vfs::collectVFSEntries(RedirectingFileSystem &VFS, + SmallVectorImpl<YAMLVFSEntry> &CollectedEntries) { + ErrorOr<RedirectingFileSystem::LookupResult> RootResult = VFS.lookupPath("/"); if (!RootResult) return; SmallVector<StringRef, 8> Components; |