Skip to content

Commit 3546136

Browse files
authored
Merge pull request #13075 from lattner/SourceLocCleanup
2 parents 6285582 + ee3b01b commit 3546136

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/swift/AST/DeclNameLoc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ class DeclNameLoc {
105105
return getSourceLocs()[FirstArgumentLabelIndex + index];
106106
}
107107

108+
SourceLoc getStartLoc() const {
109+
return getBaseNameLoc();
110+
}
111+
112+
SourceLoc getEndLoc() const {
113+
return NumArgumentLabels == 0 ? getBaseNameLoc() : getRParenLoc();
114+
}
115+
108116
/// Retrieve the complete source range for this declaration name.
109117
SourceRange getSourceRange() const {
110118
if (NumArgumentLabels == 0) return getBaseNameLoc();

include/swift/AST/Expr.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,10 @@ class SubscriptExpr final : public Expr,
23392339

23402340
SourceLoc getLoc() const { return Index->getStartLoc(); }
23412341
SourceLoc getStartLoc() const { return Base->getStartLoc(); }
2342-
SourceLoc getEndLoc() const { return Index->getEndLoc(); }
2342+
SourceLoc getEndLoc() const {
2343+
auto end = Index->getEndLoc();
2344+
return end.isValid() ? end : Base->getEndLoc();
2345+
}
23432346

23442347
static bool classof(const Expr *E) {
23452348
return E->getKind() == ExprKind::Subscript;
@@ -2396,7 +2399,7 @@ class UnresolvedDotExpr : public Expr {
23962399
: SubExpr->getStartLoc());
23972400
}
23982401
SourceLoc getEndLoc() const {
2399-
return NameLoc.getSourceRange().End ;
2402+
return NameLoc.getSourceRange().End;
24002403
}
24012404

24022405
SourceLoc getDotLoc() const { return DotLoc; }

0 commit comments

Comments
 (0)