]> granicus.if.org Git - clang/commitdiff
fix a minor bug I noticed while work with Jordy's patch for PR6101,
authorChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 23:04:41 +0000 (23:04 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Apr 2010 23:04:41 +0000 (23:04 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101084 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Lexer.cpp

index 19f25ea4a8bb19de48c5773da1302cb1ddf5f2eb..74e8d7489e9a8f20da288da4a0a2c67155e61655 100644 (file)
@@ -1874,9 +1874,10 @@ LexNextToken:
           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 @@ LexNextToken:
         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.