]> granicus.if.org Git - clang/commitdiff
When copying whitespace flags from the token naming a macro argument onto the
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 15 Jan 2016 03:24:18 +0000 (03:24 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 15 Jan 2016 03:24:18 +0000 (03:24 +0000)
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

lib/Lex/TokenLexer.cpp
test/Preprocessor/stringize_space.c

index c42966928e52ca377b2cbaf87419845637d42ba4..ed2b8cdabd1c47a9da9afa5f470d9000fb05e0e2 100644 (file)
@@ -305,6 +305,7 @@ void TokenLexer::ExpandFunctionArguments() {
         // identifier.
         ResultToks[FirstResult].setFlagValue(Token::LeadingSpace,
                                              NextTokGetsSpace);
+        ResultToks[FirstResult].setFlagValue(Token::StartOfLine, false);
         NextTokGetsSpace = false;
       }
       continue;
index 2d79d478e39d0d725a812a6b67ec4ca2e6d9ab9c..ae70bf18187c6921edcfc40b506c467e0707e09d 100644 (file)
@@ -12,3 +12,9 @@ c)
 
 // CHECK: {{^}}"a c"{{$}}
 
+#define str(x) #x
+#define f(x) str(-x)
+f(
+    1)
+
+// CHECK: {{^}}"-1"