diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-07-11 05:04:55 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-07-11 05:04:55 +0000 |
| commit | d8aee0e81bb12ec08d63628204371b366f336764 (patch) | |
| tree | bb85a66babc072890fa2b6784559405eabc6024f /clang/Lex/Lexer.cpp | |
| parent | b63d9de243dddbb7240f7786a29612842d56f531 (diff) | |
| download | bcm5719-llvm-d8aee0e81bb12ec08d63628204371b366f336764.tar.gz bcm5719-llvm-d8aee0e81bb12ec08d63628204371b366f336764.zip | |
Implement "lparen scanning" for lexer buffers, by making "skipping lexing"
completely reversible. This implements tests 3/4 of
test/Preprocessor/macro_fn_lparen_scan.c
llvm-svn: 38699
Diffstat (limited to 'clang/Lex/Lexer.cpp')
| -rw-r--r-- | clang/Lex/Lexer.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 967d4e76758..893ff04d82e 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -896,16 +896,21 @@ void Lexer::LexEndOfFile(LexerToken &Result, const char *CurPtr) { return; } - // If we are in a #if directive, emit an error. - while (!ConditionalStack.empty()) { - PP.Diag(ConditionalStack.back().IfLoc, - diag::err_pp_unterminated_conditional); - ConditionalStack.pop_back(); - } + // If we aren't skipping, issue diagnostics. If we are skipping, let the + // skipping code do this: there are multiple possible reasons for skipping, + // and not all want these diagnostics. + if (!PP.isSkipping()) { + // If we are in a #if directive, emit an error. + while (!ConditionalStack.empty()) { + PP.Diag(ConditionalStack.back().IfLoc, + diag::err_pp_unterminated_conditional); + ConditionalStack.pop_back(); + } - // If the file was empty or didn't end in a newline, issue a pedwarn. - if (CurPtr[-1] != '\n' && CurPtr[-1] != '\r') - Diag(BufferEnd, diag::ext_no_newline_eof); + // If the file was empty or didn't end in a newline, issue a pedwarn. + if (CurPtr[-1] != '\n' && CurPtr[-1] != '\r') + Diag(BufferEnd, diag::ext_no_newline_eof); + } BufferPtr = CurPtr; PP.HandleEndOfFile(Result); |

