-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang-format] AlignAfterOpenBracket tries to do too much and doesn't do what it says #80049
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
This is Note that your first example is supported:
What you ask is a major refactoring of more or less working code. Addition of support for templates and lambdas in |
This case using type = std::remove_cv_t<
add_common_cv_reference<
std::common_type_t<std::decay_t<T0>, std::decay_t<T1>>,
T0,
T1
>
>; is now possible as of commit d2b45ce It is tested: // Test from https://github.com/llvm/llvm-project/issues/80049:
verifyFormat(
"using type = std::remove_cv_t<\n"
" add_common_cv_reference<\n"
" std::common_type_t<std::decay_t<T0>, std::decay_t<T1>>,\n"
" T0,\n"
" T1\n"
" >\n"
">;",
"using type = std::remove_cv_t<\n"
" add_common_cv_reference<\n"
" std::common_type_t<std::decay_t<T0>, std::decay_t<T1>>,\n"
" T0,\n"
" T1>>;",
Style); d2b45ce#diff-3f6f57cda9809a57c5b79e22b4181b3f3aaac7216262d0ef44108f39b0443e9bR11276-R11290 |
Is this supported? No matter what I do it will automatically put the
|
AlignAfterOpenBracket
has four configuration values:Align
DontAlign
AlwaysBreak
BlockIndent
This configuration option is trying to accomplish the following separate goals, assuming you need to insert a line break between arguments:
Align
vsDontAlign
)AlwaysBreak
vs others)BlockIndent
vs others)My style (and one I've seen other people use) is to always put a new argument on each line, with one level of indentation, and have the closing bracket on its own line (I think I've seen this indented or not? I prefer not), by analogy to curly braces
{}
:function( a, b, c );
The behavior of
BlockIndent
also does not match the documentation. The documentation states:However, given
and
AlignAfterOpenBracket
set toBlockIndent
, clang-format turns that intoIt's also unclear whether
BlockIndent
is supposed to do alignment or indentation, but in my code it looks like it inconsistently does both?AlwaysBreak
is similarly ambiguous in its documentation.To summarize, my preferred resolution of this issue is that we would have something like:
AlignWithOpenBracket
true
is behavior of currentAlign
,false
is behavior of currentDontAlign
: this option controls only whether new arguments are aligned to be right after the open bracket if they don't fit on the first line.vs
BreakAfterOpenBracket
true
means that if arguments don't all fit on one line, the first argument starts on a new line,false
means the first one goes on the same line as the open bracket.vs
BreakBeforeCloseBracket
true
means that if arguments don't all fit on one line, the closing bracket starts a new line,false
means it goes on the same line as the final argument.vs
So for me to get my preferred formatting, I would have
It is not clear to me what any of the four current options correspond to exactly in this system, based on documentation and current behavior.
The text was updated successfully, but these errors were encountered: