Add hooks to use PTHLexer::Lex instead of Lexer::Lex when CurLexer is null.

Performance tests on Cocoa.h (using the regular Lexer) shows no performance
difference.

llvm-svn: 59479
This commit is contained in:
Ted Kremenek 2008-11-18 01:04:47 +00:00
parent e2c23daa14
commit 6b73291462
2 changed files with 7 additions and 3 deletions

View File

@ -330,6 +330,8 @@ public:
void Lex(Token &Result) {
if (CurLexer)
CurLexer->Lex(Result);
else if (CurPTHLexer)
CurPTHLexer->Lex(Result);
else if (CurTokenLexer)
CurTokenLexer->Lex(Result);
else

View File

@ -115,8 +115,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
bool FoundNonSkipPortion,
bool FoundElse) {
++NumSkipped;
assert(CurTokenLexer == 0 && CurLexer &&
"Lexing a macro, not a file?");
assert(CurTokenLexer == 0 && CurPPLexer && "Lexing a macro, not a file?");
CurPPLexer->pushConditionalLevel(IfTokenLoc, /*isSkipping*/false,
FoundNonSkipPortion, FoundElse);
@ -126,7 +125,10 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
CurPPLexer->LexingRawMode = true;
Token Tok;
while (1) {
CurLexer->Lex(Tok);
if (CurLexer)
CurLexer->Lex(Tok);
else
CurPTHLexer->Lex(Tok);
// If this is the end of the buffer, we have an error.
if (Tok.is(tok::eof)) {