-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang-format] Incorrect method body when combining trailing return type & decltype
in requires
clause
#78645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
decltype
in requires
clausedecltype
in requires
clause
decltype
in requires
clausedecltype
in requires
clause
decltype
in requires
clausedecltype
in requires
clause
@llvm/issue-subscribers-bug Author: Fred Helmesjö (helmesjo)
Continuation of #56176 (@HazardyKnusperkeks).
Tweaking the original example in that issue by adding template<typename T>
struct Foo
{
auto bar(T in) -> int& requires (is_integral_v<decltype(in)>) {
call_something();
return 0;
}
}; Changing one of the following fixes the formatting again:
You need parens if you negate (
|
Note that this can only be reproduced if using the option The |
If clang-format is not sure whether a `requires` keyword starts a requires clause or a requires expression, it looks ahead to see if any token disqualifies it from being a requires clause. Among these tokens was `decltype`, since it fell through the switch. This patch allows decltype to exist in a require clause. I'm not 100% sure this change won't have repercussions, but that just means we need more test coverage! Fixes llvm#78645
If clang-format is not sure whether a `requires` keyword starts a requires clause or a requires expression, it looks ahead to see if any token disqualifies it from being a requires clause. Among these tokens was `decltype`, since it fell through the switch. This patch allows decltype to exist in a require clause. I'm not 100% sure this change won't have repercussions, but that just means we need more test coverage! Fixes #78645
If clang-format is not sure whether a `requires` keyword starts a requires clause or a requires expression, it looks ahead to see if any token disqualifies it from being a requires clause. Among these tokens was `decltype`, since it fell through the switch. This patch allows decltype to exist in a require clause. I'm not 100% sure this change won't have repercussions, but that just means we need more test coverage! Fixes llvm#78645
If clang-format is not sure whether a `requires` keyword starts a requires clause or a requires expression, it looks ahead to see if any token disqualifies it from being a requires clause. Among these tokens was `decltype`, since it fell through the switch. This patch allows decltype to exist in a require clause. I'm not 100% sure this change won't have repercussions, but that just means we need more test coverage! Fixes llvm#78645
Uh oh!
There was an error while loading. Please reload this page.
Continuation of #56176 (@HazardyKnusperkeks).
Tweaking the original example in that issue by adding
&
to the trailing return and usingdecltype(...)
in the requires clause breaks it:Changing one of the following fixes the formatting again:
-> int&
to-> int
decltype(in)
toT
requires (...)
torequires ...
You need parens if you negate (
(!...)
), but I guess a (highly arbitrary looking) workaround is to change fromrequires (is_integral_v<decltype(in)>)
to
requires is_integral_v<decltype(in)> || true
works (tested).
The text was updated successfully, but these errors were encountered: