[Constraint solver] Move tryOptimizeGenericDisjunction() into partitioning

This narrow favoring rule makes more sense as part of disjunction
partitioning, because it is not dependent on the use site at all and
should only kick in when other options fail.
This commit is contained in:
Doug Gregor
2019-03-05 13:41:25 -08:00
parent fae2d1b2ac
commit b993c6e076
4 changed files with 82 additions and 92 deletions

View File

@@ -5036,34 +5036,6 @@ retry_after_fail:
break;
}
// Collect the active overload choices.
SmallVector<OverloadChoice, 4> choices;
for (auto constraint : disjunction->getNestedConstraints()) {
if (constraint->isDisabled())
continue;
choices.push_back(constraint->getOverloadChoice());
}
// If we can favor one generic result over another, do so.
if (auto favoredChoice = tryOptimizeGenericDisjunction(choices)) {
unsigned favoredIndex = favoredChoice - choices.data();
for (auto constraint : disjunction->getNestedConstraints()) {
if (constraint->isDisabled())
continue;
if (favoredIndex == 0) {
if (solverState)
solverState->favorConstraint(constraint);
else
constraint->setFavored();
break;
} else {
--favoredIndex;
}
}
}
// If there was a constraint that we couldn't reason about, don't use the
// results of any common-type computations.
if (hasUnhandledConstraints)