Skip to content

Commit a84e0b7

Browse files
committed
[Diagnostics] Obsolete and remove HasComplexLocator field from diagnostic
This was useful when CSDiag was still in play but since everything has been ported this is no longer useful.
1 parent abf520f commit a84e0b7

File tree

2 files changed

+7
-33
lines changed

2 files changed

+7
-33
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,25 @@ bool FailureDiagnostic::diagnoseAsNote() {
5050
return false;
5151
}
5252

53-
std::pair<Expr *, bool> FailureDiagnostic::computeAnchor() const {
53+
Expr *FailureDiagnostic::computeAnchor() const {
5454
auto &cs = getConstraintSystem();
5555

5656
auto *locator = getLocator();
5757
// Resolve the locator to a specific expression.
5858
SourceRange range;
59-
bool isSubscriptMember =
60-
(!locator->getPath().empty() && locator->getPath().back().getKind() ==
61-
ConstraintLocator::SubscriptMember);
62-
6359
ConstraintLocator *resolved = simplifyLocator(cs, locator, range);
6460
if (!resolved || !resolved->getAnchor())
65-
return {locator->getAnchor(), true};
61+
return locator->getAnchor();
6662

6763
Expr *anchor = resolved->getAnchor();
6864
// FIXME: Work around an odd locator representation that doesn't separate the
6965
// base of a subscript member from the member access.
70-
if (isSubscriptMember) {
66+
if (locator->isLastElement<LocatorPathElt::SubscriptMember>()) {
7167
if (auto subscript = dyn_cast<SubscriptExpr>(anchor))
7268
anchor = subscript->getBase();
7369
}
7470

75-
return {anchor, !resolved->getPath().empty()};
71+
return anchor;
7672
}
7773

7874
Type FailureDiagnostic::getType(Expr *expr, bool wantRValue) const {
@@ -874,9 +870,6 @@ bool NoEscapeFuncToTypeConversionFailure::diagnoseParameterUse() const {
874870
}
875871

876872
bool MissingForcedDowncastFailure::diagnoseAsError() {
877-
if (hasComplexLocator())
878-
return false;
879-
880873
auto *expr = getAnchor();
881874
if (auto *assignExpr = dyn_cast<AssignExpr>(expr))
882875
expr = assignExpr->getSrc();
@@ -894,9 +887,6 @@ bool MissingForcedDowncastFailure::diagnoseAsError() {
894887
}
895888

896889
bool MissingAddressOfFailure::diagnoseAsError() {
897-
if (hasComplexLocator())
898-
return false;
899-
900890
auto *anchor = getAnchor();
901891
auto argTy = getFromType();
902892
auto paramTy = getToType();
@@ -913,9 +903,6 @@ bool MissingAddressOfFailure::diagnoseAsError() {
913903
}
914904

915905
bool MissingExplicitConversionFailure::diagnoseAsError() {
916-
if (hasComplexLocator())
917-
return false;
918-
919906
auto *DC = getDC();
920907
auto *anchor = getAnchor();
921908
if (auto *assign = dyn_cast<AssignExpr>(anchor))
@@ -976,9 +963,6 @@ bool MissingExplicitConversionFailure::diagnoseAsError() {
976963
}
977964

978965
bool MemberAccessOnOptionalBaseFailure::diagnoseAsError() {
979-
if (hasComplexLocator())
980-
return false;
981-
982966
auto *anchor = getAnchor();
983967
auto baseType = getType(anchor);
984968
bool resultIsOptional = ResultTypeIsOptional;
@@ -1101,9 +1085,6 @@ class VarDeclMultipleReferencesChecker : public ASTWalker {
11011085
};
11021086

11031087
bool MissingOptionalUnwrapFailure::diagnoseAsError() {
1104-
if (hasComplexLocator())
1105-
return false;
1106-
11071088
if (!getUnwrappedType()->isBool()) {
11081089
if (diagnoseConversionToBool())
11091090
return true;

lib/Sema/CSDiagnostics.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,11 @@ class FailureDiagnostic {
4545
Expr *RawAnchor;
4646
/// Simplified anchor associated with the given locator.
4747
Expr *Anchor;
48-
/// Indicates whether locator could be simplified
49-
/// down to anchor expression.
50-
bool HasComplexLocator;
5148

5249
public:
5350
FailureDiagnostic(const Solution &solution, ConstraintLocator *locator)
54-
: S(solution), Locator(locator), RawAnchor(locator->getAnchor()) {
55-
std::tie(Anchor, HasComplexLocator) = computeAnchor();
56-
}
51+
: S(solution), Locator(locator), RawAnchor(locator->getAnchor()),
52+
Anchor(computeAnchor()) {}
5753

5854
FailureDiagnostic(const Solution &solution, Expr *anchor)
5955
: FailureDiagnostic(solution, solution.getConstraintLocator(anchor)) {}
@@ -189,9 +185,6 @@ class FailureDiagnostic {
189185
return S.getFunctionArgApplyInfo(locator);
190186
}
191187

192-
/// \returns true is locator hasn't been simplified down to expression.
193-
bool hasComplexLocator() const { return HasComplexLocator; }
194-
195188
/// \returns A parent expression if sub-expression is contained anywhere
196189
/// in the root expression or `nullptr` otherwise.
197190
Expr *findParentExpr(Expr *subExpr) const;
@@ -219,7 +212,7 @@ class FailureDiagnostic {
219212

220213
private:
221214
/// Compute anchor expression associated with current diagnostic.
222-
std::pair<Expr *, bool> computeAnchor() const;
215+
Expr *computeAnchor() const;
223216
};
224217

225218
/// Base class for all of the diagnostics related to generic requirement

0 commit comments

Comments
 (0)