The sixteenth batch
[git/gitster.git] / .clang-format
blobdcfd0aad60c31e507989efac53be45f46ef4a9bf
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.
11 UseTab: Always
12 TabWidth: 8
13 IndentWidth: 8
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
19 # false positives.
21 # NEEDSWORK: It would be nice if we can find optimal settings to ensure we
22 # can re-enable the limit here.
23 ColumnLimit: 0
25 # C Language specifics
26 Language: Cpp
28 # Align parameters on the open bracket
29 # someLongFunction(argument1,
30 #                  argument2);
31 AlignAfterOpenBracket: Align
33 # Don't align consecutive assignments
34 # int aaaa = 12;
35 # int b = 14;
36 AlignConsecutiveAssignments: false
38 # Don't align consecutive declarations
39 # int aaaa = 12;
40 # double b = 3.14;
41 AlignConsecutiveDeclarations: false
43 # Align consecutive macro definitions.
44 AlignConsecutiveMacros: true
46 # Align escaped newlines as far left as possible
47 # #define A   \
48 #   int aaaa; \
49 #   int b;    \
50 #   int cccccccc;
51 AlignEscapedNewlines: Left
53 # Align operands of binary and ternary expressions
54 # int aaa = bbbbbbbbbbb +
55 #           cccccc;
56 AlignOperands: true
58 # Don't align trailing comments
59 # int a; // Comment a
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;
69 #   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
77 # int foo();
78 AlwaysBreakAfterReturnType: None
80 # Pack as many parameters or arguments onto the same line as possible
81 # int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
82 #                int cccc);
83 BinPackArguments: true
84 BinPackParameters: true
86 # Add no space around the bit field
87 # unsigned bf:2;
88 BitFieldColonSpacing: None
90 # Attach braces to surrounding context except break before braces on function
91 # definitions.
92 # void foo()
93 # {
94 #    if (true) {
95 #    } else {
96 #    }
97 # };
98 BreakBeforeBraces: Linux
100 # Break after operators
101 # int value = aaaaaaaaaaaaa +
102 #             bbbbbb -
103 #             ccccccccccc;
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
115 # indentation.
116 # #if FOO
117 # # include <foo>
118 # #endif
119 IndentPPDirectives: AfterHash
120 PPIndentWidth: 1
122 # Don't indent a function definition or declaration if it is wrapped after the
123 # type
124 IndentWrappedFunctionNames: false
126 # Align pointer to the right
127 # int *a;
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;
139 # a += 42;             a+=42;
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.
147 # void f() {
148 #   if (true) {
149 #     f();
150 #   }
151 # }
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
192 ForEachMacros:
193   - 'for_each_builtin'
194   - 'for_each_string_list_item'
195   - 'for_each_ut'
196   - 'for_each_wanted_builtin'
197   - 'hashmap_for_each_entry'
198   - 'hashmap_for_each_entry_from'
199   - 'kh_foreach'
200   - 'kh_foreach_value'
201   - 'list_for_each'
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
211 # function calls.
212 IfMacros:
213   - 'if_test'
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
222 SortIncludes: false
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