@@ -40,59 +40,11 @@ class SolverTrail {
4040
4141 // / The kind of change made to the graph.
4242 enum class ChangeKind : unsigned {
43- // / Added a new vertex to the constraint graph.
44- AddedTypeVariable,
45- // / Added a new constraint to the constraint graph.
46- AddedConstraint,
47- // / Removed an existing constraint from the constraint graph.
48- RemovedConstraint,
49- // / Extended the equivalence class of a type variable in the constraint graph.
50- ExtendedEquivalenceClass,
51- // / Added a new edge in the constraint graph.
52- RelatedTypeVariables,
53- // / Inferred potential bindings from a constraint.
54- InferredBindings,
55- // / Retracted potential bindings from a constraint.
56- RetractedBindings,
57- // / Set the fixed type or parent and flags for a type variable.
58- UpdatedTypeVariable,
59- // / Recorded a conversion restriction kind.
60- AddedConversionRestriction,
61- // / Recorded a fix.
62- AddedFix,
63- // / Recorded a fixed requirement.
64- AddedFixedRequirement,
65- // / Recorded a disjunction choice.
66- RecordedDisjunctionChoice,
67- // / Recorded an applied disjunction.
68- RecordedAppliedDisjunction,
69- // / Recorded an argument matching choice.
70- RecordedMatchCallArgumentResult,
71- // / Recorded a list of opened types at a locator.
72- RecordedOpenedTypes,
73- // / Recorded the opening of an existential type at a locator.
74- RecordedOpenedExistentialType,
75- // / Recorded the opening of a pack existential type.
76- RecordedOpenedPackExpansionType,
77- // / Recorded the creation of a generic environment for a pack expansion expression.
78- RecordedPackExpansionEnvironment,
79- // / Recorded the mapping from a pack element expression to its parent
80- // / pack expansion expression.
81- RecordedPackEnvironment,
82- // / Recorded a defaulted constraint at a locator.
83- RecordedDefaultedConstraint,
84- // / Recorded an assignment of a type to an AST node.
85- RecordedNodeType,
86- // / Recorded an assignment of a type to a keypath component.
87- RecordedKeyPathComponentType,
88- // / Disabled a constraint.
89- DisabledConstraint,
90- // / Favored a constraint.
91- FavoredConstraint,
92- // / Recorded a result builder transform.
93- RecordedResultBuilderTransform,
94- // / Applied a property wrapper.
95- AppliedPropertyWrapper,
43+ #define CHANGE (Name ) Name,
44+ #define LAST_CHANGE (Name ) Last = Name
45+ #include " CSTrail.def"
46+ #undef CHANGE
47+ #undef LAST_CHANGE
9648 };
9749
9850 // / A change made to the constraint system.
@@ -176,97 +128,82 @@ class SolverTrail {
176128
177129 Change () : Kind(ChangeKind::AddedTypeVariable), TypeVar(nullptr ) { }
178130
131+ #define LOCATOR_CHANGE (Name ) static Change Name (ConstraintLocator *locator);
132+ #include " swift/Sema/CSTrail.def"
133+
179134 // / Create a change that added a type variable.
180- static Change addedTypeVariable (TypeVariableType *typeVar);
135+ static Change AddedTypeVariable (TypeVariableType *typeVar);
181136
182137 // / Create a change that added a constraint.
183- static Change addedConstraint (TypeVariableType *typeVar, Constraint *constraint);
138+ static Change AddedConstraint (TypeVariableType *typeVar, Constraint *constraint);
184139
185140 // / Create a change that removed a constraint.
186- static Change removedConstraint (TypeVariableType *typeVar, Constraint *constraint);
141+ static Change RemovedConstraint (TypeVariableType *typeVar, Constraint *constraint);
187142
188143 // / Create a change that extended an equivalence class.
189- static Change extendedEquivalenceClass (TypeVariableType *typeVar,
144+ static Change ExtendedEquivalenceClass (TypeVariableType *typeVar,
190145 unsigned prevSize);
191146
192147 // / Create a change that updated the references/referenced by sets of
193148 // / a type variable pair.
194- static Change relatedTypeVariables (TypeVariableType *typeVar,
149+ static Change RelatedTypeVariables (TypeVariableType *typeVar,
195150 TypeVariableType *otherTypeVar);
196151
197152 // / Create a change that inferred bindings from a constraint.
198- static Change inferredBindings (TypeVariableType *typeVar,
153+ static Change InferredBindings (TypeVariableType *typeVar,
199154 Constraint *constraint);
200155
201156 // / Create a change that retracted bindings from a constraint.
202- static Change retractedBindings (TypeVariableType *typeVar,
157+ static Change RetractedBindings (TypeVariableType *typeVar,
203158 Constraint *constraint);
204159
205160 // / Create a change that updated a type variable.
206- static Change updatedTypeVariable (
161+ static Change UpdatedTypeVariable (
207162 TypeVariableType *typeVar,
208163 llvm::PointerUnion<TypeVariableType *, TypeBase *> parentOrFixed,
209164 unsigned options);
210165
211166 // / Create a change that recorded a restriction.
212- static Change addedConversionRestriction (Type srcType, Type dstType);
167+ static Change AddedConversionRestriction (Type srcType, Type dstType);
213168
214169 // / Create a change that recorded a fix.
215- static Change addedFix (ConstraintFix *fix);
170+ static Change AddedFix (ConstraintFix *fix);
216171
217172 // / Create a change that recorded a fixed requirement.
218- static Change addedFixedRequirement (GenericTypeParamType *GP,
173+ static Change AddedFixedRequirement (GenericTypeParamType *GP,
219174 unsigned reqKind,
220175 Type requirementTy);
221176
222177 // / Create a change that recorded a disjunction choice.
223- static Change recordedDisjunctionChoice (ConstraintLocator *locator,
178+ static Change RecordedDisjunctionChoice (ConstraintLocator *locator,
224179 unsigned index);
225180
226- // / Create a change that recorded an applied disjunction.
227- static Change recordedAppliedDisjunction (ConstraintLocator *locator);
228-
229- // / Create a change that recorded an applied disjunction.
230- static Change recordedMatchCallArgumentResult (ConstraintLocator *locator);
231-
232- // / Create a change that recorded a list of opened types.
233- static Change recordedOpenedTypes (ConstraintLocator *locator);
234-
235- // / Create a change that recorded the opening of an existential type.
236- static Change recordedOpenedExistentialType (ConstraintLocator *locator);
237-
238181 // / Create a change that recorded the opening of a pack expansion type.
239- static Change recordedOpenedPackExpansionType (PackExpansionType *expansion);
240-
241- // / Create a change that recorded the opening of a pack expansion type.
242- static Change recordedPackExpansionEnvironment (ConstraintLocator *locator);
182+ static Change RecordedOpenedPackExpansionType (PackExpansionType *expansion);
243183
244184 // / Create a change that recorded a mapping from a pack element expression
245185 // / to its parent expansion expression.
246- static Change recordedPackEnvironment (PackElementExpr *packElement);
247-
248- // / Create a change that recorded a defaulted constraint at a locator.
249- static Change recordedDefaultedConstraint (ConstraintLocator *locator);
186+ static Change RecordedPackEnvironment (PackElementExpr *packElement);
250187
251188 // / Create a change that recorded an assignment of a type to an AST node.
252- static Change recordedNodeType (ASTNode node, Type oldType);
189+ static Change RecordedNodeType (ASTNode node, Type oldType);
253190
254191 // / Create a change that recorded an assignment of a type to an AST node.
255- static Change recordedKeyPathComponentType (const KeyPathExpr *expr,
192+ static Change RecordedKeyPathComponentType (const KeyPathExpr *expr,
256193 unsigned component,
257194 Type oldType);
258195
259196 // / Create a change that disabled a constraint.
260- static Change disabledConstraint (Constraint *constraint);
197+ static Change DisabledConstraint (Constraint *constraint);
261198
262199 // / Create a change that favored a constraint.
263- static Change favoredConstraint (Constraint *constraint);
200+ static Change FavoredConstraint (Constraint *constraint);
264201
265202 // / Create a change that recorded a result builder transform.
266- static Change recordedResultBuilderTransform (AnyFunctionRef fn);
203+ static Change RecordedResultBuilderTransform (AnyFunctionRef fn);
267204
268205 // / Create a change that recorded a result builder transform.
269- static Change appliedPropertyWrapper (Expr *anchor);
206+ static Change AppliedPropertyWrapper (Expr *anchor);
270207
271208 // / Undo this change, reverting the constraint graph to the state it
272209 // / had prior to this change.
@@ -278,7 +215,7 @@ class SolverTrail {
278215 unsigned indent = 0 ) const ;
279216 };
280217
281- SolverTrail (ConstraintSystem &cs) : CS(cs) {}
218+ SolverTrail (ConstraintSystem &cs);
282219
283220 ~SolverTrail ();
284221
@@ -305,6 +242,8 @@ class SolverTrail {
305242 // / The list of changes made to this constraint system.
306243 std::vector<Change> Changes;
307244
245+ uint64_t Profile[unsigned (ChangeKind::Last) + 1 ];
246+
308247 bool UndoActive = false ;
309248 unsigned Total = 0 ;
310249 unsigned Max = 0 ;
0 commit comments