@@ -2143,8 +2143,6 @@ class ConstraintSystem {
21432143 friend struct ClosureIsolatedByPreconcurrency ;
21442144 friend class SolverTrail ;
21452145
2146- class SolverScope ;
2147-
21482146 // / Expressions that are known to be unevaluated.
21492147 // / Note: this is only used to support ObjCSelectorExpr at the moment.
21502148 llvm::SmallPtrSet<Expr *, 2 > UnevaluatedRootExprs;
@@ -2555,23 +2553,21 @@ class ConstraintSystem {
25552553 }
25562554
25572555 // / Update statistics when a scope begins.
2558- // /
2559- // / \param scope The scope to associate with current solver state.
2560- void beginScope (SolverScope *scope) {
2556+ unsigned beginScope () {
25612557 ++depth;
25622558 maxDepth = std::max (maxDepth, depth);
2563- scope->scopeNumber = NumStatesExplored++;
25642559
25652560 CS.incrementScopeCounter ();
2561+
2562+ return NumStatesExplored++;
25662563 }
25672564
25682565 // / Update statistics when a scope ends.
2569- // /
2570- // / \param scope The solver scope to rollback.
2571- void endScope (SolverScope *scope) {
2566+ void endScope (unsigned scopeNumber) {
2567+ ASSERT (depth > 0 );
25722568 --depth;
25732569
2574- unsigned countScopesExplored = NumStatesExplored - scope-> scopeNumber ;
2570+ unsigned countScopesExplored = NumStatesExplored - scopeNumber;
25752571 if (countScopesExplored == 1 )
25762572 CS.incrementLeafScopes ();
25772573 }
@@ -2775,7 +2771,7 @@ class ConstraintSystem {
27752771 // / this object is destroyed.
27762772 // /
27772773 // /
2778- class SolverScope {
2774+ struct SolverScope {
27792775 ConstraintSystem &cs;
27802776
27812777 // / The length of \c TypeVariables.
@@ -2785,15 +2781,19 @@ class ConstraintSystem {
27852781 unsigned numTrailChanges;
27862782
27872783 // / The scope number of this scope. Set when the scope is registered.
2788- unsigned scopeNumber = 0 ;
2784+ unsigned scopeNumber : 31 ;
2785+
2786+ // / A moved-from scope skips doing anything in the destructor.
2787+ unsigned moved : 1 ;
2788+
2789+ explicit SolverScope (ConstraintSystem &cs);
27892790
27902791 SolverScope (const SolverScope &) = delete ;
2791- SolverScope & operator =( const SolverScope &) = delete ;
2792+ SolverScope ( SolverScope &&other) ;
27922793
2793- friend class ConstraintSystem ;
2794+ SolverScope &operator =(const SolverScope &) = delete ;
2795+ SolverScope &operator =(SolverScope &&) = delete ;
27942796
2795- public:
2796- explicit SolverScope (ConstraintSystem &cs);
27972797 ~SolverScope ();
27982798 };
27992799
@@ -5465,6 +5465,15 @@ class ConstraintSystem {
54655465 // / Primitive form of the above. Records a change in the trail.
54665466 void increaseScore (ScoreKind kind, unsigned value);
54675467
5468+ // / Apply the score from a partial solution. Records the change in the
5469+ // / trail.
5470+ void replayScore (const Score &score);
5471+
5472+ // / Temporarily zero out the score, and record this in the trail so that
5473+ // / we restore the score when the scope ends. Used when solving a
5474+ // / ConjunctionStep.
5475+ void clearScore ();
5476+
54685477 // / Determine whether this solution is guaranteed to be worse than the best
54695478 // / solution found so far.
54705479 bool worseThanBestSolution () const ;
0 commit comments