.clang-format 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. # Configuration of clang-format
  2. # =============================
  3. #
  4. # Tested to work with versions: 6 to 8.
  5. # This causes parameters on continuations to align to the opening brace.
  6. #
  7. # like_this_long_name(parameter_one,
  8. # parameter_two,
  9. # parameter_three);
  10. #
  11. AlignAfterOpenBracket: 'Align'
  12. # Disallow short functions on one line; break them up.
  13. AllowShortBlocksOnASingleLine: false
  14. # These two settings trigger stacking of parameters in most cases; this is
  15. # easier to read and also makes diffs easier to read (since an added or removed
  16. # parameter is obvious). For example, function calls will look like this:
  17. #
  18. # like_this_long_name(parameter_one,
  19. # parameter_two,
  20. # parameter_three,
  21. # parameter_four,
  22. # parameter_five,
  23. # parameter_six);
  24. #
  25. # Instead of:
  26. #
  27. # like_this_long_name(parameter_one, parameter_two, parameter_three, parameter_four,
  28. # parameter_five, parameter_six);
  29. #
  30. BinPackArguments: false
  31. BinPackParameters: false
  32. # Line width (don't exceed 100).
  33. ColumnLimit: 99
  34. # Cause initializer lists to have one member initialized per line, in the case
  35. # that all initializers can't fit on a single line.
  36. ConstructorInitializerAllOnOneLineOrOnePerLine: true
  37. # Indent the : after a constructor. For example:
  38. #
  39. # explicit foo_class ()
  40. # : member1_(5)
  41. # {
  42. # }
  43. #
  44. ConstructorInitializerIndentWidth: 4
  45. # Make access modifier slightly more visible.
  46. AccessModifierOffset: -1
  47. # This will unfortunately use spaces in some cases where it's not desired (like
  48. # function calls) but the overall result is better since it will allow
  49. # alignment to work properly with different tab width settings.
  50. ContinuationIndentWidth: 4
  51. # This tries to match Blender's style as much as possible. One
  52. BreakBeforeBraces: Custom
  53. BraceWrapping: {
  54. AfterClass: 'false'
  55. AfterControlStatement: 'false'
  56. AfterEnum : 'false'
  57. AfterFunction : 'true'
  58. AfterNamespace : 'false'
  59. AfterStruct : 'false'
  60. AfterUnion : 'false'
  61. BeforeCatch : 'true'
  62. BeforeElse : 'true'
  63. IndentBraces : 'false'
  64. AfterObjCDeclaration: 'true'
  65. }
  66. # For switch statements, indent the cases.
  67. IndentCaseLabels: true
  68. # Indent after the hash inside preprocessor directives
  69. IndentPPDirectives: AfterHash
  70. BreakBeforeTernaryOperators: false
  71. SpaceAfterTemplateKeyword: false
  72. # Handy comment at the end of each C++ name space.
  73. FixNamespaceComments: true
  74. # Use "if (...)" instead of "if(...)", but have function calls like foo().
  75. SpaceBeforeParens: ControlStatements
  76. SpaceInEmptyParentheses: false
  77. # Use two spaces before trailing comments, for example
  78. #
  79. # foo = bar; // comment
  80. #
  81. # Note that this doesn't work for C-style comments.
  82. SpacesBeforeTrailingComments: 2
  83. # Reflow comments, developers must disable formatting as with code to override this.
  84. ReflowComments: true
  85. # Never use tabs for indentation.
  86. # Note: TabWidth and IndentWidth must be the same, or strange things happen.
  87. UseTab: Never
  88. TabWidth: 2
  89. IndentWidth: 2
  90. # Add a big penalty on breaking after the return type of functions. For example,
  91. #
  92. # static void foo(...)
  93. #
  94. # Instead of:
  95. #
  96. # static void
  97. # foo(very long content here that maybe could be stacked)
  98. #
  99. PenaltyReturnTypeOnItsOwnLine: 10000
  100. # Avoid having function calls broken onto a new line:
  101. #
  102. # int a = foo(
  103. # long, list, of, many, params);
  104. #
  105. # Instead of:
  106. #
  107. # int a =
  108. # foo(long, list, of, many, params);
  109. #
  110. PenaltyBreakAssignment: 100
  111. AllowShortFunctionsOnASingleLine: None
  112. # Disable for now since it complicates initial migration tests,
  113. # TODO: look into enabling this in the future.
  114. SortIncludes: false
  115. # Don't right align escaped newlines to the right because we have a wide default
  116. AlignEscapedNewlines: DontAlign
  117. # Always break:
  118. #
  119. # const char *foo =
  120. # "multi"
  121. # "line";
  122. #
  123. # Instead of:
  124. #
  125. # const char *foo = "multi"
  126. # "line";
  127. #
  128. AlwaysBreakBeforeMultilineStrings: true
  129. # We don't want literal strings to break,
  130. # however clang-format seems to ignore this (sigh).
  131. PenaltyBreakString: 1000000
  132. # There are macros in Blender for custom for loops; tell Clang to treat them
  133. # like loops rather than an expression, and so put the { on the same line.
  134. #
  135. # To find these use multi-line regex search:
  136. # "^\s+[A-Z][A-Z0-9_]+\s*\([^\n]*\)\n\s*\{"
  137. ForEachMacros:
  138. - BEGIN_ANIMFILTER_SUBCHANNELS
  139. - BLI_FOREACH_SPARSE_RANGE
  140. - BLI_SMALLSTACK_ITER_BEGIN
  141. - BMO_ITER
  142. - BMO_ITER_INDEX
  143. - BMW_ITER
  144. - BM_FACES_OF_VERT_ITER_BEGIN
  145. - BM_ITER_BPY_BM_SEQ
  146. - BM_ITER_ELEM
  147. - BM_ITER_ELEM_INDEX
  148. - BM_ITER_MESH
  149. - BM_ITER_MESH_INDEX
  150. - BM_ITER_MESH_MUTABLE
  151. - BM_LOOPS_OF_VERT_ITER_BEGIN
  152. - BOOST_FOREACH
  153. - CTX_DATA_BEGIN
  154. - CTX_DATA_BEGIN_WITH_ID
  155. - DEG_OBJECT_ITER_BEGIN
  156. - DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN
  157. - DRIVER_TARGETS_LOOPER_BEGIN
  158. - DRIVER_TARGETS_USED_LOOPER_BEGIN
  159. - FOREACH_BASE_IN_EDIT_MODE_BEGIN
  160. - FOREACH_BASE_IN_MODE_BEGIN
  161. - FOREACH_BEGIN
  162. - FOREACH_COLLECTION_BEGIN
  163. - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN
  164. - FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN
  165. - FOREACH_EDIT_OBJECT_BEGIN
  166. - FOREACH_MAIN_ID_BEGIN
  167. - FOREACH_MAIN_LISTBASE_BEGIN
  168. - FOREACH_MAIN_LISTBASE_ID_BEGIN
  169. - FOREACH_NODETREE_BEGIN
  170. - FOREACH_OBJECT_BEGIN
  171. - FOREACH_OBJECT_FLAG_BEGIN
  172. - FOREACH_OBJECT_IN_EDIT_MODE_BEGIN
  173. - FOREACH_OBJECT_IN_MODE_BEGIN
  174. - FOREACH_OBJECT_RENDERABLE_BEGIN
  175. - FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN
  176. - FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN
  177. - FOREACH_SCENE_COLLECTION_BEGIN
  178. - FOREACH_SCENE_OBJECT_BEGIN
  179. - FOREACH_SELECTED_BASE_BEGIN
  180. - FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN
  181. - FOREACH_SELECTED_OBJECT_BEGIN
  182. - FOREACH_TRANS_DATA_CONTAINER
  183. - FOREACH_VIEW_LAYER_TO_RENDER_BEGIN
  184. - FOREACH_VISIBLE_BASE_BEGIN
  185. - FOREACH_VISIBLE_OBJECT_BEGIN
  186. - GHASH_FOREACH_BEGIN
  187. - GHASH_ITER
  188. - GHASH_ITER_INDEX
  189. - GPU_SELECT_LOAD_IF_PICKSEL_LIST
  190. - GP_EDITABLE_STROKES_BEGIN
  191. - GSET_FOREACH_BEGIN
  192. - GSET_ITER
  193. - GSET_ITER_INDEX
  194. - ITER_BEGIN
  195. - ITER_PIXELS
  196. - ITER_SLOTS
  197. - LISTBASE_CIRCULAR_BACKWARD_BEGIN
  198. - LISTBASE_CIRCULAR_FORWARD_BEGIN
  199. - LISTBASE_FOREACH
  200. - LISTBASE_FOREACH_MUTABLE
  201. - MAN2D_ITER_AXES_BEGIN
  202. - MAN_ITER_AXES_BEGIN
  203. - NODE_INSTANCE_HASH_ITER
  204. - NODE_SOCKET_TYPES_BEGIN
  205. - NODE_TREE_TYPES_BEGIN
  206. - NODE_TYPES_BEGIN
  207. - PIXEL_LOOPER_BEGIN
  208. - PIXEL_LOOPER_BEGIN_CHANNELS
  209. - RNA_BEGIN
  210. - RNA_PROP_BEGIN
  211. - RNA_STRUCT_BEGIN
  212. - RNA_STRUCT_BEGIN_SKIP_RNA_TYPE
  213. - SEQP_BEGIN
  214. - SEQ_BEGIN
  215. - foreach
  216. # Use once we bump the minimum verison to version 8.
  217. # # Without this string literals that in-line 'STRINGIFY' behave strangely (a bug?).
  218. # StatementMacros:
  219. # - PyObject_VAR_HEAD
  220. # - STRINGIFY