]> granicus.if.org Git - clang/commitdiff
Don't divide L and #x in macro definitions. Fixes http://llvm.org/PR17144
authorAlexander Kornienko <alexfh@google.com>
Tue, 10 Sep 2013 13:41:43 +0000 (13:41 +0000)
committerAlexander Kornienko <alexfh@google.com>
Tue, 10 Sep 2013 13:41:43 +0000 (13:41 +0000)
Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1639

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

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index d9aef602d3f811c49417096af024f1541c7295d6..f10e68c3405a83d70ce63f049806b23206d4be89 100644 (file)
@@ -1286,6 +1286,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
     return false;
   if (Left.Type == TT_BlockComment && Left.TokenText.endswith("=*/"))
     return false;
+  if (Right.is(tok::hash) && Left.is(tok::identifier) && Left.TokenText == "L")
+    return false;
   return true;
 }
 
index c7991b4711b6121fc9f486e87f3a57324243b230..7f6956e8bbf19adbc76e0d2cccd87634da3b1a4f 100644 (file)
@@ -1930,6 +1930,7 @@ TEST_F(FormatTest, MacroDefinitionInsideStatement) {
 }
 
 TEST_F(FormatTest, HashInMacroDefinition) {
+  EXPECT_EQ("#define A(c) L#c", format("#define A(c) L#c", getLLVMStyle()));
   verifyFormat("#define A \\\n  b #c;", getLLVMStyleWithColumns(11));
   verifyFormat("#define A  \\\n"
                "  {        \\\n"