@@ -103,29 +103,10 @@ static unsigned recomputeSummaryFlags(ConstraintLocator *oldLocator,
103103
104104ConstraintLocator *
105105constraints::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) {
117107 auto path = locator->getPath ();
118108 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);
129110
130111 // If we didn't simplify anything, just return the input.
131112 if (anchor == locator->getAnchor () &&
@@ -141,52 +122,32 @@ constraints::simplifyLocator(ConstraintSystem &cs, ConstraintLocator *locator,
141122
142123void constraints::simplifyLocator (Expr *&anchor,
143124 ArrayRef<LocatorPathElt> &path,
144- Expr *&targetAnchor,
145- SmallVectorImpl<LocatorPathElt> &targetPath,
146125 SourceRange &range) {
147126 range = SourceRange ();
148- targetAnchor = nullptr ;
149127
150128 while (!path.empty ()) {
151129 switch (path[0 ].getKind ()) {
152130 case ConstraintLocator::ApplyArgument: {
153131 // Extract application argument.
154132 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-
159133 anchor = applyExpr->getArg ();
160134 path = path.slice (1 );
161135 continue ;
162136 }
163137
164138 if (auto subscriptExpr = dyn_cast<SubscriptExpr>(anchor)) {
165- // The target anchor is the subscript.
166- targetAnchor = subscriptExpr;
167- targetPath.clear ();
168-
169139 anchor = subscriptExpr->getIndex ();
170140 path = path.slice (1 );
171141 continue ;
172142 }
173143
174144 if (auto objectLiteralExpr = dyn_cast<ObjectLiteralExpr>(anchor)) {
175- targetAnchor = nullptr ;
176- targetPath.clear ();
177-
178145 anchor = objectLiteralExpr->getArg ();
179146 path = path.slice (1 );
180147 continue ;
181148 }
182149
183150 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-
190151 anchor = UME->getArgument ();
191152 path = path.slice (1 );
192153 continue ;
@@ -197,21 +158,13 @@ void constraints::simplifyLocator(Expr *&anchor,
197158 case ConstraintLocator::ApplyFunction:
198159 // Extract application function.
199160 if (auto applyExpr = dyn_cast<ApplyExpr>(anchor)) {
200- // No additional target locator information.
201- targetAnchor = nullptr ;
202- targetPath.clear ();
203-
204161 anchor = applyExpr->getFn ();
205162 path = path.slice (1 );
206163 continue ;
207164 }
208165
209166 // The subscript itself is the function.
210167 if (auto subscriptExpr = dyn_cast<SubscriptExpr>(anchor)) {
211- // No additional target locator information.
212- targetAnchor = nullptr ;
213- targetPath.clear ();
214-
215168 anchor = subscriptExpr;
216169 path = path.slice (1 );
217170 continue ;
@@ -220,10 +173,6 @@ void constraints::simplifyLocator(Expr *&anchor,
220173 // The unresolved member itself is the function.
221174 if (auto unresolvedMember = dyn_cast<UnresolvedMemberExpr>(anchor)) {
222175 if (unresolvedMember->getArgument ()) {
223- // No additional target locator information.
224- targetAnchor = nullptr ;
225- targetPath.clear ();
226-
227176 anchor = unresolvedMember;
228177 path = path.slice (1 );
229178 continue ;
@@ -248,11 +197,6 @@ void constraints::simplifyLocator(Expr *&anchor,
248197 if (auto tupleExpr = dyn_cast<TupleExpr>(anchor)) {
249198 unsigned index = path[0 ].getValue ();
250199 if (index < tupleExpr->getNumElements ()) {
251- // Append this extraction to the target locator path.
252- if (targetAnchor) {
253- targetPath.push_back (path[0 ]);
254- }
255-
256200 anchor = tupleExpr->getElement (index);
257201 path = path.slice (1 );
258202 continue ;
@@ -265,11 +209,6 @@ void constraints::simplifyLocator(Expr *&anchor,
265209 if (auto tupleExpr = dyn_cast<TupleExpr>(anchor)) {
266210 unsigned index = path[0 ].getValue ();
267211 if (index < tupleExpr->getNumElements ()) {
268- // Append this extraction to the target locator path.
269- if (targetAnchor) {
270- targetPath.push_back (path[0 ]);
271- }
272-
273212 anchor = tupleExpr->getElement (index);
274213 path = path.slice (1 );
275214 continue ;
@@ -280,11 +219,6 @@ void constraints::simplifyLocator(Expr *&anchor,
280219 if (auto parenExpr = dyn_cast<ParenExpr>(anchor)) {
281220 assert (path[0 ].getValue () == 0 );
282221
283- // Append this extraction to the target locator path.
284- if (targetAnchor) {
285- targetPath.push_back (path[0 ]);
286- }
287-
288222 anchor = parenExpr->getSubExpr ();
289223 path = path.slice (1 );
290224 continue ;
@@ -295,8 +229,6 @@ void constraints::simplifyLocator(Expr *&anchor,
295229 if (auto typeExpr = dyn_cast<TypeExpr>(anchor)) {
296230 // This is really an implicit 'init' MemberRef, so point at the base,
297231 // i.e. the TypeExpr.
298- targetAnchor = nullptr ;
299- targetPath.clear ();
300232 range = SourceRange ();
301233 anchor = typeExpr;
302234 path = path.slice (1 );
@@ -307,10 +239,6 @@ void constraints::simplifyLocator(Expr *&anchor,
307239 case ConstraintLocator::Member:
308240 case ConstraintLocator::MemberRefBase:
309241 if (auto UDE = dyn_cast<UnresolvedDotExpr>(anchor)) {
310- // No additional target locator information.
311- targetAnchor = nullptr ;
312- targetPath.clear ();
313-
314242 range = UDE->getNameLoc ().getSourceRange ();
315243 anchor = UDE->getBase ();
316244 path = path.slice (1 );
@@ -320,8 +248,6 @@ void constraints::simplifyLocator(Expr *&anchor,
320248
321249 case ConstraintLocator::SubscriptMember:
322250 if (isa<SubscriptExpr>(anchor)) {
323- targetAnchor = nullptr ;
324- targetPath.clear ();
325251 path = path.slice (1 );
326252 continue ;
327253 }
@@ -330,8 +256,6 @@ void constraints::simplifyLocator(Expr *&anchor,
330256 case ConstraintLocator::ClosureResult:
331257 if (auto CE = dyn_cast<ClosureExpr>(anchor)) {
332258 if (CE->hasSingleExpressionBody ()) {
333- targetAnchor = nullptr ;
334- targetPath.clear ();
335259 anchor = CE->getSingleExpressionBody ();
336260 path = path.slice (1 );
337261 continue ;
0 commit comments