[cfe-commits] r59479 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Lex/PPDirectives.cpp

Ted Kremenek kremenek at apple.com
Mon Nov 17 17:04:48 PST 2008


Author: kremenek
Date: Mon Nov 17 19:04:47 2008
New Revision: 59479

URL: http://llvm.org/viewvc/llvm-project?rev=59479&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=59479&r1=59478&r2=59479&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Mon Nov 17 19:04:47 2008
@@ -330,6 +330,8 @@
   void Lex(Token &Result) {
     if (CurLexer)
       CurLexer->Lex(Result);
+    else if (CurPTHLexer)
+      CurPTHLexer->Lex(Result);
     else if (CurTokenLexer)
       CurTokenLexer->Lex(Result);
     else

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=59479&r1=59478&r2=59479&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Nov 17 19:04:47 2008
@@ -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)) {





More information about the cfe-commits mailing list