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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59479 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 2217873..69a3efe 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -115,8 +115,7 @@
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 @@
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)) {