From: Daniel Jasper Date: Thu, 26 Feb 2015 11:46:29 +0000 (+0000) Subject: clang-format: Make braced list formatting more consistent. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0204780a15d9d8d1bd2de6333e9abcd8ac19edf1;p=clang clang-format: Make braced list formatting more consistent. Before: Aaaa aaaaaaaaaaa{ { a, // +1 indent weird. b, // trailing comma signals one per line. }, // trailing comma signals one per line. }; After: Aaaa aaaaaaaaaaa{ { a, // better!? b, // trailing comma signals one per line. }, // trailing comma signals one per line. }; Interesting that this apparently was entirely untested :-(. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230627 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 7b36cac5dc..7c2d916ac5 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -824,7 +824,6 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State, ++NewIndentLevel; } else { NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth; - NewIndent = std::min(State.Column + 1, NewIndent); } const FormatToken *NextNoComment = Current.getNextNonComment(); AvoidBinPacking = diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index cc27969946..9738877e45 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5943,6 +5943,11 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { verifyFormat("std::vector v = {1, 0 /* comment */};"); verifyFormat("Node n{1, Node{1000}, //\n" " 2};"); + verifyFormat("Aaaa aaaaaaa{\n" + " {\n" + " aaaa,\n" + " },\n" + "};"); // In combination with BinPackParameters = false. FormatStyle NoBinPacking = getLLVMStyle();