Skip to content

Commit 9f26b56

Browse files
committed
[SyntaxParse] Remove unused overload of parseMatchingTokenSyntax()
1 parent c022ff2 commit 9f26b56

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

include/swift/Parse/Parser.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -899,10 +899,6 @@ class Parser {
899899
parseMatchingTokenSyntax(tok K, Diag<> ErrorDiag, SourceLoc OtherLoc,
900900
bool silenceDiag = false);
901901

902-
llvm::Optional<ParsedTokenSyntax>
903-
parseMatchingTokenSyntax(tok K, SourceLoc &TokLoc, Diag<> ErrorDiag,
904-
SourceLoc OtherLoc);
905-
906902
/// Returns the proper location for a missing right brace, parenthesis, etc.
907903
SourceLoc getLocForMissingMatchingToken() const;
908904

@@ -923,7 +919,6 @@ class Parser {
923919
llvm::function_ref<ParserStatus()> callback);
924920
ParserStatus parseListSyntax(tok RightK, SourceLoc LeftLoc,
925921
llvm::Optional<ParsedTokenSyntax> &LastComma,
926-
SourceLoc &RightLoc,
927922
llvm::Optional<ParsedTokenSyntax> &Right,
928923
llvm::SmallVectorImpl<ParsedSyntax>& Junk,
929924
bool AllowSepAfterLast, Diag<> ErrorDiag,

lib/Parse/ParseType.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,11 +976,10 @@ ParsedSyntaxResult<ParsedTypeSyntax> Parser::parseTypeTupleBody() {
976976

977977
Optional<ParsedTokenSyntax> Comma;
978978

979-
SourceLoc RParenLoc;
980979
Optional<ParsedTokenSyntax> RParen;
981980

982981
ParserStatus Status =
983-
parseListSyntax(tok::r_paren, LParenLoc, Comma, RParenLoc, RParen, Junk,
982+
parseListSyntax(tok::r_paren, LParenLoc, Comma, RParen, Junk,
984983
false, diag::expected_rparen_tuple_type_list, [&]() {
985984
Optional<BacktrackingScope> Backtracking;
986985
SmallVector<ParsedSyntax, 0> LocalJunk;

lib/Parse/Parser.cpp

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,18 +1276,6 @@ Parser::parseMatchingTokenSyntax(tok K, Diag<> ErrorDiag, SourceLoc OtherLoc,
12761276
return makeParserError();
12771277
}
12781278

1279-
Optional<ParsedTokenSyntax>
1280-
Parser::parseMatchingTokenSyntax(tok K, SourceLoc &TokLoc, Diag<> ErrorDiag,
1281-
SourceLoc OtherLoc) {
1282-
TokLoc = Tok.getLoc();
1283-
auto result = parseMatchingTokenSyntax(K, ErrorDiag, OtherLoc);
1284-
if (result.isNull()) {
1285-
TokLoc = getLocForMissingMatchingToken();
1286-
return None;
1287-
}
1288-
return result.get();
1289-
}
1290-
12911279
SourceLoc Parser::getLocForMissingMatchingToken() const {
12921280
// At present, use the same location whether it's an error or whether
12931281
// the matching token is missing.
@@ -1333,7 +1321,6 @@ static SyntaxKind getListElementKind(SyntaxKind ListKind) {
13331321
ParserStatus
13341322
Parser::parseListSyntax(tok RightK, SourceLoc LeftLoc,
13351323
Optional<ParsedTokenSyntax> &LastComma,
1336-
SourceLoc &RightLoc,
13371324
Optional<ParsedTokenSyntax> &Right,
13381325
SmallVectorImpl<ParsedSyntax>& Junk,
13391326
bool AllowSepAfterLast, Diag<> ErrorDiag,
@@ -1343,13 +1330,11 @@ Parser::parseListSyntax(tok RightK, SourceLoc LeftLoc,
13431330
};
13441331

13451332
if (Tok.is(RightK)) {
1346-
RightLoc = Tok.getLoc();
13471333
Right = consumeTokenSyntax(RightK);
13481334
return makeParserSuccess();
13491335
}
13501336
if (TokIsStringInterpolationEOF()) {
13511337
Tok.setKind(RightK);
1352-
RightLoc = Tok.getLoc();
13531338
Right = consumeTokenSyntax();
13541339
return makeParserSuccess();
13551340
}
@@ -1372,7 +1357,6 @@ Parser::parseListSyntax(tok RightK, SourceLoc LeftLoc,
13721357
// Just accept the ")" and build the tuple as we usually do.
13731358
if (TokIsStringInterpolationEOF()) {
13741359
Tok.setKind(RightK);
1375-
RightLoc = Tok.getLoc();
13761360
Right = consumeTokenSyntax();
13771361
return Status;
13781362
}
@@ -1409,20 +1393,10 @@ Parser::parseListSyntax(tok RightK, SourceLoc LeftLoc,
14091393
Status.setIsParseError();
14101394
}
14111395

1412-
if (Status.isError()) {
1413-
// If we've already got errors, don't emit missing RightK diagnostics.
1414-
if (Tok.is(RightK)) {
1415-
RightLoc = Tok.getLoc();
1416-
Right = consumeTokenSyntax(RightK);
1417-
} else {
1418-
RightLoc = getLocForMissingMatchingToken();
1419-
}
1420-
} else {
1421-
Right = parseMatchingTokenSyntax(RightK, RightLoc, ErrorDiag, LeftLoc);
1422-
if (!Right)
1423-
Status.setIsParseError();
1424-
}
1425-
1396+
auto RightResult = parseMatchingTokenSyntax(RightK, ErrorDiag, LeftLoc,
1397+
Status.isError());
1398+
Status |= RightResult.getStatus();
1399+
Right = RightResult.getOrNull();
14261400
return Status;
14271401
}
14281402

0 commit comments

Comments
 (0)