<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Options to control how lambda capture group/arguments are reflowed"
href="https://bugs.llvm.org/show_bug.cgi?id=49353">49353</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Options to control how lambda capture group/arguments are reflowed
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>vlovich@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Currently clang-format doesn't expose any knobs to tune the formatting of
lambdas. For the KJ style guide
(<a href="https://github.com/capnproto/capnproto/blob/master/style-guide.md">https://github.com/capnproto/capnproto/blob/master/style-guide.md</a>) 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
- <a class="bz_bug_link
bz_status_NEW "
title="NEW - Inconsistent & non-configurable indentation of lambda body"
href="show_bug.cgi?id=49352">https://bugs.llvm.org/show_bug.cgi?id=49352</a> 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
- <a class="bz_bug_link
bz_status_NEW "
title="NEW - Inconsistent & non-configurable indentation of lambda body"
href="show_bug.cgi?id=49352">https://bugs.llvm.org/show_bug.cgi?id=49352</a> for an enhancement there)
});
So the two options (using terrible names) to control this behavior might look
like:
LambdaArgumentListOnNewlineIfNotSingleLine: bool
CaptureGroupOnNewlineIfLambdaHeaderNotSingleLine: bool</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>