summaryrefslogtreecommitdiffstats
path: root/clang/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-19 06:31:49 +0000
committerChris Lattner <sabre@nondot.org>2006-07-19 06:31:49 +0000
commit30a2fa14aeb91c43686fcbaf5cba22fe302a5668 (patch)
treef3246ae94c13a76b819eaae4401dae4231bd93d9 /clang/Lex/Lexer.cpp
parentab30c0360d3cec05efca240dc7d87b56962df454 (diff)
downloadbcm5719-llvm-30a2fa14aeb91c43686fcbaf5cba22fe302a5668.tar.gz
bcm5719-llvm-30a2fa14aeb91c43686fcbaf5cba22fe302a5668.zip
Move LexingRawMode handling of file EOF out of the preprocessor into the
lexer. This makes more logical sense and also unbreaks the case when the lexer hasn't been pushed onto the PP include stack. This is the case when pasting identifiers. This patch implements macro_paste_bcpl_comment.c. llvm-svn: 38736
Diffstat (limited to 'clang/Lex/Lexer.cpp')
-rw-r--r--clang/Lex/Lexer.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp
index 7f50f350e50..a9905f33916 100644
--- a/clang/Lex/Lexer.cpp
+++ b/clang/Lex/Lexer.cpp
@@ -904,23 +904,32 @@ bool Lexer::LexEndOfFile(LexerToken &Result, const char *CurPtr) {
return true; // Have a token.
}
- // If we aren't in raw mode, issue diagnostics. If we are in raw mode, let the
- // code that put us into raw mode do this: there are multiple possible reasons
- // for raw mode, and not all want these diagnostics.
- if (!LexingRawMode) {
- // 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 are in raw mode, return this event as an EOF token. Let the caller
+ // that put us in raw mode handle the event.
+ if (LexingRawMode) {
+ Result.StartToken();
+ BufferPtr = BufferEnd;
+ FormTokenWithChars(Result, BufferEnd);
+ Result.SetKind(tok::eof);
+ return true;
+ }
- // 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);
+ // 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,
+ 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);
+
BufferPtr = CurPtr;
+
+ // Finally, let the preprocessor handle this.
return PP.HandleEndOfFile(Result);
}
OpenPOWER on IntegriCloud