[cfe-commits] r173685 - Make continuations in constructor initializers consistent.
Daniel Jasper
djasper at google.com
Mon Jan 28 05:31:35 PST 2013
Author: djasper
Date: Mon Jan 28 07:31:35 2013
New Revision: 173685
URL: http://llvm.org/viewvc/llvm-project?rev=173685&view=rev
Log:
Make continuations in constructor initializers consistent.
Before:
Constructor
: LooooooooooooooooooooongVariable(
LooooooooooooooooooooongValue) {}
After:
Constructor
: LooooooooooooooooooooongVariable(
LooooooooooooooooooooongValue) {}
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=173685&r1=173684&r2=173685&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Jan 28 07:31:35 2013
@@ -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 &&
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=173685&r1=173684&r2=173685&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 28 07:31:35 2013
@@ -924,6 +924,10 @@ TEST_F(FormatTest, ConstructorInitialize
" 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(
More information about the cfe-commits
mailing list