r175277 - Re-enable ConstructorInitializerAllOnOneLineOrOnePerLine option.
Daniel Jasper
djasper at google.com
Fri Feb 15 08:49:44 PST 2013
Author: djasper
Date: Fri Feb 15 10:49:44 2013
New Revision: 175277
URL: http://llvm.org/viewvc/llvm-project?rev=175277&view=rev
Log:
Re-enable ConstructorInitializerAllOnOneLineOrOnePerLine option.
This got lost and was untested as the same effect is achieved by
avoiding bin packing, which is active in Google style by default.
However, moving forward, we want more control over the bin packing
option(s) and thus, this flag should work as expected.
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=175277&r1=175276&r2=175277&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Feb 15 10:49:44 2013
@@ -580,6 +580,9 @@ private:
State.Stack.back().FirstLessLess = State.Column;
if (Current.is(tok::question))
State.Stack.back().QuestionColumn = State.Column;
+ if (Current.Type == TT_CtorInitializerColon &&
+ Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
+ State.Stack.back().AvoidBinPacking = true;
if (Current.is(tok::l_brace) && Current.MatchingParen != NULL &&
!Current.MatchingParen->MustBreakBefore) {
if (getLengthToMatchingParen(Current) + State.Column > getColumnLimit())
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=175277&r1=175276&r2=175277&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Feb 15 10:49:44 2013
@@ -1059,17 +1059,6 @@ TEST_F(FormatTest, ConstructorInitialize
"SomeClass::Constructor()\n"
" : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {\n}");
- verifyGoogleFormat(
- "SomeClass::Constructor()\n"
- " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
- " aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
- " aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {\n}");
- verifyGoogleFormat(
- "SomeClass::Constructor()\n"
- " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), // Some comment\n"
- " aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
- " aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {\n}");
-
verifyFormat(
"SomeClass::Constructor()\n"
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
@@ -1093,10 +1082,20 @@ TEST_F(FormatTest, ConstructorInitialize
" aaaaaaaaaaa(aaaaaaaaaaa),\n"
" aaaaaaaaaaaaaaaaaaaaat(aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}");
- verifyGoogleFormat("MyClass::MyClass(int var)\n"
- " : some_var_(var), // 4 space indent\n"
- " some_other_var_(var + 1) { // lined up\n"
- "}");
+ FormatStyle OnePerLine = getLLVMStyle();
+ OnePerLine.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+ verifyFormat("SomeClass::Constructor()\n"
+ " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
+ " aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
+ " aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {\n}", OnePerLine);
+ verifyFormat("SomeClass::Constructor()\n"
+ " : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), // Some comment\n"
+ " aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
+ " aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {\n}", OnePerLine);
+ verifyFormat("MyClass::MyClass(int var)\n"
+ " : some_var_(var), // 4 space indent\n"
+ " some_other_var_(var + 1) { // lined up\n"
+ "}", OnePerLine);
// This test takes VERY long when memoization is broken.
std::string input = "Constructor()\n"
More information about the cfe-commits
mailing list