clang-format: Make AlignAfterOpenBracket also affect angle brackets.

Patch by Matthew Whitehead, thank you.

llvm-svn: 259487
This commit is contained in:
Daniel Jasper
2016-02-02 10:28:11 +00:00
parent f5e239c4c3
commit b618a98582
2 changed files with 11 additions and 1 deletions

View File

@@ -353,7 +353,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
// disallowing any further line breaks if there is no line break after the
// opening parenthesis. Don't break if it doesn't conserve columns.
if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak &&
Previous.is(tok::l_paren) && State.Column > getNewLineColumn(State) &&
Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
State.Column > getNewLineColumn(State) &&
(!Previous.Previous ||
!Previous.Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch)))
State.Stack.back().NoLineBreak = true;

View File

@@ -10325,6 +10325,15 @@ TEST_F(FormatTest, ConstructorInitializerIndentWidth) {
": aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {}",
Style);
Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
verifyFormat(
"SomeLongTemplateVariableName<\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>",
Style);
verifyFormat(
"bool smaller = 1 < bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
Style);
}
TEST_F(FormatTest, BreakConstructorInitializersBeforeComma) {