================
@@ -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:

@ChuanqiXu9 The part that I'm struggling with a bit here is the fact that we 
can't really implement this behavior for header units in general. Specifically, 
a header unit that is imported via `-fmodule-file=<pcm>` actually needs the PCM 
file info embedded. Of course this is kind of weird/awkward as well since IIRC 
`-fmodule-file=<pcm>` is the official mechanism for header units, but also 
deprecated? and has eager loading behavior so not really usable in practice 
(well, at least not for us). I'm trying to understand what your preference is. 
Would `IsCXX20ModuleOrPrebuiltHeaderUnit` work for you? I don't believe you're 
asking to remove PCM file info for imported header units in general, right?

https://github.com/llvm/llvm-project/pull/235597
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to