-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang-format] Incorrect formatting for annotated constrained functions #69325
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
@llvm/issue-subscribers-clang-format Author: Utkarsh Saxena (usx95)
clang-format's output:
```
#define ANNOTATE(A) [[clang::annotate(A)]]
template <typename Message>
requires(true)
ANNOTATE(
"Loooooooooooooooooooooooooooooooooooooooooooooooooooong message"
"Loooooooooooooooooooooooooooooooooooooooooooooooooooong message"
"message") void foo(){};
```
Expected formatting:
```
#define ANNOTATE(A) [[clang::annotate(A)]]
template <typename Message>
requires(true)
ANNOTATE(
"Loooooooooooooooooooooooooooooooooooooooooooooooooooong message"
"Loooooooooooooooooooooooooooooooooooooooooooooooooooong message"
"message")
void foo(){};
```
removing the requires clause fixes the formatting (moved |
@llvm/issue-subscribers-c-20 Author: Utkarsh Saxena (usx95)
clang-format's output:
```
#define ANNOTATE(A) [[clang::annotate(A)]]
template <typename Message>
requires(true)
ANNOTATE(
"Loooooooooooooooooooooooooooooooooooooooooooooooooooong message"
"Loooooooooooooooooooooooooooooooooooooooooooooooooooong message"
"message") void foo(){};
```
Expected formatting:
```
#define ANNOTATE(A) [[clang::annotate(A)]]
template <typename Message>
requires(true)
ANNOTATE(
"Loooooooooooooooooooooooooooooooooooooooooooooooooooong message"
"Loooooooooooooooooooooooooooooooooooooooooooooooooooong message"
"message")
void foo(){};
```
removing the requires clause fixes the formatting (moved |
I'll take a look what's the difference. In the meantime maybe https://clang.llvm.org/docs/ClangFormatStyleOptions.html#macros could help you. |
The clang-format settings below would work:
|
I think the problem is that we do not want to "always" have a break (for example, when the annotation is small enough). The problem is that the existence of a requires clause removes the line break, which looks unexpected. |
I'd say we have two issues here. One is that it is handled differently with the requires clause. But the bigger issue would be that
I'll try to fix the second issue, and then we'll see if the first is still around. |
If you declare your |
Then setting it to |
So I actually corrected the first issue. The second issue will be tracked in #70603. |
Uh oh!
There was an error while loading. Please reload this page.
clang-format's output:
Expected formatting:
removing the requires clause fixes the formatting (moved
void foo()
to the next line).The text was updated successfully, but these errors were encountered: