[clang] [clang][deps] Use the caching VFS even in the 'preprocess' mode (PR #168970)
Qiongsi Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 21 11:08:27 PST 2025
================
@@ -102,7 +94,18 @@ bool DependencyScanningWorker::scanDependencies(
StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
DependencyConsumer &Consumer, DependencyActionController &Controller,
DiagnosticConsumer &DC,
- llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> OverlayFS) {
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = DepFS;
+ if (OverlayFS) {
+#ifndef NDEBUG
+ bool SawDepFS = false;
+ OverlayFS->visit(
+ [&](llvm::vfs::FileSystem &VFS) { SawDepFS |= &VFS == DepFS.get(); });
+ assert(SawDepFS && "OverlayFS not based on DepFS");
+#endif
+ FS = std::move(OverlayFS);
+ }
+
DignosticsEngineWithDiagOpts DiagEngineWithCmdAndOpts(CommandLine, FS, DC);
DependencyScanningAction Action(Service, WorkingDirectory, Consumer,
Controller, DepFS);
----------------
qiongsiwu wrote:
Oh I see that makes sense! Thanks for clarifying!
> (Or maybe we could make FS a scanner-specific VFS CustomizedDependencyScanningWorkerFileSystem that provides DependencyScanningWorkerFilesystem &getDepFS() instead, to avoid the visitation.)
Yeah this sounds good! Visitation _feels_ expensive. I don't think we need to do this soon or in this PR though as this is NFC.
https://github.com/llvm/llvm-project/pull/168970
More information about the cfe-commits
mailing list