@@ -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
28242822Restart:
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
29402930SourceLoc Lexer::getLocForEndOfToken (const SourceManager &SM, SourceLoc Loc) {
0 commit comments