| Issue |
61413
|
| Summary |
[clang-format] Separate ConsecutiveIndent for arguments/parameters
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
BahJiy
|
is it possible to have ConsecutiveIndent value just for function/constructor arguments/parameters?
I would like to format my code as:
```cpp
struct TestStruct {
TestStruct(
const std::string& aReallyLongStringHere,
const std::string& anotherLongString ):
_someStrHere( aReallyLongStringHere ),
_anotherStr( anotherLongString ) {
int x = 10;
assert( x + x == 20 );
}
auto doSomethingHere(
int aLongNameForNoReason,
double anotherLongName ) const
-> double {
return aLongNameForNoReason + anotherLongName
+ anotherLongName;
}
}
```
When the parameters overflows to the next line, they are double indent, but if a statement overflows, it is only one single indent. Currently, ConsecutiveIndent will force both the parameters and statement to be the same indent on overflow.
I got somewhat close with my current config, it's slightly off
```
---
BasedOnStyle: Chromium
AlignAfterOpenBracket: AlwaysBreak
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Inline
AlwaysBreakBeforeMultilineStrings: false
BitFieldColonSpacing: After
BreakBeforeBinaryOperators: All
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
ColumnLimit: 53
CompactNamespaces: true
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
EmptyLineBeforeAccessModifier: Always
IncludeBlocks: Regroup
IndentCaseBlocks: true
IndentExternBlock: Indent
IndentGotoLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 4
InsertBraces: true
NamespaceIndentation: All
ReferenceAlignment: Left
SeparateDefinitionBlocks: Always
SortIncludes: CaseInsensitive
SpaceAfterTemplateKeyword: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: true
SpacesInCStyleCastParentheses: true
SpacesInConditionalStatement: true
SpacesInParentheses: true
SpacesInSquareBrackets: true
Standard: c++20
TabWidth: 4
UseTab: Always
```
```cpp
struct TestStruct {
TestStruct(
const std::string& aReallyLongStringHere,
const std::string& anotherLongString ):
_someStrHere( aReallyLongStringHere ),
_anotherStr( anotherLongString ) {
int x = 10;
assert( x + x == 20 );
}
auto doSomethingHere(
int aLongNameForNoReason,
double anotherLongName ) const
-> double {
return aLongNameForNoReason + anotherLongName
+ anotherLongName;
}
std::string _someStrHere;
std::string _anotherStr;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs