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

Chris Lattner sabre at nondot.org
Mon Apr 12 16:04:41 PDT 2010


Author: lattner
Date: Mon Apr 12 18:04:41 2010
New Revision: 101084

URL: http://llvm.org/viewvc/llvm-project?rev=101084&view=rev
Log:
fix a minor bug I noticed while work with Jordy's patch for PR6101,
in an input file like this:

# 42
int x;

we were emitting:

# <something>
 int x;

(with a space before the int) because we weren't clearing the leading 
whitespace flag properly after the \n from the directive was handled.

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=101084&r1=101083&r2=101084&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Mon Apr 12 18:04:41 2010
@@ -1874,9 +1874,10 @@
           if (PP->isCurrentLexer(this)) {
             // Start a new token. If this is a #include or something, the PP may
             // want us starting at the beginning of the line again.  If so, set
-            // the StartOfLine flag.
+            // the StartOfLine flag and clear LeadingSpace.
             if (IsAtStartOfLine) {
               Result.setFlag(Token::StartOfLine);
+              Result.clearFlag(Token::LeadingSpace);
               IsAtStartOfLine = false;
             }
             goto LexNextToken;   // GCC isn't tail call eliminating.
@@ -2024,9 +2025,10 @@
         if (PP->isCurrentLexer(this)) {
           // Start a new token.  If this is a #include or something, the PP may
           // want us starting at the beginning of the line again.  If so, set
-          // the StartOfLine flag.
+          // the StartOfLine flag and clear LeadingSpace.
           if (IsAtStartOfLine) {
             Result.setFlag(Token::StartOfLine);
+            Result.clearFlag(Token::LeadingSpace);
             IsAtStartOfLine = false;
           }
           goto LexNextToken;   // GCC isn't tail call eliminating.





More information about the cfe-commits mailing list