Skip to content

Commit d31f6ed

Browse files
committed
Drop the ASTContext parameter on FindCapturedVars
Just get it from the decl context
1 parent 4cd873a commit d31f6ed

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/Sema/TypeCheckCaptures.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ class FindCapturedVars : public ASTWalker {
4545
bool NoEscape, ObjC, IsGenericFunction;
4646

4747
public:
48-
FindCapturedVars(ASTContext &Context,
49-
SourceLoc CaptureLoc,
48+
FindCapturedVars(SourceLoc CaptureLoc,
5049
DeclContext *CurDC,
5150
bool NoEscape,
5251
bool ObjC,
5352
bool IsGenericFunction)
54-
: Context(Context), CaptureLoc(CaptureLoc), CurDC(CurDC),
53+
: Context(CurDC->getASTContext()), CaptureLoc(CaptureLoc), CurDC(CurDC),
5554
NoEscape(NoEscape), ObjC(ObjC), IsGenericFunction(IsGenericFunction) {}
5655

5756
CaptureInfo getCaptureInfo() const {
@@ -595,8 +594,7 @@ void TypeChecker::computeCaptures(AnyFunctionRef AFR) {
595594
isGeneric = (AFD->getGenericParams() != nullptr);
596595

597596
auto &Context = AFR.getAsDeclContext()->getASTContext();
598-
FindCapturedVars finder(Context,
599-
AFR.getLoc(),
597+
FindCapturedVars finder(AFR.getLoc(),
600598
AFR.getAsDeclContext(),
601599
AFR.isKnownNoEscape(),
602600
AFR.isObjC(),
@@ -613,8 +611,7 @@ void TypeChecker::computeCaptures(AnyFunctionRef AFR) {
613611
if (auto *AFD = AFR.getAbstractFunctionDecl()) {
614612
for (auto *P : *AFD->getParameters()) {
615613
if (auto E = P->getTypeCheckedDefaultExpr()) {
616-
FindCapturedVars finder(Context,
617-
E->getLoc(),
614+
FindCapturedVars finder(E->getLoc(),
618615
AFD,
619616
/*isNoEscape=*/false,
620617
/*isObjC=*/false,
@@ -680,14 +677,15 @@ void TypeChecker::checkPatternBindingCaptures(NominalTypeDecl *typeDecl) {
680677
if (init == nullptr)
681678
continue;
682679

683-
FindCapturedVars finder(ctx,
684-
init->getLoc(),
685-
PBD->getInitContext(i),
680+
auto *DC = PBD->getInitContext(i);
681+
FindCapturedVars finder(init->getLoc(),
682+
DC,
686683
/*NoEscape=*/false,
687684
/*ObjC=*/false,
688685
/*IsGenericFunction*/false);
689686
init->walk(finder);
690687

688+
auto &ctx = DC->getASTContext();
691689
if (finder.getDynamicSelfCaptureLoc().isValid() && !isLazy(PBD)) {
692690
ctx.Diags.diagnose(finder.getDynamicSelfCaptureLoc(),
693691
diag::dynamic_self_stored_property_init);

0 commit comments

Comments
 (0)