r257863 - When copying whitespace flags from the token naming a macro argument onto the

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 14 19:24:19 PST 2016


Author: rsmith
Date: Thu Jan 14 21:24:18 2016
New Revision: 257863

URL: http://llvm.org/viewvc/llvm-project?rev=257863&view=rev
Log:
When copying whitespace flags from the token naming a macro argument onto the
first token of the expansion, don't forget to copy the "is at the start of a
line" token (which is always false, as newlines cannot appear within a macro
body); otherwise, stringizing the result can insert spurious whitespace.

Modified:
    cfe/trunk/lib/Lex/TokenLexer.cpp
    cfe/trunk/test/Preprocessor/stringize_space.c

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=257863&r1=257862&r2=257863&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Thu Jan 14 21:24:18 2016
@@ -305,6 +305,7 @@ void TokenLexer::ExpandFunctionArguments
         // identifier.
         ResultToks[FirstResult].setFlagValue(Token::LeadingSpace,
                                              NextTokGetsSpace);
+        ResultToks[FirstResult].setFlagValue(Token::StartOfLine, false);
         NextTokGetsSpace = false;
       }
       continue;

Modified: cfe/trunk/test/Preprocessor/stringize_space.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/stringize_space.c?rev=257863&r1=257862&r2=257863&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/stringize_space.c (original)
+++ cfe/trunk/test/Preprocessor/stringize_space.c Thu Jan 14 21:24:18 2016
@@ -12,3 +12,9 @@ c)
 
 // CHECK: {{^}}"a c"{{$}}
 
+#define str(x) #x
+#define f(x) str(-x)
+f(
+    1)
+
+// CHECK: {{^}}"-1"




More information about the cfe-commits mailing list