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 consecutive macro definitions.
36 AlignConsecutiveMacros: true
38 # Align escaped newlines as far left as possible
43 AlignEscapedNewlines: Left
45 # Align operands of binary and ternary expressions
46 # int aaa = bbbbbbbbbbb +
50 # Don't align trailing comments
52 # int b = 2; // Comment b
53 AlignTrailingComments: false
55 # By default don't allow putting parameters onto the next line
56 # myFunction(foo, bar, baz);
57 AllowAllParametersOfDeclarationOnNextLine: false
59 # Don't allow short braced statements to be on a single line
60 # if (a) not if (a) return;
62 AllowShortBlocksOnASingleLine: false
63 AllowShortCaseLabelsOnASingleLine: false
64 AllowShortFunctionsOnASingleLine: false
65 AllowShortIfStatementsOnASingleLine: false
66 AllowShortLoopsOnASingleLine: false
68 # By default don't add a line break after the return type of top-level functions
70 AlwaysBreakAfterReturnType: None
72 # Pack as many parameters or arguments onto the same line as possible
73 # int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
75 BinPackArguments: true
76 BinPackParameters: true
78 # Add no space around the bit field
80 BitFieldColonSpacing: None
82 # Attach braces to surrounding context except break before braces on function
90 BreakBeforeBraces: Linux
92 # Break after operators
93 # int value = aaaaaaaaaaaaa +
96 BreakBeforeBinaryOperators: None
97 BreakBeforeTernaryOperators: false
99 # Don't break string literals
100 BreakStringLiterals: false
102 # Use the same indentation level as for the switch statement.
103 # Switch statement body is always indented one level more than case labels.
104 IndentCaseLabels: false
106 # Indents directives before the hash. Each level uses a single space for
111 IndentPPDirectives: AfterHash
114 # Don't indent a function definition or declaration if it is wrapped after the
116 IndentWrappedFunctionNames: false
118 # Align pointer to the right
120 PointerAlignment: Right
122 # Don't insert a space after a cast
123 # x = (int32)y; not x = (int32) y;
124 SpaceAfterCStyleCast: false
126 # No space is inserted after the logical not operator
127 SpaceAfterLogicalNot: false
129 # Insert spaces before and after assignment operators
130 # int a = 5; not int a=5;
132 SpaceBeforeAssignmentOperators: true
134 # Spaces will be removed before case colon.
135 # case 1: break; not case 1 : break;
136 SpaceBeforeCaseColon: false
138 # Put a space before opening parentheses only after control statement keywords.
144 SpaceBeforeParens: ControlStatements
146 # Don't insert spaces inside empty '()'
147 SpaceInEmptyParentheses: false
149 # No space before first '[' in arrays
150 # int a[5][5]; not int a [5][5];
151 SpaceBeforeSquareBrackets: false
153 # No space will be inserted into {}
154 # while (true) {} not while (true) { }
155 SpaceInEmptyBlock: false
157 # The number of spaces before trailing line comments (// - comments).
158 # This does not affect trailing block comments (/* - comments).
159 SpacesBeforeTrailingComments: 1
161 # Don't insert spaces in casts
162 # x = (int32) y; not x = ( int32 ) y;
163 SpacesInCStyleCastParentheses: false
165 # Don't insert spaces inside container literals
166 # var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
167 SpacesInContainerLiterals: false
169 # Don't insert spaces after '(' or before ')'
170 # f(arg); not f( arg );
171 SpacesInParentheses: false
173 # Don't insert spaces after '[' or before ']'
174 # int a[5]; not int a[ 5 ];
175 SpacesInSquareBrackets: false
177 # Insert a space after '{' and before '}' in struct initializers
178 Cpp11BracedListStyle: false
180 # A list of macros that should be interpreted as foreach loops instead of as
181 # function calls. Taken from:
182 # git grep -h '^#define [^[:space:]]*for_\?each[^[:space:]]*(' |
183 # sed "s/^#define / - '/; s/(.*$/'/" | sort | uniq
186 - 'for_each_string_list_item'
188 - 'for_each_wanted_builtin'
189 - 'hashmap_for_each_entry'
190 - 'hashmap_for_each_entry_from'
194 - 'list_for_each_dir'
195 - 'list_for_each_prev'
196 - 'list_for_each_prev_safe'
197 - 'list_for_each_safe'
198 - 'strintmap_for_each_entry'
199 - 'strmap_for_each_entry'
200 - 'strset_for_each_entry'
202 # A list of macros that should be interpreted as conditionals instead of as
207 # The maximum number of consecutive empty lines to keep.
208 MaxEmptyLinesToKeep: 1
210 # No empty line at the start of a block.
211 KeepEmptyLinesAtTheStartOfBlocks: false
214 # This decides what order things should be done if a line is too long
215 PenaltyBreakAssignment: 5
216 PenaltyBreakBeforeFirstCallParameter: 5
217 PenaltyBreakComment: 5
218 PenaltyBreakFirstLessLess: 0
219 PenaltyBreakOpenParenthesis: 300
220 PenaltyBreakString: 5
221 PenaltyExcessCharacter: 10
222 PenaltyReturnTypeOnItsOwnLine: 300
224 # Don't sort #include's