[all-commits] [llvm/llvm-project] 922320: [clang][deps] Handle precompiled headers' AST files

Jan Svoboda via All-commits all-commits at lists.llvm.org
Mon Jun 14 02:29:12 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9223209be11e93c1b701054c6fff88d46ee54658
      https://github.com/llvm/llvm-project/commit/9223209be11e93c1b701054c6fff88d46ee54658
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-06-14 (Mon, 14 Jun 2021)

  Changed paths:
    M clang/include/clang/Frontend/FrontendActions.h
    M clang/lib/Frontend/FrontendActions.cpp
    M clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
    M clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
    M clang/test/ClangScanDeps/modules-pch.c

  Log Message:
  -----------
  [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




More information about the All-commits mailing list