]> granicus.if.org Git - clang/commitdiff
Formatter: Don't put a space after parameter-naming block comments.
authorNico Weber <nicolasweber@gmx.de>
Wed, 26 Jun 2013 00:15:19 +0000 (00:15 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 26 Jun 2013 00:15:19 +0000 (00:15 +0000)
Before: f(a, b, /*doFoo=*/ false);
Now: f(a, b, /*doFoo=*/false);

This style is a lot more common:
$ ack -H '=\*\/\w' lib | wc -l
    1281
$ ack -H '=\*\/ \w' lib | wc -l
      70

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

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

index c5315e72600cbbb15e5ca874ff50d639a485eb62..681903b4124cdc6115aecb5fcbe868034385a6da 100644 (file)
@@ -1110,6 +1110,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
     return false;
   if (Left.is(tok::period) || Right.is(tok::period))
     return false;
+  if (Left.Type == TT_BlockComment && Left.TokenText.endswith("=*/"))
+    return false;
   return true;
 }
 
index 6b1d2d3f400c75ec95ac440ed11393768e3e757f..909932e7c4b6754cbd495ca2f1dcd9f1adcc3746 100644 (file)
@@ -756,7 +756,7 @@ TEST_F(FormatTest, RemovesTrailingWhitespaceOfComments) {
 }
 
 TEST_F(FormatTest, UnderstandsBlockComments) {
-  verifyFormat("f(/*test=*/ true);");
+  verifyFormat("f(/*noSpaceAfterParameterNamingComment=*/true);");
   EXPECT_EQ(
       "f(aaaaaaaaaaaaaaaaaaaaaaaaa, /* Trailing comment for aa... */\n"
       "  bbbbbbbbbbbbbbbbbbbbbbbbb);",