forked from OSchip/llvm-project
clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.
If a call takes a single argument, using AlwaysBreak can lead to lots of wasted lines and additional indentation without improving the readability in a significant way. Before: caaaaaaaaaaaall( caaaaaaaaaaaall( caaaaaaaaaaaall( caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa)))); After: caaaaaaaaaaaall(caaaaaaaaaaaall(caaaaaaaaaaaall( caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa)))); llvm-svn: 263709
This commit is contained in:
parent
16f2460575
commit
710f8493c8
|
@ -356,7 +356,17 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
|
||||||
Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
|
Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
|
||||||
State.Column > getNewLineColumn(State) &&
|
State.Column > getNewLineColumn(State) &&
|
||||||
(!Previous.Previous ||
|
(!Previous.Previous ||
|
||||||
!Previous.Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch)))
|
!Previous.Previous->isOneOf(tok::kw_for, tok::kw_while,
|
||||||
|
tok::kw_switch)) &&
|
||||||
|
// Don't do this for simple (no expressions) one-argument function calls
|
||||||
|
// as that feels like needlessly wasting whitespace, e.g.:
|
||||||
|
//
|
||||||
|
// caaaaaaaaaaaall(
|
||||||
|
// caaaaaaaaaaaall(
|
||||||
|
// caaaaaaaaaaaall(
|
||||||
|
// caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa))));
|
||||||
|
Current.FakeLParens.size() > 0 &&
|
||||||
|
Current.FakeLParens.back() > prec::Unknown)
|
||||||
State.Stack.back().NoLineBreak = true;
|
State.Stack.back().NoLineBreak = true;
|
||||||
|
|
||||||
if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
|
if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
|
||||||
|
|
|
@ -4461,12 +4461,31 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
|
||||||
" aaaaaaaaaaa aaaaaaaaa,\n"
|
" aaaaaaaaaaa aaaaaaaaa,\n"
|
||||||
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
|
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
|
||||||
Style);
|
Style);
|
||||||
verifyFormat("SomeLongVariableName->someFunction(\n"
|
verifyFormat("SomeLongVariableName->someFunction(foooooooo(\n"
|
||||||
" foooooooo(\n"
|
" aaaaaaaaaaaaaaa,\n"
|
||||||
" aaaaaaaaaaaaaaa,\n"
|
" aaaaaaaaaaaaaaaaaaaaa,\n"
|
||||||
" aaaaaaaaaaaaaaaaaaaaa,\n"
|
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));",
|
||||||
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));",
|
|
||||||
Style);
|
Style);
|
||||||
|
verifyFormat(
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa(\n"
|
||||||
|
" aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa)));",
|
||||||
|
Style);
|
||||||
|
verifyFormat(
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaa.aaaaaaaaaa(\n"
|
||||||
|
" aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa)));",
|
||||||
|
Style);
|
||||||
|
verifyFormat(
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaa(\n"
|
||||||
|
" aaaaaaaaaaaaaaaaaaaaa(\n"
|
||||||
|
" aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa)),\n"
|
||||||
|
" aaaaaaaaaaaaaaaa);",
|
||||||
|
Style);
|
||||||
|
verifyFormat(
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaa(\n"
|
||||||
|
" aaaaaaaaaaaaaaaaaaaaa(\n"
|
||||||
|
" aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa)) &&\n"
|
||||||
|
" aaaaaaaaaaaaaaaa);",
|
||||||
|
Style);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FormatTest, ParenthesesAndOperandAlignment) {
|
TEST_F(FormatTest, ParenthesesAndOperandAlignment) {
|
||||||
|
|
Loading…
Reference in New Issue