[cfe-users] How can clang-format don't put if statements into one line?

fly2never via cfe-users cfe-users at lists.llvm.org
Sat Dec 10 23:51:10 PST 2016


Just like the code below, I use clang-format to automatic format my codes

if(detectBeats[*beatsCont-2] > detectBeats[*beatsCont-1]
   || fabs(detectBeats[*beatsCont-2] > detectBeats[*beatsCont-1]) < 1.0){
    *beatsCont -=1;}

Whatever I set the .clang-formt file, it always formatted like this:

if(detectBeats[*beatsCont-2] > detectBeats[*beatsCont-1] ||
fabs(detectBeats[*beatsCont-2] > detectBeats[*beatsCont-1]) < 1.0){
    *beatsCont -=1;}

How can I set the rules not wrap the if statements into oneline?

Here is my .clang-format file

AccessModifierOffset : -4AllowAllParametersOfDeclarationOnNextLine :
falseAlignEscapedNewlinesLeft : falseAlignOperands:
trueAlignTrailingComments : trueAllowShortCaseLabelsOnASingleLine:
trueAllowShortFunctionsOnASingleLine:
falseAllowShortIfStatementsOnASingleLine :
trueAllowShortLoopsOnASingleLine: trueBinPackArguments :
falseBinPackParameters : falseBreakBeforeBraces : LinuxColumnLimit:
0CommentPragmas: '^
*\/\/'ConstructorInitializerAllOnOneLineOrOnePerLine:
falseConstructorInitializerIndentWidth: 4ContinuationIndentWidth:
4Cpp11BracedListStyle: trueIndentWidth :
4KeepEmptyLinesAtTheStartOfBlocks : falseLanguage :
CppMaxEmptyLinesToKeep : 2ObjCBlockIndentWidth :
2ObjCSpaceAfterProperty: trueObjCSpaceBeforeProtocolList :
falsePointerAlignment: RightReflowComments:  trueSortIncludes:
trueSpaceAfterCStyleCast: falseSpaceBeforeAssignmentOperators :
trueSpaceBeforeParens : ControlStatementsSpaceInEmptyParentheses:
falseSpacesBeforeTrailingComments : 1SpacesInAngles:
falseSpacesInContainerLiterals : falseSpacesInParentheses :
falseSpacesInSquareBrackets: falseStandard: Cpp11UseTab : Never
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20161211/afb98415/attachment.html>


More information about the cfe-users mailing list