@@ -194,6 +194,8 @@ class ExpressionTimer {
194
194
195
195
AnchorType getAnchor () const { return Anchor; }
196
196
197
+ SourceRange getAffectedRange () const ;
198
+
197
199
unsigned getWarnLimit () const {
198
200
return Context.TypeCheckerOpts .WarnLongExpressionTypeChecking ;
199
201
}
@@ -5415,9 +5417,17 @@ class ConstraintSystem {
5415
5417
5416
5418
// / Determine if we've already explored too many paths in an
5417
5419
// / attempt to solve this expression.
5418
- bool isAlreadyTooComplex = false ;
5420
+ std::pair<bool , SourceRange> isAlreadyTooComplex = {false , SourceRange ()};
5421
+
5422
+ // / If optional is not nil, result is guaranteed to point at a valid
5423
+ // / location.
5424
+ Optional<SourceRange> getTooComplexRange () const {
5425
+ auto range = isAlreadyTooComplex.second ;
5426
+ return range.isValid () ? range : Optional<SourceRange>();
5427
+ }
5428
+
5419
5429
bool isTooComplex (size_t solutionMemory) {
5420
- if (isAlreadyTooComplex)
5430
+ if (isAlreadyTooComplex. first )
5421
5431
return true ;
5422
5432
5423
5433
auto CancellationFlag = getASTContext ().CancellationFlag ;
@@ -5428,7 +5438,9 @@ class ConstraintSystem {
5428
5438
MaxMemory = std::max (used, MaxMemory);
5429
5439
auto threshold = getASTContext ().TypeCheckerOpts .SolverMemoryThreshold ;
5430
5440
if (MaxMemory > threshold) {
5431
- return isAlreadyTooComplex= true ;
5441
+ // No particular location for OoM problems.
5442
+ isAlreadyTooComplex.first = true ;
5443
+ return true ;
5432
5444
}
5433
5445
5434
5446
if (Timer && Timer->isExpired ()) {
@@ -5437,20 +5449,22 @@ class ConstraintSystem {
5437
5449
// emitting an error.
5438
5450
Timer->disableWarning ();
5439
5451
5440
- return isAlreadyTooComplex = true ;
5452
+ isAlreadyTooComplex = {true , Timer->getAffectedRange ()};
5453
+ return true ;
5441
5454
}
5442
5455
5443
5456
// Bail out once we've looked at a really large number of
5444
5457
// choices.
5445
5458
if (CountScopes > getASTContext ().TypeCheckerOpts .SolverBindingThreshold ) {
5446
- return isAlreadyTooComplex = true ;
5459
+ isAlreadyTooComplex.first = true ;
5460
+ return true ;
5447
5461
}
5448
5462
5449
5463
return false ;
5450
5464
}
5451
5465
5452
5466
bool isTooComplex (SmallVectorImpl<Solution> const &solutions) {
5453
- if (isAlreadyTooComplex)
5467
+ if (isAlreadyTooComplex. first )
5454
5468
return true ;
5455
5469
5456
5470
size_t solutionMemory = 0 ;
0 commit comments