Skip to content

Commit d9b03a5

Browse files
authored
Merge pull request #28104 from CodaFi/broken-declspec
[NFC] Drop More Type Checkers
2 parents 069db6e + 35654f7 commit d9b03a5

13 files changed

+432
-437
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
7474

7575
case DeclContextKind::AbstractFunctionDecl: {
7676
auto *AFD = cast<AbstractFunctionDecl>(DC);
77-
typeCheckAbstractFunctionBodyUntil(AFD, Loc);
77+
swift::typeCheckAbstractFunctionBodyUntil(AFD, Loc);
7878
break;
7979
}
8080

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5604,7 +5604,7 @@ ClosureExpr *ExprRewriter::coerceClosureExprToVoid(ClosureExpr *closureExpr) {
56045604
cs.getType(singleExpr)->getWithoutSpecifierType());
56055605

56065606
cs.setExprTypes(singleExpr);
5607-
tc.checkIgnoredExpr(singleExpr);
5607+
TypeChecker::checkIgnoredExpr(singleExpr);
56085608

56095609
SmallVector<ASTNode, 2> elements;
56105610
elements.push_back(singleExpr);
@@ -5643,7 +5643,7 @@ ClosureExpr *ExprRewriter::coerceClosureExprFromNever(ClosureExpr *closureExpr)
56435643
auto singleExpr = returnStmt->getResult();
56445644

56455645
cs.setExprTypes(singleExpr);
5646-
tc.checkIgnoredExpr(singleExpr);
5646+
TypeChecker::checkIgnoredExpr(singleExpr);
56475647

