@@ -98,9 +98,7 @@ class Path {
98
98
};
99
99
100
100
// / A helper class for performing a circularity check.
101
- class CircularityChecker {
102
- TypeChecker &TC;
103
-
101
+ class CircularityChecker final {
104
102
// / The original type declaration we're starting with.
105
103
NominalTypeDecl *OriginalDecl;
106
104
@@ -111,9 +109,9 @@ class CircularityChecker {
111
109
SmallVector<WorkItem, 8 > Workstack;
112
110
113
111
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) {}
117
115
118
116
void run ();
119
117
@@ -178,7 +176,7 @@ class CircularityChecker {
178
176
} // end anonymous namespace
179
177
180
178
void TypeChecker::checkDeclCircularity (NominalTypeDecl *decl) {
181
- CircularityChecker (* this , decl).run ();
179
+ CircularityChecker (decl).run ();
182
180
}
183
181
184
182
// / The main routine for performing circularity checks.
@@ -523,18 +521,12 @@ bool CircularityChecker::diagnoseCircularity(CanType parentType,
523
521
524
522
auto baseType = path[0 ].Ty ;
525
523
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);
529
525
} 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);
533
527
} 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 " );
538
530
} else {
539
531
llvm_unreachable (" what kind of entity was this?" );
540
532
}
@@ -545,12 +537,9 @@ bool CircularityChecker::diagnoseCircularity(CanType parentType,
545
537
llvm::raw_svector_ostream out (pathString);
546
538
path.printCycle (out, cycleIndex);
547
539
}
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);
551
541
} 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);
554
543
}
555
544
556
545
return true ;
@@ -573,19 +562,15 @@ bool CircularityChecker::diagnoseInfiniteRecursion(CanType parentType,
573
562
}
574
563
575
564
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);
579
566
580
567
// Add a note about the start of the path.
581
568
llvm::SmallString<128 > pathString; {
582
569
llvm::raw_svector_ostream out (pathString);
583
570
path.printInfinite (out);
584
571
}
585
572
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);
589
574
590
575
return true ;
591
576
}
@@ -628,5 +613,5 @@ void CircularityChecker::diagnoseNonWellFoundedEnum(EnumDecl *E) {
628
613
};
629
614
630
615
if (isNonWellFounded ())
631
- TC .diagnose (E, diag::enum_non_well_founded);
616
+ E-> getASTContext (). Diags .diagnose (E, diag::enum_non_well_founded);
632
617
}
0 commit comments