mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user