[cfe-dev] clang-format: optional change behaviour of placing all function arguments/parameters into the next line
Tilo Kühn
tilo.kuehn.73 at GOOGLEMAIL.com
Tue May 19 00:14:03 PDT 2015
i would like to see an option to format arguments and parameters a bit
different.
at the moment if you have a function definition which doesn't fit to the
current line and all arguments fit to the next line clang-format prefers
method (2):
e.g.
col limit 140:
(1) void FunctionName01234567890(const Argument& a1, const Argument& a2,
const Argument& a3, const Argument& a4, const Argument& a5);
(2) void FunctionName01234567890(const Argument& a1, const Argument& a2,
const Argument& a3, const Argument& a4, const Argument& a5, const
Argument& a6);
(3) void FunctionName01234567890(const Argument& a1, const Argument& a2,
const Argument& a3, const Argument& a4, const Argument& a5, const
Argument& a6, const Argument& a7);
results in:
(1) void FunctionName01234567890(const Argument& a1, const Argument& a2,
const Argument& a3, const Argument& a4, const Argument& a5);
(2) void FunctionName01234567890(
const Argument& a1, const Argument& a2, const Argument& a3, const
Argument& a4, const Argument& a5, const Argument& a6);
(3) void FunctionName01234567890(const Argument& a1, const Argument& a2,
const Argument& a3, const Argument& a4, const Argument& a5,
const Argument& a6, const Argument& a7);
i prefer (1) and (3) and i will never see (2). I would love to get this
result:
(2b) void FunctionName01234567890(const Argument& a1, const Argument&
a2, const Argument& a3, const Argument& a4, const Argument& a5,
const Argument& a6);
Q:
- is this just a matter of settings (penalties?)?
- if not, can somebody guide me to the place in the source where the
decision is done if all parameters fit to one line? i would like to add
an option for that behaviour.
Best regards
Tilo
my .clang-format settings
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
BinPackArguments: true
ColumnLimit: 140
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 3
KeepEmptyLinesAtTheStartOfBlocks: true
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 100
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SpacesBeforeTrailingComments: 1
Cpp11BracedListStyle: true
Standard: Cpp11
IndentWidth: 2
TabWidth: 2
UseTab: Always
BreakBeforeBraces: Allman
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 2
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH]
SpaceBeforeParens: ControlStatements
DisableFormat: false
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150519/b76f79ae/attachment.html>
More information about the cfe-dev
mailing list