================
@@ -147,7 +147,8 @@ static bool startsNextOperand(const FormatToken &Current) {
 // Returns \c true if \c Current is a binary operation that must break.
 static bool mustBreakBinaryOperation(const FormatToken &Current,
                                      const FormatStyle &Style) {
-  return Style.BreakBinaryOperations != FormatStyle::BBO_Never &&
+  return Current.CanBreakBefore &&
----------------
andergnet wrote:

That's hard to put in words, I'll try.

Part of the issue is that `>>` are two tokens and `<<` is only one, and there 
is an extra step in the processing.

The algorithm tries all possible solutions, split or not to split the line at 
every point. 
During the processing it reaches this line:
https://github.com/llvm/llvm-project/blob/602e7a81e23c4e7b481494cd92e754ad01aa9007/clang/lib/Format/ContinuationIndenter.cpp#L904

When it's a variable name, the first `>`or the token `<<` it behaves as it 
should. For a variable mustBreak returns false: it's not a binary operation, 
and for the others returns according to the format style. However, before the 
second `<` it does not behave well, because it's a binary operator and tries to 
apply the format style accordingly (the same way it does for the others) and 
returns must break to `true`. This in turn causes `CurrentState.NoLineBreak = 
true;` which prevents further analyzing this solution branch which is valid. 

What I'm trying to do is force must break to be `false` when the token format 
says it `CanBreakBefore == false`, because it shouldn't be a problem not to 
break in a place not allowed to break. In the operator `<<` is not relevant 
because every time it enters this path `CanBreakBefore == true`.

If you still have questions, do not hesitate to come back. It is complicated, 
it took me a while to figure it out what was going on.

https://github.com/llvm/llvm-project/pull/122282
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to