This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by jansvoboda11 on Jun 2 2021, 7:06 AM.

Details

Summary

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.

Diff Detail

Event Timeline

jansvoboda11 requested review of this revision.Jun 2 2021, 7:06 AM
jansvoboda11 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2021, 7:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Bigcheese accepted this revision.Jun 3 2021, 9:32 AM

lgtm.

clang/test/ClangScanDeps/modules-pch.c
7

Is this needed for this commit?

11–60

You should mention that PCHs don't work with minimization yet.

This revision is now accepted and ready to land.Jun 3 2021, 9:32 AM
This revision was landed with ongoing or failed builds.Jun 14 2021, 2:29 AM
This revision was automatically updated to reflect the committed changes.