@@ -103,29 +103,10 @@ static unsigned recomputeSummaryFlags(ConstraintLocator *oldLocator,
103
103
104
104
ConstraintLocator *
105
105
constraints::simplifyLocator (ConstraintSystem &cs, ConstraintLocator *locator,
106
- SourceRange &range,
107
- ConstraintLocator **targetLocator) {
108
- // Clear out the target locator result.
109
- if (targetLocator)
110
- *targetLocator = nullptr ;
111
-
112
- // The path to be tacked on to the target locator to identify the specific
113
- // target.
114
- Expr *targetAnchor;
115
- SmallVector<LocatorPathElt, 4 > targetPath;
116
-
106
+ SourceRange &range) {
117
107
auto path = locator->getPath ();
118
108
auto anchor = locator->getAnchor ();
119
- simplifyLocator (anchor, path, targetAnchor, targetPath, range);
120
-
121
-
122
- // If we have a target anchor, build and simplify the target locator.
123
- if (targetLocator && targetAnchor) {
124
- SourceRange targetRange;
125
- unsigned targetFlags = recomputeSummaryFlags (locator, targetPath);
126
- auto loc = cs.getConstraintLocator (targetAnchor, targetPath, targetFlags);
127
- *targetLocator = simplifyLocator (cs, loc, targetRange);
128
- }
109
+ simplifyLocator (anchor, path, range);
129
110
130
111
// If we didn't simplify anything, just return the input.
131
112
if (anchor == locator->getAnchor () &&
@@ -141,52 +122,32 @@ constraints::simplifyLocator(ConstraintSystem &cs, ConstraintLocator *locator,
141
122
142
123
void constraints::simplifyLocator (Expr *&anchor,
143
124
ArrayRef<LocatorPathElt> &path,
144
- Expr *&targetAnchor,
145
- SmallVectorImpl<LocatorPathElt> &targetPath,
146
125
SourceRange &range) {
147
126
range = SourceRange ();
148
- targetAnchor = nullptr ;
149
127
150
128
while (!path.empty ()) {
151
129
switch (path[0 ].getKind ()) {
152
130
case ConstraintLocator::ApplyArgument: {
153
131
// Extract application argument.
154
132
if (auto applyExpr = dyn_cast<ApplyExpr>(anchor)) {
155
- // The target anchor is the function being called.
156
- targetAnchor = applyExpr->getFn ();
157
- targetPath.push_back (path[0 ]);
158
-
159
133
anchor = applyExpr->getArg ();
160
134
path = path.slice (1 );
161
135
continue ;
162
136
}
163
137
164
138
if (auto subscriptExpr = dyn_cast<SubscriptExpr>(anchor)) {
165
- // The target anchor is the subscript.
166
- targetAnchor = subscriptExpr;
167
- targetPath.clear ();
168
-
169
139
anchor = subscriptExpr->getIndex ();
170
140
path = path.slice (1 );
171
141
continue ;
172
142
}
173
143
174
144
if (auto objectLiteralExpr = dyn_cast<ObjectLiteralExpr>(anchor)) {
175
- targetAnchor = nullptr ;
176
- targetPath.clear ();
177
-
178
145
anchor = objectLiteralExpr->getArg ();
179
146
path = path.slice (1 );
180
147
continue ;
181
148
}
182
149
183
150
if (auto *UME = dyn_cast<UnresolvedMemberExpr>(anchor)) {
184
- // The target anchor is the method being called,
185
- // no additional information could be retrieved
186
- // about this call.
187
- targetAnchor = nullptr ;
188
- targetPath.clear ();
189
-
190
151
anchor = UME->getArgument ();
191
152
path = path.slice (1 );
192
153
continue ;
@@ -197,21 +158,13 @@ void constraints::simplifyLocator(Expr *&anchor,
197
158
case ConstraintLocator::ApplyFunction:
198
159
// Extract application function.
199
160
if (auto applyExpr = dyn_cast<ApplyExpr>(anchor)) {
200
- // No additional target locator information.
201
- targetAnchor = nullptr ;
202
- targetPath.clear ();
203
-
204
161
anchor = applyExpr->getFn ();
205
162
path = path.slice (1 );
206
163
continue ;
207
164
}
208
165
209
166
// The subscript itself is the function.
210
167
if (auto subscriptExpr = dyn_cast<SubscriptExpr>(anchor)) {
211
- // No additional target locator information.
212
- targetAnchor = nullptr ;
213
- targetPath.clear ();
214
-
215
168
anchor = subscriptExpr;
216
169
path = path.slice (1 );
217
170
continue ;
@@ -220,10 +173,6 @@ void constraints::simplifyLocator(Expr *&anchor,
220
173
// The unresolved member itself is the function.
221
174
if (auto unresolvedMember = dyn_cast<UnresolvedMemberExpr>(anchor)) {
222
175
if (unresolvedMember->getArgument ()) {
223
- // No additional target locator information.
224
- targetAnchor = nullptr ;
225
- targetPath.clear ();
226
-
227
176
anchor = unresolvedMember;
228
177
path = path.slice (1 );
229
178
continue ;
@@ -248,11 +197,6 @@ void constraints::simplifyLocator(Expr *&anchor,
248
197
if (auto tupleExpr = dyn_cast<TupleExpr>(anchor)) {
249
198
unsigned index = path[0 ].getValue ();
250
199
if (index < tupleExpr->getNumElements ()) {
251
- // Append this extraction to the target locator path.
252
- if (targetAnchor) {
253
- targetPath.push_back (path[0 ]);
254
- }
255
-
256
200
anchor = tupleExpr->getElement (index);
257
201
path = path.slice (1 );
258
202
continue ;
@@ -265,11 +209,6 @@ void constraints::simplifyLocator(Expr *&anchor,
265
209
if (auto tupleExpr = dyn_cast<TupleExpr>(anchor)) {
266
210
unsigned index = path[0 ].getValue ();
267
211
if (index < tupleExpr->getNumElements ()) {
268
- // Append this extraction to the target locator path.
269
- if (targetAnchor) {
270
- targetPath.push_back (path[0 ]);
271
- }
272
-
273
212
anchor = tupleExpr->getElement (index);
274
213
path = path.slice (1 );
275
214
continue ;
@@ -280,11 +219,6 @@ void constraints::simplifyLocator(Expr *&anchor,
280
219
if (auto parenExpr = dyn_cast<ParenExpr>(anchor)) {
281
220
assert (path[0 ].getValue () == 0 );
282
221
283
- // Append this extraction to the target locator path.
284
- if (targetAnchor) {
285
- targetPath.push_back (path[0 ]);
286
- }
287
-
288
222
anchor = parenExpr->getSubExpr ();
289
223
path = path.slice (1 );
290
224
continue ;
@@ -295,8 +229,6 @@ void constraints::simplifyLocator(Expr *&anchor,
295
229
if (auto typeExpr = dyn_cast<TypeExpr>(anchor)) {
296
230
// This is really an implicit 'init' MemberRef, so point at the base,
297
231
// i.e. the TypeExpr.
298
- targetAnchor = nullptr ;
299
- targetPath.clear ();
300
232
range = SourceRange ();
301
233
anchor = typeExpr;
302
234
path = path.slice (1 );
@@ -307,10 +239,6 @@ void constraints::simplifyLocator(Expr *&anchor,
307
239
case ConstraintLocator::Member:
308
240
case ConstraintLocator::MemberRefBase:
309
241
if (auto UDE = dyn_cast<UnresolvedDotExpr>(anchor)) {
310
- // No additional target locator information.
311
- targetAnchor = nullptr ;
312
- targetPath.clear ();
313
-
314
242
range = UDE->getNameLoc ().getSourceRange ();
315
243
anchor = UDE->getBase ();
316
244
path = path.slice (1 );
@@ -320,8 +248,6 @@ void constraints::simplifyLocator(Expr *&anchor,
320
248
321
249
case ConstraintLocator::SubscriptMember:
322
250
if (isa<SubscriptExpr>(anchor)) {
323
- targetAnchor = nullptr ;
324
- targetPath.clear ();
325
251
path = path.slice (1 );
326
252
continue ;
327
253
}
@@ -330,8 +256,6 @@ void constraints::simplifyLocator(Expr *&anchor,
330
256
case ConstraintLocator::ClosureResult:
331
257
if (auto CE = dyn_cast<ClosureExpr>(anchor)) {
332
258
if (CE->hasSingleExpressionBody ()) {
333
- targetAnchor = nullptr ;
334
- targetPath.clear ();
335
259
anchor = CE->getSingleExpressionBody ();
336
260
path = path.slice (1 );
337
261
continue ;
0 commit comments