diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-07-11 05:39:23 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-07-11 05:39:23 +0000 |
| commit | 3ebcf4e2cd606f3d649e94bdeced50e924b878a4 (patch) | |
| tree | 5c14ace5a8c2b08e5691fe8a4a8d0dc91ce097a1 /clang/Lex/Lexer.cpp | |
| parent | 69f88b883d8eabe75616456e0f8a4af4cc34f39c (diff) | |
| download | bcm5719-llvm-3ebcf4e2cd606f3d649e94bdeced50e924b878a4.tar.gz bcm5719-llvm-3ebcf4e2cd606f3d649e94bdeced50e924b878a4.zip | |
Change Preprocessor::SkippingContents into Lexer::LexingRawMode. Raw mode
is an intra-lexer property, not a inter-lexer property, so it makes sense
for it to be define here. It also makes no sense for macros, and allows us
to define it more carefully in the header.
While I'm at it, improve comments and structuring in Lexer.h
llvm-svn: 38701
Diffstat (limited to 'clang/Lex/Lexer.cpp')
| -rw-r--r-- | clang/Lex/Lexer.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 893ff04d82e..2a1bcc0248f 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -58,6 +58,12 @@ Lexer::Lexer(const SourceBuffer *File, unsigned fileid, Preprocessor &pp, // We are not after parsing #include. ParsingFilename = false; + + // We are not in raw mode. Raw mode disables diagnostics and interpretation + // of tokens (e.g. identifiers, thus disabling macro expansion). It is used + // to quickly lex the tokens of the buffer, e.g. when handling a "#if 0" block + // or otherwise skipping over tokens. + LexingRawMode = false; } /// Stringify - Convert the specified string into a C string, with surrounding @@ -896,10 +902,10 @@ void Lexer::LexEndOfFile(LexerToken &Result, const char *CurPtr) { return; } - // 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 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, @@ -1176,7 +1182,7 @@ LexNextToken: // it's actually the start of a preprocessing directive. Callback to // the preprocessor to handle it. // FIXME: -fpreprocessed mode?? - if (Result.isAtStartOfLine() && !PP.isSkipping()) { + if (Result.isAtStartOfLine() && !LexingRawMode) { BufferPtr = CurPtr; PP.HandleDirective(Result); @@ -1321,7 +1327,7 @@ LexNextToken: // it's actually the start of a preprocessing directive. Callback to // the preprocessor to handle it. // FIXME: -fpreprocessed mode?? - if (Result.isAtStartOfLine() && !PP.isSkipping()) { + if (Result.isAtStartOfLine() && !LexingRawMode) { BufferPtr = CurPtr; PP.HandleDirective(Result); @@ -1357,7 +1363,7 @@ LexNextToken: return LexIdentifier(Result, CurPtr); } - if (!PP.isSkipping()) Diag(CurPtr-1, diag::err_stray_character); + if (!LexingRawMode) Diag(CurPtr-1, diag::err_stray_character); BufferPtr = CurPtr; goto LexNextToken; // GCC isn't tail call eliminating. } |

