[cfe-commits] r67235 - /cfe/trunk/lib/Lex/Lexer.cpp

Chris Lattner sabre at nondot.org
Wed Mar 18 13:58:28 PDT 2009


Author: lattner
Date: Wed Mar 18 15:58:27 2009
New Revision: 67235

URL: http://llvm.org/viewvc/llvm-project?rev=67235&view=rev
Log:
properly form a full token for # before calling HandleDirective.

Modified:
    cfe/trunk/lib/Lex/Lexer.cpp

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

==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Mar 18 15:58:27 2009
@@ -1595,15 +1595,13 @@
         if (!isLexingRawMode())
           Diag(BufferPtr, diag::charize_microsoft_ext);
         Kind = tok::hashat;
-      } else {
-        Kind = tok::hash;       // '%:' -> '#'
-        
+      } else {                                         // '%:' -> '#'
         // We parsed a # character.  If this occurs at the start of the line,
         // it's actually the start of a preprocessing directive.  Callback to
         // the preprocessor to handle it.
         // FIXME: -fpreprocessed mode??
         if (Result.isAtStartOfLine() && !LexingRawMode) {
-          BufferPtr = CurPtr;
+          FormTokenWithChars(Result, CurPtr, tok::hash);
           PP->HandleDirective(Result);
           
           // As an optimization, if the preprocessor didn't switch lexers, tail
@@ -1621,6 +1619,8 @@
           
           return PP->Lex(Result);
         }
+        
+        Kind = tok::hash;
       }
     } else {
       Kind = tok::percent;
@@ -1727,13 +1727,12 @@
         Diag(BufferPtr, diag::charize_microsoft_ext);
       CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
     } else {
-      Kind = tok::hash;
       // We parsed a # character.  If this occurs at the start of the line,
       // it's actually the start of a preprocessing directive.  Callback to
       // the preprocessor to handle it.
       // FIXME: -fpreprocessed mode??
       if (Result.isAtStartOfLine() && !LexingRawMode) {
-        BufferPtr = CurPtr;
+        FormTokenWithChars(Result, CurPtr, tok::hash);
         PP->HandleDirective(Result);
         
         // As an optimization, if the preprocessor didn't switch lexers, tail
@@ -1750,6 +1749,8 @@
         }
         return PP->Lex(Result);
       }
+      
+      Kind = tok::hash;
     }
     break;
 





More information about the cfe-commits mailing list