@@ -1515,7 +1515,7 @@ class Solution {
15151515 // / Maps expressions for implied results (e.g implicit 'then' statements,
15161516 // / implicit 'return' statements in single expression body closures) to their
15171517 // / result kind.
1518- llvm::MapVector< const Expr *, ImpliedResultKind> ImpliedResults;
1518+ llvm::DenseMap< Expr *, ImpliedResultKind> ImpliedResults;
15191519
15201520 // / For locators associated with call expressions, the trailing closure
15211521 // / matching rule and parameter bindings that were applied.
@@ -2233,7 +2233,7 @@ class ConstraintSystem {
22332233 // / Maps expressions for implied results (e.g implicit 'then' statements,
22342234 // / implicit 'return' statements in single expression body closures) to their
22352235 // / result kind.
2236- llvm::MapVector< const Expr *, ImpliedResultKind> ImpliedResults;
2236+ llvm::DenseMap< Expr *, ImpliedResultKind> ImpliedResults;
22372237
22382238 // / This is a *global* list of all result builder bodies that have
22392239 // / been determined to be incorrect by failing constraint generation.
@@ -2860,9 +2860,6 @@ class ConstraintSystem {
28602860 // / FIXME: Remove this.
28612861 unsigned numFixes;
28622862
2863- // / The length of \c ImpliedResults.
2864- unsigned numImpliedResults;
2865-
28662863 // / The length of \c contextualTypes.
28672864 unsigned numContextualTypes;
28682865
@@ -3065,16 +3062,24 @@ class ConstraintSystem {
30653062 }
30663063
30673064 // / Record an implied result for a ReturnStmt or ThenStmt.
3068- void recordImpliedResult (const Expr *E, ImpliedResultKind kind) {
3069- assert (E);
3065+ void recordImpliedResult (Expr *E, ImpliedResultKind kind) {
3066+ ASSERT (E);
30703067 auto inserted = ImpliedResults.insert ({E, kind}).second ;
3071- assert (inserted && " Duplicate implied result?" );
3072- (void )inserted;
3068+ ASSERT (inserted && " Duplicate implied result?" );
3069+
3070+ if (solverState)
3071+ recordChange (SolverTrail::Change::RecordedImpliedResult (E));
3072+ }
3073+
3074+ // / Undo the above change.
3075+ void removeImpliedResult (Expr *E) {
3076+ bool erased = ImpliedResults.erase (E);
3077+ ASSERT (erased);
30733078 }
30743079
30753080 // / Whether the given expression is the implied result for either a ReturnStmt
30763081 // / or ThenStmt, and if so, the kind of implied result.
3077- std::optional<ImpliedResultKind> isImpliedResult (const Expr *E) const {
3082+ std::optional<ImpliedResultKind> isImpliedResult (Expr *E) const {
30783083 auto result = ImpliedResults.find (E);
30793084 if (result == ImpliedResults.end ())
30803085 return std::nullopt ;
0 commit comments