From: Daniel Jasper Date: Fri, 6 Dec 2013 15:19:50 +0000 (+0000) Subject: clang-format: Change line break decisions for array subscripts. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=143a2f208bbd404d06f63584d757c2d9b4523f41;p=clang clang-format: Change line break decisions for array subscripts. Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [aaaaaaaaaaaa]; After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaa]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196582 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 804db62833..d4880a472d 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1134,7 +1134,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Left.is(tok::comma)) return 1; if (Right.is(tok::l_square)) - return 150; + return 250; if (Right.Type == TT_StartOfName || Right.is(tok::kw_operator)) { if (Line.First->is(tok::kw_for) && Right.PartOfMultiVariableDeclStmt) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 575644efc5..2860bbbedd 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4558,6 +4558,9 @@ TEST_F(FormatTest, FormatsArrays) { "llvm::outs() << \"aaaaaaaaaaaa: \"\n" " << (*aaaaaaaiaaaaaaa)[aaaaaaaaaaaaaaaaaaaaaaaaa]\n" " [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];"); + + verifyGoogleFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaa];"); } TEST_F(FormatTest, LineStartsWithSpecialCharacter) {