• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright © 2022 Imagination Technologies Ltd.
2
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9
10# The above copyright notice and this permission notice (including the next
11# paragraph) shall be included in all copies or substantial portions of the
12# Software.
13
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20# SOFTWARE.
21
22Language: Cpp
23Standard: c++11
24
25UseCRLF: false
26ColumnLimit: 80
27
28DeriveLineEnding: false
29DerivePointerAlignment: false
30ExperimentalAutoDetectBinPacking: false
31
32DisableFormat: false
33
34########
35# Tabs #
36########
37UseTab: Never
38TabWidth: 3
39
40ConstructorInitializerIndentWidth: 6
41ContinuationIndentWidth: 3
42
43IndentWidth: 3
44#IndentCaseBlocks: true  # Requires clang-11
45IndentCaseLabels: false
46#IndentExternBlock: NoIndent  # Requires clang-11
47IndentGotoLabels: false
48IndentPPDirectives: AfterHash
49IndentWrappedFunctionNames: false
50AccessModifierOffset: -4  # -IndentWidth
51
52NamespaceIndentation: None
53
54##########
55# Braces #
56##########
57AlignAfterOpenBracket: Align
58AllowAllArgumentsOnNextLine: false
59AllowAllConstructorInitializersOnNextLine: false
60AllowAllParametersOfDeclarationOnNextLine: false
61BinPackArguments: false
62BinPackParameters: false
63
64Cpp11BracedListStyle: false
65
66########################
67# Whitespace Alignment #
68########################
69AlignConsecutiveAssignments: false
70#AlignConsecutiveBitFields: false  # Requires clang-11
71AlignConsecutiveDeclarations: false
72AlignConsecutiveMacros: false
73AlignTrailingComments: false
74
75AlignEscapedNewlines: Left
76
77#AlignOperands: Align  # Requires clang-11
78#BitFieldColonSpacing: Both  # Requires clang-12
79
80PointerAlignment: Right
81#SpaceAroundPointerQualifiers: Both  # Requires clang-12
82
83SpaceAfterCStyleCast: false
84SpaceAfterLogicalNot: false
85SpaceAfterTemplateKeyword: true
86SpaceBeforeAssignmentOperators: true
87SpaceBeforeCpp11BracedList: false
88SpaceBeforeCtorInitializerColon: true
89SpaceBeforeInheritanceColon: true
90SpaceBeforeParens: ControlStatements
91#SpaceBeforeParens: ControlStatementsExceptForEachMacros  # Requires clang-11
92SpaceBeforeRangeBasedForLoopColon: true
93SpaceBeforeSquareBrackets: false
94SpaceInEmptyBlock: false
95SpaceInEmptyParentheses: false
96SpacesInAngles: false
97SpacesInCStyleCastParentheses: false
98SpacesInConditionalStatement: false
99SpacesInContainerLiterals: false
100SpacesInParentheses: false
101SpacesInSquareBrackets: false
102SpacesBeforeTrailingComments: 2
103
104############################
105# Multi-line constructions #
106############################
107AllowShortBlocksOnASingleLine: Empty
108AllowShortCaseLabelsOnASingleLine: false
109#AllowShortEnumsOnASingleLine: false  # Requires clang-11
110AllowShortFunctionsOnASingleLine: Empty
111AllowShortIfStatementsOnASingleLine: Never
112AllowShortLambdasOnASingleLine: All
113AllowShortLoopsOnASingleLine: false
114
115AlwaysBreakAfterReturnType: None
116AlwaysBreakBeforeMultilineStrings: false
117AlwaysBreakTemplateDeclarations: Yes
118
119BreakBeforeBraces: Custom
120BraceWrapping:
121  AfterCaseLabel: false
122  AfterClass: false
123  AfterControlStatement: Never
124  AfterEnum: false
125  AfterFunction: true
126  AfterNamespace: true
127  AfterObjCDeclaration: false
128  AfterStruct: false
129  AfterUnion: false
130  BeforeCatch: false
131  BeforeElse: false
132#  BeforeLambdaBody: false  # Requires clang-11
133  IndentBraces: false
134  SplitEmptyFunction: true
135  SplitEmptyNamespace: true
136  SplitEmptyRecord: true
137
138BreakBeforeBinaryOperators: None
139BreakBeforeTernaryOperators: true
140
141BreakConstructorInitializers: AfterColon
142BreakInheritanceList: AfterColon
143
144BreakStringLiterals: false
145
146CompactNamespaces: false
147ConstructorInitializerAllOnOneLineOrOnePerLine: true
148
149#InsertTrailingCommas: Wrapped  # Requires clang-11
150
151KeepEmptyLinesAtTheStartOfBlocks: false
152MaxEmptyLinesToKeep: 1
153
154SortUsingDeclarations: true
155
156############
157# Includes #
158############
159# TODO: Temporary config
160IncludeBlocks: Preserve
161SortIncludes: false
162# TODO: This requires additional work to clean up headers & includes first
163#IncludeBlocks: Regroup
164#SortIncludes: true
165#IncludeIsMainRegex: '(_test)?$'
166##IncludeIsMainSourceRegex: <default>
167#IncludeCategories:
168#  - Regex:        '^"'
169#    Priority:     1
170
171############
172# Comments #
173############
174FixNamespaceComments: false
175
176#############
177# Penalties #
178#############
179# Taken from torvalds/kernel:.clang-format
180PenaltyBreakAssignment: 10
181PenaltyBreakBeforeFirstCallParameter: 30
182PenaltyBreakComment: 10
183PenaltyBreakFirstLessLess: 0
184PenaltyBreakString: 10
185PenaltyBreakTemplateDeclaration: 10
186PenaltyExcessCharacter: 100
187PenaltyReturnTypeOnItsOwnLine: 60
188
189#######################
190# User-defined macros #
191#######################
192CommentPragmas: '^ IWYU pragma:'
193
194MacroBlockBegin: ''
195MacroBlockEnd: ''
196
197#AttributeMacros: []  # Requires clang-12
198
199ForEachMacros: [
200  'BITSET_FOREACH_SET',
201  'foreach_instr',
202  'foreach_instr_safe',
203  'foreach_list_typed',
204  'hash_table_foreach',
205  'hash_table_u64_foreach',
206  'LIST_FOR_EACH_ENTRY',
207  'LIST_FOR_EACH_ENTRY_FROM',
208  'LIST_FOR_EACH_ENTRY_FROM_REV',
209  'LIST_FOR_EACH_ENTRY_SAFE',
210  'LIST_FOR_EACH_ENTRY_SAFE_REV',
211  'list_for_each_entry',
212  'list_for_each_entry_from',
213  'list_for_each_entry_from_rev',
214  'list_for_each_entry_from_safe',
215  'list_for_each_entry_rev',
216  'list_for_each_entry_safe',
217  'list_for_each_entry_safe_rev',
218  'list_pair_for_each_entry',
219  'pvr_csb_emit',
220  'pvr_csb_emit_merge',
221  'pvr_csb_pack',
222  'nir_foreach_block',
223  'nir_foreach_block_safe',
224  'nir_foreach_block_unstructured',
225  'nir_foreach_function',
226  'nir_foreach_function_with_impl',
227  'nir_foreach_instr',
228  'nir_foreach_instr_safe',
229  'nir_foreach_shader_in_variable',
230  'nir_foreach_shader_out_variable',
231  'nir_foreach_use',
232  'nir_foreach_use_safe',
233  'nir_foreach_variable_with_modes',
234  'pco_foreach_block_in_func',
235  'pco_foreach_block_in_func_from',
236  'pco_foreach_block_in_func_from_rev',
237  'pco_foreach_block_in_func_rev',
238  'pco_foreach_cf_node_in_func',
239  'pco_foreach_cf_node_in_if_else',
240  'pco_foreach_cf_node_in_if_then',
241  'pco_foreach_cf_node_in_loop',
242  'pco_foreach_func_in_shader',
243  'pco_foreach_func_in_shader_rev',
244  'pco_foreach_igrp_in_block',
245  'pco_foreach_instr_dest',
246  'pco_foreach_instr_dest_ssa',
247  'pco_foreach_instr_src',
248  'pco_foreach_instr_src_ssa',
249  'pco_foreach_instr_in_block',
250  'pco_foreach_instr_in_block_safe',
251  'pco_foreach_instr_in_func',
252  'pco_foreach_instr_in_func_from',
253  'pco_foreach_instr_in_func_from_rev',
254  'pco_foreach_instr_in_func_safe',
255  'pco_foreach_instr_in_func_rev',
256  'pco_foreach_instr_in_func_safe_rev',
257  'pco_foreach_phi_src_in_instr',
258  'rogue_foreach_block',
259  'rogue_foreach_block_safe',
260  'rogue_foreach_block_rev',
261  'rogue_foreach_block_safe_rev',
262  'rogue_foreach_block_use',
263  'rogue_foreach_block_use_safe',
264  'rogue_foreach_drc_trxn',
265  'rogue_foreach_drc_trxn_safe',
266  'rogue_foreach_phase_in_set',
267  'rogue_foreach_phase_in_set_rev',
268  'rogue_foreach_imm_use',
269  'rogue_foreach_imm_use_safe',
270  'rogue_foreach_instr_group_in_block',
271  'rogue_foreach_instr_group_in_block_safe',
272  'rogue_foreach_instr_group_in_shader',
273  'rogue_foreach_instr_group_in_shader_safe',
274  'rogue_foreach_instr_in_block',
275  'rogue_foreach_instr_in_block_safe',
276  'rogue_foreach_instr_in_block_rev',
277  'rogue_foreach_instr_in_block_safe_rev',
278  'rogue_foreach_instr_in_shader',
279  'rogue_foreach_instr_in_shader_safe',
280  'rogue_foreach_instr_in_shader_rev',
281  'rogue_foreach_instr_in_shader_safe_rev',
282  'rogue_foreach_mod_in_set',
283  'rogue_foreach_reg',
284  'rogue_foreach_reg_safe',
285  'rogue_foreach_reg_use',
286  'rogue_foreach_reg_use_safe',
287  'rogue_foreach_reg_write',
288  'rogue_foreach_reg_write_safe',
289  'rogue_foreach_regarray',
290  'rogue_foreach_regarray_safe',
291  'rogue_foreach_regarray_use',
292  'rogue_foreach_regarray_use_safe',
293  'rogue_foreach_regarray_write',
294  'rogue_foreach_regarray_write_safe',
295  'rogue_foreach_subarray',
296  'rogue_foreach_subarray_safe',
297  'rb_tree_foreach',
298  'rb_tree_foreach_safe',
299  'u_foreach_bit',
300  'u_foreach_bit64',
301  'u_vector_foreach',
302  'util_dynarray_foreach',
303  'util_dynarray_foreach_reverse',
304  'vk_foreach_struct',
305  'vk_foreach_struct_const',
306# FIXME: vk_outarray_append doesn't fit here, remove
307# it when a better solution exists for it.
308  'vk_outarray_append',
309  'vk_outarray_append_typed'
310]
311
312NamespaceMacros: [
313]
314
315StatementMacros: [
316]
317
318TypenameMacros: [
319]
320
321#WhitespaceSensitiveMacros: []  # Requires clang-11
322