From 3a1847e0a1810a0b1b963182abc59114cc5ff53d Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 1 Jul 2013 09:34:09 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185320 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 +- unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index eb5616d5ab..7cbacd9042 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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 && diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index c4d9c6f573..25e1d49f08 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) { -- 2.40.0