Skip to content

Commit 88619a5

Browse files
committed
[Parse] Remove unused parameters and return value of lexTrivia function
1 parent e7c92f7 commit 88619a5

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

include/swift/Parse/Lexer.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,7 @@ class Lexer {
598598
void lexHexNumber();
599599
void lexNumber();
600600

601-
/// Skip over trivia and return characters that were skipped over in a \c
602-
/// StringRef. \p AllTriviaStart determines the start of the trivia. In nearly
603-
/// all cases, this should be \c CurPtr. If other trivia has already been
604-
/// skipped over (like a BOM), this can be used to point to the start of the
605-
/// BOM. The returned \c StringRef will always start at \p AllTriviaStart.
606-
StringRef lexTrivia(bool IsForTrailingTrivia, const char *AllTriviaStart);
601+
void lexTrivia();
607602
static unsigned lexUnicodeEscape(const char *&CurPtr, Lexer *Diags);
608603

609604
unsigned lexCharacter(const char *&CurPtr, char StopQuote,

lib/Parse/Lexer.cpp

+4-14
Original file line numberDiff line numberDiff line change
@@ -2601,7 +2601,6 @@ void Lexer::lexImpl() {
26012601
if (DiagQueue)
26022602
DiagQueue->clear();
26032603

2604-
const char *LeadingTriviaStart = CurPtr;
26052604
if (CurPtr == BufferStart) {
26062605
if (BufferStart < ContentStart) {
26072606
size_t BOMLen = ContentStart - BufferStart;
@@ -2613,7 +2612,7 @@ void Lexer::lexImpl() {
26132612
NextToken.setAtStartOfLine(false);
26142613
}
26152614

2616-
lexTrivia(/*IsForTrailingTrivia=*/false, LeadingTriviaStart);
2615+
lexTrivia();
26172616

26182617
// Remember the start of the token so we can form the text range.
26192618
const char *TokStart = CurPtr;
@@ -2817,22 +2816,17 @@ Token Lexer::getTokenAtLocation(const SourceManager &SM, SourceLoc Loc,
28172816
return L.peekNextToken();
28182817
}
28192818

2820-
StringRef Lexer::lexTrivia(bool IsForTrailingTrivia,
2821-
const char *AllTriviaStart) {
2819+
void Lexer::lexTrivia() {
28222820
CommentStart = nullptr;
28232821

28242822
Restart:
28252823
const char *TriviaStart = CurPtr;
28262824

28272825
switch (*CurPtr++) {
28282826
case '\n':
2829-
if (IsForTrailingTrivia)
2830-
break;
28312827
NextToken.setAtStartOfLine(true);
28322828
goto Restart;
28332829
case '\r':
2834-
if (IsForTrailingTrivia)
2835-
break;
28362830
NextToken.setAtStartOfLine(true);
28372831
if (CurPtr[0] == '\n') {
28382832
++CurPtr;
@@ -2844,8 +2838,7 @@ StringRef Lexer::lexTrivia(bool IsForTrailingTrivia,
28442838
case '\f':
28452839
goto Restart;
28462840
case '/':
2847-
if (IsForTrailingTrivia || isKeepingComments()) {
2848-
// Don't lex comments as trailing trivia (for now).
2841+
if (isKeepingComments()) {
28492842
// Don't try to lex comments here if we are lexing comments as Tokens.
28502843
break;
28512844
} else if (*CurPtr == '/') {
@@ -2926,15 +2919,12 @@ StringRef Lexer::lexTrivia(bool IsForTrailingTrivia,
29262919
bool ShouldTokenize = lexUnknown(/*EmitDiagnosticsIfToken=*/false);
29272920
if (ShouldTokenize) {
29282921
CurPtr = Tmp;
2929-
size_t Length = CurPtr - AllTriviaStart;
2930-
return StringRef(AllTriviaStart, Length);
2922+
return;
29312923
}
29322924
goto Restart;
29332925
}
29342926
// Reset the cursor.
29352927
--CurPtr;
2936-
size_t Length = CurPtr - AllTriviaStart;
2937-
return StringRef(AllTriviaStart, Length);
29382928
}
29392929

29402930
SourceLoc Lexer::getLocForEndOfToken(const SourceManager &SM, SourceLoc Loc) {

0 commit comments

Comments
 (0)