xref: /linux/.clang-format (revision 74cc09fd8d04c56b652cfb332adb61f10bc2c199)
1# SPDX-License-Identifier: GPL-2.0
2#
3# clang-format configuration file. Intended for clang-format >= 4.
4#
5# For more information, see:
6#
7#   Documentation/process/clang-format.rst
8#   https://clang.llvm.org/docs/ClangFormat.html
9#   https://clang.llvm.org/docs/ClangFormatStyleOptions.html
10#
11---
12AccessModifierOffset: -4
13AlignAfterOpenBracket: Align
14AlignConsecutiveAssignments: false
15AlignConsecutiveDeclarations: false
16#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
17AlignOperands: true
18AlignTrailingComments: false
19AllowAllParametersOfDeclarationOnNextLine: false
20AllowShortBlocksOnASingleLine: false
21AllowShortCaseLabelsOnASingleLine: false
22AllowShortFunctionsOnASingleLine: None
23AllowShortIfStatementsOnASingleLine: false
24AllowShortLoopsOnASingleLine: false
25AlwaysBreakAfterDefinitionReturnType: None
26AlwaysBreakAfterReturnType: None
27AlwaysBreakBeforeMultilineStrings: false
28AlwaysBreakTemplateDeclarations: false
29BinPackArguments: true
30BinPackParameters: true
31BraceWrapping:
32  AfterClass: false
33  AfterControlStatement: false
34  AfterEnum: false
35  AfterFunction: true
36  AfterNamespace: true
37  AfterObjCDeclaration: false
38  AfterStruct: false
39  AfterUnion: false
40  #AfterExternBlock: false # Unknown to clang-format-5.0
41  BeforeCatch: false
42  BeforeElse: false
43  IndentBraces: false
44  #SplitEmptyFunction: true # Unknown to clang-format-4.0
45  #SplitEmptyRecord: true # Unknown to clang-format-4.0
46  #SplitEmptyNamespace: true # Unknown to clang-format-4.0
47BreakBeforeBinaryOperators: None
48BreakBeforeBraces: Custom
49#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
50BreakBeforeTernaryOperators: false
51BreakConstructorInitializersBeforeComma: false
52#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
53BreakAfterJavaFieldAnnotations: false
54BreakStringLiterals: false
55ColumnLimit: 80
56CommentPragmas: '^ IWYU pragma:'
57#CompactNamespaces: false # Unknown to clang-format-4.0
58ConstructorInitializerAllOnOneLineOrOnePerLine: false
59ConstructorInitializerIndentWidth: 8
60ContinuationIndentWidth: 8
61Cpp11BracedListStyle: false
62DerivePointerAlignment: false
63DisableFormat: false
64ExperimentalAutoDetectBinPacking: false
65#FixNamespaceComments: false # Unknown to clang-format-4.0
66
67# Taken from:
68#   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
69#   | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$,  - '\1'," \
70#   | sort | uniq
71ForEachMacros:
72  - 'apei_estatus_for_each_section'
73  - 'ata_for_each_dev'
74  - 'ata_for_each_link'
75  - '__ata_qc_for_each'
76  - 'ata_qc_for_each'
77  - 'ata_qc_for_each_raw'
78  - 'ata_qc_for_each_with_internal'
79  - 'ax25_for_each'
80  - 'ax25_uid_for_each'
81  - '__bio_for_each_bvec'
82  - 'bio_for_each_bvec'
83  - 'bio_for_each_bvec_all'
84  - 'bio_for_each_integrity_vec'
85  - '__bio_for_each_segment'
86  - 'bio_for_each_segment'
87  - 'bio_for_each_segment_all'
88  - 'bio_list_for_each'
89  - 'bip_for_each_vec'
90  - 'bitmap_for_each_clear_region'
91  - 'bitmap_for_each_set_region'
92  - 'blkg_for_each_descendant_post'
93  - 'blkg_for_each_descendant_pre'
94  - 'blk_queue_for_each_rl'
95  - 'bond_for_each_slave'
96  - 'bond_for_each_slave_rcu'
97  - 'bpf_for_each_spilled_reg'
98  - 'btree_for_each_safe128'
99  - 'btree_for_each_safe32'
100  - 'btree_for_each_safe64'
101  - 'btree_for_each_safel'
102  - 'card_for_each_dev'
103  - 'cgroup_taskset_for_each'
104  - 'cgroup_taskset_for_each_leader'
105  - 'cpufreq_for_each_entry'
106  - 'cpufreq_for_each_entry_idx'
107  - 'cpufreq_for_each_valid_entry'
108  - 'cpufreq_for_each_valid_entry_idx'
109  - 'css_for_each_child'
110  - 'css_for_each_descendant_post'
111  - 'css_for_each_descendant_pre'
112  - 'device_for_each_child_node'
113  - 'dma_fence_chain_for_each'
114  - 'drm_atomic_crtc_for_each_plane'
115  - 'drm_atomic_crtc_state_for_each_plane'
116  - 'drm_atomic_crtc_state_for_each_plane_state'
117  - 'drm_atomic_for_each_plane_damage'
118  - 'drm_client_for_each_connector_iter'
119  - 'drm_client_for_each_modeset'
120  - 'drm_connector_for_each_possible_encoder'
121  - 'drm_for_each_bridge_in_chain'
122  - 'drm_for_each_connector_iter'
123  - 'drm_for_each_crtc'
124  - 'drm_for_each_encoder'
125  - 'drm_for_each_encoder_mask'
126  - 'drm_for_each_fb'
127  - 'drm_for_each_legacy_plane'
128  - 'drm_for_each_plane'
129  - 'drm_for_each_plane_mask'
130  - 'drm_for_each_privobj'
131  - 'drm_mm_for_each_hole'
132  - 'drm_mm_for_each_node'
133  - 'drm_mm_for_each_node_in_range'
134  - 'drm_mm_for_each_node_safe'
135  - 'flow_action_for_each'
136  - 'for_each_active_dev_scope'
137  - 'for_each_active_drhd_unit'
138  - 'for_each_active_iommu'
139  - 'for_each_available_child_of_node'
140  - 'for_each_bio'
141  - 'for_each_board_func_rsrc'
142  - 'for_each_bvec'
143  - 'for_each_card_auxs'
144  - 'for_each_card_auxs_safe'
145  - 'for_each_card_components'
146  - 'for_each_card_dapms'
147  - 'for_each_card_pre_auxs'
148  - 'for_each_card_prelinks'
149  - 'for_each_card_rtds'
150  - 'for_each_card_rtds_safe'
151  - 'for_each_card_widgets'
152  - 'for_each_card_widgets_safe'
153  - 'for_each_cgroup_storage_type'
154  - 'for_each_child_of_node'
155  - 'for_each_clear_bit'
156  - 'for_each_clear_bit_from'
157  - 'for_each_cmsghdr'
158  - 'for_each_compatible_node'
159  - 'for_each_component_dais'
160  - 'for_each_component_dais_safe'
161  - 'for_each_comp_order'
162  - 'for_each_console'
163  - 'for_each_cpu'
164  - 'for_each_cpu_and'
165  - 'for_each_cpu_not'
166  - 'for_each_cpu_wrap'
167  - 'for_each_dapm_widgets'
168  - 'for_each_dev_addr'
169  - 'for_each_dev_scope'
170  - 'for_each_displayid_db'
171  - 'for_each_dma_cap_mask'
172  - 'for_each_dpcm_be'
173  - 'for_each_dpcm_be_rollback'
174  - 'for_each_dpcm_be_safe'
175  - 'for_each_dpcm_fe'
176  - 'for_each_drhd_unit'
177  - 'for_each_dss_dev'
178  - 'for_each_efi_memory_desc'
179  - 'for_each_efi_memory_desc_in_map'
180  - 'for_each_element'
181  - 'for_each_element_extid'
182  - 'for_each_element_id'
183  - 'for_each_endpoint_of_node'
184  - 'for_each_evictable_lru'
185  - 'for_each_fib6_node_rt_rcu'
186  - 'for_each_fib6_walker_rt'
187  - 'for_each_free_mem_pfn_range_in_zone'
188  - 'for_each_free_mem_pfn_range_in_zone_from'
189  - 'for_each_free_mem_range'
190  - 'for_each_free_mem_range_reverse'
191  - 'for_each_func_rsrc'
192  - 'for_each_hstate'
193  - 'for_each_if'
194  - 'for_each_iommu'
195  - 'for_each_ip_tunnel_rcu'
196  - 'for_each_irq_nr'
197  - 'for_each_link_codecs'
198  - 'for_each_link_cpus'
199  - 'for_each_link_platforms'
200  - 'for_each_lru'
201  - 'for_each_matching_node'
202  - 'for_each_matching_node_and_match'
203  - 'for_each_member'
204  - 'for_each_memblock'
205  - 'for_each_memblock_type'
206  - 'for_each_memcg_cache_index'
207  - 'for_each_mem_pfn_range'
208  - 'for_each_mem_range'
209  - 'for_each_mem_range_rev'
210  - 'for_each_migratetype_order'
211  - 'for_each_msi_entry'
212  - 'for_each_msi_entry_safe'
213  - 'for_each_net'
214  - 'for_each_net_continue_reverse'
215  - 'for_each_netdev'
216  - 'for_each_netdev_continue'
217  - 'for_each_netdev_continue_rcu'
218  - 'for_each_netdev_continue_reverse'
219  - 'for_each_netdev_feature'
220  - 'for_each_netdev_in_bond_rcu'
221  - 'for_each_netdev_rcu'
222  - 'for_each_netdev_reverse'
223  - 'for_each_netdev_safe'
224  - 'for_each_net_rcu'
225  - 'for_each_new_connector_in_state'
226  - 'for_each_new_crtc_in_state'
227  - 'for_each_new_mst_mgr_in_state'
228  - 'for_each_new_plane_in_state'
229  - 'for_each_new_private_obj_in_state'
230  - 'for_each_node'
231  - 'for_each_node_by_name'
232  - 'for_each_node_by_type'
233  - 'for_each_node_mask'
234  - 'for_each_node_state'
235  - 'for_each_node_with_cpus'
236  - 'for_each_node_with_property'
237  - 'for_each_of_allnodes'
238  - 'for_each_of_allnodes_from'
239  - 'for_each_of_cpu_node'
240  - 'for_each_of_pci_range'
241  - 'for_each_old_connector_in_state'
242  - 'for_each_old_crtc_in_state'
243  - 'for_each_old_mst_mgr_in_state'
244  - 'for_each_oldnew_connector_in_state'
245  - 'for_each_oldnew_crtc_in_state'
246  - 'for_each_oldnew_mst_mgr_in_state'
247  - 'for_each_oldnew_plane_in_state'
248  - 'for_each_oldnew_plane_in_state_reverse'
249  - 'for_each_oldnew_private_obj_in_state'
250  - 'for_each_old_plane_in_state'
251  - 'for_each_old_private_obj_in_state'
252  - 'for_each_online_cpu'
253  - 'for_each_online_node'
254  - 'for_each_online_pgdat'
255  - 'for_each_pci_bridge'
256  - 'for_each_pci_dev'
257  - 'for_each_pci_msi_entry'
258  - 'for_each_pcm_streams'
259  - 'for_each_populated_zone'
260  - 'for_each_possible_cpu'
261  - 'for_each_present_cpu'
262  - 'for_each_prime_number'
263  - 'for_each_prime_number_from'
264  - 'for_each_process'
265  - 'for_each_process_thread'
266  - 'for_each_property_of_node'
267  - 'for_each_registered_fb'
268  - 'for_each_reserved_mem_region'
269  - 'for_each_rtd_codec_dais'
270  - 'for_each_rtd_codec_dais_rollback'
271  - 'for_each_rtd_components'
272  - 'for_each_rtd_cpu_dais'
273  - 'for_each_rtd_cpu_dais_rollback'
274  - 'for_each_rtd_dais'
275  - 'for_each_set_bit'
276  - 'for_each_set_bit_from'
277  - 'for_each_set_clump8'
278  - 'for_each_sg'
279  - 'for_each_sg_dma_page'
280  - 'for_each_sg_page'
281  - 'for_each_sibling_event'
282  - 'for_each_subelement'
283  - 'for_each_subelement_extid'
284  - 'for_each_subelement_id'
285  - '__for_each_thread'
286  - 'for_each_thread'
287  - 'for_each_wakeup_source'
288  - 'for_each_zone'
289  - 'for_each_zone_zonelist'
290  - 'for_each_zone_zonelist_nodemask'
291  - 'fwnode_for_each_available_child_node'
292  - 'fwnode_for_each_child_node'
293  - 'fwnode_graph_for_each_endpoint'
294  - 'gadget_for_each_ep'
295  - 'genradix_for_each'
296  - 'genradix_for_each_from'
297  - 'hash_for_each'
298  - 'hash_for_each_possible'
299  - 'hash_for_each_possible_rcu'
300  - 'hash_for_each_possible_rcu_notrace'
301  - 'hash_for_each_possible_safe'
302  - 'hash_for_each_rcu'
303  - 'hash_for_each_safe'
304  - 'hctx_for_each_ctx'
305  - 'hlist_bl_for_each_entry'
306  - 'hlist_bl_for_each_entry_rcu'
307  - 'hlist_bl_for_each_entry_safe'
308  - 'hlist_for_each'
309  - 'hlist_for_each_entry'
310  - 'hlist_for_each_entry_continue'
311  - 'hlist_for_each_entry_continue_rcu'
312  - 'hlist_for_each_entry_continue_rcu_bh'
313  - 'hlist_for_each_entry_from'
314  - 'hlist_for_each_entry_from_rcu'
315  - 'hlist_for_each_entry_rcu'
316  - 'hlist_for_each_entry_rcu_bh'
317  - 'hlist_for_each_entry_rcu_notrace'
318  - 'hlist_for_each_entry_safe'
319  - '__hlist_for_each_rcu'
320  - 'hlist_for_each_safe'
321  - 'hlist_nulls_for_each_entry'
322  - 'hlist_nulls_for_each_entry_from'
323  - 'hlist_nulls_for_each_entry_rcu'
324  - 'hlist_nulls_for_each_entry_safe'
325  - 'i3c_bus_for_each_i2cdev'
326  - 'i3c_bus_for_each_i3cdev'
327  - 'ide_host_for_each_port'
328  - 'ide_port_for_each_dev'
329  - 'ide_port_for_each_present_dev'
330  - 'idr_for_each_entry'
331  - 'idr_for_each_entry_continue'
332  - 'idr_for_each_entry_continue_ul'
333  - 'idr_for_each_entry_ul'
334  - 'in_dev_for_each_ifa_rcu'
335  - 'in_dev_for_each_ifa_rtnl'
336  - 'inet_bind_bucket_for_each'
337  - 'inet_lhash2_for_each_icsk_rcu'
338  - 'key_for_each'
339  - 'key_for_each_safe'
340  - 'klp_for_each_func'
341  - 'klp_for_each_func_safe'
342  - 'klp_for_each_func_static'
343  - 'klp_for_each_object'
344  - 'klp_for_each_object_safe'
345  - 'klp_for_each_object_static'
346  - 'kunit_suite_for_each_test_case'
347  - 'kvm_for_each_memslot'
348  - 'kvm_for_each_vcpu'
349  - 'list_for_each'
350  - 'list_for_each_codec'
351  - 'list_for_each_codec_safe'
352  - 'list_for_each_continue'
353  - 'list_for_each_entry'
354  - 'list_for_each_entry_continue'
355  - 'list_for_each_entry_continue_rcu'
356  - 'list_for_each_entry_continue_reverse'
357  - 'list_for_each_entry_from'
358  - 'list_for_each_entry_from_rcu'
359  - 'list_for_each_entry_from_reverse'
360  - 'list_for_each_entry_lockless'
361  - 'list_for_each_entry_rcu'
362  - 'list_for_each_entry_reverse'
363  - 'list_for_each_entry_safe'
364  - 'list_for_each_entry_safe_continue'
365  - 'list_for_each_entry_safe_from'
366  - 'list_for_each_entry_safe_reverse'
367  - 'list_for_each_prev'
368  - 'list_for_each_prev_safe'
369  - 'list_for_each_safe'
370  - 'llist_for_each'
371  - 'llist_for_each_entry'
372  - 'llist_for_each_entry_safe'
373  - 'llist_for_each_safe'
374  - 'mci_for_each_dimm'
375  - 'media_device_for_each_entity'
376  - 'media_device_for_each_intf'
377  - 'media_device_for_each_link'
378  - 'media_device_for_each_pad'
379  - 'nanddev_io_for_each_page'
380  - 'netdev_for_each_lower_dev'
381  - 'netdev_for_each_lower_private'
382  - 'netdev_for_each_lower_private_rcu'
383  - 'netdev_for_each_mc_addr'
384  - 'netdev_for_each_uc_addr'
385  - 'netdev_for_each_upper_dev_rcu'
386  - 'netdev_hw_addr_list_for_each'
387  - 'nft_rule_for_each_expr'
388  - 'nla_for_each_attr'
389  - 'nla_for_each_nested'
390  - 'nlmsg_for_each_attr'
391  - 'nlmsg_for_each_msg'
392  - 'nr_neigh_for_each'
393  - 'nr_neigh_for_each_safe'
394  - 'nr_node_for_each'
395  - 'nr_node_for_each_safe'
396  - 'of_for_each_phandle'
397  - 'of_property_for_each_string'
398  - 'of_property_for_each_u32'
399  - 'pci_bus_for_each_resource'
400  - 'pcm_for_each_format'
401  - 'ping_portaddr_for_each_entry'
402  - 'plist_for_each'
403  - 'plist_for_each_continue'
404  - 'plist_for_each_entry'
405  - 'plist_for_each_entry_continue'
406  - 'plist_for_each_entry_safe'
407  - 'plist_for_each_safe'
408  - 'pnp_for_each_card'
409  - 'pnp_for_each_dev'
410  - 'protocol_for_each_card'
411  - 'protocol_for_each_dev'
412  - 'queue_for_each_hw_ctx'
413  - 'radix_tree_for_each_slot'
414  - 'radix_tree_for_each_tagged'
415  - 'rbtree_postorder_for_each_entry_safe'
416  - 'rdma_for_each_block'
417  - 'rdma_for_each_port'
418  - 'resource_list_for_each_entry'
419  - 'resource_list_for_each_entry_safe'
420  - 'rhl_for_each_entry_rcu'
421  - 'rhl_for_each_rcu'
422  - 'rht_for_each'
423  - 'rht_for_each_entry'
424  - 'rht_for_each_entry_from'
425  - 'rht_for_each_entry_rcu'
426  - 'rht_for_each_entry_rcu_from'
427  - 'rht_for_each_entry_safe'
428  - 'rht_for_each_from'
429  - 'rht_for_each_rcu'
430  - 'rht_for_each_rcu_from'
431  - '__rq_for_each_bio'
432  - 'rq_for_each_bvec'
433  - 'rq_for_each_segment'
434  - 'scsi_for_each_prot_sg'
435  - 'scsi_for_each_sg'
436  - 'sctp_for_each_hentry'
437  - 'sctp_skb_for_each'
438  - 'shdma_for_each_chan'
439  - '__shost_for_each_device'
440  - 'shost_for_each_device'
441  - 'sk_for_each'
442  - 'sk_for_each_bound'
443  - 'sk_for_each_entry_offset_rcu'
444  - 'sk_for_each_from'
445  - 'sk_for_each_rcu'
446  - 'sk_for_each_safe'
447  - 'sk_nulls_for_each'
448  - 'sk_nulls_for_each_from'
449  - 'sk_nulls_for_each_rcu'
450  - 'snd_array_for_each'
451  - 'snd_pcm_group_for_each_entry'
452  - 'snd_soc_dapm_widget_for_each_path'
453  - 'snd_soc_dapm_widget_for_each_path_safe'
454  - 'snd_soc_dapm_widget_for_each_sink_path'
455  - 'snd_soc_dapm_widget_for_each_source_path'
456  - 'tb_property_for_each'
457  - 'tcf_exts_for_each_action'
458  - 'udp_portaddr_for_each_entry'
459  - 'udp_portaddr_for_each_entry_rcu'
460  - 'usb_hub_for_each_child'
461  - 'v4l2_device_for_each_subdev'
462  - 'v4l2_m2m_for_each_dst_buf'
463  - 'v4l2_m2m_for_each_dst_buf_safe'
464  - 'v4l2_m2m_for_each_src_buf'
465  - 'v4l2_m2m_for_each_src_buf_safe'
466  - 'virtio_device_for_each_vq'
467  - 'xa_for_each'
468  - 'xa_for_each_marked'
469  - 'xa_for_each_range'
470  - 'xa_for_each_start'
471  - 'xas_for_each'
472  - 'xas_for_each_conflict'
473  - 'xas_for_each_marked'
474  - 'xbc_array_for_each_value'
475  - 'xbc_for_each_key_value'
476  - 'xbc_node_for_each_array_value'
477  - 'xbc_node_for_each_child'
478  - 'xbc_node_for_each_key_value'
479  - 'zorro_for_each_dev'
480
481#IncludeBlocks: Preserve # Unknown to clang-format-5.0
482IncludeCategories:
483  - Regex: '.*'
484    Priority: 1
485IncludeIsMainRegex: '(Test)?$'
486IndentCaseLabels: false
487#IndentPPDirectives: None # Unknown to clang-format-5.0
488IndentWidth: 8
489IndentWrappedFunctionNames: false
490JavaScriptQuotes: Leave
491JavaScriptWrapImports: true
492KeepEmptyLinesAtTheStartOfBlocks: false
493MacroBlockBegin: ''
494MacroBlockEnd: ''
495MaxEmptyLinesToKeep: 1
496NamespaceIndentation: None
497#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
498ObjCBlockIndentWidth: 8
499ObjCSpaceAfterProperty: true
500ObjCSpaceBeforeProtocolList: true
501
502# Taken from git's rules
503#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
504PenaltyBreakBeforeFirstCallParameter: 30
505PenaltyBreakComment: 10
506PenaltyBreakFirstLessLess: 0
507PenaltyBreakString: 10
508PenaltyExcessCharacter: 100
509PenaltyReturnTypeOnItsOwnLine: 60
510
511PointerAlignment: Right
512ReflowComments: false
513SortIncludes: false
514#SortUsingDeclarations: false # Unknown to clang-format-4.0
515SpaceAfterCStyleCast: false
516SpaceAfterTemplateKeyword: true
517SpaceBeforeAssignmentOperators: true
518#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
519#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
520SpaceBeforeParens: ControlStatements
521#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
522SpaceInEmptyParentheses: false
523SpacesBeforeTrailingComments: 1
524SpacesInAngles: false
525SpacesInContainerLiterals: false
526SpacesInCStyleCastParentheses: false
527SpacesInParentheses: false
528SpacesInSquareBrackets: false
529Standard: Cpp03
530TabWidth: 8
531UseTab: Always
532...
533