@@ -71,7 +71,10 @@ class SyntacticElementTarget {
7171 caseLabelItem,
7272 patternBinding,
7373 uninitializedVar,
74- forEachStmt,
74+
75+ // / The preamble of a for-in statement, including everything except the
76+ // / body.
77+ forEachPreamble,
7578 } kind;
7679
7780private:
@@ -245,7 +248,7 @@ class SyntacticElementTarget {
245248 SyntacticElementTarget (ForEachStmt *stmt, DeclContext *dc,
246249 bool ignoreWhereClause,
247250 GenericEnvironment *packElementEnv)
248- : kind(Kind::forEachStmt ) {
251+ : kind(Kind::forEachPreamble ) {
249252 forEachStmt.stmt = stmt;
250253 forEachStmt.dc = dc;
251254 forEachStmt.ignoreWhereClause = ignoreWhereClause;
@@ -268,11 +271,11 @@ class SyntacticElementTarget {
268271 static SyntacticElementTarget
269272 forReturn (ReturnStmt *returnStmt, Type contextTy, DeclContext *dc);
270273
271- // / Form a target for a for-in loop.
274+ // / Form a target for the preamble of a for-in loop, excluding its body .
272275 static SyntacticElementTarget
273- forForEachStmt (ForEachStmt *stmt, DeclContext *dc,
274- bool ignoreWhereClause = false ,
275- GenericEnvironment *packElementEnv = nullptr );
276+ forForEachPreamble (ForEachStmt *stmt, DeclContext *dc,
277+ bool ignoreWhereClause = false ,
278+ GenericEnvironment *packElementEnv = nullptr );
276279
277280 // / Form a target for a property with an attached property wrapper that is
278281 // / initialized out-of-line.
@@ -311,7 +314,7 @@ class SyntacticElementTarget {
311314 return ref.getAbstractClosureExpr ();
312315 }
313316
314- case Kind::forEachStmt :
317+ case Kind::forEachPreamble :
315318 return getAsForEachStmt ();
316319
317320 case Kind::stmtCondition:
@@ -339,7 +342,7 @@ class SyntacticElementTarget {
339342 case Kind::caseLabelItem:
340343 case Kind::patternBinding:
341344 case Kind::uninitializedVar:
342- case Kind::forEachStmt :
345+ case Kind::forEachPreamble :
343346 return nullptr ;
344347 }
345348 llvm_unreachable (" invalid expression type" );
@@ -372,7 +375,7 @@ class SyntacticElementTarget {
372375 return uninitializedVar.binding ->getInitContext (uninitializedVar.index );
373376 }
374377
375- case Kind::forEachStmt :
378+ case Kind::forEachPreamble :
376379 return forEachStmt.dc ;
377380 }
378381 llvm_unreachable (" invalid decl context type" );
@@ -477,8 +480,8 @@ class SyntacticElementTarget {
477480 // / For a pattern initialization target, retrieve the contextual pattern.
478481 ContextualPattern getContextualPattern () const ;
479482
480- // / Whether this target is for a for-in statement .
481- bool isForEachStmt () const { return kind == Kind::forEachStmt ; }
483+ // / Whether this target is for a for-in preamble, excluding the body .
484+ bool isForEachPreamble () const { return kind == Kind::forEachPreamble ; }
482485
483486 // / Whether this is an initialization for an Optional.Some pattern.
484487 bool isOptionalSomePatternInit () const {
@@ -502,7 +505,7 @@ class SyntacticElementTarget {
502505 bool shouldBindPatternVarsOneWay () const {
503506 if (kind == Kind::expression)
504507 return expression.bindPatternVarsOneWay ;
505- if (kind == Kind::forEachStmt )
508+ if (kind == Kind::forEachPreamble )
506509 return !ignoreForEachWhereClause () && forEachStmt.stmt ->getWhere ();
507510 return false ;
508511 }
@@ -553,22 +556,22 @@ class SyntacticElementTarget {
553556 }
554557
555558 bool ignoreForEachWhereClause () const {
556- assert (isForEachStmt ());
559+ assert (isForEachPreamble ());
557560 return forEachStmt.ignoreWhereClause ;
558561 }
559562
560563 GenericEnvironment *getPackElementEnv () const {
561- assert (isForEachStmt ());
564+ assert (isForEachPreamble ());
562565 return forEachStmt.packElementEnv ;
563566 }
564567
565568 const ForEachStmtInfo &getForEachStmtInfo () const {
566- assert (isForEachStmt ());
569+ assert (isForEachPreamble ());
567570 return forEachStmt.info ;
568571 }
569572
570573 ForEachStmtInfo &getForEachStmtInfo () {
571- assert (isForEachStmt ());
574+ assert (isForEachPreamble ());
572575 return forEachStmt.info ;
573576 }
574577
@@ -595,7 +598,7 @@ class SyntacticElementTarget {
595598 return ;
596599 }
597600
598- if (kind == Kind::forEachStmt ) {
601+ if (kind == Kind::forEachPreamble ) {
599602 forEachStmt.pattern = pattern;
600603 return ;
601604 }
@@ -621,7 +624,7 @@ class SyntacticElementTarget {
621624 case Kind::caseLabelItem:
622625 case Kind::patternBinding:
623626 case Kind::uninitializedVar:
624- case Kind::forEachStmt :
627+ case Kind::forEachPreamble :
625628 return std::nullopt ;
626629
627630 case Kind::function:
@@ -638,7 +641,7 @@ class SyntacticElementTarget {
638641 case Kind::caseLabelItem:
639642 case Kind::patternBinding:
640643 case Kind::uninitializedVar:
641- case Kind::forEachStmt :
644+ case Kind::forEachPreamble :
642645 return std::nullopt ;
643646
644647 case Kind::stmtCondition:
@@ -655,7 +658,7 @@ class SyntacticElementTarget {
655658 case Kind::stmtCondition:
656659 case Kind::patternBinding:
657660 case Kind::uninitializedVar:
658- case Kind::forEachStmt :
661+ case Kind::forEachPreamble :
659662 return std::nullopt ;
660663
661664 case Kind::caseLabelItem:
@@ -672,7 +675,7 @@ class SyntacticElementTarget {
672675 case Kind::stmtCondition:
673676 case Kind::caseLabelItem:
674677 case Kind::uninitializedVar:
675- case Kind::forEachStmt :
678+ case Kind::forEachPreamble :
676679 return nullptr ;
677680
678681 case Kind::patternBinding:
@@ -689,7 +692,7 @@ class SyntacticElementTarget {
689692 case Kind::stmtCondition:
690693 case Kind::caseLabelItem:
691694 case Kind::patternBinding:
692- case Kind::forEachStmt :
695+ case Kind::forEachPreamble :
693696 return nullptr ;
694697
695698 case Kind::uninitializedVar:
@@ -706,7 +709,7 @@ class SyntacticElementTarget {
706709 case Kind::stmtCondition:
707710 case Kind::caseLabelItem:
708711 case Kind::patternBinding:
709- case Kind::forEachStmt :
712+ case Kind::forEachPreamble :
710713 return nullptr ;
711714
712715 case Kind::uninitializedVar:
@@ -726,7 +729,7 @@ class SyntacticElementTarget {
726729 case Kind::uninitializedVar:
727730 return nullptr ;
728731
729- case Kind::forEachStmt :
732+ case Kind::forEachPreamble :
730733 return forEachStmt.stmt ;
731734 }
732735 llvm_unreachable (" invalid case label type" );
@@ -740,7 +743,7 @@ class SyntacticElementTarget {
740743 case Kind::stmtCondition:
741744 case Kind::caseLabelItem:
742745 case Kind::patternBinding:
743- case Kind::forEachStmt :
746+ case Kind::forEachPreamble :
744747 return nullptr ;
745748
746749 case Kind::uninitializedVar:
@@ -757,7 +760,7 @@ class SyntacticElementTarget {
757760 case Kind::stmtCondition:
758761 case Kind::caseLabelItem:
759762 case Kind::patternBinding:
760- case Kind::forEachStmt :
763+ case Kind::forEachPreamble :
761764 return nullptr ;
762765
763766 case Kind::uninitializedVar:
@@ -774,7 +777,7 @@ class SyntacticElementTarget {
774777 case Kind::stmtCondition:
775778 case Kind::caseLabelItem:
776779 case Kind::patternBinding:
777- case Kind::forEachStmt :
780+ case Kind::forEachPreamble :
778781 return 0 ;
779782
780783 case Kind::uninitializedVar:
@@ -837,8 +840,8 @@ class SyntacticElementTarget {
837840 return uninitializedVar.declaration .get <Pattern *>()->getSourceRange ();
838841 }
839842
840- // For-in statement target doesn't cover the body.
841- case Kind::forEachStmt :
843+ // For-in preamble target doesn't cover the body.
844+ case Kind::forEachPreamble :
842845 auto *stmt = forEachStmt.stmt ;
843846 SourceLoc startLoc = stmt->getForLoc ();
844847 SourceLoc endLoc = stmt->getParsedSequence ()->getEndLoc ();
@@ -881,7 +884,7 @@ class SyntacticElementTarget {
881884 return uninitializedVar.declaration .get <Pattern *>()->getLoc ();
882885 }
883886
884- case Kind::forEachStmt :
887+ case Kind::forEachPreamble :
885888 return forEachStmt.stmt ->getStartLoc ();
886889 }
887890 llvm_unreachable (" invalid target type" );
0 commit comments