[ConstraintSolver] Refactor solveSimplified to consolidate disjunction choice attributes/operations

Consolidate some of the attributes and operations common to disjunction choice
in new `DisjunctionChoice` class, which simplifies implementation of the
`ConstraintSystem::solveSimplified` method related to overload selection.
This commit is contained in:
Pavel Yaskevich
2017-05-26 23:32:31 -07:00
parent e73e11be4a
commit 817b86f9bf
3 changed files with 123 additions and 76 deletions

View File

@@ -4986,3 +4986,26 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
llvm_unreachable("Unhandled ConstraintKind in switch.");
}
void ConstraintSystem::simplifyDisjunctionChoice(Constraint *choice) {
// Simplify this term in the disjunction.
switch (simplifyConstraint(*choice)) {
case ConstraintSystem::SolutionKind::Error:
if (!failedConstraint)
failedConstraint = choice;
solverState->retireConstraint(choice);
break;
case ConstraintSystem::SolutionKind::Solved:
solverState->retireConstraint(choice);
break;
case ConstraintSystem::SolutionKind::Unsolved:
InactiveConstraints.push_back(choice);
CG.addConstraint(choice);
break;
}
// Record this as a generated constraint.
solverState->addGeneratedConstraint(choice);
}