Keep space between pointer and block comment.
authorDaniel Jasper <djasper@google.com>
Mon, 1 Jul 2013 09:34:09 +0000 (09:34 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 1 Jul 2013 09:34:09 +0000 (09:34 +0000)
Before: void f(int */* unused */) {}
After:  void f(int * /* unused */) {}

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

llvm-svn: 185320

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

index eb5616d..7cbacd9 100644 (file)
@@ -1073,7 +1073,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
       (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 &&
index c4d9c6f..25e1d49 100644 (file)
@@ -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) {