diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-21 16:56:56 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-21 16:56:56 +0000 |
commit | 86d9a52c24d390631a888d4ff812e1b15445e0a0 (patch) | |
tree | 1f30ab2df64a31faf773231cf5ac963cb118b134 /lib/Lex/Lexer.cpp | |
parent | 657f21bee4750eb28dfb4d60662919417a53d724 (diff) |
Refactor and simplify the CodeCompleteConsumer, so that all of the
real work is performed within Sema. Addresses Chris's comments, but
still retains the heavyweight list-of-multimaps data structure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r-- | lib/Lex/Lexer.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 351b63f6bb..74ac55cf2e 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -1309,6 +1309,18 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { SetCommentRetentionState(PP->getCommentRetentionState()); return true; // Have a token. } + + // 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()) { + Result.startToken(); + BufferPtr = BufferEnd; + FormTokenWithChars(Result, BufferEnd, tok::eof); + return true; + } + + // Otherwise, check if we are code-completing, then issue diagnostics for + // unterminated #if and missing newline. if (IsEofCodeCompletion) { // We're at the end of the file, but we've been asked to conside the @@ -1316,23 +1328,12 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { // 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()) { - Result.startToken(); - BufferPtr = BufferEnd; - FormTokenWithChars(Result, BufferEnd, tok::eof); - return true; - } - - // Otherwise, issue diagnostics for unterminated #if and missing newline. - // If we are in a #if directive, emit an error. while (!ConditionalStack.empty()) { PP->Diag(ConditionalStack.back().IfLoc, |