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) ||


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) ||
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to