From: Ted Kremenek Date: Tue, 18 Nov 2008 01:04:47 +0000 (+0000) Subject: Add hooks to use PTHLexer::Lex instead of Lexer::Lex when CurLexer is null. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f6452c5421c5db5a7ceff581525f286931d97f1a;p=clang 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/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index d87813da02..f048923a67 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -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 diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 2217873986..69a3efe287 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -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)) {