[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

Francois Ferrand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 17 09:31:50 PDT 2017


Typz added a comment.

we are using this style at our company, not sure if it is used elsewhere; I will check.

however, it seems to me that this behavior does not match the name of the option : AlignOperands does not align the operands anymore when BreakBeforeBinaryOperators is set...
so, for this patch to go forward, should I change AlignOperands into OperandAlignment enum, with 3 options? Something like

- OA_NotAligned, same as AlignOperands=false
- OA_AlignOperator, same the current AlignOperands=true
- OA_AlignOperands, same as AlignOperands=true when BreakBeforeBinaryOperators=false but my "new" mode when BreakBeforeBinaryOperators=true



================
Comment at: unittests/Format/FormatTest.cpp:2476
       "bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
-      "                     + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
-      "                     + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
-      "                 == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
-      "                            * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"
-      "                        + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"
-      "             && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
-      "                        * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
-      "                    > ccccccccccccccccccccccccccccccccccccccccc;",
+      "                   + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+      "                   + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
----------------
djasper wrote:
> This looks very inconsistent to me.
not sure what you mean, I do not really understand how this expression was aligned before the patch...
it is not so much better in this case with the patch, but the '&&' is actually right-aligned with the '=' sign.


https://reviews.llvm.org/D32478





More information about the cfe-commits mailing list