File tree Expand file tree Collapse file tree 3 files changed +18
-19
lines changed Expand file tree Collapse file tree 3 files changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -3227,18 +3227,11 @@ namespace {
3227
3227
void associateArgumentLabels (Expr *expr,
3228
3228
ConstraintSystem::ArgumentInfo info,
3229
3229
bool labelsArePermanent = true ) {
3230
- ConstraintLocator *locator = nullptr ;
3231
- if (auto *apply = dyn_cast<ApplyExpr>(expr)) {
3232
- auto *fnExpr = getArgumentLabelTargetExpr (apply->getFn ());
3233
- locator = CS.getConstraintLocator (fnExpr);
3234
- } else {
3235
- locator = CS.getCalleeLocator (expr);
3236
- }
3237
-
3230
+ assert (expr);
3238
3231
// Record the labels.
3239
3232
if (!labelsArePermanent)
3240
3233
info.Labels = CS.allocateCopy (info.Labels );
3241
- CS.ArgumentInfos [locator ] = info;
3234
+ CS.ArgumentInfos [CS. getArgumentInfoLocator (expr) ] = info;
3242
3235
}
3243
3236
};
3244
3237
Original file line number Diff line number Diff line change @@ -2780,23 +2780,25 @@ void ConstraintSystem::generateConstraints(
2780
2780
}
2781
2781
}
2782
2782
2783
- Optional<ConstraintSystem::ArgumentInfo>
2784
- ConstraintSystem::getArgumentInfo (ConstraintLocator *locator) {
2785
- Expr *anchor = locator->getAnchor ();
2783
+ ConstraintLocator *ConstraintSystem::getArgumentInfoLocator (Expr *anchor) {
2786
2784
if (!anchor)
2787
- return None ;
2785
+ return nullptr ;
2788
2786
2789
2787
if (auto *apply = dyn_cast<ApplyExpr>(anchor)) {
2790
2788
auto *fnExpr = getArgumentLabelTargetExpr (apply->getFn ());
2791
- locator = getConstraintLocator (fnExpr);
2792
- } else {
2793
- locator = getCalleeLocator (anchor);
2789
+ return getConstraintLocator (fnExpr);
2794
2790
}
2795
2791
2796
- auto known = ArgumentInfos.find (locator);
2797
- if (known != ArgumentInfos.end ())
2798
- return known->second ;
2792
+ return getCalleeLocator (anchor);
2793
+ }
2799
2794
2795
+ Optional<ConstraintSystem::ArgumentInfo>
2796
+ ConstraintSystem::getArgumentInfo (ConstraintLocator *locator) {
2797
+ if (auto *infoLocator = getArgumentInfoLocator (locator->getAnchor ())) {
2798
+ auto known = ArgumentInfos.find (infoLocator);
2799
+ if (known != ArgumentInfos.end ())
2800
+ return known->second ;
2801
+ }
2800
2802
return None;
2801
2803
}
2802
2804
Original file line number Diff line number Diff line change @@ -1559,6 +1559,10 @@ class ConstraintSystem {
1559
1559
// / that locator.
1560
1560
llvm::DenseMap<ConstraintLocator *, ArgumentInfo> ArgumentInfos;
1561
1561
1562
+ // / Form a locator with given anchor which then could be used
1563
+ // / to retrieve argument information cached in the constraint system.
1564
+ ConstraintLocator *getArgumentInfoLocator (Expr *anchor);
1565
+
1562
1566
// / Retrieve the argument info that is associated with a member
1563
1567
// / reference at the given locator.
1564
1568
Optional<ArgumentInfo> getArgumentInfo (ConstraintLocator *locator);
You can’t perform that action at this time.
0 commit comments