Skip to content

Commit f83a51c

Browse files
authored
Merge pull request #63707 from tshortli/remove-check-api-availability
Frontend: Remove support for the `-check-api-availability-only` flag
2 parents beb7449 + a58ad6b commit f83a51c

11 files changed

+13
-322
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ ERROR(error_mode_cannot_emit_module_semantic_info,none,
161161
ERROR(cannot_emit_ir_skipping_function_bodies,none,
162162
"the -experimental-skip-*-function-bodies* flags do not support "
163163
"emitting IR", ())
164-
ERROR(cannot_emit_ir_checking_api_availability_only,none,
165-
"the flag -check-api-availability-only does not support "
166-
"emitting IR", ())
167164

168165
WARNING(emit_reference_dependencies_without_primary_file,none,
169166
"ignoring -emit-reference-dependencies (requires -primary-file)", ())

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ namespace swift {
171171
/// Disable API availability checking.
172172
bool DisableAvailabilityChecking = false;
173173

174-
/// Only check the availability of the API, ignore function bodies.
175-
bool CheckAPIAvailabilityOnly = false;
176-
177174
/// Causes the compiler to use weak linkage for symbols belonging to
178175
/// declarations introduced at the deployment target.
179176
bool WeakLinkAtTarget = false;

include/swift/Option/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def define_availability : Separate<["-"], "define-availability">,
488488

489489
def check_api_availability_only : Flag<["-"], "check-api-availability-only">,
490490
Flags<[HelpHidden, FrontendOption, NoInteractiveOption]>,
491-
HelpText<"Only check the availability of the APIs, ignore function bodies">;
491+
HelpText<"Deprecated, has no effect">;
492492

493493
def library_level : Separate<["-"], "library-level">,
494494
MetaVarName<"<level>">,

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,6 @@ bool ArgsToFrontendOptionsConverter::convert(
256256
Diags.diagnose(SourceLoc(), diag::cannot_emit_ir_skipping_function_bodies);
257257
return true;
258258
}
259-
260-
if (Args.hasArg(OPT_check_api_availability_only)) {
261-
Diags.diagnose(SourceLoc(), diag::cannot_emit_ir_checking_api_availability_only);
262-
return true;
263-
}
264259
}
265260

266261
if (const Arg *A = Args.getLastArg(OPT_module_abi_name))

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,10 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
548548

549549
Opts.DisableAvailabilityChecking |=
550550
Args.hasArg(OPT_disable_availability_checking);
551-
Opts.CheckAPIAvailabilityOnly |=
552-
Args.hasArg(OPT_check_api_availability_only);
551+
if (Args.hasArg(OPT_check_api_availability_only))
552+
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
553+
"-check-api-availability-only");
554+
553555
Opts.WeakLinkAtTarget |= Args.hasArg(OPT_weak_link_at_target);
554556

555557
if (auto A = Args.getLastArg(OPT_enable_conformance_availability_errors,
@@ -1195,12 +1197,6 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
11951197
Opts.DebugTimeExpressions |=
11961198
Args.hasArg(OPT_debug_time_expression_type_checking);
11971199

1198-
// Checking availability of the API only relies on skipping non-inlinable
1199-
// function bodies. Define it first so it can be overridden by the other
1200-
// flags.
1201-
if (Args.hasArg(OPT_check_api_availability_only))
1202-
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
1203-
12041200
// Check for SkipFunctionBodies arguments in order from skipping less to
12051201
// skipping more.
12061202
if (Args.hasArg(

lib/Sema/TypeCheckAccess.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,9 +2052,6 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
20522052
}
20532053

20542054
void visitPatternBindingDecl(PatternBindingDecl *PBD) {
2055-
if (!shouldCheckAvailability(PBD->getAnchoringVarDecl(0)))
2056-
return;
2057-
20582055
llvm::DenseSet<const VarDecl *> seenVars;
20592056
for (auto idx : range(PBD->getNumPatternEntries())) {
20602057
PBD->getPattern(idx)->forEachNode([&](const Pattern *P) {
@@ -2351,22 +2348,5 @@ void swift::checkAccessControl(Decl *D) {
23512348
if (where.isImplicit())
23522349
return;
23532350

2354-
if (!shouldCheckAvailability(D))
2355-
return;
2356-
23572351
DeclAvailabilityChecker(where).visit(D);
23582352
}
2359-
2360-
bool swift::shouldCheckAvailability(const Decl *D) {
2361-
if (D && D->getASTContext().LangOpts.CheckAPIAvailabilityOnly) {
2362-
// Skip whole decl if not API-public.
2363-
if (auto valueDecl = dyn_cast<const ValueDecl>(D)) {
2364-
AccessScope scope =
2365-
valueDecl->getFormalAccessScope(/*useDC*/nullptr,
2366-
/*treatUsableFromInlineAsPublic*/true);
2367-
if (!scope.isPublic())
2368-
return false;
2369-
}
2370-
}
2371-
return true;
2372-
}

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,9 +2051,6 @@ void TypeChecker::checkConcurrencyAvailability(SourceRange ReferenceRange,
20512051
if (ctx.LangOpts.DisableAvailabilityChecking)
20522052
return;
20532053

2054-
if (!shouldCheckAvailability(ReferenceDC->getAsDecl()))
2055-
return;
2056-
20572054
auto runningOS =
20582055
TypeChecker::overApproximateAvailabilityAtLocation(
20592056
ReferenceRange.Start, ReferenceDC);
@@ -3022,9 +3019,6 @@ bool swift::diagnoseParameterizedProtocolAvailability(
30223019
if (ctx.LangOpts.DisableAvailabilityChecking)
30233020
return false;
30243021

3025-
if (!shouldCheckAvailability(ReferenceDC->getAsDecl()))
3026-
return false;
3027-
30283022
auto runningOS = TypeChecker::overApproximateAvailabilityAtLocation(
30293023
ReferenceRange.Start, ReferenceDC);
30303024
auto availability = ctx.getParameterizedExistentialRuntimeAvailability();

lib/Sema/TypeCheckAvailability.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ bool diagnoseParameterizedProtocolAvailability(SourceRange loc,
282282
/// Check if \p decl has a introduction version required by -require-explicit-availability
283283
void checkExplicitAvailability(Decl *decl);
284284

285-
/// Check if \p D needs to be checked for correct availability depending on the
286-
/// flag -check-api-availability-only.
287-
bool shouldCheckAvailability(const Decl *D);
288-
289285
} // namespace swift
290286

291287
#endif // SWIFT_SEMA_TYPE_CHECK_AVAILABILITY_H

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -777,16 +777,6 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
777777
initializer, DC, patternType, pattern,
778778
/*bindPatternVarsOneWay=*/false);
779779

780-
if (DC->getASTContext().LangOpts.CheckAPIAvailabilityOnly &&
781-
PBD && !DC->getAsDecl()) {
782-
// Skip checking the initializer for non-public decls when
783-
// checking the API only.
784-
auto VD = PBD->getAnchoringVarDecl(0);
785-
if (!swift::shouldCheckAvailability(VD)) {
786-
options |= TypeCheckExprFlags::DisableExprAvailabilityChecking;
787-
}
788-
}
789-
790780
// Type-check the initializer.
791781
auto resultTarget = typeCheckExpression(target, options);
792782

test/Sema/api-availability-only-ok.swift

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)