Skip to content

Conversation

@vsapsai
Copy link
Collaborator

@vsapsai vsapsai commented Nov 13, 2025

rdar://164612831

@vsapsai vsapsai requested a review from jansvoboda11 November 13, 2025 06:03
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2025

@llvm/pr-subscribers-clang

Author: Volodymyr Sapsai (vsapsai)

Changes

rdar://164612831


Full diff: https://github.com/llvm/llvm-project/pull/167824.diff

2 Files Affected:

  • (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (+4)
  • (modified) clang/test/ClangScanDeps/modules-header-sharing.m (+2-1)
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 0022597348a82..56a364545cd2a 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -616,6 +616,10 @@ void ModuleDepCollectorPP::EndOfMainFile() {
   if (!MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
     MDC.addFileDep(MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
 
+  for (const std::string &Overlay :
+       MDC.ScanInstance.getHeaderSearchOpts().VFSOverlayFiles)
+    MDC.addFileDep(Overlay);
+
   for (const Module *M :
        MDC.ScanInstance.getPreprocessor().getAffectingClangModules())
     if (!MDC.isPrebuiltModule(M))
diff --git a/clang/test/ClangScanDeps/modules-header-sharing.m b/clang/test/ClangScanDeps/modules-header-sharing.m
index 31ef351ec38b7..9bba435188721 100644
--- a/clang/test/ClangScanDeps/modules-header-sharing.m
+++ b/clang/test/ClangScanDeps/modules-header-sharing.m
@@ -79,7 +79,8 @@
 // CHECK:                ],
 // CHECK:                "file-deps": [
 // CHECK-NEXT:             "[[PREFIX]]/tu.m",
-// CHECK-NEXT:             "[[PREFIX]]/shared/H.h"
+// CHECK-NEXT:             "[[PREFIX]]/shared/H.h",
+// CHECK-NEXT:             "[[PREFIX]]/overlay.json"
 // CHECK-NEXT:           ],
 // CHECK-NEXT:           "input-file": "[[PREFIX]]/tu.m"
 // CHECK-NEXT:         }

@vsapsai
Copy link
Collaborator Author

vsapsai commented Nov 13, 2025

Don't have a strong opinion on where tracking VFS files should be done. Mostly was trying to do that after ModuleDepCollectorPP::handleTopLevelModule prunes VFSOverlayFiles in optimizeHeaderSearchOpts.

Copy link
Contributor

@jansvoboda11 jansvoboda11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

It is OK to use `StringRef` because the method type is `void ModuleDepCollector::addFileDep(StringRef Path)`
so we aren't adding extra unnecessary `StringRef` instances.
@vsapsai vsapsai merged commit 513232f into llvm:main Nov 13, 2025
8 of 9 checks passed
@vsapsai vsapsai deleted the add-vfs-overlay-to-file-dependencies branch November 13, 2025 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants