@@ -1782,25 +1782,29 @@ ConstraintSystem::filterDisjunction(
17821782 llvm::errs ().indent (indent) << " )\n " ;
17831783 }
17841784
1785- if (restoreOnFail)
1786- constraintsToRestoreOnFail.push_back (constraint);
1787-
17881785 if (!constraint->isDisabled ()) {
1789- if (solverState)
1786+ if (restoreOnFail)
1787+ constraintsToRestoreOnFail.push_back (constraint);
1788+ else if (solverState)
17901789 solverState->disableConstraint (constraint);
17911790 else
17921791 constraint->setDisabled ();
17931792 }
17941793 }
17951794
1796- switch (numEnabledTerms) {
1797- case 0 :
1795+ if (numEnabledTerms == 0 )
1796+ return SolutionKind::Error;
1797+
1798+ if (restoreOnFail) {
17981799 for (auto constraint : constraintsToRestoreOnFail) {
1799- constraint->setEnabled ();
1800+ if (solverState)
1801+ solverState->disableConstraint (constraint);
1802+ else
1803+ constraint->setDisabled ();
18001804 }
1801- return SolutionKind::Error;
1805+ }
18021806
1803- case 1 : {
1807+ if (numEnabledTerms == 1 ) {
18041808 // Only a single constraint remains. Retire the disjunction and make
18051809 // the remaining constraint active.
18061810 auto choice = disjunction->getNestedConstraints ()[choiceIdx];
@@ -1849,9 +1853,7 @@ ConstraintSystem::filterDisjunction(
18491853 return failedConstraint ? SolutionKind::Unsolved : SolutionKind::Solved;
18501854 }
18511855
1852- default :
1853- return SolutionKind::Unsolved;
1854- }
1856+ return SolutionKind::Unsolved;
18551857}
18561858
18571859// Attempt to find a disjunction of bind constraints where all options
0 commit comments