[clang][deps] Support inferred modules
authorMichael Spencer <bigcheesegs@gmail.com>
Mon, 17 May 2021 08:41:44 +0000 (10:41 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Mon, 17 May 2021 09:41:54 +0000 (11:41 +0200)
commit1d9e8e13dd7b3204fa51ada17d1608bdbd1bed66
tree3914be77dc6cbeffba7063b64b13a40682ad6a72
parent1fbb484ea45f85740b7450b175096e5fcff6ecd9
[clang][deps] Support inferred modules

This patch adds support for inferred modules to the dependency scanner.

Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 authored by @Bigcheese with libclang and other changes omitted.

Contains following changes:

1. [Clang][ScanDeps] Ignore __inferred_module.map dependency.
  * This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency.

2. [Clang][ScanDeps] Use the module map a module was inferred from for inferred modules.

Also includes a smoke test that uses clang-scan-deps output to perform an explicit build. There's no intention to duplicate whatever `test/Modules` contains, just to verify the produced command-line does "work" (with very loose definition of work).

Split from D100934.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D102495
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Headers/Inferred.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Headers/System.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Modules/module.modulemap [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/frameworks/module.modulemap [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json [new file with mode: 0644]
clang/test/ClangScanDeps/modules-full.cpp
clang/test/ClangScanDeps/modules-inferred-explicit-build.m [new file with mode: 0644]
clang/test/ClangScanDeps/modules-inferred.m [new file with mode: 0644]
clang/utils/module-deps-to-rsp.py [new file with mode: 0755]