56485648
SmallVector<ASTNode, 1> elements;
56495649
elements.push_back(singleExpr);

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2323,7 +2323,7 @@ namespace {
23232323
// Okay, now it should be safe to coerce the pattern.
23242324
// Pull the top-level pattern back out.
23252325
pattern = clause->getErrorPattern();
2326-
Type exnType = CS.TC.getExceptionType(CS.DC, clause->getCatchLoc());
2326+
Type exnType = CS.getASTContext().getErrorDecl()->getDeclaredType();
23272327
if (!exnType)
23282328
return false;
23292329
if (CS.TC.coercePatternToType(pattern,

lib/Sema/ResilienceDiagnostics.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,6 @@ TypeChecker::getFragileFunctionKind(const DeclContext *DC) {
8484
llvm_unreachable("Context is not nested inside a fragile function");
8585
}
8686

87-
void TypeChecker::diagnoseInlinableLocalType(const NominalTypeDecl *NTD) {
88-
auto *DC = NTD->getDeclContext();
89-
auto expansion = DC->getResilienceExpansion();
90-
if (expansion == ResilienceExpansion::Minimal) {
91-
auto kind = getFragileFunctionKind(DC);
92-
diagnose(NTD, diag::local_type_in_inlinable_function,
93-
NTD->getFullName(),
94-
static_cast<unsigned>(kind.first));
95-
}
96-
}
97-
9887
/// A uniquely-typed boolean to reduce the chances of accidentally inverting
9988
/// a check.
10089
enum class DowngradeToWarning: bool {

lib/Sema/TypeCheckCircularity.cpp

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ class Path {
9898
};
9999

100100
/// A helper class for performing a circularity check.
101-
class CircularityChecker {
102-
TypeChecker &TC;
103-
101+
class CircularityChecker final {
104102
/// The original type declaration we're starting with.
105103
NominalTypeDecl *OriginalDecl;
106104

@@ -111,9 +109,9 @@ class CircularityChecker {
111109
SmallVector<WorkItem, 8> Workstack;
112110

113111
public:
114-
CircularityChecker(TypeChecker &tc, NominalTypeDecl *typeDecl)
115-
: TC(tc), OriginalDecl(typeDecl),
116-
MaxDepth(tc.Context.LangOpts.MaxCircularityDepth) {}
112+
CircularityChecker(NominalTypeDecl *typeDecl)
113+
: OriginalDecl(typeDecl),
114+
MaxDepth(typeDecl->getASTContext().LangOpts.MaxCircularityDepth) {}
117115

118116
void run();
119117

@@ -178,7 +176,7 @@ class CircularityChecker {
178176
} // end anonymous namespace
179177

180178
void TypeChecker::checkDeclCircularity(NominalTypeDecl *decl) {
181-
CircularityChecker(*this, decl).run();
179+
CircularityChecker(decl).run();
182180
}
183181

184182
/// The main routine for performing circularity checks.
@@ -523,18 +521,12 @@ bool CircularityChecker::diagnoseCircularity(CanType parentType,
523521

524522
auto baseType = path[0].Ty;
525523
if (cycleIndex != 0) {
526-
TC.diagnose(OriginalDecl->getLoc(),
527-
diag::unsupported_infinitely_sized_type,
528-
baseType);
524+
OriginalDecl->diagnose(diag::unsupported_infinitely_sized_type, baseType);
529525
} else if (isa<StructDecl>(OriginalDecl)) {
530-
TC.diagnose(path[1].Member->getLoc(),
531-
diag::unsupported_recursive_struct,
532-
baseType);
526+
path[1].Member->diagnose(diag::unsupported_recursive_struct, baseType);
533527
} else if (isa<EnumDecl>(OriginalDecl)) {
534-
TC.diagnose(OriginalDecl->getLoc(),
535-
diag::recursive_enum_not_indirect,
536-
baseType)
537-
.fixItInsert(OriginalDecl->getStartLoc(), "indirect ");
528+
OriginalDecl->diagnose(diag::recursive_enum_not_indirect, baseType)
529+
.fixItInsert(OriginalDecl->getStartLoc(), "indirect ");
538530
} else {
539531
llvm_unreachable("what kind of entity was this?");
540532
}
@@ -545,12 +537,9 @@ bool CircularityChecker::diagnoseCircularity(CanType parentType,
545537
llvm::raw_svector_ostream out(pathString);
546538
path.printCycle(out, cycleIndex);
547539
}
548-
TC.diagnose(path[1].Member->getLoc(),
549-
diag::note_type_cycle_starts_here,
550-
pathString);
540+
path[1].Member->diagnose(diag::note_type_cycle_starts_here, pathString);
551541
} else if (isa<EnumDecl>(OriginalDecl)) {
552-
TC.diagnose(path[1].Member->getLoc(),
553-
diag::note_recursive_enum_case_here);
542+
path[1].Member->diagnose(diag::note_recursive_enum_case_here);
554543
}
555544

556545
return true;
@@ -573,19 +562,15 @@ bool CircularityChecker::diagnoseInfiniteRecursion(CanType parentType,
573562
}
574563

575564
auto baseType = path[0].Ty;
576-
TC.diagnose(OriginalDecl->getLoc(),
577-
diag::unsupported_infinitely_sized_type,
578-
baseType);
565+
OriginalDecl->diagnose(diag::unsupported_infinitely_sized_type, baseType);
579566

580567
// Add a note about the start of the path.
581568
llvm::SmallString<128> pathString; {
582569
llvm::raw_svector_ostream out(pathString);
583570
path.printInfinite(out);
584571
}
585572

586-
TC.diagnose(path[1].Member->getLoc(),
587-
diag::note_type_cycle_starts_here,
588-
pathString);
573+
path[1].Member->diagnose(diag::note_type_cycle_starts_here, pathString);
589574

590575
return true;
591576
}
@@ -628,5 +613,5 @@ void CircularityChecker::diagnoseNonWellFoundedEnum(EnumDecl *E) {
628613
};
629614

630615
if (isNonWellFounded())
631-
TC.diagnose(E, diag::enum_non_well_founded);
616+
E->getASTContext().Diags.diagnose(E, diag::enum_non_well_founded);
632617
}

0 commit comments

Comments
 (0)