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
16 # While we do want to enforce a character limit of 80 characters, we often
17 # allow lines to overflow that limit to prioritize readability. Setting a
18 # character limit here with penalties has been finicky and creates too many
21 # NEEDSWORK: It would be nice if we can find optimal settings to ensure we
22 # can re-enable the limit here.
25 # C Language specifics
28 # Align parameters on the open bracket
29 # someLongFunction(argument1,
31 AlignAfterOpenBracket: Align
33 # Don't align consecutive assignments
36 AlignConsecutiveAssignments: false
38 # Don't align consecutive declarations
41 AlignConsecutiveDeclarations: false
43 # Align consecutive macro definitions.
44 AlignConsecutiveMacros: true
46 # Align escaped newlines as far left as possible
51 AlignEscapedNewlines: Left
53 # Align operands of binary and ternary expressions
54 # int aaa = bbbbbbbbbbb +
58 # Don't align trailing comments
60 # int b = 2; // Comment b
61 AlignTrailingComments: false
63 # By default don't allow putting parameters onto the next line
64 # myFunction(foo, bar, baz);
65 AllowAllParametersOfDeclarationOnNextLine: false
67 # Don't allow short braced statements to be on a single line
68 # if (a) not if (a) return;
70 AllowShortBlocksOnASingleLine: false
71 AllowShortCaseLabelsOnASingleLine: false
72 AllowShortFunctionsOnASingleLine: false
73 AllowShortIfStatementsOnASingleLine: false
74 AllowShortLoopsOnASingleLine: false
76 # By default don't add a line break after the return type of top-level functions
78 AlwaysBreakAfterReturnType: None
80 # Pack as many parameters or arguments onto the same line as possible
81 # int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
83 BinPackArguments: true
84 BinPackParameters: true
86 # Add no space around the bit field
88 BitFieldColonSpacing: None
90 # Attach braces to surrounding context except break before braces on function
98 BreakBeforeBraces: Linux
100 # Break after operators
101 # int value = aaaaaaaaaaaaa +
104 BreakBeforeBinaryOperators: None
105 BreakBeforeTernaryOperators: false
107 # Don't break string literals
108 BreakStringLiterals: false
110 # Use the same indentation level as for the switch statement.
111 # Switch statement body is always indented one level more than case labels.
112 IndentCaseLabels: false
114 # Indents directives before the hash. Each level uses a single space for
119 IndentPPDirectives: AfterHash
122 # Don't indent a function definition or declaration if it is wrapped after the
124 IndentWrappedFunctionNames: false
126 # Align pointer to the right
128 PointerAlignment: Right
130 # Don't insert a space after a cast
131 # x = (int32)y; not x = (int32) y;
132 SpaceAfterCStyleCast: false
134 # No space is inserted after the logical not operator
135 SpaceAfterLogicalNot: false
137 # Insert spaces before and after assignment operators
138 # int a = 5; not int a=5;
140 SpaceBeforeAssignmentOperators: true
142 # Spaces will be removed before case colon.
143 # case 1: break; not case 1 : break;
144 SpaceBeforeCaseColon: false
146 # Put a space before opening parentheses only after control statement keywords.
152 SpaceBeforeParens: ControlStatements
154 # Don't insert spaces inside empty '()'
155 SpaceInEmptyParentheses: false
157 # No space before first '[' in arrays
158 # int a[5][5]; not int a [5][5];
159 SpaceBeforeSquareBrackets: false
161 # No space will be inserted into {}
162 # while (true) {} not while (true) { }
163 SpaceInEmptyBlock: false
165 # The number of spaces before trailing line comments (// - comments).
166 # This does not affect trailing block comments (/* - comments).
167 SpacesBeforeTrailingComments: 1
169 # Don't insert spaces in casts
170 # x = (int32) y; not x = ( int32 ) y;
171 SpacesInCStyleCastParentheses: false
173 # Don't insert spaces inside container literals
174 # var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
175 SpacesInContainerLiterals: false
177 # Don't insert spaces after '(' or before ')'
178 # f(arg); not f( arg );
179 SpacesInParentheses: false
181 # Don't insert spaces after '[' or before ']'
182 # int a[5]; not int a[ 5 ];
183 SpacesInSquareBrackets: false
185 # Insert a space after '{' and before '}' in struct initializers
186 Cpp11BracedListStyle: false
188 # A list of macros that should be interpreted as foreach loops instead of as
189 # function calls. Taken from:
190 # git grep -h '^#define [^[:space:]]*for_\?each[^[:space:]]*(' |
191 # sed "s/^#define / - '/; s/(.*$/'/" | sort | uniq
194 - 'for_each_string_list_item'
196 - 'for_each_wanted_builtin'
197 - 'hashmap_for_each_entry'
198 - 'hashmap_for_each_entry_from'
202 - 'list_for_each_dir'
203 - 'list_for_each_prev'
204 - 'list_for_each_prev_safe'
205 - 'list_for_each_safe'
206 - 'strintmap_for_each_entry'
207 - 'strmap_for_each_entry'
208 - 'strset_for_each_entry'
210 # A list of macros that should be interpreted as conditionals instead of as
215 # The maximum number of consecutive empty lines to keep.
216 MaxEmptyLinesToKeep: 1
218 # No empty line at the start of a block.
219 KeepEmptyLinesAtTheStartOfBlocks: false
221 # Don't sort #include's
224 # Remove optional braces of control statements (if, else, for, and while)
225 # according to the LLVM coding style. This avoids braces on simple
226 # single-statement bodies of statements but keeps braces if one side of
227 # if/else if/.../else cascade has multi-statement body.
228 RemoveBracesLLVM: true