Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 2b9f6f3

Browse files
committed
clang-format: Make AlignAfterOpenBracket also affect angle brackets.
Patch by Matthew Whitehead, thank you. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259487 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent f3056a3 commit 2b9f6f3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/Format/ContinuationIndenter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
353353
// disallowing any further line breaks if there is no line break after the
354354
// opening parenthesis. Don't break if it doesn't conserve columns.
355355
if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak &&
356-
Previous.is(tok::l_paren) && State.Column > getNewLineColumn(State) &&
356+
Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
357+
State.Column > getNewLineColumn(State) &&
357358
(!Previous.Previous ||
358359
!Previous.Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch)))
359360
State.Stack.back().NoLineBreak = true;

unittests/Format/FormatTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10325,6 +10325,15 @@ TEST_F(FormatTest, ConstructorInitializerIndentWidth) {
1032510325
": aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
1032610326
" aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {}",
1032710327
Style);
10328+
Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
10329+
verifyFormat(
10330+
"SomeLongTemplateVariableName<\n"
10331+
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>",
10332+
Style);
10333+
verifyFormat(
10334+
"bool smaller = 1 < bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n"
10335+
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
10336+
Style);
1032810337
}
1032910338

1033010339
TEST_F(FormatTest, BreakConstructorInitializersBeforeComma) {

0 commit comments

Comments
 (0)