Add a CLI option to warn when a public decl has no availability

Add the command line option -require-explicit-availability to detect public
or `@usableFromInline` declarations and warn if they don't declare
an introduction OS version. This option should catch forgotten `@available`
attributes in frameworks where all services are expected to be introduced
by an OS version.

The option -require-explicit-availability-target "macOS 10.14, iOS 12.0"
can be specified for the compiler to suggest fix-its with the missing
attributes `@available(macOS 10.14, iOS 12.0, *)`.

rdar://51001662
This commit is contained in:
Alexis Laferrière
2019-05-28 16:01:38 -07:00
parent b8722fd7d4
commit c44cff7c97
8 changed files with 147 additions and 0 deletions

View File

@@ -386,6 +386,13 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.RequestEvaluatorGraphVizPath = A->getValue();
}
if (Args.getLastArg(OPT_require_explicit_availability, OPT_require_explicit_availability_target)) {
Opts.RequireExplicitAvailability = true;
if (const Arg *A = Args.getLastArg(OPT_require_explicit_availability_target)) {
Opts.RequireExplicitAvailabilityTarget = A->getValue();
}
}
if (const Arg *A = Args.getLastArg(OPT_solver_memory_threshold)) {
unsigned threshold;
if (StringRef(A->getValue()).getAsInteger(10, threshold)) {