summaryrefslogtreecommitdiffstats
path: root/clang/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
commitb0262c1e648386cd9faecde3cd065810d5da4ca6 (patch)
treeb9c6ef2c94be13e336316aaa8b36aed6b0244f98 /clang/lib/Lex/PTHLexer.cpp
parent4ce15e12b9a5c3d8ca43334fef159dfb98a0c94e (diff)
downloadbcm5719-llvm-b0262c1e648386cd9faecde3cd065810d5da4ca6.tar.gz
bcm5719-llvm-b0262c1e648386cd9faecde3cd065810d5da4ca6.zip
- Default initialize ParsingPreprocessorDirective, ParsingFilename, and
LexingRawMode in the ctor of PreprocessorLexer. - PTHLexer: Use "LastToken" instead of "NumToken" llvm-svn: 59690
Diffstat (limited to 'clang/lib/Lex/PTHLexer.cpp')
-rw-r--r--clang/lib/Lex/PTHLexer.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp
index 5adcd9f6a14..936a03ac0f0 100644
--- a/clang/lib/Lex/PTHLexer.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud