<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54827>54827</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format: AllowShortLambdasOnASingleLine: Inline regression
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Megamouse
</td>
</tr>
</table>
<pre>
In October last year, I added `AllowShortLambdasOnASingleLine: Inline` to our project in order to fix some ugly lambdas.
It worked fine until now, but it seems to have regressed.
Using `AllowShortLambdasOnASingleLine: Empty` will fix the issue below, but it will obviously re-format all single-line lambdas as well.
### Input:
I expect the Opening Bracket of the callback to go to the next line.
```
void foo()
{
auto bar = [](std::function<bool()> func) -> void
{
if (func && func())
printf("Hello world\n");
};
bar([]() -> bool {
if (true)
{
return true;
}
return false;
});
}
```
### Expected:
The opening bracket moved to the next line as expected.
```
void foo()
{
auto bar = [](std::function<bool()> func) -> void
{
if (func && func())
printf("Hello world\n");
};
bar([]() -> bool
{
if (true)
{
return true;
}
return false;
});
}
```
### Actual Output:
The opening bracket moved to the next line as expected, but the closing bracket is now in the same line as the return statement.
```
void foo()
{
auto bar = [](std::function<bool()> func) -> void
{
if (func && func())
printf("Hello world\n");
};
bar([]() -> bool
{
if (true)
{
return true;
}
return false; });
}
```
Here the contents of our .clang-format
```
Standard: c++20
UseTab: AlignWithSpaces
TabWidth: 4
IndentWidth: 4
AccessModifierOffset: -4
PointerAlignment: Left
NamespaceIndentation: All
ColumnLimit: 0
BreakBeforeBraces: Allman
BreakConstructorInitializers: BeforeColon
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
AlwaysBreakTemplateDeclarations: Yes
AllowShortIfStatementsOnASingleLine: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AllowShortLambdasOnASingleLine: Inline
Cpp11BracedListStyle: true
IndentCaseLabels: false
SortIncludes: false
ReflowComments: true
AlignConsecutiveAssignments: true
AlignTrailingComments: true
AlignAfterOpenBracket: DontAlign
ConstructorInitializerAllOnOneLineOrOnePerLine: false
BinPackArguments: true
BinPackParameters: true
AlwaysBreakAfterReturnType: None
KeepEmptyLinesAtTheStartOfBlocks: true
IndentWrappedFunctionNames: false
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztV9-P4jYQ_mvCi7UoJMDCAw8B9nSo3LI6OK366CST4K5jR7YDS__6jp2EhUDbbd9anWRB4vn1eeazx4llepqtBNkkRsagCKfakBNQ5QULsiI0TSEl3tiPOJfH7V4qs6ZFnFK9EdGWiZzDmgnwwoisBLdPY58YSWSlSKnkb5AYwgSRKkXfOJ-xd6JlAaTK-QmDOVd9z196frQy5CjVG8bL0BGphGGcCHm0SOIK_RiiAQpt_ezpAYiCXIHWkDYO6t8fGmF9DvJTUZqTRXxknDtsZg-EaV0BiYFfhXYqMj4wWWmEruAhk6qghlCc187tg01AuyiC4wicX2HzgrAemK2yMoihWTqB99LmysbflCDsEuaKJm9giMzcdIKBYpyxy8-l_bWzAt4NsXHbOGO_Ge71IBmmU0ovmHjBtFF5nLeYprRCPzFVxAuXxBvNvdESVbVJLbQwyiqRGCaFFy5iKXnjJXwiVoCP5MG-2CBnj5fecbCMoJVVx_8xjsbUOTojcqo4SsWEyZw0-IrJk5YRPPVGC4EzLvaF98flxWszGVvmTs4rOWO08EkH2xmeURXcgrnVxqHAVEoQZxHeyBHRNZwro4xyfWOFJpfLOnu4rmOXPk-OLpCeGbRDLsiGOHFDnEIecDN1iWKJCY35T9L8LWmui_V_4U-UmIpysqnM5TH070jUHpLukOJSX1ozbU9w2wKsVFM8-VtzO9EsTBtqoABhfvLxv8hH8o9I-BUU1FyRwmDNtW1w9r7QTzgVedNW7zrYGipSqmxdCaZ_jiPw264POxpbQcRZLl6Z2W9LmoBumE3jV5aavVU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