r184894 - Formatter: Don't put a space after parameter-naming block comments.

Nico Weber nicolasweber at gmx.de
Tue Jun 25 17:15:19 PDT 2013


Author: nico
Date: Tue Jun 25 19:15:19 2013
New Revision: 184894

URL: http://llvm.org/viewvc/llvm-project?rev=184894&view=rev
Log:
Formatter: Don't put a space after parameter-naming block comments.

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


Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=184894&r1=184893&r2=184894&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jun 25 19:15:19 2013
@@ -1110,6 +1110,8 @@ bool TokenAnnotator::spaceRequiredBetwee
     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;
 }
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=184894&r1=184893&r2=184894&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jun 25 19:15:19 2013
@@ -756,7 +756,7 @@ TEST_F(FormatTest, RemovesTrailingWhites
 }
 
 TEST_F(FormatTest, UnderstandsBlockComments) {
-  verifyFormat("f(/*test=*/ true);");
+  verifyFormat("f(/*noSpaceAfterParameterNamingComment=*/true);");
   EXPECT_EQ(
       "f(aaaaaaaaaaaaaaaaaaaaaaaaa, /* Trailing comment for aa... */\n"
       "  bbbbbbbbbbbbbbbbbbbbbbbbb);",





More information about the cfe-commits mailing list