|
| 1 | +--- |
| 2 | +Language: Cpp |
| 3 | +# BasedOnStyle: LLVM |
| 4 | +# |
| 5 | +# Proposed clang-format-11 style for OpenFOAM, trying to follow the OpenFOAM style guide: |
| 6 | +# https://develop.openfoam.com/Development/openfoam/-/wikis/coding/style/style |
| 7 | +# Configuration developed for the OpenFOAM-preCICE adapter code: |
| 8 | +# https://github.com/precice/openfoam-adapter |
| 9 | +# Contribute to the discussion at the respective OpenFOAM issue: |
| 10 | +# https://develop.openfoam.com/Development/openfoam/-/issues/1634 |
| 11 | +# |
| 12 | +# Keep `public:` at the first indentation level |
| 13 | +AccessModifierOffset: -4 |
| 14 | +# Undocumented guideline: align arguments after an open bracket. |
| 15 | +AlignAfterOpenBracket: Align |
| 16 | +AlignConsecutiveMacros: false |
| 17 | +AlignConsecutiveAssignments: false |
| 18 | +AlignConsecutiveBitFields: false |
| 19 | +AlignConsecutiveDeclarations: false |
| 20 | +AlignEscapedNewlines: Right |
| 21 | +# Align operands after operators (+,*,<<) (see BreakBeforeBinaryOperators) |
| 22 | +AlignOperands: AlignAfterOperator |
| 23 | +AlignTrailingComments: true |
| 24 | +AllowAllArgumentsOnNextLine: true |
| 25 | +AllowAllConstructorInitializersOnNextLine: true |
| 26 | +AllowAllParametersOfDeclarationOnNextLine: true |
| 27 | +AllowShortEnumsOnASingleLine: true |
| 28 | +AllowShortBlocksOnASingleLine: Never |
| 29 | +AllowShortCaseLabelsOnASingleLine: false |
| 30 | +AllowShortFunctionsOnASingleLine: All |
| 31 | +AllowShortLambdasOnASingleLine: All |
| 32 | +AllowShortIfStatementsOnASingleLine: Always |
| 33 | +AllowShortLoopsOnASingleLine: false |
| 34 | +# Guideline: Splitting return type and function name |
| 35 | +# (this guideline is apparently not strictly followed in OpenFOAM) |
| 36 | +# AlwaysBreakAfterReturnType: All |
| 37 | +AlwaysBreakBeforeMultilineStrings: false |
| 38 | +AlwaysBreakTemplateDeclarations: Yes |
| 39 | +BinPackArguments: false |
| 40 | +BinPackParameters: false |
| 41 | +# Covered by "BreakBeforeBraces" |
| 42 | +BraceWrapping: |
| 43 | + AfterCaseLabel: true |
| 44 | + AfterClass: true |
| 45 | + AfterControlStatement: Always |
| 46 | + AfterEnum: true |
| 47 | + AfterFunction: true |
| 48 | + AfterNamespace: true |
| 49 | + AfterObjCDeclaration: true |
| 50 | + AfterStruct: true |
| 51 | + AfterUnion: true |
| 52 | + AfterExternBlock: true |
| 53 | + BeforeCatch: true |
| 54 | + BeforeElse: true |
| 55 | + BeforeLambdaBody: true |
| 56 | + BeforeWhile: true |
| 57 | + IndentBraces: true |
| 58 | + SplitEmptyFunction: true |
| 59 | + SplitEmptyRecord: true |
| 60 | + SplitEmptyNamespace: true |
| 61 | +# Guideline (almost): Splitting long lines at an = sign. Indent after split. |
| 62 | +# Guideline (almost): Splitting formulae over several lines. |
| 63 | +BreakBeforeBinaryOperators: NonAssignment |
| 64 | +# Always break before braces: if, for, functions, classes, etc. |
| 65 | +BreakBeforeBraces: Allman |
| 66 | +BreakBeforeInheritanceComma: false |
| 67 | +BreakInheritanceList: BeforeColon |
| 68 | +# Guideline (almost): Splitting logical tests over several lines. |
| 69 | +BreakBeforeTernaryOperators: true |
| 70 | +BreakConstructorInitializersBeforeComma: false |
| 71 | +# Undocumented guideline (almost): Have the initializer : in a new line. |
| 72 | +BreakConstructorInitializers: BeforeColon |
| 73 | +BreakStringLiterals: true |
| 74 | +# Here we could set the 80 charactes limit, but that would lead to more aggressive changes. |
| 75 | +ColumnLimit: 0 |
| 76 | +CommentPragmas: '^ IWYU pragma:' |
| 77 | +CompactNamespaces: false |
| 78 | +ConstructorInitializerAllOnOneLineOrOnePerLine: false |
| 79 | +ConstructorInitializerIndentWidth: 0 |
| 80 | +ContinuationIndentWidth: 4 |
| 81 | +Cpp11BracedListStyle: true |
| 82 | +DeriveLineEnding: true |
| 83 | +DerivePointerAlignment: false |
| 84 | +DisableFormat: false |
| 85 | +# Undocumented guideline: add line after "public:" etc (since clang-format 12) |
| 86 | +# EmptyLineAfterAccessModifier: Always |
| 87 | +ExperimentalAutoDetectBinPacking: false |
| 88 | +FixNamespaceComments: false |
| 89 | +# Guideline: Macro loops are like for loops, but without a space. |
| 90 | +ForEachMacros: |
| 91 | + - forAllIters |
| 92 | + - forAllConstIters |
| 93 | + - forAllReverseIters |
| 94 | + - forAllConstReverseIters |
| 95 | + - forAll |
| 96 | + - forAllReverse |
| 97 | + - forAllIter |
| 98 | + - forAllConstIter |
| 99 | +IncludeBlocks: Preserve |
| 100 | +IncludeCategories: |
| 101 | + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' |
| 102 | + Priority: 2 |
| 103 | + SortPriority: 0 |
| 104 | + - Regex: '^(<|"(gtest|gmock|isl|json)/)' |
| 105 | + Priority: 3 |
| 106 | + SortPriority: 0 |
| 107 | + - Regex: '.*' |
| 108 | + Priority: 1 |
| 109 | + SortPriority: 0 |
| 110 | +IncludeIsMainRegex: '(Test)?$' |
| 111 | +IncludeIsMainSourceRegex: '' |
| 112 | +IndentCaseLabels: false |
| 113 | +IndentCaseBlocks: false |
| 114 | +IndentGotoLabels: true |
| 115 | +IndentPPDirectives: None |
| 116 | +IndentExternBlock: AfterExternBlock |
| 117 | +# Guideline: The normal indentation is 4 spaces per logical level. |
| 118 | +IndentWidth: 4 |
| 119 | +IndentWrappedFunctionNames: false |
| 120 | +InsertTrailingCommas: None |
| 121 | +KeepEmptyLinesAtTheStartOfBlocks: true |
| 122 | +MacroBlockBegin: '' |
| 123 | +MacroBlockEnd: '' |
| 124 | +# Required to not change code following the guidelines |
| 125 | +# "Leave two empty lines between sections" and |
| 126 | +# "Use two empty lines between functions" |
| 127 | +MaxEmptyLinesToKeep: 2 |
| 128 | +NamespaceIndentation: None |
| 129 | +PenaltyBreakAssignment: 2 |
| 130 | +PenaltyBreakBeforeFirstCallParameter: 19 |
| 131 | +PenaltyBreakComment: 300 |
| 132 | +PenaltyBreakFirstLessLess: 120 |
| 133 | +PenaltyBreakString: 1000 |
| 134 | +PenaltyBreakTemplateDeclaration: 10 |
| 135 | +PenaltyExcessCharacter: 1000000 |
| 136 | +PenaltyReturnTypeOnItsOwnLine: 60 |
| 137 | +PointerAlignment: Left |
| 138 | +ReflowComments: true |
| 139 | +# Do not change the order of include statements (could be catastrophic for OpenFOAM) |
| 140 | +SortIncludes: false |
| 141 | +SortUsingDeclarations: false |
| 142 | +SpaceAfterCStyleCast: false |
| 143 | +SpaceAfterLogicalNot: false |
| 144 | +# No "template <T>" (guideline already used, but not documented) |
| 145 | +SpaceAfterTemplateKeyword: false |
| 146 | +SpaceBeforeAssignmentOperators: true |
| 147 | +# No a{1} (no guideline) |
| 148 | +SpaceBeforeCpp11BracedList: true |
| 149 | +SpaceBeforeCtorInitializerColon: true |
| 150 | +SpaceBeforeInheritanceColon: true |
| 151 | +# Guideline: Spaces in "if ()", "for ()", but not "forAll ()". |
| 152 | +SpaceBeforeParens: ControlStatementsExceptForEachMacros |
| 153 | +# Guideline: Range-based for should have a space surrounding the ':'. |
| 154 | +SpaceBeforeRangeBasedForLoopColon: true |
| 155 | +SpaceInEmptyBlock: false |
| 156 | +SpaceInEmptyParentheses: false |
| 157 | +SpacesBeforeTrailingComments: 1 |
| 158 | +SpacesInAngles: false |
| 159 | +SpacesInConditionalStatement: false |
| 160 | +# No "arr[3] = [ 1, 2, 3 ]" (no guideline). |
| 161 | +SpacesInContainerLiterals: false |
| 162 | +SpacesInCStyleCastParentheses: false |
| 163 | +SpacesInParentheses: false |
| 164 | +SpacesInSquareBrackets: false |
| 165 | +SpaceBeforeSquareBrackets: false |
| 166 | +# Treat the code as C++11 or later |
| 167 | +Standard: Latest |
| 168 | +StatementMacros: |
| 169 | +TabWidth: 4 |
| 170 | +UseCRLF: false |
| 171 | +# Guideline: No tab characters - only use spaces for indentation. |
| 172 | +UseTab: Never |
| 173 | +WhitespaceSensitiveMacros: |
| 174 | +... |
| 175 | + |
0 commit comments