2 # Configuration of clang-format
3 # =============================
5 # Tested to work with versions: 8 to 11.
7 # This causes parameters on continuations to align to the opening brace.
9 # like_this_long_name(parameter_one,
13 AlignAfterOpenBracket: 'Align'
15 # Disallow short functions on one line; break them up.
16 AllowShortBlocksOnASingleLine: false
18 # These two settings trigger stacking of parameters in most cases; this is
19 # easier to read and also makes diffs easier to read (since an added or removed
20 # parameter is obvious). For example, function calls will look like this:
22 # like_this_long_name(parameter_one,
31 # like_this_long_name(parameter_one, parameter_two, parameter_three, parameter_four,
32 # parameter_five, parameter_six);
34 BinPackArguments: false
35 BinPackParameters: false
37 # Line width (don't exceed 100).
40 # Cause initializer lists to have one member initialized per line, in the case
41 # that all initializers can't fit on a single line.
42 ConstructorInitializerAllOnOneLineOrOnePerLine: true
44 # Indent the : after a constructor. For example:
46 # explicit foo_class ()
51 ConstructorInitializerIndentWidth: 4
53 # Make access modifier slightly more visible.
54 AccessModifierOffset: -1
56 # This will unfortunately use spaces in some cases where it's not desired (like
57 # function calls) but the overall result is better since it will allow
58 # alignment to work properly with different tab width settings.
59 ContinuationIndentWidth: 4
61 # This tries to match Blender's style as much as possible. One
62 BreakBeforeBraces: Custom
65 AfterControlStatement: 'MultiLine',
67 AfterFunction : 'true',
68 AfterNamespace : 'false',
69 AfterStruct : 'false',
73 IndentBraces : 'false',
74 AfterObjCDeclaration: 'true',
77 # For switch statements, indent the cases.
78 IndentCaseLabels: true
80 # Indent after the hash inside preprocessor directives
81 IndentPPDirectives: AfterHash
83 BreakBeforeTernaryOperators: false
85 SpaceAfterTemplateKeyword: false
87 # Handy comment at the end of each C++ name space.
88 FixNamespaceComments: true
90 # Use "if (...)" instead of "if(...)", but have function calls like foo().
91 SpaceBeforeParens: ControlStatements
92 SpaceInEmptyParentheses: false
94 # Use two spaces before trailing comments, for example
96 # foo = bar; // comment
98 # Note that this doesn't work for C-style comments.
99 SpacesBeforeTrailingComments: 2
101 # Reflow comments, developers must disable formatting as with code to override this.
104 # Never use tabs for indentation.
105 # Note: TabWidth and IndentWidth must be the same, or strange things happen.
110 # Add a big penalty on breaking after the return type of functions. For example,
112 # static void foo(...)
117 # foo(very long content here that maybe could be stacked)
119 PenaltyReturnTypeOnItsOwnLine: 10000
121 # Avoid having function calls broken onto a new line:
124 # long, list, of, many, params);
129 # foo(long, list, of, many, params);
131 PenaltyBreakAssignment: 100
133 AllowShortFunctionsOnASingleLine: Empty
137 # Don't right align escaped newlines to the right because we have a wide default
138 AlignEscapedNewlines: DontAlign
148 # const char *foo = "multi"
151 AlwaysBreakBeforeMultilineStrings: true
153 # We don't want literal strings to break,
154 # however clang-format seems to ignore this (sigh).
155 PenaltyBreakString: 1000000
157 # There are macros in Blender for custom for loops; tell Clang to treat them
158 # like loops rather than an expression, and so put the { on the same line.
160 # To find these use multi-line regex search:
161 # "^\s+[A-Z][A-Z0-9_]+\s*\([^\n]*\)\n\s*\{"
163 - BEGIN_ANIMFILTER_SUBCHANNELS
164 - BKE_pbvh_vertex_iter_begin
165 - BKE_pbvh_face_iter_begin
166 - BLI_FOREACH_SPARSE_RANGE
167 - BLI_SMALLSTACK_ITER_BEGIN
171 - BM_FACES_OF_VERT_ITER_BEGIN
177 - BM_ITER_MESH_MUTABLE
178 - BM_LOOPS_OF_VERT_ITER_BEGIN
181 - CTX_DATA_BEGIN_WITH_ID
182 - DEG_OBJECT_ITER_BEGIN
183 - DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN
184 - DRW_ENABLED_ENGINE_ITER
185 - DRIVER_TARGETS_LOOPER_BEGIN
186 - DRIVER_TARGETS_USED_LOOPER_BEGIN
187 - FOREACH_BASE_IN_EDIT_MODE_BEGIN
188 - FOREACH_BASE_IN_MODE_BEGIN
190 - FOREACH_COLLECTION_BEGIN
191 - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN
192 - FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN
193 - FOREACH_EDIT_OBJECT_BEGIN
194 - FOREACH_MAIN_ID_BEGIN
195 - FOREACH_MAIN_LISTBASE_BEGIN
196 - FOREACH_MAIN_LISTBASE_ID_BEGIN
197 - FOREACH_MESH_BUFFER_CACHE
198 - FOREACH_NODETREE_BEGIN
199 - FOREACH_OBJECT_BEGIN
200 - FOREACH_OBJECT_FLAG_BEGIN
201 - FOREACH_OBJECT_IN_EDIT_MODE_BEGIN
202 - FOREACH_OBJECT_IN_MODE_BEGIN
203 - FOREACH_OBJECT_RENDERABLE_BEGIN
204 - FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN
205 - FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN
206 - FOREACH_SCENE_COLLECTION_BEGIN
207 - FOREACH_SCENE_OBJECT_BEGIN
208 - FOREACH_SELECTED_BASE_BEGIN
209 - FOREACH_SELECTED_BEZT_BEGIN
210 - FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN
211 - FOREACH_SELECTED_OBJECT_BEGIN
212 - FOREACH_TRANS_DATA_CONTAINER
213 - FOREACH_VIEW_LAYER_TO_RENDER_BEGIN
214 - FOREACH_VISIBLE_BASE_BEGIN
215 - FOREACH_VISIBLE_OBJECT_BEGIN
216 - GHASH_FOREACH_BEGIN
219 - GPU_SELECT_LOAD_IF_PICKSEL_LIST
220 - GP_EDITABLE_STROKES_BEGIN
221 - GP_EVALUATED_STROKES_BEGIN
233 - LOOP_SELECTED_POINTS
236 - LOOP_UNSELECTED_POINTS
238 - LOOP_VISIBLE_POINTS
239 - LIGHT_FOREACH_BEGIN_DIRECTIONAL
240 - LIGHT_FOREACH_BEGIN_LOCAL
241 - LISTBASE_CIRCULAR_BACKWARD_BEGIN
242 - LISTBASE_CIRCULAR_FORWARD_BEGIN
244 - LISTBASE_FOREACH_BACKWARD
245 - LISTBASE_FOREACH_MUTABLE
246 - LISTBASE_FOREACH_BACKWARD_MUTABLE
247 - LISTBASE_FOREACH_INDEX
248 - MAN_ITER_AXES_BEGIN
249 - NODE_INSTANCE_HASH_ITER
250 - NODE_SOCKET_TYPES_BEGIN
251 - NODE_TREE_TYPES_BEGIN
254 - PIXEL_LOOPER_BEGIN_CHANNELS
255 - RENDER_PASS_ITER_BEGIN
259 - RNA_STRUCT_BEGIN_SKIP_RNA_TYPE
260 - SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN
261 - SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN
263 - SEQ_ITERATOR_FOREACH
264 - SURFACE_QUAD_ITER_BEGIN
266 - ED_screen_areas_iter
268 - SET_SLOT_PROBING_BEGIN
269 - MAP_SLOT_PROBING_BEGIN
270 - VECTOR_SET_SLOT_PROBING_BEGIN
272 - FOREACH_SPECTRUM_CHANNEL
277 - ccl_gpu_kernel_postfix
279 MacroBlockBegin: "^OSL_CLOSURE_STRUCT_BEGIN$"
280 MacroBlockEnd: "^OSL_CLOSURE_STRUCT_END$"
282 # Ensure single new line at the end of source files.
283 InsertNewlineAtEOF: True
284 KeepEmptyLinesAtEOF: False