clang-format: Allow splitting the line after /**/-comments.

While it might change the meaning of the comment in rare circumstances,
it is better than violating the column limit.

llvm-svn: 270975
This commit is contained in:
Daniel Jasper 2016-05-27 08:59:34 +00:00
parent 5fa681ee78
commit 99302edd1c
2 changed files with 5 additions and 1 deletions

View File

@ -1826,6 +1826,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return 500; return 500;
if (Left.isOneOf(tok::kw_class, tok::kw_struct)) if (Left.isOneOf(tok::kw_class, tok::kw_struct))
return 5000; return 5000;
if (Left.is(tok::comment))
return 1000;
if (Left.isOneOf(TT_RangeBasedForLoopColon, TT_InheritanceColon)) if (Left.isOneOf(TT_RangeBasedForLoopColon, TT_InheritanceColon))
return 2; return 2;
@ -2464,7 +2466,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
Left.getPrecedence() == prec::Assignment)) Left.getPrecedence() == prec::Assignment))
return true; return true;
return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace, return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
tok::kw_class, tok::kw_struct) || tok::kw_class, tok::kw_struct, tok::comment) ||
Right.isMemberAccess() || Right.isMemberAccess() ||
Right.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow, tok::lessless, Right.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow, tok::lessless,
tok::colon, tok::l_square, tok::at) || tok::colon, tok::l_square, tok::at) ||

View File

@ -1143,6 +1143,8 @@ TEST_F(FormatTest, UnderstandsBlockComments) {
" aaaaaaaaaaaaaaaaaa ,\n" " aaaaaaaaaaaaaaaaaa ,\n"
" aaaaaaaaaaaaaaaaaa) { /*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/\n" " aaaaaaaaaaaaaaaaaa) { /*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/\n"
"}")); "}"));
verifyFormat("f(/* aaaaaaaaaaaaaaaaaa = */\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
FormatStyle NoBinPacking = getLLVMStyle(); FormatStyle NoBinPacking = getLLVMStyle();
NoBinPacking.BinPackParameters = false; NoBinPacking.BinPackParameters = false;