summaryrefslogtreecommitdiffstats
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
commit65585ed86aa23fd5e0ad481e869f0cecbf025b77 (patch)
treebe044ca4e799213d38673c5d47f13c239deeceff
parent0b41cbb5337eda65fa354fc24c22951cd77730a0 (diff)
downloadbcm5719-llvm-65585ed86aa23fd5e0ad481e869f0cecbf025b77.tar.gz
bcm5719-llvm-65585ed86aa23fd5e0ad481e869f0cecbf025b77.zip
Make continuations in constructor initializers consistent.
Before: Constructor : LooooooooooooooooooooongVariable( LooooooooooooooooooooongValue) {} After: Constructor : LooooooooooooooooooooongVariable( LooooooooooooooooooooongValue) {} llvm-svn: 173685
-rw-r--r--clang/lib/Format/Format.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index a6a53f48fd8..27d47109bd8 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index c1430193eb6..417dc9e9a24 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/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(
OpenPOWER on IntegriCloud