[clang] [clang][modules] Deserialize submodules lazily (PR #194968)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Wed May 6 13:53:52 PDT 2026


================
@@ -222,6 +230,41 @@ struct ModuleAttributes {
         NoUndeclaredIncludes(false) {}
 };
 
+/// A reference to either a fully materialized Module object, or
+/// a yet-to-be-deserialized submodule in an AST file.
+class ModuleRef {
+  mutable Module *Existing = nullptr;
+  mutable ExternalSubmoduleSource *ExternalSource = nullptr;
----------------
jansvoboda11 wrote:

I don't this so, because I want `ModuleRef` to represent either the materialized `Module *`, or the external submodule in `ASTReader`, or _both_.

This will become useful in a later patch, where even if a `Module *` gets deserialized/materialized from an AST file, the `ExternalSubmoduleSource` is still able to give me some information for `SubmoduleID` more efficiently than the `Module *` object can. (More specifically - get me the set of _exported_ `ModuleRef`s without fully deserializing imports, submodules, etc. that `Module *` would trigger.)

https://github.com/llvm/llvm-project/pull/194968


More information about the cfe-commits mailing list