[clang] [C++20][Modules] Omit imported PCM file info for explicitly mapped header units (PR #235597)
Michael Park via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 25 23:30:00 PDT 2026
================
@@ -1607,9 +1609,19 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
AddStringBlob(M.ModuleName, Record, Blob);
Record.push_back(M.StandardCXXModule);
- // We don't want to hard code the information about imported modules
- // in the C++20 named modules.
- if (M.StandardCXXModule) {
+ // We don't want to hard code file information for C++20 Modules
+ // (including explicitly mapped header units).
+ const Module *ImportedModule =
+ PP.getHeaderSearchInfo().getModuleMap().findModule(M.ModuleName);
+ bool IsPrebuiltHeaderUnit =
+ ImportedModule && ImportedModule->isHeaderUnit() &&
+ M.Kind == MK_PrebuiltModule &&
+ HSOpts.PrebuiltModuleFiles.count(M.ModuleName);
+
+ bool HasFileInfo = !M.StandardCXXModule && !IsPrebuiltHeaderUnit;
----------------
mpark wrote:
I see. Okay, I'm going to update this PR to use `IsCXX20ModuleOrPrebuiltHeaderUnit`.
> And it is not the official mechanism for header units. If you're talking about the doc, I've mentioned the interfaces for HU is experimental.
Ah, gotcha. Okay. I'm planning to give that some more thought. We have a very unnecessarily convoluted setup internally to workaround this, and agree that it could/should be much simpler/cleaner.
https://github.com/llvm/llvm-project/pull/235597
More information about the cfe-commits
mailing list