aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-28 13:31:35 +0000
committerDaniel Jasper <djasper@google.com>2013-01-28 13:31:35 +0000
commit02b771e3110f7799f93d5d17dc6fefc5713387c3 (patch)
treebb914d3077491be622f82064cee86467cead695b
parent3b9a8fc5bee5434bebc9058646896423adac625b (diff)
Make continuations in constructor initializers consistent.
Before: Constructor : LooooooooooooooooooooongVariable( LooooooooooooooooooooongValue) {} After: Constructor : LooooooooooooooooooooongVariable( LooooooooooooooooooooongValue) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173685 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/Format.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index a6a53f48fd..27d47109bd 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -625,7 +625,8 @@ private:
// Top-level spaces are exempt as that mostly leads to better results.
State.Stack.back().LastSpace = State.Column;
else if ((Previous.Type == TT_BinaryOperator ||
- Previous.Type == TT_ConditionalExpr) &&
+ Previous.Type == TT_ConditionalExpr ||
+ Previous.Type == TT_CtorInitializerColon) &&
getPrecedence(Previous) != prec::Assignment)
State.Stack.back().LastSpace = State.Column;
else if (Previous.ParameterCount > 1 &&
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index c1430193eb..417dc9e9a2 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -924,6 +924,10 @@ TEST_F(FormatTest, ConstructorInitializers) {
" aaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaaaaaaaaaaaa() {\n}");
+ verifyFormat("Constructor()\n"
+ " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}");
+
// Here a line could be saved by splitting the second initializer onto two
// lines, but that is not desireable.
verifyFormat(