aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PTHLexer.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-20 01:29:45 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-20 01:29:45 +0000
commit452e37837a48b2f0ced144784277fd4d28cbede9 (patch)
tree6c53176393b527ab5656def9eb71104b898cfcb4 /lib/Lex/PTHLexer.cpp
parent4d35da2e41941965bbee8ed7e8c30e7c21000d71 (diff)
- Default initialize ParsingPreprocessorDirective, ParsingFilename, and
LexingRawMode in the ctor of PreprocessorLexer. - PTHLexer: Use "LastToken" instead of "NumToken" git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59690 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r--lib/Lex/PTHLexer.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index 5adcd9f6a1..936a03ac0f 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -17,21 +17,19 @@
using namespace clang;
PTHLexer::PTHLexer(Preprocessor& pp, SourceLocation fileloc,
- const Token *TokArray, unsigned NumToks)
- : PreprocessorLexer(&pp, fileloc), FileLoc(fileloc),
- Tokens(TokArray), NumTokens(NumToks), CurToken(0) {
+ const Token *TokArray, unsigned NumTokens)
+ : PreprocessorLexer(&pp, fileloc),
+ Tokens(TokArray),
+ LastToken(NumTokens - 1),
+ CurToken(0) {
- assert (Tokens[NumTokens-1].is(tok::eof));
- --NumTokens;
-
- LexingRawMode = false;
- ParsingPreprocessorDirective = false;
- ParsingFilename = false;
+ assert (NumTokens >= 1);
+ assert (Tokens[LastToken].is(tok::eof));
}
void PTHLexer::Lex(Token& Tok) {
- if (CurToken == NumTokens) {
+ if (CurToken == LastToken) {
// If we hit the end of the file while parsing a preprocessor directive,
// end the preprocessor directive first. The next token returned will
// then be the end of file.
@@ -73,8 +71,7 @@ void PTHLexer::Lex(Token& Tok) {
}
void PTHLexer::setEOF(Token& Tok) {
- Tok = Tokens[NumTokens]; // NumTokens is already adjusted, so this isn't
- // an overflow.
+ Tok = Tokens[LastToken];
}
void PTHLexer::DiscardToEndOfLine() {
@@ -82,17 +79,17 @@ void PTHLexer::DiscardToEndOfLine() {
"Must be in a preprocessing directive!");
// Already at end-of-file?
- if (CurToken == NumTokens)
+ if (CurToken == LastToken)
return;
// Find the first token that is not the start of the *current* line.
- for ( ++CurToken; CurToken != NumTokens ; ++CurToken )
+ for ( ++CurToken; CurToken != LastToken ; ++CurToken )
if (Tokens[CurToken].isAtStartOfLine())
return;
}
unsigned PTHLexer::isNextPPTokenLParen() {
- if (CurToken == NumTokens)
+ if (CurToken == LastToken)
return 2;
return Tokens[CurToken].is(tok::l_paren);