diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-12 17:04:55 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-12 17:04:55 +0000 |
commit | 2d474ba9e8ae43a1a5a9f72718c0d79092b9453f (patch) | |
tree | 5c50bc0003de23ebc542dbb00627a151a193bc3c /lib/Lex/Lexer.cpp | |
parent | d5f4487fc66689c5bed6055e669d71d2e3e11b5c (diff) |
Don't emit end-of-file diagnostics like "unterminated conditional" or
"unterminated string" when we're performing code completion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110933 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r-- | lib/Lex/Lexer.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 7e6f7c1af6..9a96934d49 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -962,7 +962,8 @@ void Lexer::LexStringLiteral(Token &Result, const char *CurPtr, bool Wide) { if (C == '\n' || C == '\r' || // Newline. (C == 0 && CurPtr-1 == BufferEnd)) { // End of file. - if (!isLexingRawMode() && !Features.AsmPreprocessor) + if (!isLexingRawMode() && !Features.AsmPreprocessor && + !PP->isCodeCompletionFile(FileLoc)) Diag(BufferPtr, diag::err_unterminated_string); FormTokenWithChars(Result, CurPtr-1, tok::unknown); return; @@ -1039,7 +1040,8 @@ void Lexer::LexCharConstant(Token &Result, const char *CurPtr) { C = getAndAdvanceChar(CurPtr, Result); } else if (C == '\n' || C == '\r' || // Newline. (C == 0 && CurPtr-1 == BufferEnd)) { // End of file. - if (!isLexingRawMode() && !Features.AsmPreprocessor) + if (!isLexingRawMode() && !Features.AsmPreprocessor && + !PP->isCodeCompletionFile(FileLoc)) Diag(BufferPtr, diag::err_unterminated_char); FormTokenWithChars(Result, CurPtr-1, tok::unknown); return; @@ -1564,8 +1566,9 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { // If we are in a #if directive, emit an error. while (!ConditionalStack.empty()) { - PP->Diag(ConditionalStack.back().IfLoc, - diag::err_pp_unterminated_conditional); + if (!PP->isCodeCompletionFile(FileLoc)) + PP->Diag(ConditionalStack.back().IfLoc, + diag::err_pp_unterminated_conditional); ConditionalStack.pop_back(); } |