r185320 - Keep space between pointer and block comment.

Daniel Jasper djasper at google.com
Mon Jul 1 02:34:09 PDT 2013


Author: djasper
Date: Mon Jul  1 04:34:09 2013
New Revision: 185320

URL: http://llvm.org/viewvc/llvm-project?rev=185320&view=rev
Log:
Keep space between pointer and block comment.

Before: void f(int */* unused */) {}
After:  void f(int * /* unused */) {}

The previous version seems to be valid C++ code but confuses many syntax
highlighters.

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=185320&r1=185319&r2=185320&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jul  1 04:34:09 2013
@@ -1073,7 +1073,7 @@ bool TokenAnnotator::spaceRequiredBetwee
       (Left.Type != TT_PointerOrReference || Style.PointerBindsToType))
     return true;
   if (Left.Type == TT_PointerOrReference)
-    return Right.Tok.isLiteral() ||
+    return Right.Tok.isLiteral() || Right.Type == TT_BlockComment ||
            ((Right.Type != TT_PointerOrReference) &&
             Right.isNot(tok::l_paren) && Style.PointerBindsToType &&
             Left.Previous &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=185320&r1=185319&r2=185320&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jul  1 04:34:09 2013
@@ -3887,6 +3887,8 @@ TEST_F(FormatTest, BlockComments) {
       format("int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; /* comment */\n"
              "int      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; /* comment */\n"
              "int    cccccccccccccccccccccccccccccc;  /* comment */\n"));
+
+  verifyFormat("void f(int * /* unused */) {}");
 }
 
 TEST_F(FormatTest, BlockCommentsInMacros) {





More information about the cfe-commits mailing list