[Sema] Intro flag to limit availability checks to the API

Intro the frontend flag `-check-api-availability-only` that limits
availability checking to the API and SPI. This mode doesn't check the
availability of non-inlinable function bodies and of non-ABI-public decl
signatures.

This mode goal is to check all that is printed in the swiftinterface
file. It should be used in place of the wider
`-disable-availability-checking` when generating an interface for
platforms with no binaries.

rdar://81679692
This commit is contained in:
Alexis Laferrière
2021-10-06 13:40:20 -07:00
parent 76260c2235
commit a34953ece9
6 changed files with 241 additions and 0 deletions

View File

@@ -473,6 +473,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.DisableAvailabilityChecking |=
Args.hasArg(OPT_disable_availability_checking);
Opts.CheckAPIAvailabilityOnly |=
Args.hasArg(OPT_check_api_availability_only);
if (auto A = Args.getLastArg(OPT_enable_conformance_availability_errors,
OPT_disable_conformance_availability_errors)) {
@@ -915,6 +917,12 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
Opts.DebugTimeExpressions |=
Args.hasArg(OPT_debug_time_expression_type_checking);
// Checking availability of the API only relies on skipping non-inlinable
// function bodies. Define it first so it can be overridden by the other
// flags.
if (Args.hasArg(OPT_check_api_availability_only))
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
// Check for SkipFunctionBodies arguments in order from skipping less to
// skipping more.
if (Args.hasArg(