Frontend: Refactor how flags are saved for module interfaces.

There are two axes on which a saved frontend flag can be categorized for
printing in a `.swiftinterface` file:

1. Whether the flag is "ignorable" or not.
2. Which levels of interface the flag should be in (public, package).

This refactor ensures that those two axes are modeled independently and
prepares the infrastructure to allow flags to appear in the private and package
interfaces without being included in the public interface.
This commit is contained in:
Allan Shortlidge
2024-07-02 16:09:15 -07:00
parent a28b729594
commit f6e30ea83c
3 changed files with 64 additions and 52 deletions

View File

@@ -41,19 +41,22 @@ struct ModuleInterfaceOptions {
/// [TODO: Clang-type-plumbing] This check should go away.
bool PrintFullConvention = false;
/// Copy of all the command-line flags passed at .swiftinterface
/// generation time, re-applied to CompilerInvocation when reading
/// back .swiftinterface and reconstructing .swiftmodule.
std::string Flags;
struct InterfaceFlags {
/// Copy of all the command-line flags passed at .swiftinterface
/// generation time, re-applied to CompilerInvocation when reading
/// back .swiftinterface and reconstructing .swiftmodule.
std::string Flags = "";
/// Keep track of flags to be printed in package.swiftinterface only.
/// If -disable-print-package-name-for-non-package-interface is passed,
/// package-name flag should only be printed in package.swiftinterface.
std::string FlagsForPackageOnly;
/// Flags that should be emitted to the .swiftinterface file but are OK to
/// be ignored by the earlier version of the compiler.
std::string IgnorableFlags = "";
};
/// Flags that should be emitted to the .swiftinterface file but are OK to be
/// ignored by the earlier version of the compiler.
std::string IgnorableFlags;
/// Flags which appear in all .swiftinterface files.
InterfaceFlags PublicFlags = {};
/// Flags which appear only in the .package.swiftinterface.
InterfaceFlags PackageFlags = {};
/// Print imports with both @_implementationOnly and @_spi, only applies
/// when PrintSPIs is true.