From: Richard Smith Date: Fri, 15 Jan 2016 03:24:18 +0000 (+0000) Subject: When copying whitespace flags from the token naming a macro argument onto the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae328a93ad3fe615e1080d5777603fd37dc633a4;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257863 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index c42966928e..ed2b8cdabd 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -305,6 +305,7 @@ void TokenLexer::ExpandFunctionArguments() { // identifier. ResultToks[FirstResult].setFlagValue(Token::LeadingSpace, NextTokGetsSpace); + ResultToks[FirstResult].setFlagValue(Token::StartOfLine, false); NextTokGetsSpace = false; } continue; diff --git a/test/Preprocessor/stringize_space.c b/test/Preprocessor/stringize_space.c index 2d79d478e3..ae70bf1818 100644 --- a/test/Preprocessor/stringize_space.c +++ b/test/Preprocessor/stringize_space.c @@ -12,3 +12,9 @@ c) // CHECK: {{^}}"a c"{{$}} +#define str(x) #x +#define f(x) str(-x) +f( + 1) + +// CHECK: {{^}}"-1"