summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-02-02 10:28:11 +0000
committerDaniel Jasper <djasper@google.com>2016-02-02 10:28:11 +0000
commitb618a985821ffcdf65b84eec5f3d50677efef776 (patch)
tree9791098cf264223407da5502722ec40f620b9dbc
parentf5e239c4c39a5b9638715481edc40776cadc5c34 (diff)
downloadbcm5719-llvm-b618a985821ffcdf65b84eec5f3d50677efef776.tar.gz
bcm5719-llvm-b618a985821ffcdf65b84eec5f3d50677efef776.zip
clang-format: Make AlignAfterOpenBracket also affect angle brackets.
Patch by Matthew Whitehead, thank you. llvm-svn: 259487
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp9
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 76a458db9bd..fa51f055438 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -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;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index ad355398508..6ffeb65280a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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) {
OpenPOWER on IntegriCloud