[clang][deps] Handle precompiled headers' AST files

Authored by jansvoboda11 on Jun 14 2021, 2:15 AM.


[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