diff options
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r-- | lib/Lex/Lexer.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 23ba6e1ca7..351b63f6bb 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -70,7 +70,8 @@ void Lexer::InitLexer(const char *BufStart, const char *BufPtr, " to simplify lexing!"); Is_PragmaLexer = false; - + IsEofCodeCompletion = false; + // Start of the file is a start of line. IsAtStartOfLine = true; @@ -1309,6 +1310,18 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { return true; // Have a token. } + if (IsEofCodeCompletion) { + // We're at the end of the file, but we've been asked to conside the + // end of the file to be a code-completion token. Return the + // code-completion token. + Result.startToken(); + FormTokenWithChars(Result, CurPtr, tok::code_completion); + + // Only do the eof -> code_completion translation once. + IsEofCodeCompletion = false; + return true; + } + // If we are in raw mode, return this event as an EOF token. Let the caller // that put us in raw mode handle the event. if (isLexingRawMode()) { |