[Serialization] Add precomputed layout table for hidden types

Add the module-format machinery that lets a Swift library record the
physical layout of hidden types (currently limited to C types imported via internal bridging header).
into binary modules, so downstream consumers can pull the layouts of these hidden types without
loading the internal dependency.

To test this, this change also added a frontend action to print hidden types' layouts
from both the module under compilation and all the modules being imported.
This commit is contained in:
Xi Ge
2026-05-14 22:37:31 -07:00
parent 227346870c
commit 00897a0efb
17 changed files with 375 additions and 18 deletions
+5
View File
@@ -266,6 +266,11 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
Status status = Status::Valid;
ModuleDecl *M = file->getParentModule();
// Propagate any deserialized hidden-type layouts onto the AST.
for (auto &entry : Core->HiddenTypeLayouts)
M->recordHiddenTypeLayout(entry.getKey(), entry.getValue());
// The real (on-disk) name of the module should be checked here as that's the
// actually loaded module. In case module aliasing is used when building the main
// module, e.g. -module-name MyModule -module-alias Foo=Bar, the loaded module