Issue 175151
Summary [clang-format] Wrong use of spaces inside lambda when using AlignWithSpaces
Labels clang-format
Assignees
Reporter GreenLightning
    In the following example, the second through last line of the comment are indented with tabs and spaces, even though I would expect them to be indented with only tabs, since there is nothing to align to.

clang-format version 20.1.8

Example code:
```
#include <functional>

void example(std::function<void()> x);

int main()
{
	example(
		[]()
		{
			// Lorem ipsum dolor sit amet,
		    // consectetur adipiscing elit,
		    // sed do eiusmod tempor incididunt
		    // ut labore et dolore magna aliqua.
		});
	return 0;
}
```

.clang-format
```
BasedOnStyle: LLVM
Language: Cpp
Standard: Auto

AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignConsecutiveShortCaseStatements:
 Enabled: true
  AcrossEmptyLines: true
  AcrossComments: true
 AlignCaseColons: false
  AlignCaseArrows: false
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments: Always
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BraceWrapping:
 AfterCaseLabel: true
  AfterClass: true
  AfterControlStatement: Always
 AfterEnum: true
  AfterFunction: true
  AfterNamespace: true
 AfterObjCDeclaration: true
  AfterStruct: true
  AfterUnion: true
 AfterExternBlock: true
  BeforeCatch: true
  BeforeElse: true
 BeforeLambdaBody: true
  BeforeWhile: false
  IndentBraces: false
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^(@@TODO|TODO)'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
ForEachMacros: []
IncludeBlocks: Regroup
IncludeCategories:
  - Regex: '.*\.generated\.h'
    Priority: 9999
    SortPriority: 9999
  - Regex: 'CoreMinimal.h'
    Priority: 1
    SortPriority: 1
  - Regex: '.*(I3DH|Instant3DHub).*\.(h|hpp)"$'
    Priority: 2
  - Regex: '".*"'
    Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: false
IndentPPDirectives: None
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
NamespaceMacros: []
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: false
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: CurrentLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
  - Language: Cpp
 Delimiters:
      - cc
      - CC
      - cpp
      - Cpp
      - CPP
 - 'c++'
      - 'C++'
    CanonicalDelimiter: ''
    BasedOnStyle: google
  - Language: TextProto
    Delimiters:
      - pb
      - PB
 - proto
      - PROTO
    EnclosingFunctions:
      - EqualsProto
 - EquivToProto
      - PARSE_PARTIAL_TEXT_PROTO
      - PARSE_TEST_PROTO
 - PARSE_TEXT_PROTO
      - ParseTextOrDie
      - ParseTextProtoOrDie
 CanonicalDelimiter: ''
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: AlignWithSpaces 
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to