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 'foreach_instr', 201 'foreach_instr_safe', 202 'hash_table_foreach', 203 'LIST_FOR_EACH_ENTRY', 204 'LIST_FOR_EACH_ENTRY_FROM', 205 'LIST_FOR_EACH_ENTRY_FROM_REV', 206 'LIST_FOR_EACH_ENTRY_SAFE', 207 'LIST_FOR_EACH_ENTRY_SAFE_REV', 208 'list_for_each_entry', 209 'list_for_each_entry_from', 210 'list_for_each_entry_from_rev', 211 'list_for_each_entry_from_safe', 212 'list_for_each_entry_rev', 213 'list_for_each_entry_safe', 214 'list_for_each_entry_safe_rev', 215 'list_pair_for_each_entry', 216 'pvr_csb_emit', 217 'pvr_csb_emit_merge', 218 'pvr_csb_pack', 219 'nir_foreach_block', 220 'nir_foreach_block_safe', 221 'nir_foreach_function', 222 'nir_foreach_instr', 223 'nir_foreach_instr_safe', 224 'nir_foreach_shader_in_variable', 225 'nir_foreach_shader_out_variable', 226 'nir_foreach_use', 227 'nir_foreach_use_safe', 228 'nir_foreach_variable_with_modes', 229 'u_vector_foreach', 230 'util_dynarray_foreach', 231 'vk_foreach_struct', 232 'vk_foreach_struct_const', 233# FIXME: vk_outarray_append doesn't fit here, remove 234# it when a better solution exists for it. 235 'vk_outarray_append', 236 'vk_outarray_append_typed' 237] 238 239NamespaceMacros: [ 240] 241 242StatementMacros: [ 243] 244 245TypenameMacros: [ 246] 247 248#WhitespaceSensitiveMacros: [] # Requires clang-11 249