Skip to content

Commit 0b656ff

Browse files
AnthonyLatsisCatfish-Man
authored andcommitted
CSRanking: Check for timeouts during solution comparisons, which are time-consuming
1 parent 4dc6ba4 commit 0b656ff

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5665,7 +5665,7 @@ class ConstraintSystem {
56655665
return false;
56665666
}
56675667

5668-
bool isTooComplex(SmallVectorImpl<Solution> const &solutions) {
5668+
bool isTooComplex(ArrayRef<Solution> solutions) {
56695669
if (isAlreadyTooComplex.first)
56705670
return true;
56715671

lib/Sema/CSRanking.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,10 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
14531453
bestIdx = i;
14541454
break;
14551455
}
1456+
1457+
// Give up if we're out of time.
1458+
if (isTooComplex(/*solutions=*/{}))
1459+
return None;
14561460
}
14571461

14581462
// Make sure that our current best is better than all of the solved systems.
@@ -1483,6 +1487,10 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
14831487
ambiguous = true;
14841488
break;
14851489
}
1490+
1491+
// Give up if we're out of time.
1492+
if (isTooComplex(/*solutions=*/{}))
1493+
return None;
14861494
}
14871495

14881496
// If the result was not ambiguous, we're done.

0 commit comments

Comments
 (0)