[clang] [clang][modules-driver] Add dependency scan and dependency graph (PR #152770)

Naveen Seth Hanig via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 4 06:44:56 PST 2025


================
@@ -99,5 +100,6 @@ add_clang_library(clangDriver
   LINK_LIBS
   clangBasic
   clangLex
+  clangDependencyScanning
----------------
naveen-seth wrote:

> As mentioned in my previous comment, this causes a cycle because clangDependencyScanning depends on clangDriver. This is fine when statically linking, but will fail with dynamic linking which we support.
> 
> This is only used by `DependencyScanningWorker::scanDependencies` to handle driver commands. To fix this I think it would be best to remove this dependency and instead have `scanDependencies` only work on frontend commands. I would then add a function to `clangDriver` that takes a `DependencyScanningWorker` and runs the scanner on all of frontend jobs, this would then be used to replace calls to `scanDependencies`.
> 
> This will need to be handled before (or maybe as part of) this PR lands to avoid build issues.

`clang-scan-deps` and `clangd` don’t call `computeDependencies` (which in turn calls `scanDependencies`) directly, but indirectly through `DependencyScanningTool`.
If we want `DependencyScanningTool` to continue supporting Driver command lines, it will necessarily need to keep a dependency on the Driver.

Can `DependencyScanningTool.cpp` / `DependencyScanningTool.h` be moved into the Driver as well? Conceptually, that might not be the cleanest fit, but it would resolve the dynamic linking issue.

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


More information about the cfe-commits mailing list