File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -2728,9 +2728,17 @@ bool InvalidMethodRefInKeyPath::diagnoseAsError() {
2728
2728
return true ;
2729
2729
}
2730
2730
2731
+ SourceLoc InvalidUseOfAddressOf::getLoc () const {
2732
+ auto *anchor = getAnchor ();
2733
+
2734
+ if (auto *assign = dyn_cast<AssignExpr>(anchor))
2735
+ anchor = assign->getSrc ();
2736
+
2737
+ return anchor->getLoc ();
2738
+ }
2739
+
2731
2740
bool InvalidUseOfAddressOf::diagnoseAsError () {
2732
- auto *anchor = cast<AssignExpr>(getAnchor ());
2733
- emitDiagnostic (anchor->getSrc ()->getLoc (), diag::extraneous_address_of);
2741
+ emitDiagnostic (getLoc (), diag::extraneous_address_of);
2734
2742
return true ;
2735
2743
}
2736
2744
Original file line number Diff line number Diff line change @@ -1158,6 +1158,10 @@ class InvalidUseOfAddressOf final : public FailureDiagnostic {
1158
1158
: FailureDiagnostic(root, cs, locator) {}
1159
1159
1160
1160
bool diagnoseAsError () override ;
1161
+
1162
+ protected:
1163
+ // / Compute location of the failure for diagnostic.
1164
+ SourceLoc getLoc () const ;
1161
1165
};
1162
1166
1163
1167
// / Diagnose an attempt return something from a function which
You can’t perform that action at this time.
0 commit comments