Skip to content

Commit 3021ce2

Browse files
committed
clang-format: Add include sorting directives
Let's make sure clang-format sorts includes according to our style guide.
1 parent 7e5ef4e commit 3021ce2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.clang-format

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,29 @@ ForEachMacros:
107107
- STRV_FOREACH
108108
- STRV_FOREACH_BACKWARDS
109109
- STRV_FOREACH_PAIR
110+
IncludeBlocks: Regroup
111+
IncludeCategories:
112+
# "vmlinux.h" must always be included first in BPF programs before anything else.
113+
- Regex: '^"vmlinux.h"$'
114+
Priority: 1
115+
# <bpf/*.h> headers must be included after <linux/types.h> by design.
116+
- Regex: '^<bpf/.*\.h>$'
117+
Priority: 2
118+
SortPriority: 3
119+
# <linux/vm_sockets.h> must be included after <sys/socket.h>.
120+
- Regex: '^<linux/vm_sockets\.h>$'
121+
Priority: 2
122+
SortPriority: 3
123+
- Regex: '^<.*\.h>$'
124+
Priority: 2
125+
- Regex: '^"sd-.*\.h"$'
126+
Priority: 4
127+
- Regex: '^"audit_type-to-name.h"$'
128+
Priority: 6
129+
- Regex: '.*'
130+
Priority: 5
131+
# Make sure the "main header" is not treated any differently than other headers.
132+
IncludeIsMainRegex: '^$'
110133
IndentPPDirectives: AfterHash
111134
IndentWidth: 8
112135
IndentWrappedFunctionNames: true

0 commit comments

Comments
 (0)