1- // ===--- PreCheckExpr .cpp - Expression pre -checking pass ------------------===//
1+ // ===--- PreCheckTarget .cpp - Pre -checking pass --------- ------------------===//
22//
33// This source file is part of the Swift.org open source project
44//
@@ -1036,7 +1036,7 @@ void markDirectCallee(Expr *callee) {
10361036 }
10371037}
10381038
1039- class PreCheckExpression : public ASTWalker {
1039+ class PreCheckTarget final : public ASTWalker {
10401040 ASTContext &Ctx;
10411041 DeclContext *DC;
10421042
@@ -1101,7 +1101,7 @@ class PreCheckExpression : public ASTWalker {
11011101 void markAcceptableDiscardExprs (Expr *E);
11021102
11031103public:
1104- PreCheckExpression (DeclContext *dc) : Ctx(dc->getASTContext ()), DC(dc) {}
1104+ PreCheckTarget (DeclContext *dc) : Ctx(dc->getASTContext ()), DC(dc) {}
11051105
11061106 ASTContext &getASTContext () const { return Ctx; }
11071107
@@ -1475,7 +1475,7 @@ class PreCheckExpression : public ASTWalker {
14751475
14761476// / Perform prechecking of a ClosureExpr before we dive into it. This returns
14771477// / true when we want the body to be considered part of this larger expression.
1478- bool PreCheckExpression ::walkToClosureExprPre (ClosureExpr *closure) {
1478+ bool PreCheckTarget ::walkToClosureExprPre (ClosureExpr *closure) {
14791479 // Pre-check the closure body.
14801480 (void )evaluateOrDefault (Ctx.evaluator , PreCheckClosureBodyRequest{closure},
14811481 nullptr );
@@ -1489,7 +1489,7 @@ bool PreCheckExpression::walkToClosureExprPre(ClosureExpr *closure) {
14891489 return true ;
14901490}
14911491
1492- TypeExpr *PreCheckExpression ::simplifyNestedTypeExpr (UnresolvedDotExpr *UDE) {
1492+ TypeExpr *PreCheckTarget ::simplifyNestedTypeExpr (UnresolvedDotExpr *UDE) {
14931493 if (!UDE->getName ().isSimpleName () ||
14941494 UDE->getName ().isSpecial ())
14951495 return nullptr ;
@@ -1612,7 +1612,7 @@ TypeExpr *PreCheckExpression::simplifyNestedTypeExpr(UnresolvedDotExpr *UDE) {
16121612 return nullptr ;
16131613}
16141614
1615- TypeExpr *PreCheckExpression ::simplifyUnresolvedSpecializeExpr (
1615+ TypeExpr *PreCheckTarget ::simplifyUnresolvedSpecializeExpr (
16161616 UnresolvedSpecializeExpr *us) {
16171617 // If this is a reference type a specialized type, form a TypeExpr.
16181618 // The base should be a TypeExpr that we already resolved.
@@ -1630,7 +1630,7 @@ TypeExpr *PreCheckExpression::simplifyUnresolvedSpecializeExpr(
16301630
16311631// / Whether the given expression "looks like" a (possibly sugared) type. For
16321632// / example, `(foo, bar)` "looks like" a type, but `foo + bar` does not.
1633- bool PreCheckExpression ::exprLooksLikeAType (Expr *expr) {
1633+ bool PreCheckTarget ::exprLooksLikeAType (Expr *expr) {
16341634 return isa<OptionalEvaluationExpr>(expr) ||
16351635 isa<BindOptionalExpr>(expr) ||
16361636 isa<ForceValueExpr>(expr) ||
@@ -1646,7 +1646,7 @@ bool PreCheckExpression::exprLooksLikeAType(Expr *expr) {
16461646 getCompositionExpr (expr);
16471647}
16481648
1649- bool PreCheckExpression ::possiblyInTypeContext (Expr *E) {
1649+ bool PreCheckTarget ::possiblyInTypeContext (Expr *E) {
16501650 // Walk back up the stack of parents looking for a valid type context.
16511651 for (auto *ParentExpr : llvm::reverse (ExprStack)) {
16521652 // We're considered to be in a type context if either:
@@ -1666,7 +1666,7 @@ bool PreCheckExpression::possiblyInTypeContext(Expr *E) {
16661666
16671667// / Only allow simplification of a DiscardAssignmentExpr if it hasn't already
16681668// / been explicitly marked as correct, and the current AST state allows it.
1669- bool PreCheckExpression ::canSimplifyDiscardAssignmentExpr (
1669+ bool PreCheckTarget ::canSimplifyDiscardAssignmentExpr (
16701670 DiscardAssignmentExpr *DAE) {
16711671 return !CorrectDiscardAssignmentExprs.count (DAE) &&
16721672 possiblyInTypeContext (DAE);
@@ -1676,7 +1676,7 @@ bool PreCheckExpression::canSimplifyDiscardAssignmentExpr(
16761676// / In Swift < 5, diagnose and correct invalid multi-argument or
16771677// / argument-labeled interpolations. Returns \c true if the AST walk should
16781678// / continue, or \c false if it should be aborted.
1679- bool PreCheckExpression ::correctInterpolationIfStrange (
1679+ bool PreCheckTarget ::correctInterpolationIfStrange (
16801680 InterpolatedStringLiteralExpr *ISLE) {
16811681 // These expressions are valid in Swift 5+.
16821682 if (getASTContext ().isSwiftVersionAtLeast (5 ))
@@ -1799,7 +1799,7 @@ bool PreCheckExpression::correctInterpolationIfStrange(
17991799// / Scout out the specified destination of an AssignExpr to recursively
18001800// / identify DiscardAssignmentExpr in legal places. We can only allow them
18011801// / in simple pattern-like expressions, so we reject anything complex here.
1802- void PreCheckExpression ::markAcceptableDiscardExprs (Expr *E) {
1802+ void PreCheckTarget ::markAcceptableDiscardExprs (Expr *E) {
18031803 if (!E) return ;
18041804
18051805 if (auto *PE = dyn_cast<ParenExpr>(E))
@@ -1817,7 +1817,7 @@ void PreCheckExpression::markAcceptableDiscardExprs(Expr *E) {
18171817 // Otherwise, we can't support this.
18181818}
18191819
1820- VarDecl *PreCheckExpression ::getImplicitSelfDeclForSuperContext (SourceLoc Loc) {
1820+ VarDecl *PreCheckTarget ::getImplicitSelfDeclForSuperContext (SourceLoc Loc) {
18211821 auto *methodContext = DC->getInnermostMethodContext ();
18221822
18231823 if (auto *typeContext = DC->getInnermostTypeContext ()) {
@@ -1884,7 +1884,7 @@ static bool isTildeOperator(Expr *expr) {
18841884// / Simplify expressions which are type sugar productions that got parsed
18851885// / as expressions due to the parser not knowing which identifiers are
18861886// / type names.
1887- TypeExpr *PreCheckExpression ::simplifyTypeExpr (Expr *E) {
1887+ TypeExpr *PreCheckTarget ::simplifyTypeExpr (Expr *E) {
18881888 // If it's already a type expression, return it.
18891889 if (auto typeExpr = dyn_cast<TypeExpr>(E))
18901890 return typeExpr;
@@ -2207,7 +2207,7 @@ TypeExpr *PreCheckExpression::simplifyTypeExpr(Expr *E) {
22072207 return nullptr ;
22082208}
22092209
2210- void PreCheckExpression ::resolveKeyPathExpr (KeyPathExpr *KPE) {
2210+ void PreCheckTarget ::resolveKeyPathExpr (KeyPathExpr *KPE) {
22112211 if (KPE->isObjC ())
22122212 return ;
22132213
@@ -2353,7 +2353,7 @@ void PreCheckExpression::resolveKeyPathExpr(KeyPathExpr *KPE) {
23532353 KPE->setComponents (getASTContext (), components);
23542354}
23552355
2356- Expr *PreCheckExpression ::simplifyTypeConstructionWithLiteralArg (Expr *E) {
2356+ Expr *PreCheckTarget ::simplifyTypeConstructionWithLiteralArg (Expr *E) {
23572357 // If constructor call is expected to produce an optional let's not attempt
23582358 // this optimization because literal initializers aren't failable.
23592359 if (!getASTContext ().LangOpts .isSwiftVersionAtLeast (5 )) {
@@ -2429,7 +2429,7 @@ bool ConstraintSystem::preCheckTarget(SyntacticElementTarget &target) {
24292429 auto &ctx = DC->getASTContext ();
24302430
24312431 FrontendStatsTracer StatsTracer (ctx.Stats , " precheck-target" );
2432- PreCheckExpression preCheck (DC);
2432+ PreCheckTarget preCheck (DC);
24332433
24342434 auto newTarget = target.walk (preCheck);
24352435 if (!newTarget)
0 commit comments