@@ -5671,13 +5671,22 @@ class ConstraintSystem {
5671
5671
if (CancellationFlag && CancellationFlag->load (std::memory_order_relaxed))
5672
5672
return true ;
5673
5673
5674
+ auto markTooComplex = [&](SourceRange range, StringRef reason) {
5675
+ if (isDebugMode ()) {
5676
+ if (solverState)
5677
+ llvm::errs ().indent (solverState->getCurrentIndent ());
5678
+ llvm::errs () << " (too complex: " << reason << " )\n " ;
5679
+ }
5680
+ isAlreadyTooComplex = {true , range};
5681
+ return true ;
5682
+ };
5683
+
5674
5684
auto used = getASTContext ().getSolverMemory () + solutionMemory;
5675
5685
MaxMemory = std::max (used, MaxMemory);
5676
5686
auto threshold = getASTContext ().TypeCheckerOpts .SolverMemoryThreshold ;
5677
5687
if (MaxMemory > threshold) {
5678
5688
// No particular location for OoM problems.
5679
- isAlreadyTooComplex.first = true ;
5680
- return true ;
5689
+ return markTooComplex (SourceRange (), " exceeded memory limit" );
5681
5690
}
5682
5691
5683
5692
if (Timer && Timer->isExpired ()) {
@@ -5686,23 +5695,18 @@ class ConstraintSystem {
5686
5695
// emitting an error.
5687
5696
Timer->disableWarning ();
5688
5697
5689
- isAlreadyTooComplex = {true , Timer->getAffectedRange ()};
5690
- return true ;
5698
+ return markTooComplex (Timer->getAffectedRange (), " exceeded time limit" );
5691
5699
}
5692
5700
5693
5701
auto &opts = getASTContext ().TypeCheckerOpts ;
5694
5702
5695
5703
// Bail out once we've looked at a really large number of choices.
5696
- if (opts.SolverScopeThreshold && NumSolverScopes > opts.SolverScopeThreshold ) {
5697
- isAlreadyTooComplex.first = true ;
5698
- return true ;
5699
- }
5704
+ if (opts.SolverScopeThreshold && NumSolverScopes > opts.SolverScopeThreshold )
5705
+ return markTooComplex (SourceRange (), " exceeded scope limit" );
5700
5706
5701
5707
// Bail out once we've taken a really large number of steps.
5702
- if (opts.SolverTrailThreshold && NumTrailSteps > opts.SolverTrailThreshold ) {
5703
- isAlreadyTooComplex.first = true ;
5704
- return true ;
5705
- }
5708
+ if (opts.SolverTrailThreshold && NumTrailSteps > opts.SolverTrailThreshold )
5709
+ return markTooComplex (SourceRange (), " exceeded trail limit" );
5706
5710
5707
5711
return false ;
5708
5712
}
0 commit comments