[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 22:43:54 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:
Hm... I was trying to capture it from the perspective of whether PCM file info corresponding to an imported module is available or not. Would you consider something like `HasImportedPCMFileInfo` to be more explicit and more acceptable?
If we want to go in the direction of something like `IsCXX20ModuleOrHeaderUnit` I think... maybe `IsStandardCXXModuleOrPrebuiltHeaderUnit` or something like that? Personally I would prefer to go in the direction because it's more... let's say precise in what it represents? For example, if let's say we want different mechanisms to also omit the PCM file info, `HasImportedPCMFileInfo` would remain accurate.
What do you think?
https://github.com/llvm/llvm-project/pull/235597
More information about the cfe-commits
mailing list