[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 09:42:38 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:

Hmm I am now confused by this _existing_ code (my bug). When we create the diagnostics engine we use `FS` but when we create the dependency scanning action we use `DepFS`. Should we use `FS` for the dependency scanning action as well? 

https://github.com/llvm/llvm-project/pull/168970


More information about the cfe-commits mailing list