File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -233,11 +233,8 @@ class Lexer {
233
233
Result = NextToken;
234
234
LeadingTriviaResult = {LeadingTrivia};
235
235
TrailingTriviaResult = {TrailingTrivia};
236
- if (Result.isNot (tok::eof)) {
237
- LeadingTrivia.clear ();
238
- TrailingTrivia.clear ();
236
+ if (Result.isNot (tok::eof))
239
237
lexImpl ();
240
- }
241
238
}
242
239
243
240
void lex (Token &Result) {
@@ -288,8 +285,6 @@ class Lexer {
288
285
void restoreState (State S, bool enableDiagnostics = false ) {
289
286
assert (S.isValid ());
290
287
CurPtr = getBufferPtrForSourceLoc (S.Loc );
291
- LeadingTrivia.clear ();
292
- TrailingTrivia.clear ();
293
288
// Don't reemit diagnostics while readvancing the lexer.
294
289
llvm::SaveAndRestore<DiagnosticEngine*>
295
290
D (Diags, enableDiagnostics ? Diags : nullptr );
Original file line number Diff line number Diff line change @@ -2058,6 +2058,10 @@ void Lexer::lexImpl() {
2058
2058
assert (CurPtr >= BufferStart &&
2059
2059
CurPtr <= BufferEnd && " Current pointer out of range!" );
2060
2060
2061
+ if (TriviaRetention == TriviaRetentionMode::WithTrivia) {
2062
+ LeadingTrivia.clear ();
2063
+ TrailingTrivia.clear ();
2064
+ }
2061
2065
NextToken.setAtStartOfLine (CurPtr == BufferStart);
2062
2066
2063
2067
// Remember where we started so that we can find the comment range.
You can’t perform that action at this time.
0 commit comments