Skip to content

Commit 786b16c

Browse files
committed
[Diagnostics] NFC: Switch to which doesn't require constraint system
1 parent 5a7c70d commit 786b16c

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,20 @@ bool FailureDiagnostic::diagnoseAsNote() {
5252
}
5353

5454
ASTNode FailureDiagnostic::getAnchor() const {
55-
auto &cs = getConstraintSystem();
56-
5755
auto *locator = getLocator();
5856
// Resolve the locator to a specific expression.
59-
SourceRange range;
60-
ConstraintLocator *resolved = simplifyLocator(cs, locator, range);
61-
if (!resolved || !resolved->getAnchor())
62-
return locator->getAnchor();
6357

64-
auto anchor = resolved->getAnchor();
58+
auto anchor = locator->getAnchor();
59+
60+
{
61+
SourceRange range;
62+
auto path = locator->getPath();
63+
64+
simplifyLocator(anchor, path, range);
65+
if (!anchor)
66+
return locator->getAnchor();
67+
}
68+
6569
// FIXME: Work around an odd locator representation that doesn't separate the
6670
// base of a subscript member from the member access.
6771
if (locator->isLastElement<LocatorPathElt::SubscriptMember>()) {
@@ -3148,12 +3152,18 @@ bool MissingPropertyWrapperUnwrapFailure::diagnoseAsError() {
31483152
}
31493153

31503154
bool SubscriptMisuseFailure::diagnoseAsError() {
3155+
auto *locator = getLocator();
31513156
auto &sourceMgr = getASTContext().SourceMgr;
31523157

31533158
auto *memberExpr = castToExpr<UnresolvedDotExpr>(getRawAnchor());
31543159

31553160
auto memberRange = getSourceRange();
3156-
(void)simplifyLocator(getConstraintSystem(), getLocator(), memberRange);
3161+
3162+
{
3163+
auto rawAnchor = getRawAnchor();
3164+
auto path = locator->getPath();
3165+
simplifyLocator(rawAnchor, path, memberRange);
3166+
}
31573167

31583168
auto nameLoc = DeclNameLoc(memberRange.Start);
31593169

@@ -3183,7 +3193,7 @@ bool SubscriptMisuseFailure::diagnoseAsError() {
31833193
}
31843194
diag.flush();
31853195

3186-
if (auto overload = getOverloadChoiceIfAvailable(getLocator())) {
3196+
if (auto overload = getOverloadChoiceIfAvailable(locator)) {
31873197
emitDiagnosticAt(overload->choice.getDecl(), diag::kind_declared_here,
31883198
DescriptiveDeclKind::Subscript);
31893199
}

0 commit comments

Comments
 (0)