Skip to content

[Parse] Remove unused parameters and return value of lexTrivia function #70713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions include/swift/Parse/Lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,7 @@ class Lexer {
void lexHexNumber();
void lexNumber();

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

unsigned lexCharacter(const char *&CurPtr, char StopQuote,
Expand Down
18 changes: 4 additions & 14 deletions lib/Parse/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2601,7 +2601,6 @@ void Lexer::lexImpl() {
if (DiagQueue)
DiagQueue->clear();

const char *LeadingTriviaStart = CurPtr;
if (CurPtr == BufferStart) {
if (BufferStart < ContentStart) {
size_t BOMLen = ContentStart - BufferStart;
Expand All @@ -2613,7 +2612,7 @@ void Lexer::lexImpl() {
NextToken.setAtStartOfLine(false);
}

lexTrivia(/*IsForTrailingTrivia=*/false, LeadingTriviaStart);
lexTrivia();

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

StringRef Lexer::lexTrivia(bool IsForTrailingTrivia,
const char *AllTriviaStart) {
void Lexer::lexTrivia() {
CommentStart = nullptr;

Restart:
const char *TriviaStart = CurPtr;

switch (*CurPtr++) {
case '\n':
if (IsForTrailingTrivia)
break;
NextToken.setAtStartOfLine(true);
goto Restart;
case '\r':
if (IsForTrailingTrivia)
break;
NextToken.setAtStartOfLine(true);
if (CurPtr[0] == '\n') {
++CurPtr;
Expand All @@ -2844,8 +2838,7 @@ StringRef Lexer::lexTrivia(bool IsForTrailingTrivia,
case '\f':
goto Restart;
case '/':
if (IsForTrailingTrivia || isKeepingComments()) {
// Don't lex comments as trailing trivia (for now).
if (isKeepingComments()) {
// Don't try to lex comments here if we are lexing comments as Tokens.
break;
} else if (*CurPtr == '/') {
Expand Down Expand Up @@ -2926,15 +2919,12 @@ StringRef Lexer::lexTrivia(bool IsForTrailingTrivia,
bool ShouldTokenize = lexUnknown(/*EmitDiagnosticsIfToken=*/false);
if (ShouldTokenize) {
CurPtr = Tmp;
size_t Length = CurPtr - AllTriviaStart;
return StringRef(AllTriviaStart, Length);
return;
}
goto Restart;
}
// Reset the cursor.
--CurPtr;
size_t Length = CurPtr - AllTriviaStart;
return StringRef(AllTriviaStart, Length);
}

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