You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clang-format: AlignAfterOpenBracket: AlwaysBreak not having an effect on braced blocks results in annoying formatting of requires expressions in concept definitions
#57108
Closed
griwes opened this issue
Aug 12, 2022
· 2 comments
I have a config with a 110 column limit, 4 space indent, and AlignAfterOpenBracket: AlwaysBreak. The result of formatting the above should be something like this:
This is broken in two ways, but, surprisingly, the wild placement of the braces doesn't actually annoy me that much; arguably, there is a sane coding style to find there if the closing brace was aligned with the opening brace around the atomic constraint.
The alignment of the whole block, though, is really bad. clang-format also ignores this config flag when formatting lambdas in subexpressions, but that is a much more minor annoyance IMHO; yanking a lambda out into a variable when we get to this behavior arguably results in cleaner code. The same cannot, however, be said about concepts, because concepts can only be placed at a namespace scope, so factoring a requires expression out pollutes that namespace with symbols that aren't a part of the interface.
And yes, I am aware that the docs do say that the option doesn't apply to braces, but that is in fact the bug here. Though if there's desire to not have this option change the behavior of braced blocks like this, I'd be happy to get a separate option to control this.
I would be happy to make an attempt at a solution for this, but quick searching through the codebase for the use of the config flag didn't help me with understanding of what would need to happen for this option to become correctly accepted for these cases, so if someone is able to give me a pointers on where to start, maybe I can fix this myself.
The text was updated successfully, but these errors were encountered:
Patch for one part of this issue (misaligment of the closing brace compared to the opening brace of the compound requirement): https://reviews.llvm.org/D134626
The other part (indentation of the whole requires expression) is arguably a duplicate of #56283
Consider the following snippet:
I have a config with a 110 column limit, 4 space indent, and
AlignAfterOpenBracket: AlwaysBreak
. The result of formatting the above should be something like this:However, clang-format-15 turns it into the following:
This is broken in two ways, but, surprisingly, the wild placement of the braces doesn't actually annoy me that much; arguably, there is a sane coding style to find there if the closing brace was aligned with the opening brace around the atomic constraint.
The alignment of the whole block, though, is really bad. clang-format also ignores this config flag when formatting lambdas in subexpressions, but that is a much more minor annoyance IMHO; yanking a lambda out into a variable when we get to this behavior arguably results in cleaner code. The same cannot, however, be said about concepts, because concepts can only be placed at a namespace scope, so factoring a requires expression out pollutes that namespace with symbols that aren't a part of the interface.
And yes, I am aware that the docs do say that the option doesn't apply to braces, but that is in fact the bug here. Though if there's desire to not have this option change the behavior of braced blocks like this, I'd be happy to get a separate option to control this.
I would be happy to make an attempt at a solution for this, but quick searching through the codebase for the use of the config flag didn't help me with understanding of what would need to happen for this option to become correctly accepted for these cases, so if someone is able to give me a pointers on where to start, maybe I can fix this myself.
The text was updated successfully, but these errors were encountered: