Skip to content

Commit b67f061

Browse files
committed
clang-format: Add include sorting directives
Let's make sure clang-format sorts includes according to our style guide.
1 parent 6be15dc commit b67f061

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.clang-format

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,27 @@ 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+
- Regex: '^<.*\.h>$'
120+
Priority: 2
121+
- Regex: '^"_?sd-.*\.h"$'
122+
Priority: 4
123+
- Regex: '^"libudev\.h"$'
124+
Priority: 4
125+
- Regex: '^"audit_type-to-name.h"$'
126+
Priority: 6
127+
- Regex: '.*'
128+
Priority: 5
129+
# Make sure the "main header" is not treated any differently than other headers.
130+
IncludeIsMainRegex: '^$'
110131
IndentPPDirectives: AfterHash
111132
IndentWidth: 8
112133
IndentWrappedFunctionNames: true

0 commit comments

Comments
 (0)