[bug][clang-format][21.1.8] Cannot correctly format rvalue-ref declarator && in requires clause.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```
template
requires std::is_lvalue_reference_v and (std::is_rvalue_reference_v)
void f() {
}
```
`std::is_lvalue_reference_v` is ok; however, `(std::is_rvalue_reference_v)` is not ok, a unexpected space inserted into `T` and `&&`.
my .clang-format file:
```
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: true
AcrossComments: false
AlignCompound: true
AcrossEmptyLines: false
PadOperators : true
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations:
Enabled: true
AlignFunctionDeclarations: true
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortCaseExpressionOnASingleLine: true
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AllowShortNamespacesOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BreakAdjacentStringLiterals: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeTernaryOperators: true
BreakBinaryOperations: Never
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: AfterColon
BreakFunctionDefinitionParameters: false
BreakInheritanceList: BeforeComma
BreakStringLiterals: false
BreakTemplateDeclarations: Yes
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
FixNamespaceComments: true
ForEachMacros: ['LOOP', 'TEST_CASE', 'TEST_CASE_GENERATOR']
TypenameMacros: ['LIST_ENTRY']
IncludeBlocks: Preserve
IndentAccessModifiers: false
IndentCaseLabels: false
IndentExportBlock: true
IndentExternBlock: NoIndent
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
InsertTrailingCommas: None
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
KeepEmptyLinesAtTheStartOfBlocks: false
LineEnding: LF
MacroBlockBegin: "^BEGIN_OF_EXAMPLE1|BEGIN_OF_EXAMPLE2$"
MacroBlockEnd: "^END_OF_EXAMPLE$"
MainIncludeChar: Any
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PointerAlignment: Left
PointerBindsToType: true
PackConstructorInitializers: BinPack
ReflowComments: false
RemoveEmptyLinesInUnwrappedLines: true
SeparateDefinitionBlocks: Always
SkipMacroDefinitionBody: false
SortIncludes: true
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterFunctionDeclarationName: false
AfterPlacementOperator: true
AfterRequiresInClause: true
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: 1
SpacesInParens: Custom
SpacesInParensOptions:
ExceptDoubleParentheses: false
InConditionalStatements: false
Other: false
SpacesInSquareBrackets: false
Standard: Latest
StatementMacros: []
TabWidth: 4
UseTab: Never
WrapNamespaceBodyWithEmptyLines: Always
---
Language: Cpp
---
Language: Proto
```
Contributor guide
Research direction
Run clang-format 21.1.8 with the supplied configuration on the C++ requires-clause reproducer and compare the two trait expressions. Trace the clang-format path handling the rvalue-reference declarator in this context, then add coverage showing that the formatting no longer inserts a space between T and &&.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100