[PATCH] D145642: [clang-format] Annotate lambdas with requires clauses.
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 11 01:33:17 PST 2023
owenpan added a comment.
In D145642#4186462 <https://reviews.llvm.org/D145642#4186462>, @rymiel wrote:
> Could you please clarify what you mean by "regressions" here? Isn't the behaviour of this syntax broken to begin with? It doesn't change anything about lambdas without //requires-clause//s
Let's use you example <https://godbolt.org/z/x8oT5Y9bz>:
$ cat test.cpp
#include <type_traits>
template <typename T>
struct foo {
static const bool value = true;
};
template <typename T>
inline constexpr bool foo_v = foo<T>::value;
template <typename T>
concept foo_c = foo_v<T>;
int main() {
[&]<typename Callable>
requires foo<Callable>::value
(Callable&& callable)
{
static_cast<void>(callable);
};
[&]<typename Callable>
requires foo_c<Callable>
(Callable&& callable)
{
static_cast<void>(callable);
};
[&]<typename Callable>
requires foo_v<Callable>
(Callable&& callable)
{
static_cast<void>(callable);
};
}
$ clang-format -version
clang-format version 17.0.0 (https://github.com/llvm/llvm-project f6e7a5c29221f445e4cbddc32667a1e12a1446db)
$ clang-format test.cpp
#include <type_traits>
template <typename T> struct foo {
static const bool value = true;
};
template <typename T> inline constexpr bool foo_v = foo<T>::value;
template <typename T>
concept foo_c = foo_v<T>;
int main() {
[&]<typename Callable>
requires foo<Callable>::value(Callable && callable)
{
static_cast<void>(callable);
};
[&]<typename Callable>
requires foo_c<Callable>(Callable && callable)
{
static_cast<void>(callable);
};
[&]<typename Callable>
requires foo_v<Callable>(Callable && callable)
{
static_cast<void>(callable);
};
}
If this patch would merge the lambda bodies into single lines, would that be considered a possible regression? My guess is that it would be unless the lambda bodies should be merged in the first place, in which case the patch would also fix a formatting bug in addition to the annotation bug.
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