1 # This file is an example configuration for clang-format 5.0.
3 # Note that this style definition should only be understood as a hint
4 # for writing new code. The rules are still work-in-progress and does
5 # not yet exactly match the style we have in the existing code.
7 # Use tabs whenever we need to fill whitespace that spans at least from one tab
8 # stop to the next one.
10 # These settings are mirrored in .editorconfig. Keep them in sync.
14 ContinuationIndentWidth: 8
17 # C Language specifics
20 # Align parameters on the open bracket
21 # someLongFunction(argument1,
23 AlignAfterOpenBracket: Align
25 # Don't align consecutive assignments
28 AlignConsecutiveAssignments: false
30 # Don't align consecutive declarations
33 AlignConsecutiveDeclarations: false
35 # Align escaped newlines as far left as possible
40 AlignEscapedNewlines: Left
42 # Align operands of binary and ternary expressions
43 # int aaa = bbbbbbbbbbb +
47 # Don't align trailing comments
49 # int b = 2; // Comment b
50 AlignTrailingComments: false
52 # By default don't allow putting parameters onto the next line
53 # myFunction(foo, bar, baz);
54 AllowAllParametersOfDeclarationOnNextLine: false
56 # Don't allow short braced statements to be on a single line
57 # if (a) not if (a) return;
59 AllowShortBlocksOnASingleLine: false
60 AllowShortCaseLabelsOnASingleLine: false
61 AllowShortFunctionsOnASingleLine: false
62 AllowShortIfStatementsOnASingleLine: false
63 AllowShortLoopsOnASingleLine: false
65 # By default don't add a line break after the return type of top-level functions
67 AlwaysBreakAfterReturnType: None
69 # Pack as many parameters or arguments onto the same line as possible
70 # int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
72 BinPackArguments: true
73 BinPackParameters: true
75 # Add no space around the bit field
77 BitFieldColonSpacing: None
79 # Attach braces to surrounding context except break before braces on function
87 BreakBeforeBraces: Linux
89 # Break after operators
90 # int value = aaaaaaaaaaaaa +
93 BreakBeforeBinaryOperators: None
94 BreakBeforeTernaryOperators: false
96 # Don't break string literals
97 BreakStringLiterals: false
99 # Use the same indentation level as for the switch statement.
100 # Switch statement body is always indented one level more than case labels.
101 IndentCaseLabels: false
103 # Indents directives before the hash. Each level uses a single space for
108 IndentPPDirectives: AfterHash
111 # Don't indent a function definition or declaration if it is wrapped after the
113 IndentWrappedFunctionNames: false
115 # Align pointer to the right
117 PointerAlignment: Right
119 # Don't insert a space after a cast
120 # x = (int32)y; not x = (int32) y;
121 SpaceAfterCStyleCast: false
123 # No space is inserted after the logical not operator
124 SpaceAfterLogicalNot: false
126 # Insert spaces before and after assignment operators
127 # int a = 5; not int a=5;
129 SpaceBeforeAssignmentOperators: true
131 # Spaces will be removed before case colon.
132 # case 1: break; not case 1 : break;
133 SpaceBeforeCaseColon: false
135 # Put a space before opening parentheses only after control statement keywords.
141 SpaceBeforeParens: ControlStatements
143 # Don't insert spaces inside empty '()'
144 SpaceInEmptyParentheses: false
146 # No space before first '[' in arrays
147 # int a[5][5]; not int a [5][5];
148 SpaceBeforeSquareBrackets: false
150 # No space will be inserted into {}
151 # while (true) {} not while (true) { }
152 SpaceInEmptyBlock: false
154 # The number of spaces before trailing line comments (// - comments).
155 # This does not affect trailing block comments (/* - comments).
156 SpacesBeforeTrailingComments: 1
158 # Don't insert spaces in casts
159 # x = (int32) y; not x = ( int32 ) y;
160 SpacesInCStyleCastParentheses: false
162 # Don't insert spaces inside container literals
163 # var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
164 SpacesInContainerLiterals: false
166 # Don't insert spaces after '(' or before ')'
167 # f(arg); not f( arg );
168 SpacesInParentheses: false
170 # Don't insert spaces after '[' or before ']'
171 # int a[5]; not int a[ 5 ];
172 SpacesInSquareBrackets: false
174 # Insert a space after '{' and before '}' in struct initializers
175 Cpp11BracedListStyle: false
177 # A list of macros that should be interpreted as foreach loops instead of as
178 # function calls. Taken from:
179 # git grep -h '^#define [^[:space:]]*for_\?each[^[:space:]]*(' |
180 # sed "s/^#define / - '/; s/(.*$/'/" | sort | uniq
183 - 'for_each_string_list_item'
185 - 'for_each_wanted_builtin'
186 - 'hashmap_for_each_entry'
187 - 'hashmap_for_each_entry_from'
191 - 'list_for_each_dir'
192 - 'list_for_each_prev'
193 - 'list_for_each_prev_safe'
194 - 'list_for_each_safe'
195 - 'strintmap_for_each_entry'
196 - 'strmap_for_each_entry'
197 - 'strset_for_each_entry'
199 # A list of macros that should be interpreted as conditionals instead of as
204 # The maximum number of consecutive empty lines to keep.
205 MaxEmptyLinesToKeep: 1
207 # No empty line at the start of a block.
208 KeepEmptyLinesAtTheStartOfBlocks: false
211 # This decides what order things should be done if a line is too long
212 PenaltyBreakAssignment: 10
213 PenaltyBreakBeforeFirstCallParameter: 30
214 PenaltyBreakComment: 10
215 PenaltyBreakFirstLessLess: 0
216 PenaltyBreakString: 10
217 PenaltyExcessCharacter: 100
218 PenaltyReturnTypeOnItsOwnLine: 60
220 # Don't sort #include's