[PATCH] D44609: [Clang-Format] New option BreakBeforeLambdaBody to manage lambda line break inside function parameter call

Francois JEAN via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 6 06:51:02 PDT 2018


Wawha added a comment.

I'm not working on a public project with a public style guide, so not sure it will fit all the requirement inside. But perhaps the request of Rian for bareflank (https://bugs.llvm.org//show_bug.cgi?id=32151#c4) could help to fit the needs.

The current patch do not exactly do what he ask, but like you say, it's not easy to find all options or one options to match lambda formatting.

In my case, the main requirement is to be able **avoid** a lambda in one line. It's not easy to manage, when you put a breakpoint on a such line. It could break when the function taking the lambda in arg is call, or when the lambda body is executed. Which very annoying for debugging.
As example:

  return something([] ()  { somethingelse(); }); // Breakpoint one this line will break when calling something() AND somethingelse()

For the moment, there is no way to format is code in another way. We could have this possibilities:

  return something(
       [] ()
       {
             somethingelse();
       });

or

  return something([] ()  {
             somethingelse();
       });

or

  return something(
       [] ()  {
             somethingelse();
       });

The current patch are able to manage the first case, and I'm agree it make sense in allman option. So I'm ok to have it by default for allman.


Repository:
  rC Clang

https://reviews.llvm.org/D44609





More information about the cfe-commits mailing list