Skip to content

Test #10075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: stable/20240723
Choose a base branch
from
Draft

Test #10075

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
19 changes: 17 additions & 2 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,28 @@ std::vector<bool> HeaderSearch::collectVFSUsageAndClear() const {
// `createVFSFromOverlayFiles`.
RootFS.visit([&](llvm::vfs::FileSystem &FS) {
if (auto *RFS = dyn_cast<llvm::vfs::RedirectingFileSystem>(&FS)) {
VFSUsage.push_back(RFS->hasBeenUsed());
RFS->clearHasBeenUsed();
// Skip the `RedirectingFileSystem that was added by
// createClangInvocationFileMappingVFS, if any, since it's not
// created by createVFSFromOverlayFiles
if (!RFS->getOverlayFileDir().empty()) {
// llvm::dbgs() << "createVFSFromOverlayFiles counting RedirectingFileSystem\n";
// RFS->print(llvm::dbgs());
VFSUsage.push_back(RFS->hasBeenUsed());
RFS->clearHasBeenUsed();
} else {
// llvm::dbgs() << "createVFSFromOverlayFiles skipping RedirectingFileSystem\n";
// RFS->print(llvm::dbgs());
}
}
});
//
if (VFSUsage.size() != getHeaderSearchOpts().VFSOverlayFiles.size()) {
llvm::dbgs() << "HeaderSearch::collectVFSUsageAndClear VFSUsage.size() " << VFSUsage.size() << " != getHeaderSearchOpts().VFSOverlayFiles.size() " << getHeaderSearchOpts().VFSOverlayFiles.size() << "\n";
}
assert(VFSUsage.size() == getHeaderSearchOpts().VFSOverlayFiles.size() &&
"A different number of RedirectingFileSystem's were present than "
"-ivfsoverlay options passed to Clang!");
//
// VFS visit order is the opposite of VFSOverlayFiles order.
std::reverse(VFSUsage.begin(), VFSUsage.end());
return VFSUsage;
Expand Down
5 changes: 5 additions & 0 deletions clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ optimizeHeaderSearchOpts(HeaderSearchOptions &Opts, ASTReader &Reader,
};
VisitMF(&MF);

//
if (VFSUsage.size() != VFSOverlayFiles.size()) {
llvm::dbgs() << "optimizeHeaderSearchOpts VFSUsage.size() " << VFSUsage.size() << " != VFSOverlayFiles.size() " << VFSOverlayFiles.size() << "\n";
}
if (VFSUsage.size() != VFSOverlayFiles.size())
llvm::report_fatal_error(
"Inconsistent -ivfsoverlay options between modules detected");
//

for (auto Idx : VFSUsage.set_bits())
Opts.VFSOverlayFiles.push_back(std::move(VFSOverlayFiles[Idx]));
Expand Down