This is an archive of the discontinued LLVM Phabricator instance.

[clang][clang-scan-deps] Add support for extracting full module dependencies.
ClosedPublic

Authored by Bigcheese on Oct 24 2019, 5:50 PM.

Details

Summary

This adds experimental support for extracting a Clang module dependency graph
from a compilation database. The output format is experimental and will change.
It is currently a concatenation of JSON outputs for each compilation. Future
patches will change this to deduplicate modules between compilations.

This patch doesn't implement deduplication as the patch was already getting pretty
large. This also doesn't properly support C++20 modules yet.

Diff Detail

Event Timeline

Bigcheese created this revision.Oct 24 2019, 5:50 PM

A few nit comments

clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
34

"ScanningOutputFormat" or "DependencyOutputFormat" ?

35

IIUC, this format would NOT include module dependencies right?

If so, can you explicitly state that in the comment?

clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
94

Should output arguments be at the end?

Bigcheese updated this revision to Diff 226508.Oct 25 2019, 3:38 PM
Bigcheese marked 3 inline comments as done.

Address review comments.

clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
94

The point was to match up with MakeDependencyPrinterConsumer's printDependencies. This will also be going away with the patch to merge the dependencies.

Bigcheese updated this revision to Diff 226972.Oct 29 2019, 2:34 PM
Bigcheese set the repository for this revision to rG LLVM Github Monorepo.

This fixes some issues I received externally.

  • Fix issue with MSVC getting confused about ModuleDeps::ModuleDeps.
  • Always generate absolute paths.
Bigcheese updated this revision to Diff 226974.Oct 29 2019, 2:43 PM

I forgot to clang-format.

arphaman accepted this revision.Oct 29 2019, 6:30 PM
arphaman added inline comments.
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
44

It would be nice if the dependency collector could be reused outside of clang-scan-deps, like for a new -cc1 flag that computes the modular dependencies in the same fashion. However, its something that can be done as a follow-up, so for now this seems fine.

This revision is now accepted and ready to land.Oct 29 2019, 6:30 PM
This revision was automatically updated to reflect the committed changes.

It looks like Inputs/modules_cdb.json missing from this patch?

It was already there from a previous commit. I see it in tree currently.

It was already there from a previous commit. I see it in tree currently.

Oh, sorry. I missed it in my cherry-picking and GitHub search failed to find it.