Skip to content

Commit 28cb859

Browse files
committed
Add a basic clang-format configuration file
This gets reasonably close to the existing format in sys/kern but will probably require some changes to upstream clang-format before it can be used as the default formatting tool. I tried formatting a few files in sys/kern and the result is pretty close to the existing code. However, this configuration file is not ready to be used without manually checking the output. Reviewed By: emaste Differential Revision: https://reviews.freebsd.org/D20533
1 parent 1cb7944 commit 28cb859

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

.clang-format

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# $FreeBSD$
2+
# Basic .clang-format
3+
---
4+
BasedOnStyle: WebKit
5+
AlignAfterOpenBracket: DontAlign
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Left
9+
AlignOperands: false
10+
AlignTrailingComments: false
11+
AllowAllParametersOfDeclarationOnNextLine: false
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: InlineOnly
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterReturnType: TopLevelDefinitions
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: MultiLine
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BreakBeforeBinaryOperators: None
23+
BreakBeforeBraces: WebKit
24+
BreakBeforeTernaryOperators: false
25+
# TODO: BreakStringLiterals can cause very strange formatting so turn it off?
26+
BreakStringLiterals: false
27+
PenaltyBreakBeforeFirstCallParameter: 1000
28+
CompactNamespaces: true
29+
DerivePointerAlignment: false
30+
DisableFormat: false
31+
ForEachMacros:
32+
- SLIST_FOREACH
33+
- SLIST_FOREACH_SAFE
34+
- LIST_FOREACH
35+
- LIST_FOREACH_SAFE
36+
- STAILQ_FOREACH
37+
- STAILQ_FOREACH_SAFE
38+
- TAILQ_FOREACH
39+
- TAILQ_FOREACH_SAFE
40+
- TAILQ_FOREACH_REVERSE
41+
- TAILQ_FOREACH_REVERSE_SAFE
42+
- RB_FOREACH
43+
- RB_FOREACH_SAFE
44+
- RB_FOREACH_FROM
45+
- RB_FOREACH_REVERSE
46+
- RB_FOREACH_REVERSE_FROM
47+
- RB_FOREACH_REVERSE_SAFE
48+
- FOREACH_THREAD_IN_PROC
49+
- FOREACH_PROC_IN_SYSTEM
50+
- FOREACH_PRISON_CHILD
51+
- FOREACH_PRISON_DESCENDANT
52+
- FOREACH_PRISON_DESCENDANT_LOCKED
53+
- FOREACH_PRISON_DESCENDANT_LOCKED_LEVEL
54+
- MNT_VNODE_FOREACH_ALL
55+
- MNT_VNODE_FOREACH_ACTIVE
56+
IndentCaseLabels: false
57+
IndentPPDirectives: None
58+
Language: Cpp
59+
NamespaceIndentation: None
60+
PointerAlignment: Right
61+
ContinuationIndentWidth: 4
62+
IndentWidth: 8
63+
TabWidth: 8
64+
ColumnLimit: 80
65+
UseTab: Always
66+
SpaceAfterCStyleCast: false
67+
SortIncludes: false
68+
KeepEmptyLinesAtTheStartOfBlocks: true
69+
# The options below will only be supported starting with clang 9.0:
70+
# TODO-CLANG-9: TypenameMacros:
71+
# TODO-CLANG-9: - SLIST_HEAD
72+
# TODO-CLANG-9: - SLIST_ENTRY
73+
# TODO-CLANG-9: - TAILQ_ENTRY
74+
# TODO-CLANG-9: - TAILQ_HEAD
75+
# TODO-CLANG-9: - STAILQ_ENTRY
76+
# TODO-CLANG-9: - STAILQ_HEAD
77+
...

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*.hpp diff=cpp
55
*.py diff=python
66
. svn-properties=svn:keywords=tools/build/options/WITHOUT_LOADER_ZFS
7+
.clang-format svn-properties=svn:keywords=FreeBSD=%H

0 commit comments

Comments
 (0)