Skip to content

Commit 7dab90c

Browse files
committed
[ConstraintSystem] NFC: Drop Expression from isTooComplex check
Solver can now handle multiple different targets e.g. multi-statement closures, result builders etc. So it's more appropriate to say that the constraint system is too complex.
1 parent e2b4759 commit 7dab90c

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5415,9 +5415,9 @@ class ConstraintSystem {
54155415

54165416
/// Determine if we've already explored too many paths in an
54175417
/// attempt to solve this expression.
5418-
bool isExpressionAlreadyTooComplex = false;
5419-
bool getExpressionTooComplex(size_t solutionMemory) {
5420-
if (isExpressionAlreadyTooComplex)
5418+
bool isAlreadyTooComplex = false;
5419+
bool isTooComplex(size_t solutionMemory) {
5420+
if (isAlreadyTooComplex)
54215421
return true;
54225422

54235423
auto CancellationFlag = getASTContext().CancellationFlag;
@@ -5428,7 +5428,7 @@ class ConstraintSystem {
54285428
MaxMemory = std::max(used, MaxMemory);
54295429
auto threshold = getASTContext().TypeCheckerOpts.SolverMemoryThreshold;
54305430
if (MaxMemory > threshold) {
5431-
return isExpressionAlreadyTooComplex= true;
5431+
return isAlreadyTooComplex= true;
54325432
}
54335433

54345434
if (Timer && Timer->isExpired()) {
@@ -5437,27 +5437,27 @@ class ConstraintSystem {
54375437
// emitting an error.
54385438
Timer->disableWarning();
54395439

5440-
return isExpressionAlreadyTooComplex = true;
5440+
return isAlreadyTooComplex = true;
54415441
}
54425442

54435443
// Bail out once we've looked at a really large number of
54445444
// choices.
54455445
if (CountScopes > getASTContext().TypeCheckerOpts.SolverBindingThreshold) {
5446-
return isExpressionAlreadyTooComplex = true;
5446+
return isAlreadyTooComplex = true;
54475447
}
54485448

54495449
return false;
54505450
}
54515451

5452-
bool getExpressionTooComplex(SmallVectorImpl<Solution> const &solutions) {
5453-
if (isExpressionAlreadyTooComplex)
5452+
bool isTooComplex(SmallVectorImpl<Solution> const &solutions) {
5453+
if (isAlreadyTooComplex)
54545454
return true;
54555455

54565456
size_t solutionMemory = 0;
54575457
for (auto const& s : solutions) {
54585458
solutionMemory += s.getTotalMemory();
54595459
}
5460-
return getExpressionTooComplex(solutionMemory);
5460+
return isTooComplex(solutionMemory);
54615461
}
54625462

54635463
// If the given constraint is an applied disjunction, get the argument function

lib/Sema/CSSolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ ConstraintSystem::solveImpl(SolutionApplicationTarget &target,
13741374
SmallVector<Solution, 4> solutions;
13751375
solve(solutions, allowFreeTypeVariables);
13761376

1377-
if (getExpressionTooComplex(solutions))
1377+
if (isTooComplex(solutions))
13781378
return SolutionResult::forTooComplex();
13791379

13801380
switch (solutions.size()) {
@@ -1415,7 +1415,7 @@ bool ConstraintSystem::solve(SmallVectorImpl<Solution> &solutions,
14151415
filterSolutions(solutions);
14161416

14171417
// We fail if there is no solution or the expression was too complex.
1418-
return solutions.empty() || getExpressionTooComplex(solutions);
1418+
return solutions.empty() || isTooComplex(solutions);
14191419
}
14201420

14211421
void ConstraintSystem::solveImpl(SmallVectorImpl<Solution> &solutions) {

lib/Sema/CSStep.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ bool SplitterStep::mergePartialSolutions() const {
251251

252252
// Since merging partial solutions can go exponential, make sure we didn't
253253
// pass the "too complex" thresholds including allocated memory and time.
254-
if (CS.getExpressionTooComplex(solutionMemory))
254+
if (CS.isTooComplex(solutionMemory))
255255
return false;
256256

257257
} while (nextCombination(counts, indices));
@@ -313,7 +313,7 @@ StepResult ComponentStep::take(bool prevFailed) {
313313
// One of the previous components created by "split"
314314
// failed, it means that we can't solve this component.
315315
if ((prevFailed && DependsOnPartialSolutions.empty()) ||
316-
CS.getExpressionTooComplex(Solutions))
316+
CS.isTooComplex(Solutions))
317317
return done(/*isSuccess=*/false);
318318

319319
// Setup active scope, only if previous component didn't fail.

lib/Sema/CSStep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ template <typename P> class BindingStep : public SolverStep {
506506
StepResult take(bool prevFailed) override {
507507
// Before attempting the next choice, let's check whether the constraint
508508
// system is too complex already.
509-
if (CS.getExpressionTooComplex(Solutions))
509+
if (CS.isTooComplex(Solutions))
510510
return done(/*isSuccess=*/false);
511511

512512
while (auto choice = Producer()) {

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3776,7 +3776,7 @@ SolutionResult ConstraintSystem::salvage() {
37763776
// Fall through to produce diagnostics.
37773777
}
37783778

3779-
if (getExpressionTooComplex(viable))
3779+
if (isTooComplex(viable))
37803780
return SolutionResult::forTooComplex();
37813781

37823782
// Could not produce a specific diagnostic; punt to the client.

0 commit comments

Comments
 (0)