https://bugs.llvm.org/show_bug.cgi?id=49353
Bug ID: 49353
Summary: Options to control how lambda capture group/arguments
are reflowed
Product: clang
Version: 11.0
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangb...@nondot.org
Reporter: vlov...@gmail.com
CC: djas...@google.com, kli...@google.com,
llvm-bugs@lists.llvm.org
Currently clang-format doesn't expose any knobs to tune the formatting of
lambdas. For the KJ style guide
(https://github.com/capnproto/capnproto/blob/master/style-guide.md) the
following knobs would be ideal:
1. A knob to force the capture group + argument list for a lambda to go on a
new line if the capture group + argument list cannot fit on 1 line. Currently
clang-format will some times put it on a new line but other times will align to
the previous line.
2. A knob to force argument lists onto a separate line from the capture group
if the capture group + argument list doesn't fit on 1 line.
It should be possible to take any version of this (i.e. any length of capture
group/argument list):
callSomething([someArgument, someOtherArgument](int arg1, int arg2) {
// code
});
and always format it as:
callSomething(
[someArgument, someOtherArgument]
(int arg1, int arg2) {
// code (this indentation of the body isn't actually always guaranteed today
- https://bugs.llvm.org/show_bug.cgi?id=49352 for an enhancement there)
});
if the capture group + argument list need reflowing.
If there needs to be a reflow but the capture group + argument list can stay on
one line the expected output would be:
callSomething(
[someArgument, someOtherArgument](int arg1, int arg2) {
// code (this indentation of the body isn't actually always guaranteed today
- https://bugs.llvm.org/show_bug.cgi?id=49352 for an enhancement there)
});
So the two options (using terrible names) to control this behavior might look
like:
LambdaArgumentListOnNewlineIfNotSingleLine: bool
CaptureGroupOnNewlineIfLambdaHeaderNotSingleLine: bool
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs