[clang][deps] Handle precompiled headers' AST files
authorJan Svoboda <jan_svoboda@apple.com>
Mon, 14 Jun 2021 09:15:03 +0000 (11:15 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Mon, 14 Jun 2021 09:28:39 +0000 (11:28 +0200)
commit9223209be11e93c1b701054c6fff88d46ee54658
tree46946b1de8c10be35712a1767b03c2912bef77ca
parent0f94d68a2e15d50796439f20bcb508b95931d2ae
[clang][deps] Handle precompiled headers' AST files

The `PreprocessOnlyAction` doesn't support loading the AST file of a precompiled header. This is problematic for dependency scanning, since the `#include` manufactured for the PCH is treated as textual. This means the PCH contents get scanned with each TU, which is redundant. Moreover, dependencies of the PCH end up being considered dependency of the TU.

To handle AST file of PCH properly, this patch creates new `FrontendAction` that behaves the same way `PreprocessorOnlyAction` does, but treats the manufactured PCH `#include` as a normal compilation would (by not claiming it only uses a preprocessor and creating the default AST consumer).

The AST file is now reported as a file dependency of the TU.

Depends on D103519.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D103524
clang/include/clang/Frontend/FrontendActions.h
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/modules-pch.c