[PATCH] D15062: [clang-format] Add test for AlignAfterOpenBracket = AlwaysBreak in C++.

Jean-Philippe Dufraigne via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 29 17:22:59 PST 2015


jeanphilippeD created this revision.
jeanphilippeD added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Revision 251405 added AlwaysBreak to support Google's JavaScript style.
This changeset complete existing AlignsAfterOpenBracket tests to exercise AlwaysBreak for C++.

I thought this would be worthwhile.
With this option we can support request from http://lists.llvm.org/pipermail/cfe-dev/2015-May/042942.html, that had been requested a few times.
This also partially solve related Bug 23422 and is probably sufficient for most people.

AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
BinPackArguments = false;
BinPackParameters = false;

With these setting we obtain this formatting:

        void fooWithAVeryLongParamList(
            int firstParameter,
            int secondParameter
            int lastParameter)
        {
            object.alsoThisDoenstFitSoIBreakImmidiatly(
                firstParameter,
                secondParameter,
                lastParameter);
        }

http://reviews.llvm.org/D15062

Files:
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4344,6 +4344,26 @@
       "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n"
       "    aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));",
       Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+  verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+               "    aaaaaaaaaaa aaaaaaaa,\n"
+               "    aaaaaaaaa aaaaaaa,\n"
+               "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}",
+               Style);
+  verifyFormat("SomeLongVariableName->someVeryLongFunctionName(\n"
+               "    aaaaaaaaaaa aaaaaaaaa,\n"
+               "    aaaaaaaaaaa aaaaaaaaa,\n"
+               "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
+               Style);
+  verifyFormat("SomeLongVariableName->someFunction(\n"
+               "    foooooooo(\n"
+               "        aaaaaaaaaaaaaaa,\n"
+               "        aaaaaaaaaaaaaaaaaaaaa,\n"
+               "        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));",
+               Style);
 }
 
 TEST_F(FormatTest, ParenthesesAndOperandAlignment) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15062.41358.patch
Type: text/x-patch
Size: 1338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151130/0f9ef617/attachment.bin>


More information about the cfe-commits mailing list