Skip to content

Commit 7cb1868

Browse files
authored
Merge pull request #75392 from hamishknight/yeet
[Sema] NFC: Remove `findLHS`
2 parents 900f1b5 + a00b003 commit 7cb1868

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

lib/Sema/TypeCheckExpr.cpp

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -191,58 +191,6 @@ TypeChecker::lookupPrecedenceGroupForInfixOperator(DeclContext *DC, Expr *E,
191191
return nullptr;
192192
}
193193

194-
/// Find LHS as if we append binary operator to existing pre-folded expression.
195-
/// Returns found expression, or \c nullptr if the operator is not applicable.
196-
///
197-
/// For example, given '(== R (* A B))':
198-
/// 'findLHS(DC, expr, "+")' returns '(* A B)'.
199-
/// 'findLHS(DC, expr, "<<")' returns 'B'.
200-
/// 'findLHS(DC, expr, '==')' returns nullptr.
201-
Expr *TypeChecker::findLHS(DeclContext *DC, Expr *E, Identifier name) {
202-
auto right = lookupPrecedenceGroupForOperator(DC, name, E->getEndLoc());
203-
if (!right)
204-
return nullptr;
205-
206-
while (true) {
207-
208-
// Look through implicit conversions.
209-
if (auto ICE = dyn_cast<ImplicitConversionExpr>(E)) {
210-
E = ICE->getSyntacticSubExpr();
211-
continue;
212-
}
213-
if (auto ACE = dyn_cast<AutoClosureExpr>(E)) {
214-
E = ACE->getSingleExpressionBody();
215-
continue;
216-
}
217-
218-
auto left = lookupPrecedenceGroupForInfixOperator(DC, E, /*diagnose=*/true);
219-
if (!left)
220-
// LHS is not binary expression.
221-
return E;
222-
switch (DC->getASTContext().associateInfixOperators(left, right)) {
223-
case swift::Associativity::None:
224-
return nullptr;
225-
case swift::Associativity::Left:
226-
return E;
227-
case swift::Associativity::Right:
228-
break;
229-
}
230-
// Find the RHS of the current binary expr.
231-
if (auto *assignExpr = dyn_cast<AssignExpr>(E)) {
232-
E = assignExpr->getSrc();
233-
} else if (auto *ternary = dyn_cast<TernaryExpr>(E)) {
234-
E = ternary->getElseExpr();
235-
} else if (auto *binaryExpr = dyn_cast<BinaryExpr>(E)) {
236-
E = binaryExpr->getRHS();
237-
} else {
238-
// E.g. 'fn() as Int << 2'.
239-
// In this case '<<' has higher precedence than 'as', but the LHS should
240-
// be 'fn() as Int' instead of 'Int'.
241-
return E;
242-
}
243-
}
244-
}
245-
246194
// The way we compute isEndOfSequence relies on the assumption that
247195
// the sequence-folding algorithm never recurses with a prefix of the
248196
// entire sequence.

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,6 @@ void addImplicitConstructors(NominalTypeDecl *typeDecl);
580580
/// tree.
581581
Expr *foldSequence(SequenceExpr *expr, DeclContext *dc);
582582

583-
/// Given an pre-folded expression, find LHS from the expression if a binary
584-
/// operator \c name appended to the expression.
585-
Expr *findLHS(DeclContext *DC, Expr *E, Identifier name);
586-
587583
/// Type check the given expression.
588584
///
589585
/// \param expr The expression to type-check, which will be modified in

0 commit comments

Comments
 (0)