<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95679>95679</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] Horrible formatting for lambdas inside member initializations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
EmrecanKaracayir
</td>
</tr>
</table>
<pre>
Configuration:
```yaml
# BasedOnStyle: // Unused
AccessModifierOffset: -2
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Left
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCaseColons: true
# AlignConsecutiveTableGenCondOperatorColons: // v19
# AlignConsecutiveTableGenDefinitionColons: // v19
AlignEscapedNewlines: Right
AlignOperands: AlignAfterOperator
AlignTrailingComments:
Kind: Always
OverEmptyLines: 1
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: OnlyWithParen
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
# AttributeMacros: // Unused
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
# BreakInitializerIndentWidth: // Unused (If unset ContinuationIndentWidth is used)
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Always
# BreakAfterJavaFieldAnnotations: // Unused (Not C++)
# BreakAfterReturnType // v19
BreakArrays: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
# BreakTemplateDeclarations // v19
ColumnLimit: 80
# CommentPragmas: // Unused
CompactNamespaces: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
# ForEachMacros: // Unused
# IfMacros: // Unused
IncludeBlocks: Regroup
IncludeCategories:
- Regex: ^\".*pch\..*\"$ # Precompiled headers
Priority: -1
SortPriority: 0
CaseSensitive: false
- Regex: ^\".*\..*\"$ # Project headers
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: ^<.*\..*>$ # Included headers
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: ^<.*>$ # Standard library headers
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: $ # Main header
IncludeIsMainSourceRegex: $ # Main source
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: true
InsertNewlineAtEOF: true
InsertTrailingCommas: Wrapped
IntegerLiteralSeparator:
Binary: 4
BinaryMinDigits: 0
Decimal: 3
DecimalMinDigits: 0
Hex: 2
HexMinDigits: 0
# JavaImportGroups: // Unused (Not C++)
# JavaScriptQuotes: // Unused (Not C++)
# JavaScriptWrapImports: // Unused (Not C++)
KeepEmptyLinesAtEOF: false
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
LineEnding: LF
# MacroBlockBegin: // Unused
# MacroBlockEnd: // Unused
# Macros: // Unused
# MainIncludeChar // v19
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
# NamespaceMacros: // Unused
# ObjCBinPackProtocolList: // Unused (Not C++)
# ObjCBlockIndentWidth: // Unused (Not C++)
# ObjCBreakBeforeNestedBlockParam: // Unused (Not C++)
# ObjCPropertyAttributeOrder: // Unused (Not C++)
# ObjCSpaceAfterProperty: // Unused (Not C++)
# ObjCSpaceBeforeProtocolList: // Unused (Not C++)
PPIndentWidth: -1 # Use IndentWidth
PackConstructorInitializers: Never
PenaltyBreakAssignment: 125
PenaltyBreakBeforeFirstCallParameter: 5
PenaltyBreakComment: 250
PenaltyBreakFirstLessLess: 125
PenaltyBreakOpenParenthesis: 0
PenaltyBreakScopeResolution: 1000
PenaltyBreakString: 250
PenaltyBreakTemplateDeclaration: 25
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 5
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
QualifierAlignment: Left
# QualifierOrder: // Unused
# RawStringFormats: // Unused
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: ReturnStatement
RemoveSemicolon: true
RequiresClausePosition: WithPreceding
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 0
SkipMacroDefinitionBody: false
SortIncludes: CaseSensitive
# SortJavaStaticImport: // Unused (Not C++)
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
# SpaceBeforeJsonColon: // Unused (Not C++)
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: 1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: c++20
# StatementAttributeLikeMacros: // Unused
# StatementMacros: // Unused
TabWidth: 2
# TableGenBreakInsideDAGArg: // v19
# TableGenBreakingDAGArgOperators: // v19
# TypeNames: // Unused
# TypeNameMacros: // Unused
UseTab: Never
# VerilogBreakBetweenInstancePorts: // Unused (Not C++)
```
Result:
```cpp
Texture::Texture(
std::int32_t width,
std::int32_t height,
const Color& color,
bool transparency
)
try : m_bitmap{
[]()->Render::Target{return Render::Target{Render::Target::Action::ACQUIRE}
;
} // namespace Engine::Graphics
(), width, height
}
, m_transparency{transparency}
{
// Create off-screen render target
const Render::Target offscreenRenderTarget{
Render::Target::Action::CREATE, screenRenderTarget.getHandle()
};
// Select the bitmap into the off-screen render target
offscreenRenderTarget.selectObject(m_bitmap.getHandle());
// Create the brush
const Brush brush{color};
// Fill the bitmap with the brush
const Math::Rectangle<std::int32_t> rectangle{0, 0, width, height};
brush.fillRectangle(offscreenRenderTarget, rectangle);
}
catch (...) { throw; }
```
Expected:
```cpp
Texture::Texture(
std::int32_t width,
std::int32_t height,
const Color& color,
bool transparency
)
try
: m_bitmap
{
[]() -> Render::Target
{
return Render::Target{Render::Target::Action::ACQUIRE};
}(),
width,
height
}
, m_transparency{transparency}
{
// Create off-screen render target
const Render::Target offscreenRenderTarget{
Render::Target::Action::CREATE, screenRenderTarget.getHandle()
};
// Select the bitmap into the off-screen render target
offscreenRenderTarget.selectObject(m_bitmap.getHandle());
// Create the brush
const Brush brush{color};
// Fill the bitmap with the brush
const Math::Rectangle<std::int32_t> rectangle{0, 0, width, height};
brush.fillRectangle(offscreenRenderTarget, rectangle);
}
catch (...) { throw; }
```
Result:
```cpp
Bitmap::Bitmap(
const DeviceContext& deviceContext, std::int32_t width, std::int32_t height
)
try : m_width{width}, m_height{height},
m_bitmap{
CreateCompatibleBitmap(deviceContext.getHandle(), m_width, m_height)}
{
// Check if bitmap is valid
if (m_bitmap == nullptr)
{
throw std::runtime_error{"Failed to create bitmap!"};
}
}
catch (...)
{
throw;
}
```
Expected:
```cpp
Bitmap::Bitmap(
const DeviceContext& deviceContext, std::int32_t width, std::int32_t height
)
try
: m_width{width}
, m_height{height}
, m_bitmap{
CreateCompatibleBitmap(deviceContext.getHandle(), m_width, m_height)
}
{
// Check if bitmap is valid
if (m_bitmap == nullptr)
{
throw std::runtime_error{"Failed to create bitmap!"};
}
}
catch (...)
{
throw;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW1lz27iW_jX0C8oumfL64Aetad2WI7Xl3Dx2QeQRhTYI8AKgbc2vn8JCEFwkO-nMTN1b40p3ZOI7wMHBdzZQwVKSjAE8RNfj6Hp6hku15-JhlgtIMPsdC5zgAxFnW54eHi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