Skip to content

Commit 1e00633

Browse files
committed
[Parser] Use getLocForEndOfToken for diagnostic fix-it
1 parent 32d26ee commit 1e00633

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,15 +3497,16 @@ void Parser::validateCollectionElement(ParserResult<Expr> element) {
34973497

34983498
auto startLocOfSubscript = subscriptExpr->getIndex()->getStartLoc();
34993499
auto endLocOfArray = arrayExpr->getEndLoc();
3500+
auto locForEndOfTokenArray = L->getLocForEndOfToken(SourceMgr, endLocOfArray);
35003501

3501-
if (L->getLocForEndOfToken(SourceMgr, endLocOfArray) != startLocOfSubscript) {
3502+
if (locForEndOfTokenArray != startLocOfSubscript) {
35023503
auto subscriptLoc = subscriptExpr->getLoc();
35033504
diagnose(subscriptLoc, diag::subscript_array_element)
35043505
.highlight(subscriptExpr->getSourceRange());
35053506
diagnose(subscriptLoc, diag::subscript_array_element_fix_it_add_comma)
35063507
.fixItInsertAfter(endLocOfArray, ",");
35073508
diagnose(subscriptLoc, diag::subscript_array_element_fix_it_remove_space)
3508-
.fixItRemoveChars(endLocOfArray.getAdvancedLoc(1), startLocOfSubscript);
3509+
.fixItRemoveChars(locForEndOfTokenArray, startLocOfSubscript);
35093510
}
35103511
}
35113512

0 commit comments

Comments
 (0)