Frontend: Intro -public-module-name flag

Introduce the concept of public facing module name designed to hide support module from external clients. This name should be set on a support module that is an implementation detail of a public module, the public module name of the support module should be the name of the public module. For example, BigKitCore’s public module name can be set to BigKit for diagnostics to refer to both modules as BigKit.

This name is used to refer to the support module in diagnostics for external clients. We determine if a client is external if they also import the module identified by the public module name. If a client doesn’t import the public module, diagnostics will always use the real name of the module.

The public module name is set with the flag -public-module-name and it's preserved in textual swiftinterfaces and binary swiftmodules.

rdar://134527933
This commit is contained in:
Alexis Laferrière
2024-08-20 13:21:53 -07:00
parent 2eade1e3cc
commit 3fe97c2eb8
3 changed files with 9 additions and 0 deletions

View File

@@ -288,6 +288,9 @@ bool ArgsToFrontendOptionsConverter::convert(
Opts.ExportAsName = exportAs;
}
if (const Arg *A = Args.getLastArg(OPT_public_module_name))
Opts.PublicModuleName = A->getValue();
// This must be called after computing module name, module abi name,
// and module link name. If computing module aliases is unsuccessful,
// return early.