Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,12 @@ static void collectIncludePCH(CompilerInstance &CI,

static void collectVFSEntries(CompilerInstance &CI,
std::shared_ptr<ModuleDependencyCollector> MDC) {
if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
return;

// Collect all VFS found.
SmallVector<llvm::vfs::YAMLVFSEntry, 16> VFSEntries;
for (const std::string &VFSFile : CI.getHeaderSearchOpts().VFSOverlayFiles) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
llvm::MemoryBuffer::getFile(VFSFile);
if (!Buffer)
return;
llvm::vfs::collectVFSFromYAML(std::move(Buffer.get()),
/*DiagHandler*/ nullptr, VFSFile, VFSEntries);
}
CI.getVirtualFileSystem().visit([&](llvm::vfs::FileSystem &VFS) {
if (auto *RedirectingVFS = dyn_cast<llvm::vfs::RedirectingFileSystem>(&VFS))
llvm::vfs::collectVFSEntries(*RedirectingVFS, VFSEntries);
});

for (auto &E : VFSEntries)
MDC->addFile(E.VPath, E.RPath);
Expand Down
1 change: 0 additions & 1 deletion clang/test/VFS/broken-vfs-module-dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
// RUN: mkdir -p %t
// RUN: not %clang_cc1 -module-dependency-dir %t -ivfsoverlay %S/Inputs/invalid-yaml.yaml %s 2>&1 | FileCheck %s

// CHECK: error: Unexpected token
// CHECK: error: Unexpected token
// CHECK: 1 error generated
10 changes: 3 additions & 7 deletions llvm/include/llvm/Support/VirtualFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1114,14 +1114,10 @@ class LLVM_ABI RedirectingFileSystem
};

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

class YAMLVFSWriter {
std::vector<YAMLVFSEntry> Mappings;
Expand Down
16 changes: 3 additions & 13 deletions llvm/lib/Support/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading