@@ -171,11 +171,11 @@ uint32_t swift::validateUTF8CharacterAndAdvance(const char *&Ptr,
171
171
172
172
Lexer::Lexer (const PrincipalTag &, const LangOptions &LangOpts,
173
173
const SourceManager &SourceMgr, unsigned BufferID,
174
- DiagnosticEngine *Diags, bool InSILMode ,
174
+ DiagnosticEngine *Diags, LexerMode LexMode ,
175
175
HashbangMode HashbangAllowed, CommentRetentionMode RetainComments,
176
176
TriviaRetentionMode TriviaRetention)
177
177
: LangOpts(LangOpts), SourceMgr(SourceMgr), BufferID(BufferID),
178
- Diags(Diags), InSILMode(InSILMode ),
178
+ Diags(Diags), LexMode(LexMode ),
179
179
IsHashbangAllowed(HashbangAllowed == HashbangMode::Allowed),
180
180
RetainComments(RetainComments), TriviaRetention(TriviaRetention) {}
181
181
@@ -216,28 +216,28 @@ void Lexer::initialize(unsigned Offset, unsigned EndOffset) {
216
216
}
217
217
218
218
Lexer::Lexer (const LangOptions &Options, const SourceManager &SourceMgr,
219
- unsigned BufferID, DiagnosticEngine *Diags, bool InSILMode ,
219
+ unsigned BufferID, DiagnosticEngine *Diags, LexerMode LexMode ,
220
220
HashbangMode HashbangAllowed, CommentRetentionMode RetainComments,
221
221
TriviaRetentionMode TriviaRetention)
222
- : Lexer(PrincipalTag(), Options, SourceMgr, BufferID, Diags, InSILMode ,
222
+ : Lexer(PrincipalTag(), Options, SourceMgr, BufferID, Diags, LexMode ,
223
223
HashbangAllowed, RetainComments, TriviaRetention) {
224
224
unsigned EndOffset = SourceMgr.getRangeForBuffer (BufferID).getByteLength ();
225
225
initialize (/* Offset=*/ 0 , EndOffset);
226
226
}
227
227
228
228
Lexer::Lexer (const LangOptions &Options, const SourceManager &SourceMgr,
229
- unsigned BufferID, DiagnosticEngine *Diags, bool InSILMode ,
229
+ unsigned BufferID, DiagnosticEngine *Diags, LexerMode LexMode ,
230
230
HashbangMode HashbangAllowed, CommentRetentionMode RetainComments,
231
231
TriviaRetentionMode TriviaRetention, unsigned Offset,
232
232
unsigned EndOffset)
233
- : Lexer(PrincipalTag(), Options, SourceMgr, BufferID, Diags, InSILMode ,
233
+ : Lexer(PrincipalTag(), Options, SourceMgr, BufferID, Diags, LexMode ,
234
234
HashbangAllowed, RetainComments, TriviaRetention) {
235
235
initialize (Offset, EndOffset);
236
236
}
237
237
238
238
Lexer::Lexer (Lexer &Parent, State BeginState, State EndState)
239
239
: Lexer(PrincipalTag(), Parent.LangOpts, Parent.SourceMgr, Parent.BufferID,
240
- Parent.Diags, Parent.InSILMode ,
240
+ Parent.Diags, Parent.LexMode ,
241
241
Parent.IsHashbangAllowed
242
242
? HashbangMode::Allowed
243
243
: HashbangMode::Disallowed,
@@ -264,7 +264,7 @@ Token Lexer::getTokenAt(SourceLoc Loc) {
264
264
SourceMgr.findBufferContainingLoc (Loc)) &&
265
265
" location from the wrong buffer" );
266
266
267
- Lexer L (LangOpts, SourceMgr, BufferID, Diags, InSILMode ,
267
+ Lexer L (LangOpts, SourceMgr, BufferID, Diags, LexMode ,
268
268
HashbangMode::Allowed, CommentRetentionMode::None,
269
269
TriviaRetentionMode::WithoutTrivia);
270
270
L.restoreState (State (Loc));
@@ -672,7 +672,8 @@ void Lexer::lexIdentifier() {
672
672
// Lex [a-zA-Z_$0-9[[:XID_Continue:]]]*
673
673
while (advanceIfValidContinuationOfIdentifier (CurPtr, BufferEnd));
674
674
675
- tok Kind = kindOfIdentifier (StringRef (TokStart, CurPtr-TokStart), InSILMode);
675
+ tok Kind = kindOfIdentifier (StringRef (TokStart, CurPtr-TokStart),
676
+ LexMode == LexerMode::SIL);
676
677
return formToken (Kind, TokStart);
677
678
}
678
679
@@ -2515,7 +2516,7 @@ Token Lexer::getTokenAtLocation(const SourceManager &SM, SourceLoc Loc) {
2515
2516
// comments and normally we won't be at the beginning of a comment token
2516
2517
// (making this option irrelevant), or the caller lexed comments and
2517
2518
// we need to lex just the comment token.
2518
- Lexer L (FakeLangOpts, SM, BufferID, nullptr , /* InSILMode= */ false ,
2519
+ Lexer L (FakeLangOpts, SM, BufferID, nullptr , LexerMode::Swift ,
2519
2520
HashbangMode::Allowed, CommentRetentionMode::ReturnAsTokens);
2520
2521
L.restoreState (State (Loc));
2521
2522
return L.peekNextToken ();
@@ -2671,7 +2672,7 @@ static SourceLoc getLocForStartOfTokenInBuf(SourceManager &SM,
2671
2672
// and the exact token produced.
2672
2673
LangOptions FakeLangOptions;
2673
2674
2674
- Lexer L (FakeLangOptions, SM, BufferID, nullptr , /* InSILMode= */ false ,
2675
+ Lexer L (FakeLangOptions, SM, BufferID, nullptr , LexerMode::Swift ,
2675
2676
HashbangMode::Allowed, CommentRetentionMode::None,
2676
2677
TriviaRetentionMode::WithoutTrivia, BufferStart, BufferEnd);
2677
2678
@@ -2799,7 +2800,7 @@ SourceLoc Lexer::getLocForEndOfLine(SourceManager &SM, SourceLoc Loc) {
2799
2800
// comments and normally we won't be at the beginning of a comment token
2800
2801
// (making this option irrelevant), or the caller lexed comments and
2801
2802
// we need to lex just the comment token.
2802
- Lexer L (FakeLangOpts, SM, BufferID, nullptr , /* InSILMode= */ false ,
2803
+ Lexer L (FakeLangOpts, SM, BufferID, nullptr , LexerMode::Swift ,
2803
2804
HashbangMode::Allowed, CommentRetentionMode::ReturnAsTokens);
2804
2805
L.restoreState (State (Loc));
2805
2806
L.skipToEndOfLine (/* EatNewline=*/ true );
0 commit comments