[PATCH] D145642: [clang-format] Annotate lambdas with requires clauses.
Utkarsh Saxena via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 22 08:12:38 PDT 2023
usaxena95 added a comment.
> starting a line with an opening paren is pretty weird!)
I do not think this is weird. On the contrary, this is more readable to me and separates the requires clause from the parameters list. For example this one looks so much better:
// trunk.
template <typename T>
void func() {
auto x = []<typename U>
requires Foo<T> && Foo<T>(T t, U u) requires BarBar<U> && BarBar<U> ||
BarBar<U>
{
return u + t;
};
}
// patch.
template <typename T> void func() {
auto x = []<typename U>
requires Foo<T> && Foo<T>
(T t, U u)
requires BarBar<U> && BarBar<U> || BarBar<U>
{ return u + t; };
}
Discussion on wrapping the lambda body with single statement. FWIW: I do not think this is a regression and we are fixing things as seen in my first example.
Another point:
While testing this patch, the following still fails to recognise. Might be something special with `true`.
auto y = [&]<typename Callable>
requires true(Callable && callable)
{ static_cast<void>(callable); };
================
Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:1352
+
+ // Both at once? Probably not even valid.
+ Tokens = annotate("[] <typename T> requires Foo<T> (T t) requires Bar<T> {}");
----------------
This is valid and is accepted by the compilers https://godbolt.org/z/EPbrWbrsv
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