[all-commits] [llvm/llvm-project] aae776: [clang] NFC: Move class to make it reusable

Jan Svoboda via All-commits all-commits at lists.llvm.org
Wed Oct 13 09:10:05 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: aae776a5341ccf90a2c0a4e2e952ae4ec5ffb422
      https://github.com/llvm/llvm-project/commit/aae776a5341ccf90a2c0a4e2e952ae4ec5ffb422
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-10-13 (Wed, 13 Oct 2021)

  Changed paths:
    M clang/lib/Frontend/CompilerInstance.cpp

  Log Message:
  -----------
  [clang] NFC: Move class to make it reusable

This is a prep patch for D111560.


  Commit: 08c8016cfb2af9463514709271ae8c4ad6b19377
      https://github.com/llvm/llvm-project/commit/08c8016cfb2af9463514709271ae8c4ad6b19377
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-10-13 (Wed, 13 Oct 2021)

  Changed paths:
    M clang/lib/Frontend/CompilerInstance.cpp
    M clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
    M clang/test/ClangScanDeps/modules-pch.c
    A clang/test/Modules/Inputs/pch-shared-module/mod.h
    A clang/test/Modules/Inputs/pch-shared-module/module.modulemap
    A clang/test/Modules/Inputs/pch-shared-module/pch.h
    A clang/test/Modules/pch-shared-module.c

  Log Message:
  -----------
  [clang][modules] Cache loads of modules imported by PCH

During explicit modular build, PCM files are typically specified via the `-fmodule-file=<path>` command-line option. Early during the compilation, Clang uses the `ASTReader` to read their contents and caches the result so that the module isn't loaded implicitly later on. A listener is attached to the `ASTReader` to collect names of the modules read from the PCM files. However, if the PCM has already been loaded previously via PCH:
1. the `ASTReader` doesn't do anything for the second time,
2. the listener is not invoked at all,
3. the module load result is not cached,
4. the compilation fails when attempting to load the module implicitly later on.

This patch solves this problem by attaching the listener to the `ASTReader` for PCH reading as well.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D111560


Compare: https://github.com/llvm/llvm-project/compare/8c1553f0d7bd...08c8016cfb2a


More information about the All-commits mailing list