xref: /linux/.clang-format (revision 5ff328836dfde0cef9f28c8b8791a90a36d7a183)
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_integrity_vec'
82  - '__bio_for_each_segment'
83  - 'bio_for_each_segment'
84  - 'bio_for_each_segment_all'
85  - 'bio_list_for_each'
86  - 'bip_for_each_vec'
87  - 'blkg_for_each_descendant_post'
88  - 'blkg_for_each_descendant_pre'
89  - 'blk_queue_for_each_rl'
90  - 'bond_for_each_slave'
91  - 'bond_for_each_slave_rcu'
92  - 'bpf_for_each_spilled_reg'
93  - 'btree_for_each_safe128'
94  - 'btree_for_each_safe32'
95  - 'btree_for_each_safe64'
96  - 'btree_for_each_safel'
97  - 'card_for_each_dev'
98  - 'cgroup_taskset_for_each'
99  - 'cgroup_taskset_for_each_leader'
100  - 'cpufreq_for_each_entry'
101  - 'cpufreq_for_each_entry_idx'
102  - 'cpufreq_for_each_valid_entry'
103  - 'cpufreq_for_each_valid_entry_idx'
104  - 'css_for_each_child'
105  - 'css_for_each_descendant_post'
106  - 'css_for_each_descendant_pre'
107  - 'device_for_each_child_node'
108  - 'drm_atomic_crtc_for_each_plane'
109  - 'drm_atomic_crtc_state_for_each_plane'
110  - 'drm_atomic_crtc_state_for_each_plane_state'
111  - 'drm_atomic_for_each_plane_damage'
112  - 'drm_connector_for_each_possible_encoder'
113  - 'drm_for_each_connector_iter'
114  - 'drm_for_each_crtc'
115  - 'drm_for_each_encoder'
116  - 'drm_for_each_encoder_mask'
117  - 'drm_for_each_fb'
118  - 'drm_for_each_legacy_plane'
119  - 'drm_for_each_plane'
120  - 'drm_for_each_plane_mask'
121  - 'drm_mm_for_each_hole'
122  - 'drm_mm_for_each_node'
123  - 'drm_mm_for_each_node_in_range'
124  - 'drm_mm_for_each_node_safe'
125  - 'for_each_active_drhd_unit'
126  - 'for_each_active_iommu'
127  - 'for_each_available_child_of_node'
128  - 'for_each_bio'
129  - 'for_each_board_func_rsrc'
130  - 'for_each_bvec'
131  - 'for_each_card_components'
132  - 'for_each_card_links'
133  - 'for_each_card_links_safe'
134  - 'for_each_card_prelinks'
135  - 'for_each_card_rtds'
136  - 'for_each_card_rtds_safe'
137  - 'for_each_cgroup_storage_type'
138  - 'for_each_child_of_node'
139  - 'for_each_clear_bit'
140  - 'for_each_clear_bit_from'
141  - 'for_each_cmsghdr'
142  - 'for_each_compatible_node'
143  - 'for_each_component_dais'
144  - 'for_each_component_dais_safe'
145  - 'for_each_comp_order'
146  - 'for_each_console'
147  - 'for_each_cpu'
148  - 'for_each_cpu_and'
149  - 'for_each_cpu_not'
150  - 'for_each_cpu_wrap'
151  - 'for_each_dev_addr'
152  - 'for_each_dma_cap_mask'
153  - 'for_each_dpcm_be'
154  - 'for_each_dpcm_be_rollback'
155  - 'for_each_dpcm_be_safe'
156  - 'for_each_dpcm_fe'
157  - 'for_each_drhd_unit'
158  - 'for_each_dss_dev'
159  - 'for_each_efi_memory_desc'
160  - 'for_each_efi_memory_desc_in_map'
161  - 'for_each_endpoint_of_node'
162  - 'for_each_evictable_lru'
163  - 'for_each_fib6_node_rt_rcu'
164  - 'for_each_fib6_walker_rt'
165  - 'for_each_free_mem_range'
166  - 'for_each_free_mem_range_reverse'
167  - 'for_each_func_rsrc'
168  - 'for_each_hstate'
169  - 'for_each_if'
170  - 'for_each_iommu'
171  - 'for_each_ip_tunnel_rcu'
172  - 'for_each_irq_nr'
173  - 'for_each_link_codecs'
174  - 'for_each_lru'
175  - 'for_each_matching_node'
176  - 'for_each_matching_node_and_match'
177  - 'for_each_memblock'
178  - 'for_each_memblock_type'
179  - 'for_each_memcg_cache_index'
180  - 'for_each_mem_pfn_range'
181  - 'for_each_mem_range'
182  - 'for_each_mem_range_rev'
183  - 'for_each_migratetype_order'
184  - 'for_each_msi_entry'
185  - 'for_each_msi_entry_safe'
186  - 'for_each_net'
187  - 'for_each_netdev'
188  - 'for_each_netdev_continue'
189  - 'for_each_netdev_continue_rcu'
190  - 'for_each_netdev_feature'
191  - 'for_each_netdev_in_bond_rcu'
192  - 'for_each_netdev_rcu'
193  - 'for_each_netdev_reverse'
194  - 'for_each_netdev_safe'
195  - 'for_each_net_rcu'
196  - 'for_each_new_connector_in_state'
197  - 'for_each_new_crtc_in_state'
198  - 'for_each_new_plane_in_state'
199  - 'for_each_new_private_obj_in_state'
200  - 'for_each_node'
201  - 'for_each_node_by_name'
202  - 'for_each_node_by_type'
203  - 'for_each_node_mask'
204  - 'for_each_node_state'
205  - 'for_each_node_with_cpus'
206  - 'for_each_node_with_property'
207  - 'for_each_of_allnodes'
208  - 'for_each_of_allnodes_from'
209  - 'for_each_of_cpu_node'
210  - 'for_each_of_pci_range'
211  - 'for_each_old_connector_in_state'
212  - 'for_each_old_crtc_in_state'
213  - 'for_each_oldnew_connector_in_state'
214  - 'for_each_oldnew_crtc_in_state'
215  - 'for_each_oldnew_plane_in_state'
216  - 'for_each_oldnew_plane_in_state_reverse'
217  - 'for_each_oldnew_private_obj_in_state'
218  - 'for_each_old_plane_in_state'
219  - 'for_each_old_private_obj_in_state'
220  - 'for_each_online_cpu'
221  - 'for_each_online_node'
222  - 'for_each_online_pgdat'
223  - 'for_each_pci_bridge'
224  - 'for_each_pci_dev'
225  - 'for_each_pci_msi_entry'
226  - 'for_each_populated_zone'
227  - 'for_each_possible_cpu'
228  - 'for_each_present_cpu'
229  - 'for_each_prime_number'
230  - 'for_each_prime_number_from'
231  - 'for_each_process'
232  - 'for_each_process_thread'
233  - 'for_each_property_of_node'
234  - 'for_each_registered_fb'
235  - 'for_each_reserved_mem_region'
236  - 'for_each_rtd_codec_dai'
237  - 'for_each_rtd_codec_dai_rollback'
238  - 'for_each_rtdcom'
239  - 'for_each_rtdcom_safe'
240  - 'for_each_set_bit'
241  - 'for_each_set_bit_from'
242  - 'for_each_sg'
243  - 'for_each_sg_page'
244  - 'for_each_sibling_event'
245  - '__for_each_thread'
246  - 'for_each_thread'
247  - 'for_each_zone'
248  - 'for_each_zone_zonelist'
249  - 'for_each_zone_zonelist_nodemask'
250  - 'fwnode_for_each_available_child_node'
251  - 'fwnode_for_each_child_node'
252  - 'fwnode_graph_for_each_endpoint'
253  - 'gadget_for_each_ep'
254  - 'hash_for_each'
255  - 'hash_for_each_possible'
256  - 'hash_for_each_possible_rcu'
257  - 'hash_for_each_possible_rcu_notrace'
258  - 'hash_for_each_possible_safe'
259  - 'hash_for_each_rcu'
260  - 'hash_for_each_safe'
261  - 'hctx_for_each_ctx'
262  - 'hlist_bl_for_each_entry'
263  - 'hlist_bl_for_each_entry_rcu'
264  - 'hlist_bl_for_each_entry_safe'
265  - 'hlist_for_each'
266  - 'hlist_for_each_entry'
267  - 'hlist_for_each_entry_continue'
268  - 'hlist_for_each_entry_continue_rcu'
269  - 'hlist_for_each_entry_continue_rcu_bh'
270  - 'hlist_for_each_entry_from'
271  - 'hlist_for_each_entry_from_rcu'
272  - 'hlist_for_each_entry_rcu'
273  - 'hlist_for_each_entry_rcu_bh'
274  - 'hlist_for_each_entry_rcu_notrace'
275  - 'hlist_for_each_entry_safe'
276  - '__hlist_for_each_rcu'
277  - 'hlist_for_each_safe'
278  - 'hlist_nulls_for_each_entry'
279  - 'hlist_nulls_for_each_entry_from'
280  - 'hlist_nulls_for_each_entry_rcu'
281  - 'hlist_nulls_for_each_entry_safe'
282  - 'i3c_bus_for_each_i2cdev'
283  - 'i3c_bus_for_each_i3cdev'
284  - 'ide_host_for_each_port'
285  - 'ide_port_for_each_dev'
286  - 'ide_port_for_each_present_dev'
287  - 'idr_for_each_entry'
288  - 'idr_for_each_entry_continue'
289  - 'idr_for_each_entry_ul'
290  - 'inet_bind_bucket_for_each'
291  - 'inet_lhash2_for_each_icsk_rcu'
292  - 'iov_for_each'
293  - 'key_for_each'
294  - 'key_for_each_safe'
295  - 'klp_for_each_func'
296  - 'klp_for_each_object'
297  - 'kvm_for_each_memslot'
298  - 'kvm_for_each_vcpu'
299  - 'list_for_each'
300  - 'list_for_each_codec'
301  - 'list_for_each_codec_safe'
302  - 'list_for_each_entry'
303  - 'list_for_each_entry_continue'
304  - 'list_for_each_entry_continue_rcu'
305  - 'list_for_each_entry_continue_reverse'
306  - 'list_for_each_entry_from'
307  - 'list_for_each_entry_from_rcu'
308  - 'list_for_each_entry_from_reverse'
309  - 'list_for_each_entry_lockless'
310  - 'list_for_each_entry_rcu'
311  - 'list_for_each_entry_reverse'
312  - 'list_for_each_entry_safe'
313  - 'list_for_each_entry_safe_continue'
314  - 'list_for_each_entry_safe_from'
315  - 'list_for_each_entry_safe_reverse'
316  - 'list_for_each_prev'
317  - 'list_for_each_prev_safe'
318  - 'list_for_each_safe'
319  - 'llist_for_each'
320  - 'llist_for_each_entry'
321  - 'llist_for_each_entry_safe'
322  - 'llist_for_each_safe'
323  - 'media_device_for_each_entity'
324  - 'media_device_for_each_intf'
325  - 'media_device_for_each_link'
326  - 'media_device_for_each_pad'
327  - 'nanddev_io_for_each_page'
328  - 'netdev_for_each_lower_dev'
329  - 'netdev_for_each_lower_private'
330  - 'netdev_for_each_lower_private_rcu'
331  - 'netdev_for_each_mc_addr'
332  - 'netdev_for_each_uc_addr'
333  - 'netdev_for_each_upper_dev_rcu'
334  - 'netdev_hw_addr_list_for_each'
335  - 'nft_rule_for_each_expr'
336  - 'nla_for_each_attr'
337  - 'nla_for_each_nested'
338  - 'nlmsg_for_each_attr'
339  - 'nlmsg_for_each_msg'
340  - 'nr_neigh_for_each'
341  - 'nr_neigh_for_each_safe'
342  - 'nr_node_for_each'
343  - 'nr_node_for_each_safe'
344  - 'of_for_each_phandle'
345  - 'of_property_for_each_string'
346  - 'of_property_for_each_u32'
347  - 'pci_bus_for_each_resource'
348  - 'ping_portaddr_for_each_entry'
349  - 'plist_for_each'
350  - 'plist_for_each_continue'
351  - 'plist_for_each_entry'
352  - 'plist_for_each_entry_continue'
353  - 'plist_for_each_entry_safe'
354  - 'plist_for_each_safe'
355  - 'pnp_for_each_card'
356  - 'pnp_for_each_dev'
357  - 'protocol_for_each_card'
358  - 'protocol_for_each_dev'
359  - 'queue_for_each_hw_ctx'
360  - 'radix_tree_for_each_slot'
361  - 'radix_tree_for_each_tagged'
362  - 'rbtree_postorder_for_each_entry_safe'
363  - 'resource_list_for_each_entry'
364  - 'resource_list_for_each_entry_safe'
365  - 'rhl_for_each_entry_rcu'
366  - 'rhl_for_each_rcu'
367  - 'rht_for_each'
368  - 'rht_for_each_continue'
369  - 'rht_for_each_entry'
370  - 'rht_for_each_entry_continue'
371  - 'rht_for_each_entry_rcu'
372  - 'rht_for_each_entry_rcu_continue'
373  - 'rht_for_each_entry_safe'
374  - 'rht_for_each_rcu'
375  - 'rht_for_each_rcu_continue'
376  - '__rq_for_each_bio'
377  - 'rq_for_each_segment'
378  - 'scsi_for_each_prot_sg'
379  - 'scsi_for_each_sg'
380  - 'sctp_for_each_hentry'
381  - 'sctp_skb_for_each'
382  - 'shdma_for_each_chan'
383  - '__shost_for_each_device'
384  - 'shost_for_each_device'
385  - 'sk_for_each'
386  - 'sk_for_each_bound'
387  - 'sk_for_each_entry_offset_rcu'
388  - 'sk_for_each_from'
389  - 'sk_for_each_rcu'
390  - 'sk_for_each_safe'
391  - 'sk_nulls_for_each'
392  - 'sk_nulls_for_each_from'
393  - 'sk_nulls_for_each_rcu'
394  - 'snd_array_for_each'
395  - 'snd_pcm_group_for_each_entry'
396  - 'snd_soc_dapm_widget_for_each_path'
397  - 'snd_soc_dapm_widget_for_each_path_safe'
398  - 'snd_soc_dapm_widget_for_each_sink_path'
399  - 'snd_soc_dapm_widget_for_each_source_path'
400  - 'tb_property_for_each'
401  - 'tcf_exts_for_each_action'
402  - 'udp_portaddr_for_each_entry'
403  - 'udp_portaddr_for_each_entry_rcu'
404  - 'usb_hub_for_each_child'
405  - 'v4l2_device_for_each_subdev'
406  - 'v4l2_m2m_for_each_dst_buf'
407  - 'v4l2_m2m_for_each_dst_buf_safe'
408  - 'v4l2_m2m_for_each_src_buf'
409  - 'v4l2_m2m_for_each_src_buf_safe'
410  - 'virtio_device_for_each_vq'
411  - 'xa_for_each'
412  - 'xas_for_each'
413  - 'xas_for_each_conflict'
414  - 'xas_for_each_marked'
415  - 'zorro_for_each_dev'
416
417#IncludeBlocks: Preserve # Unknown to clang-format-5.0
418IncludeCategories:
419  - Regex: '.*'
420    Priority: 1
421IncludeIsMainRegex: '(Test)?$'
422IndentCaseLabels: false
423#IndentPPDirectives: None # Unknown to clang-format-5.0
424IndentWidth: 8
425IndentWrappedFunctionNames: false
426JavaScriptQuotes: Leave
427JavaScriptWrapImports: true
428KeepEmptyLinesAtTheStartOfBlocks: false
429MacroBlockBegin: ''
430MacroBlockEnd: ''
431MaxEmptyLinesToKeep: 1
432NamespaceIndentation: Inner
433#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
434ObjCBlockIndentWidth: 8
435ObjCSpaceAfterProperty: true
436ObjCSpaceBeforeProtocolList: true
437
438# Taken from git's rules
439#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
440PenaltyBreakBeforeFirstCallParameter: 30
441PenaltyBreakComment: 10
442PenaltyBreakFirstLessLess: 0
443PenaltyBreakString: 10
444PenaltyExcessCharacter: 100
445PenaltyReturnTypeOnItsOwnLine: 60
446
447PointerAlignment: Right
448ReflowComments: false
449SortIncludes: false
450#SortUsingDeclarations: false # Unknown to clang-format-4.0
451SpaceAfterCStyleCast: false
452SpaceAfterTemplateKeyword: true
453SpaceBeforeAssignmentOperators: true
454#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
455#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
456SpaceBeforeParens: ControlStatements
457#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
458SpaceInEmptyParentheses: false
459SpacesBeforeTrailingComments: 1
460SpacesInAngles: false
461SpacesInContainerLiterals: false
462SpacesInCStyleCastParentheses: false
463SpacesInParentheses: false
464SpacesInSquareBrackets: false
465Standard: Cpp03
466TabWidth: 8
467UseTab: Always
468...
469