Skip to content

Commit 5db1c70

Browse files
committed
[CSFix] Extend locator with ArgumentAttribute for escaping/inout fixes
If either `MarkExplicitlyEscaping` or `TreatRValueAsLValue` fix points to an argument-to-parameter conversion, let's add more more clarifying argument to the locator to pinpoint the problem.
1 parent 9347a09 commit 5db1c70

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Sema/CSFix.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ bool TreatRValueAsLValue::diagnose(const Solution &solution,
119119

120120
TreatRValueAsLValue *TreatRValueAsLValue::create(ConstraintSystem &cs,
121121
ConstraintLocator *locator) {
122+
if (locator->isLastElement<LocatorPathElt::ApplyArgToParam>())
123+
locator = cs.getConstraintLocator(
124+
locator, LocatorPathElt::ArgumentAttribute::forInOut());
125+
122126
return new (cs.getAllocator()) TreatRValueAsLValue(cs, locator);
123127
}
124128

@@ -168,6 +172,10 @@ bool MarkExplicitlyEscaping::diagnose(const Solution &solution,
168172
MarkExplicitlyEscaping *
169173
MarkExplicitlyEscaping::create(ConstraintSystem &cs, Type lhs, Type rhs,
170174
ConstraintLocator *locator) {
175+
if (locator->isLastElement<LocatorPathElt::ApplyArgToParam>())
176+
locator = cs.getConstraintLocator(
177+
locator, LocatorPathElt::ArgumentAttribute::forEscaping());
178+
171179
return new (cs.getAllocator()) MarkExplicitlyEscaping(cs, lhs, rhs, locator);
172180
}
173181

0 commit comments

Comments
 (0)