owenpan added a comment.

In D135918#3857711 <https://reviews.llvm.org/D135918#3857711>, 
@HazardyKnusperkeks wrote:
> Fun fact, there is one instance of such a case within the clang-format code. 
> I can't remember where (I stumbled upon this in January, and tried to fix it 
> ever since), should that be reformatted with this patch, or with a follow up?

Perhaps with a follow-up in which we can reformat the entire directory.



================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:333
     return false;
 
   return !CurrentState.NoLineBreak;
----------------
Return true if `Current` is a conditional colon preceded by a lambda `r_brace` 
that is followed by a pair of (possibly empty) parentheses.


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:1412-1417
   // Add special behavior to support a format commonly used for JavaScript
   // closures:
   //   SomeFunction(function() {
   //     foo();
   //     bar();
   //   }, a, b, c);
----------------
HazardyKnusperkeks wrote:
> Someone put that in on purpose, but is that only intended for java script, 
> then we could add the language check.
> As one can see I also had to disable it for requires clauses. Because I think 
> it is a very hard thing to disable line breaks for all the scopes.
> Someone put that in on purpose, but is that only intended for java script, 
> then we could add the language check.

It started as a JavaScript-only behavior but was later extended to cover all 
languages.


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:1423
+    if (State.Stack[State.Stack.size() - 2].NestedBlockInlined && Newline &&
+        // Do not forbid line breaks for directly invoced lambdas.
+        (!Current.MatchingParen ||
----------------
HazardyKnusperkeks wrote:
> Or should we limit that to lambdas in a conditional? That would be even 
> messier to detect.
> Or should we limit that to lambdas in a conditional?

IMO we should, and it might not be too bad if you override `NoLineBreak` in 
`canBreak()` instead. See line 333 above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135918/new/

https://reviews.llvm.org/D135918

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to