@@ -2116,7 +2116,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2116
2116
}, /* visitFreestandingExpanded=*/ false );
2117
2117
}
2118
2118
2119
- if (auto *Stats = getASTContext () .Stats )
2119
+ if (auto *Stats = Ctx .Stats )
2120
2120
++Stats->getFrontendCounters ().NumDeclsTypechecked ;
2121
2121
2122
2122
FrontendStatsTracer StatsTracer (getASTContext ().Stats ,
@@ -2131,8 +2131,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2131
2131
TypeChecker::checkExistentialTypes (decl);
2132
2132
2133
2133
if (auto VD = dyn_cast<ValueDecl>(decl)) {
2134
- auto &Context = getASTContext ();
2135
- TypeChecker::checkForForbiddenPrefix (Context, VD->getBaseName ());
2134
+ TypeChecker::checkForForbiddenPrefix (Ctx, VD->getBaseName ());
2136
2135
2137
2136
// Force some requests, which can produce diagnostics.
2138
2137
@@ -2205,15 +2204,15 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2205
2204
2206
2205
auto target = ID->getModule ();
2207
2206
if (target && // module would be nil if loading fails
2208
- !getASTContext () .LangOpts .PackageName .empty () &&
2209
- getASTContext () .LangOpts .PackageName == target->getPackageName ().str () &&
2207
+ !Ctx .LangOpts .PackageName .empty () &&
2208
+ Ctx .LangOpts .PackageName == target->getPackageName ().str () &&
2210
2209
!target->isNonSwiftModule () && // target is a Swift module
2211
2210
target->isNonUserModule ()) { // target module is in distributed SDK
2212
2211
// If reached here, a binary module (.swiftmodule) instead of interface of the
2213
2212
// target was loaded for the main module, where both belong to the same package;
2214
2213
// this is an expected behavior, but it should have been loaded from the local
2215
2214
// build directory, not from distributed SDK. In such case, we show a warning.
2216
- auto &diags = ID->getASTContext () .Diags ;
2215
+ auto &diags = ID->Ctx .Diags ;
2217
2216
diags.diagnose (ID,
2218
2217
diag::in_package_module_not_compiled_locally,
2219
2218
target->getBaseIdentifier (),
@@ -2222,15 +2221,15 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2222
2221
}
2223
2222
2224
2223
// Report the public import of a private module.
2225
- if (ID->getASTContext () .LangOpts .LibraryLevel == LibraryLevel::API) {
2224
+ if (ID->Ctx .LangOpts .LibraryLevel == LibraryLevel::API) {
2226
2225
auto importer = ID->getModuleContext ();
2227
2226
if (target &&
2228
2227
!ID->getAttrs ().hasAttribute <ImplementationOnlyAttr>() &&
2229
2228
!ID->getAttrs ().hasAttribute <SPIOnlyAttr>() &&
2230
2229
ID->getAccessLevel () == AccessLevel::Public &&
2231
2230
target->getLibraryLevel () == LibraryLevel::SPI) {
2232
2231
2233
- auto &diags = ID->getASTContext () .Diags ;
2232
+ auto &diags = ID->Ctx .Diags ;
2234
2233
InFlightDiagnostic inFlight =
2235
2234
diags.diagnose (ID, diag::error_public_import_of_private_module,
2236
2235
target->getName (), importer->getName ());
@@ -2485,7 +2484,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2485
2484
//
2486
2485
// NOTE: We do this here instead of TypeCheckAttr since types are not
2487
2486
// completely type checked at that point.
2488
- auto &DE = getASTContext () .Diags ;
2487
+ auto &DE = Ctx .Diags ;
2489
2488
if (auto attr = VD->getAttrs ().getAttribute <NoImplicitCopyAttr>()) {
2490
2489
if (auto *nom = VD->getInterfaceType ()->getNominalOrBoundGenericNominal ()) {
2491
2490
if (!nom->canBeCopyable ()) {
@@ -2498,10 +2497,10 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2498
2497
2499
2498
// @_staticExclusiveOnly types cannot be put into 'var's, only 'let'.
2500
2499
if (auto SD = VD->getInterfaceType ()->getStructOrBoundGenericStruct ()) {
2501
- if (getASTContext () .LangOpts .hasFeature (Feature::StaticExclusiveOnly) &&
2500
+ if (Ctx .LangOpts .hasFeature (Feature::StaticExclusiveOnly) &&
2502
2501
SD->getAttrs ().hasAttribute <StaticExclusiveOnlyAttr>() &&
2503
2502
!VD->isLet ()) {
2504
- SD->getASTContext () .Diags .diagnoseWithNotes (
2503
+ SD->Ctx .Diags .diagnoseWithNotes (
2505
2504
VD->diagnose (diag::attr_static_exclusive_only_let_only,
2506
2505
VD->getInterfaceType ()),
2507
2506
[&]() {
@@ -2538,7 +2537,6 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2538
2537
isInSILMode = sourceFile->Kind == SourceFileKind::SIL;
2539
2538
bool isTypeContext = DC->isTypeContext ();
2540
2539
2541
- auto &Ctx = getASTContext ();
2542
2540
for (auto i : range (PBD->getNumPatternEntries ())) {
2543
2541
const auto *entry = PBD->isFullyValidated (i)
2544
2542
? &PBD->getPatternList ()[i]
@@ -2881,7 +2879,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2881
2879
});
2882
2880
2883
2881
if (mentionsItself) {
2884
- auto &DE = getASTContext () .Diags ;
2882
+ auto &DE = Ctx .Diags ;
2885
2883
DE.diagnose (AT->getDefaultDefinitionTypeRepr ()->getLoc (),
2886
2884
diag::recursive_decl_reference, AT);
2887
2885
AT->diagnose (diag::kind_declared_here, DescriptiveDeclKind::Type);
@@ -2993,7 +2991,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2993
2991
2994
2992
TypeChecker::checkPatternBindingCaptures (ED);
2995
2993
2996
- auto &DE = getASTContext () .Diags ;
2994
+ auto &DE = Ctx .Diags ;
2997
2995
if (auto rawTy = ED->getRawType ()) {
2998
2996
// The raw type must be one of the blessed literal convertible types.
2999
2997
if (!computeAutomaticEnumValueKind (ED)) {
@@ -3376,7 +3374,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3376
3374
}
3377
3375
}
3378
3376
3379
- if (!getASTContext () .isAccessControlDisabled ()) {
3377
+ if (!Ctx .isAccessControlDisabled ()) {
3380
3378
// Require the superclass to be open if this is outside its
3381
3379
// defining module. But don't emit another diagnostic if we
3382
3380
// already complained about the class being inherently
@@ -3451,7 +3449,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3451
3449
if (!SF || SF->Kind != SourceFileKind::Interface)
3452
3450
TypeChecker::inferDefaultWitnesses (PD);
3453
3451
3454
- if (PD-> getASTContext () .TypeCheckerOpts .DebugGenericSignatures ) {
3452
+ if (Ctx .TypeCheckerOpts .DebugGenericSignatures ) {
3455
3453
auto sig = PD->getRequirementSignatureAsGenericSignature ();
3456
3454
llvm::errs () << " \n " ;
3457
3455
llvm::errs () << " Protocol requirement signature:\n " ;
@@ -3613,13 +3611,12 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3613
3611
if (isRepresentableInObjC (FD, reason, asyncConvention, errorConvention)) {
3614
3612
if (FD->hasAsync ()) {
3615
3613
FD->setForeignAsyncConvention (*asyncConvention);
3616
- getASTContext () .Diags .diagnose (
3614
+ Ctx .Diags .diagnose (
3617
3615
CDeclAttr->getLocation (), diag::attr_decl_async,
3618
3616
CDeclAttr->getAttrName (), FD->getDescriptiveKind ());
3619
3617
} else if (FD->hasThrows ()) {
3620
3618
FD->setForeignErrorConvention (*errorConvention);
3621
- getASTContext ().Diags .diagnose (CDeclAttr->getLocation (),
3622
- diag::cdecl_throws);
3619
+ Ctx.Diags .diagnose (CDeclAttr->getLocation (), diag::cdecl_throws);
3623
3620
}
3624
3621
} else {
3625
3622
reason.setAttrInvalid ();
@@ -3648,7 +3645,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3648
3645
checkVariadicParameters (PL, EED);
3649
3646
}
3650
3647
3651
- auto &DE = getASTContext () .Diags ;
3648
+ auto &DE = Ctx .Diags ;
3652
3649
// We don't yet support raw values on payload cases.
3653
3650
if (EED->hasAssociatedValues ()) {
3654
3651
if (auto rawTy = ED->getRawType ()) {
@@ -3843,10 +3840,11 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3843
3840
3844
3841
// Produce any diagnostics for the generic signature.
3845
3842
(void ) ED->getGenericSignature ();
3843
+ dumpGenericSignature (Ctx, ED);
3846
3844
3847
3845
checkInheritanceClause (ED);
3848
3846
3849
- diagnoseRetroactiveConformances (ED, getASTContext () .Diags );
3847
+ diagnoseRetroactiveConformances (ED, Ctx .Diags );
3850
3848
3851
3849
// Only generic and protocol types are permitted to have
3852
3850
// trailing where clauses.
@@ -3909,8 +3907,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3909
3907
void visitPoundDiagnosticDecl (PoundDiagnosticDecl *PDD) {
3910
3908
if (PDD->hasBeenEmitted ()) { return ; }
3911
3909
PDD->markEmitted ();
3912
- getASTContext ()
3913
- .Diags
3910
+ Ctx.Diags
3914
3911
.diagnose (PDD->getMessage ()->getStartLoc (),
3915
3912
PDD->isError () ? diag::pound_error : diag::pound_warning,
3916
3913
PDD->getMessage ()->getValue ())
@@ -3973,8 +3970,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3973
3970
} else {
3974
3971
CD->diagnose (diag::required_initializer_override_wrong_keyword)
3975
3972
.fixItReplace (attr->getLocation (), " required" );
3976
- CD->getAttrs ().add (new (getASTContext ())
3977
- RequiredAttr (/* IsImplicit=*/ true ));
3973
+ CD->getAttrs ().add (new (Ctx) RequiredAttr (/* IsImplicit=*/ true ));
3978
3974
}
3979
3975
3980
3976
auto *reqInit =
@@ -4016,8 +4012,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4016
4012
auto *reqInit = findNonImplicitRequiredInit (CD->getOverriddenDecl ());
4017
4013
reqInit->diagnose (diag::overridden_required_initializer_here);
4018
4014
4019
- CD->getAttrs ().add (new (getASTContext ())
4020
- RequiredAttr (/* IsImplicit=*/ true ));
4015
+ CD->getAttrs ().add (new (Ctx) RequiredAttr (/* IsImplicit=*/ true ));
4021
4016
}
4022
4017
}
4023
4018
@@ -4074,10 +4069,6 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4074
4069
}
4075
4070
4076
4071
void visitDestructorDecl (DestructorDecl *DD) {
4077
- auto haveFeature = [=](Feature f) -> bool {
4078
- return DD->getASTContext ().LangOpts .hasFeature (f);
4079
- };
4080
-
4081
4072
// Only check again for destructor decl outside of a class if our destructor
4082
4073
// is not marked as invalid.
4083
4074
if (!DD->isInvalid ()) {
@@ -4086,7 +4077,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4086
4077
if (!nom || isa<ProtocolDecl>(nom)) {
4087
4078
DD->diagnose (diag::destructor_decl_outside_class_or_noncopyable);
4088
4079
4089
- } else if (!haveFeature (Feature::NoncopyableGenerics)
4080
+ } else if (!Ctx. LangOpts . hasFeature (Feature::NoncopyableGenerics)
4090
4081
&& !isa<ClassDecl>(nom)
4091
4082
&& nom->canBeCopyable ()) {
4092
4083
// When we have NoncopyableGenerics, deinits get validated as part of
@@ -4096,7 +4087,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4096
4087
4097
4088
// Temporarily ban deinit on noncopyable enums, unless the experimental
4098
4089
// feature flag is set.
4099
- if (!haveFeature (Feature::MoveOnlyEnumDeinits)
4090
+ if (!Ctx. LangOpts . hasFeature (Feature::MoveOnlyEnumDeinits)
4100
4091
&& isa<EnumDecl>(nom)
4101
4092
&& !nom->canBeCopyable ()) {
4102
4093
DD->diagnose (diag::destructor_decl_on_noncopyable_enum);
0 commit comments