[ModuleInterface] Add mechanism to exclude experimental flags from th… (#66088)

* [ModuleInterface] Add mechanism to exclude experimental flags from the module interface

rdar://109722548

* Separate filtered flags from the typical/unfiltered case
This commit is contained in:
Dario Rexin
2023-05-24 09:03:01 -07:00
committed by GitHub
parent efe6d58152
commit 2bb08e37f6
5 changed files with 51 additions and 4 deletions

View File

@@ -417,6 +417,19 @@ static void ParseModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
}
}
/// Checks if an arg is generally allowed to be included
/// in a module interface
static bool ShouldIncludeModuleInterfaceArg(const Arg *A) {
if (!A->getOption().matches(options::OPT_enable_experimental_feature))
return true;
if (auto feature = getExperimentalFeature(A->getValue())) {
return swift::includeInModuleInterface(*feature);
}
return true;
}
/// Save a copy of any flags marked as ModuleInterfaceOption, if running
/// in a mode that is going to emit a .swiftinterface file.
static void SaveModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
@@ -428,6 +441,9 @@ static void SaveModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
ArgStringList RenderedArgsIgnorable;
ArgStringList RenderedArgsIgnorablePrivate;
for (auto A : Args) {
if (!ShouldIncludeModuleInterfaceArg(A))
continue;
if (A->getOption().hasFlag(options::ModuleInterfaceOptionIgnorablePrivate)) {
A->render(Args, RenderedArgsIgnorablePrivate);
} else if (A->getOption().hasFlag(options::ModuleInterfaceOptionIgnorable)) {