[PATCH] D24703: [clang-format] BreakBeforeBinaryOperations and AlignAfterOpenBracket conflict, bug 30304

Daphne Pfister via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 17 20:22:30 PDT 2016


daphnediane created this revision.
daphnediane added a reviewer: djasper.
daphnediane added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Fix for the formatting options combination of BreakBeforeBinaryOperators: All, AlignAfterOpenBracket: AlwaysBreak not handling long templates correctly. This patch allows a break after an opening left parenthesis, TemplateOpener, or bracket when both options are enabled.

https://reviews.llvm.org/D24703

Files:
  lib/Format/TokenAnnotator.cpp

Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2513,9 +2513,11 @@
     return true;
   if ((Left.isBinaryOperator() || Left.is(TT_BinaryOperator)) &&
       !Left.isOneOf(tok::arrowstar, tok::lessless) &&
-      Style.BreakBeforeBinaryOperators != FormatStyle::BOS_All &&
-      (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None ||
-       Left.getPrecedence() == prec::Assignment))
+      ((Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak &&
+        Left.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square)) ||
+       (Style.BreakBeforeBinaryOperators != FormatStyle::BOS_All &&
+        (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None ||
+         Left.getPrecedence() == prec::Assignment))))
     return true;
   return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
                       tok::kw_class, tok::kw_struct, tok::comment) ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24703.71741.patch
Type: text/x-patch
Size: 1029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160918/8dc74f14/attachment-0001.bin>


More information about the cfe-commits mailing list