xref: /freebsd/.clang-format (revision 02e9120893770924227138ba49df1edb3896112a)
1# Basic .clang-format
2---
3BasedOnStyle: WebKit
4AlignAfterOpenBracket: DontAlign
5AlignConsecutiveAssignments: false
6AlignConsecutiveDeclarations: false
7AlignEscapedNewlines: Left
8AlignOperands: false
9AlignTrailingComments: true
10AllowAllArgumentsOnNextLine: false
11AllowAllParametersOfDeclarationOnNextLine: false
12AllowShortBlocksOnASingleLine: Never
13AllowShortCaseLabelsOnASingleLine: false
14AllowShortFunctionsOnASingleLine: InlineOnly
15AllowShortIfStatementsOnASingleLine: Never
16AllowShortLoopsOnASingleLine: false
17AlwaysBreakAfterReturnType: TopLevelDefinitions
18AlwaysBreakBeforeMultilineStrings: false
19AlwaysBreakTemplateDeclarations: MultiLine
20BinPackArguments: true
21BinPackParameters: true
22BreakBeforeBinaryOperators: None
23BreakBeforeBraces: WebKit
24BreakBeforeTernaryOperators: false
25# TODO: BreakStringLiterals can cause very strange formatting so turn it off?
26BreakStringLiterals: false
27# Prefer:
28# some_var = function(arg1,
29#    arg2)
30# over:
31# some_var =
32#     function(arg1, arg2)
33PenaltyBreakAssignment: 100
34# Prefer:
35# some_long_function(arg1, arg2
36#     arg3)
37# over:
38# some_long_function(
39#     arg1, arg2, arg3)
40PenaltyBreakBeforeFirstCallParameter: 100
41CompactNamespaces: true
42DerivePointerAlignment: false
43DisableFormat: false
44ForEachMacros:
45  - ARB_ARRFOREACH
46  - ARB_ARRFOREACH_REVWCOND
47  - ARB_ARRFOREACH_REVERSE
48  - ARB_FOREACH
49  - ARB_FOREACH_FROM
50  - ARB_FOREACH_SAFE
51  - ARB_FOREACH_REVERSE
52  - ARB_FOREACH_REVERSE_FROM
53  - ARB_FOREACH_REVERSE_SAFE
54  - BIT_FOREACH_ISCLR
55  - BIT_FOREACH_ISSET
56  - CPU_FOREACH
57  - CPU_FOREACH_ISCLR
58  - CPU_FOREACH_ISSET
59  - FOREACH_THREAD_IN_PROC
60  - FOREACH_PROC_IN_SYSTEM
61  - FOREACH_PRISON_CHILD
62  - FOREACH_PRISON_DESCENDANT
63  - FOREACH_PRISON_DESCENDANT_LOCKED
64  - FOREACH_PRISON_DESCENDANT_LOCKED_LEVEL
65  - MNT_VNODE_FOREACH_ALL
66  - MNT_VNODE_FOREACH_ACTIVE
67  - RB_FOREACH
68  - RB_FOREACH_FROM
69  - RB_FOREACH_SAFE
70  - RB_FOREACH_REVERSE
71  - RB_FOREACH_REVERSE_FROM
72  - RB_FOREACH_REVERSE_SAFE
73  - SLIST_FOREACH
74  - SLIST_FOREACH_FROM
75  - SLIST_FOREACH_FROM_SAFE
76  - SLIST_FOREACH_SAFE
77  - SLIST_FOREACH_PREVPTR
78  - SPLAY_FOREACH
79  - LIST_FOREACH
80  - LIST_FOREACH_FROM
81  - LIST_FOREACH_FROM_SAFE
82  - LIST_FOREACH_SAFE
83  - STAILQ_FOREACH
84  - STAILQ_FOREACH_FROM
85  - STAILQ_FOREACH_FROM_SAFE
86  - STAILQ_FOREACH_SAFE
87  - TAILQ_FOREACH
88  - TAILQ_FOREACH_FROM
89  - TAILQ_FOREACH_FROM_SAFE
90  - TAILQ_FOREACH_REVERSE
91  - TAILQ_FOREACH_REVERSE_FROM
92  - TAILQ_FOREACH_REVERSE_FROM_SAFE
93  - TAILQ_FOREACH_REVERSE_SAFE
94  - TAILQ_FOREACH_SAFE
95  - VM_MAP_ENTRY_FOREACH
96  - VM_PAGE_DUMP_FOREACH
97IndentCaseLabels: false
98IndentPPDirectives: None
99Language: Cpp
100NamespaceIndentation: None
101PointerAlignment: Right
102ContinuationIndentWidth: 4
103IndentWidth: 8
104TabWidth: 8
105ColumnLimit: 80
106UseTab: Always
107SpaceAfterCStyleCast: false
108IncludeBlocks: Regroup
109IncludeCategories:
110  - Regex: '^\"opt_.*\.h\"'
111    Priority: 1
112    SortPriority: 10
113  - Regex: '^<sys/cdefs\.h>'
114    Priority: 2
115    SortPriority: 20
116  - Regex: '^<sys/types\.h>'
117    Priority: 2
118    SortPriority: 21
119  - Regex: '^<sys/param\.h>'
120    Priority: 2
121    SortPriority: 22
122  - Regex: '^<sys/systm\.h>'
123    Priority: 2
124    SortPriority: 23
125  - Regex: '^<sys.*/'
126    Priority: 2
127    SortPriority: 24
128  - Regex: '^<vm/vm\.h>'
129    Priority: 3
130    SortPriority: 30
131  - Regex: '^<vm/'
132    Priority: 3
133    SortPriority: 31
134  - Regex: '^<machine/'
135    Priority: 4
136    SortPriority: 40
137  - Regex: '^<(x86|amd64|i386|xen)/'
138    Priority: 5
139    SortPriority: 50
140  - Regex: '^<dev/'
141    Priority: 6
142    SortPriority: 60
143  - Regex: '^<net.*/'
144    Priority: 7
145    SortPriority: 70
146  - Regex: '^<protocols/'
147    Priority: 7
148    SortPriority: 71
149  - Regex: '^<(fs|nfs(|client|server)|ufs)/'
150    Priority: 8
151    SortPriority: 80
152  - Regex: '^<[^/].*\.h'
153    Priority: 9
154    SortPriority: 90
155  - Regex: '^\".*\.h\"'
156    Priority: 10
157    SortPriority: 100
158# LLVM's header include ordering style is almost the exact opposite of ours.
159# Unfortunately, they have hard-coded their preferences into clang-format.
160# Clobbering this regular expression to avoid matching prevents non-system
161# headers from being forcibly moved to the top of the include list.
162# http://llvm.org/docs/CodingStandards.html#include-style
163IncludeIsMainRegex: 'BLAH_DONT_MATCH_ANYTHING'
164SortIncludes: true
165KeepEmptyLinesAtTheStartOfBlocks: true
166TypenameMacros:
167  - ARB_ELMTYPE
168  - ARB_HEAD
169  - ARB8_HEAD
170  - ARB16_HEAD
171  - ARB32_HEAD
172  - ARB_ENTRY
173  - ARB8_ENTRY
174  - ARB16_ENTRY
175  - ARB32_ENTRY
176  - LIST_CLASS_ENTRY
177  - LIST_CLASS_HEAD
178  - LIST_ENTRY
179  - LIST_HEAD
180  - QUEUE_TYPEOF
181  - RB_ENTRY
182  - RB_HEAD
183  - SLIST_CLASS_HEAD
184  - SLIST_CLASS_ENTRY
185  - SLIST_HEAD
186  - SLIST_ENTRY
187  - SMR_POINTER
188  - SPLAY_ENTRY
189  - SPLAY_HEAD
190  - STAILQ_CLASS_ENTRY
191  - STAILQ_CLASS_HEAD
192  - STAILQ_ENTRY
193  - STAILQ_HEAD
194  - TAILQ_CLASS_ENTRY
195  - TAILQ_CLASS_HEAD
196  - TAILQ_ENTRY
197  - TAILQ_HEAD
198