]> granicus.if.org Git - clang/commitdiff
Add hooks to use PTHLexer::Lex instead of Lexer::Lex when CurLexer is null.
authorTed Kremenek <kremenek@apple.com>
Tue, 18 Nov 2008 01:04:47 +0000 (01:04 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 18 Nov 2008 01:04:47 +0000 (01:04 +0000)
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

include/clang/Lex/Preprocessor.h
lib/Lex/PPDirectives.cpp

index d87813da0268a1f1de8882e7004ed01f375dc730..f048923a67cf8bc7515911a5794e79bbeb836907 100644 (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
index 22178739867d883a67c697ddc82ab3bb1f4b7051..69a3efe287c7f797c17deb769352ab380698330d 100644 (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)) {