[PATCH] D145642: [clang-format] Annotate lambdas with requires clauses.

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 10 22:40:50 PST 2023


owenpan added a comment.

In D145642#4186304 <https://reviews.llvm.org/D145642#4186304>, @rymiel wrote:

> In D145642#4183539 <https://reviews.llvm.org/D145642#4183539>, @owenpan wrote:
>
>> Would this patch make the end result look worse without "making the requires clause formatting of lambdas
>> match the formatting for functions"? If yes, then we should not land it just yet.
>
> Depends on your definition of "worse" :)
> I outlined this on the github issue (https://github.com/llvm/llvm-project/issues/61269), essentially:
>
> The result for the example provided on the github issue something like this:
>
>   [&]<typename Callable>(Callable&& callable)
>     requires std::is_invocable_v<Callable>
>   { static_cast<void>(callable); };
>
> Unlike function declarations, lambdas with a requires clause still have the body on one line. I don't yet know how to go about changing this, and **if** I should at all. This of course isn't an issue if the lambda body has multiple lines.

I'm more concerned with the above case. If the body of the lambda (including the enclosing braces) should not be merged into a single line, then I would say the token-annotation-only fix might trigger regressions. Otherwise, we can safely land this patch now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145642



More information about the cfe-commits mailing list