[PATCH] D135918: [clang-format] Fix lambda formatting in conditional

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 13 22:59:04 PDT 2022


HazardyKnusperkeks added a comment.

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?



================
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);
----------------
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.


================
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 ||
----------------
Or should we limit that to lambdas in a conditional? That would be even messier to detect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135918



More information about the cfe-commits mailing list