Skip to content

Commit 65def07

Browse files
committed
Sema: Remove similar weirdness from ~ConjunctionStep
1 parent e0b6a96 commit 65def07

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

lib/Sema/CSStep.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,12 @@ StepResult ComponentStep::take(bool prevFailed) {
430430
return suspend(
431431
std::make_unique<DisjunctionStep>(CS, disjunction, Solutions));
432432
}
433-
case StepKind::Conjunction:
433+
case StepKind::Conjunction: {
434+
CS.retireConstraint(conjunction);
434435
return suspend(
435436
std::make_unique<ConjunctionStep>(CS, conjunction, Solutions));
436437
}
438+
}
437439
llvm_unreachable("Unhandled case in switch!");
438440
}
439441

lib/Sema/CSStep.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,6 @@ class SolverStep {
202202
return StepResult::unsolved(followup);
203203
}
204204

205-
/// Erase constraint from the constraint system (include constraint graph)
206-
/// and return the constraint which follows it.
207-
ConstraintList::iterator erase(Constraint *constraint) {
208-
CS.CG.removeConstraint(constraint);
209-
return CS.InactiveConstraints.erase(constraint);
210-
}
211-
212-
void restore(ConstraintList::iterator &iterator, Constraint *constraint) {
213-
CS.InactiveConstraints.insert(iterator, constraint);
214-
CS.CG.addConstraint(constraint);
215-
}
216-
217205
void recordDisjunctionChoice(ConstraintLocator *disjunctionLocator,
218206
unsigned index) const {
219207
CS.recordDisjunctionChoice(disjunctionLocator, index);
@@ -915,10 +903,6 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
915903

916904
/// Conjunction constraint associated with this step.
917905
Constraint *Conjunction;
918-
/// Position of the conjunction in the inactive constraints
919-
/// list which is required to re-instate it to the system
920-
/// after this step is done.
921-
ConstraintList::iterator AfterConjunction;
922906

923907
/// Indicates that one of the elements failed inference.
924908
bool HadFailure = false;
@@ -946,7 +930,7 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
946930
conjunction->isIsolated() ? IsolatedSolutions : solutions),
947931
BestScore(getBestScore()),
948932
OuterScopeCount(cs.CountScopes, 0), Conjunction(conjunction),
949-
AfterConjunction(erase(conjunction)), OuterSolutions(solutions) {
933+
OuterSolutions(solutions) {
950934
assert(conjunction->getKind() == ConstraintKind::Conjunction);
951935

952936
// Make a snapshot of the constraint system state before conjunction.
@@ -965,9 +949,6 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
965949
// Return all of the type variables and constraints back.
966950
Snapshot.reset();
967951

968-
// Restore conjunction constraint.
969-
restore(AfterConjunction, Conjunction);
970-
971952
// Restore best score only if conjunction fails because
972953
// successful outcome should keep a score set by `restoreOuterState`.
973954
if (HadFailure)

0 commit comments

Comments
 (0)