Skip to content

Commit 5ef4688

Browse files
author
git apple-llvm automerger
committed
Merge commit '4957c473bc73' from llvm.org/main into next
2 parents 575a10a + 4957c47 commit 5ef4688

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,19 +285,12 @@ static void collectIncludePCH(CompilerInstance &CI,
285285

286286
static void collectVFSEntries(CompilerInstance &CI,
287287
std::shared_ptr<ModuleDependencyCollector> MDC) {
288-
if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
289-
return;
290-
291288
// Collect all VFS found.
292289
SmallVector<llvm::vfs::YAMLVFSEntry, 16> VFSEntries;
293-
for (const std::string &VFSFile : CI.getHeaderSearchOpts().VFSOverlayFiles) {
294-
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
295-
llvm::MemoryBuffer::getFile(VFSFile);
296-
if (!Buffer)
297-
return;
298-
llvm::vfs::collectVFSFromYAML(std::move(Buffer.get()),
299-
/*DiagHandler*/ nullptr, VFSFile, VFSEntries);
300-
}
290+
CI.getVirtualFileSystem().visit([&](llvm::vfs::FileSystem &VFS) {
291+
if (auto *RedirectingVFS = dyn_cast<llvm::vfs::RedirectingFileSystem>(&VFS))
292+
llvm::vfs::collectVFSEntries(*RedirectingVFS, VFSEntries);
293+
});
301294

302295
for (auto &E : VFSEntries)
303296
MDC->addFile(E.VPath, E.RPath);

clang/test/VFS/broken-vfs-module-dep.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
// RUN: mkdir -p %t
33
// RUN: not %clang_cc1 -module-dependency-dir %t -ivfsoverlay %S/Inputs/invalid-yaml.yaml %s 2>&1 | FileCheck %s
44

5-
// CHECK: error: Unexpected token
65
// CHECK: error: Unexpected token
76
// CHECK: 1 error generated

llvm/include/llvm/Support/VirtualFileSystem.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,14 +1164,10 @@ class LLVM_ABI RedirectingFileSystem
11641164
};
11651165

11661166
/// Collect all pairs of <virtual path, real path> entries from the
1167-
/// \p YAMLFilePath. This is used by the module dependency collector to forward
1167+
/// \p VFS. This is used by the module dependency collector to forward
11681168
/// the entries into the reproducer output VFS YAML file.
1169-
LLVM_ABI void collectVFSFromYAML(
1170-
std::unique_ptr<llvm::MemoryBuffer> Buffer,
1171-
llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath,
1172-
SmallVectorImpl<YAMLVFSEntry> &CollectedEntries,
1173-
void *DiagContext = nullptr,
1174-
IntrusiveRefCntPtr<FileSystem> ExternalFS = getRealFileSystem());
1169+
void collectVFSEntries(RedirectingFileSystem &VFS,
1170+
SmallVectorImpl<YAMLVFSEntry> &CollectedEntries);
11751171

11761172
class YAMLVFSWriter {
11771173
std::vector<YAMLVFSEntry> Mappings;

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,19 +2708,9 @@ static void getVFSEntries(RedirectingFileSystem::Entry *SrcE,
27082708
Entries.push_back(YAMLVFSEntry(VPath.c_str(), FE->getExternalContentsPath()));
27092709
}
27102710

2711-
void vfs::collectVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer,
2712-
SourceMgr::DiagHandlerTy DiagHandler,
2713-
StringRef YAMLFilePath,
2714-
SmallVectorImpl<YAMLVFSEntry> &CollectedEntries,
2715-
void *DiagContext,
2716-
IntrusiveRefCntPtr<FileSystem> ExternalFS) {
2717-
std::unique_ptr<RedirectingFileSystem> VFS = RedirectingFileSystem::create(
2718-
std::move(Buffer), DiagHandler, YAMLFilePath, DiagContext,
2719-
std::move(ExternalFS));
2720-
if (!VFS)
2721-
return;
2722-
ErrorOr<RedirectingFileSystem::LookupResult> RootResult =
2723-
VFS->lookupPath("/");
2711+
void vfs::collectVFSEntries(RedirectingFileSystem &VFS,
2712+
SmallVectorImpl<YAMLVFSEntry> &CollectedEntries) {
2713+
ErrorOr<RedirectingFileSystem::LookupResult> RootResult = VFS.lookupPath("/");
27242714
if (!RootResult)
27252715
return;
27262716
SmallVector<StringRef, 8> Components;

0 commit comments

Comments
 (0)