<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97013>97013</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format: formatting is strange for lambdas with attributes in designated initializers
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jacobsa
</td>
</tr>
</table>
<pre>
clang-format doesn't seem to correctly format lambdas with attributes, at least as part of designated initializers. For example, it wants this formatting for the following code:
```c++
SendCuratorRpcsRequest request = {
.response_prototype = request.response_prototype,
.choose_curators = [] [[clang::coro_wrapper]] ()
-> k3::Gen<AddressAndChannel, void> { LOG(QFATAL) << "DO NOT SUBMIT"; },
.rpc_timeout = some_long_expression + with_multiple_long_terms +
that_wraps_across_lines,
};
```
The formatting of the lambda is atypical, not aligning the second line with the rest of the lambda expression as is done with other expressions. I would expect something more like the following:
```c++
SendCuratorRpcsRequest request = {
.response_prototype = request.response_prototype,
.choose_curators = [] [[clang::coro_wrapper]] ()
-> k3::Gen<AddressAndChannel, void> {
LOG(QFATAL) << "DO NOT SUBMIT";
},
.rpc_timeout = some_long_expression + with_multiple_long_terms +
that_wraps_across_lines,
};
```
or something closer to what you get if you remove the attribute but add a long capture list, with the second line at least indented:
```c++
SendCuratorRpcsRequest request = {
.response_prototype = request.response_prototype,
.choose_curators = [long_capture_list_here]()
-> k3::Gen<AddressAndChannel, void> { LOG(QFATAL) << "DO NOT SUBMIT"; },
.rpc_timeout = some_long_expression + with_multiple_long_terms +
that_wraps_across_lines,
};
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcls2O2zYQx5-GvgzWkCnbsg86-KMOAqQNmmzPAk2OLSYUqXJG62yfvqCkdbzpboGmPRQxBFOg_uR8_TSiIrJnj1iKxVYs9hPVcR1i-UnpcCQ1OQbzWGqn_PnuFGKjGExA8kIWDITYAAfQIUbU7B5hlDjVH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