[PATCH] D111560: [clang][modules] Cache loads of explicit modules imported by PCH
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 11 10:15:18 PDT 2021
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, rsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
During 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 asking the `ModuleManager` for the module instead of relying on the `ASTReader` listener. If the modules were loaded as part of loading the PCH, `ModuleManager` will know about them even though `ASTReader` didn't read them for the second time.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111560
Files:
clang/include/clang/Serialization/ModuleFile.h
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Serialization/ModuleFile.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/test/ClangScanDeps/modules-pch.c
clang/test/Modules/Inputs/pch-shared-module/mod.h
clang/test/Modules/Inputs/pch-shared-module/module.modulemap
clang/test/Modules/Inputs/pch-shared-module/pch.h
clang/test/Modules/pch-shared-module.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111560.378716.patch
Type: text/x-patch
Size: 5801 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211011/60d30aed/attachment.bin>
More information about the cfe-commits
mailing list