Skip to content

Commit 13ad46f

Browse files
SebastianBoecarlescufi
authored andcommitted
clang-format: Sync clang-format file with Zephyr
cp ~/ncs/zephyr/.clang-format ~/ncs/nrf/.clang-format. AFAIK we copied Zephyr's .clang-format file a long time ago and have since been maintaining a copy of it. It's not clear to me why we are maintaining a copy instead of syncing with Zephyr. I'm assuming this is a mistake. In this commit we sync with Zephyr. AFAIK we do not intentionally maintain different formatting from Zephyr. Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
1 parent 789f356 commit 13ad46f

File tree

1 file changed

+51
-114
lines changed

1 file changed

+51
-114
lines changed

.clang-format

+51-114
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,41 @@
1-
# SPDX-License-Identifier: GPL-2.0
1+
# SPDX-License-Identifier: Apache-2.0
22
#
3-
# clang-format configuration file. Intended for clang-format >= 4.
3+
# Note: The list of ForEachMacros can be obtained using:
44
#
5-
# For more information, see:
6-
#
7-
# Documentation/process/clang-format.rst
8-
# https://clang.llvm.org/docs/ClangFormat.html
9-
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
5+
# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
6+
# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
7+
# | sort | uniq
108
#
9+
# References:
10+
# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html
11+
1112
---
12-
AccessModifierOffset: -4
13-
AlignAfterOpenBracket: Align
14-
AlignConsecutiveAssignments: false
15-
AlignConsecutiveDeclarations: false
16-
#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
17-
AlignOperands: true
18-
AlignTrailingComments: false
19-
AllowAllParametersOfDeclarationOnNextLine: false
20-
AllowShortBlocksOnASingleLine: false
13+
BasedOnStyle: LLVM
14+
AlignConsecutiveMacros: AcrossComments
15+
AllowShortBlocksOnASingleLine: Never
2116
AllowShortCaseLabelsOnASingleLine: false
17+
AllowShortEnumsOnASingleLine: false
2218
AllowShortFunctionsOnASingleLine: None
2319
AllowShortIfStatementsOnASingleLine: false
2420
AllowShortLoopsOnASingleLine: false
25-
AlwaysBreakAfterDefinitionReturnType: None
26-
AlwaysBreakAfterReturnType: None
27-
AlwaysBreakBeforeMultilineStrings: false
28-
AlwaysBreakTemplateDeclarations: false
29-
BinPackArguments: true
30-
BinPackParameters: true
31-
BraceWrapping:
32-
AfterClass: false
33-
AfterControlStatement: false
34-
AfterEnum: false
35-
AfterFunction: true
36-
AfterNamespace: true
37-
AfterObjCDeclaration: false
38-
AfterStruct: false
39-
AfterUnion: false
40-
#AfterExternBlock: false # Unknown to clang-format-5.0
41-
BeforeCatch: false
42-
BeforeElse: false
43-
IndentBraces: false
44-
#SplitEmptyFunction: true # Unknown to clang-format-4.0
45-
#SplitEmptyRecord: true # Unknown to clang-format-4.0
46-
#SplitEmptyNamespace: true # Unknown to clang-format-4.0
47-
BreakBeforeBinaryOperators: None
48-
BreakBeforeBraces: Custom
49-
#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
50-
BreakBeforeTernaryOperators: false
51-
BreakConstructorInitializersBeforeComma: false
52-
#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
53-
BreakAfterJavaFieldAnnotations: false
54-
BreakStringLiterals: false
21+
AttributeMacros:
22+
- __aligned
23+
- __deprecated
24+
- __packed
25+
- __printf_like
26+
- __syscall
27+
- __subsystem
28+
BitFieldColonSpacing: After
29+
BreakBeforeBraces: Linux
5530
ColumnLimit: 100
56-
CommentPragmas: '^ IWYU pragma:'
57-
#CompactNamespaces: false # Unknown to clang-format-4.0
58-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
5931
ConstructorInitializerIndentWidth: 8
6032
ContinuationIndentWidth: 8
61-
Cpp11BracedListStyle: false
62-
DerivePointerAlignment: false
63-
DisableFormat: false
64-
ExperimentalAutoDetectBinPacking: false
65-
#FixNamespaceComments: false # Unknown to clang-format-4.0
66-
67-
# Taken from:
68-
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
69-
# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
70-
# | sort | uniq
7133
ForEachMacros:
7234
- 'FOR_EACH'
73-
- 'metal_bitmap_for_each_clear_bit'
74-
- 'metal_bitmap_for_each_set_bit'
75-
- 'metal_for_each_page_size_down'
76-
- 'metal_for_each_page_size_up'
77-
- 'metal_list_for_each'
35+
- 'FOR_EACH_FIXED_ARG'
36+
- 'FOR_EACH_IDX'
37+
- 'FOR_EACH_IDX_FIXED_ARG'
38+
- 'FOR_EACH_NONEMPTY_TERM'
7839
- 'RB_FOR_EACH'
7940
- 'RB_FOR_EACH_CONTAINER'
8041
- 'SYS_DLIST_FOR_EACH_CONTAINER'
@@ -90,62 +51,38 @@ ForEachMacros:
9051
- 'SYS_SLIST_FOR_EACH_NODE'
9152
- 'SYS_SLIST_FOR_EACH_NODE_SAFE'
9253
- '_WAIT_Q_FOR_EACH'
54+
- 'Z_FOR_EACH'
55+
- 'Z_FOR_EACH_ENGINE'
56+
- 'Z_FOR_EACH_EXEC'
57+
- 'Z_FOR_EACH_FIXED_ARG'
58+
- 'Z_FOR_EACH_FIXED_ARG_EXEC'
59+
- 'Z_FOR_EACH_IDX'
60+
- 'Z_FOR_EACH_IDX_EXEC'
61+
- 'Z_FOR_EACH_IDX_FIXED_ARG'
62+
- 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC'
9363
- 'Z_GENLIST_FOR_EACH_CONTAINER'
9464
- 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE'
9565
- 'Z_GENLIST_FOR_EACH_NODE'
9666
- 'Z_GENLIST_FOR_EACH_NODE_SAFE'
97-
98-
#IncludeBlocks: Preserve # Unknown to clang-format-5.0
67+
IfMacros:
68+
- 'CHECKIF'
69+
# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520
70+
#IncludeBlocks: Regroup
9971
IncludeCategories:
100-
- Regex: '.*'
72+
- Regex: '^".*\.h"$'
73+
Priority: 0
74+
- Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$'
10175
Priority: 1
102-
IncludeIsMainRegex: '(Test)?$'
76+
- Regex: '^\<zephyr/.*\.h\>$'
77+
Priority: 2
78+
- Regex: '.*'
79+
Priority: 3
10380
IndentCaseLabels: false
104-
IndentGotoLabels: false
105-
#IndentPPDirectives: None # Unknown to clang-format-5.0
10681
IndentWidth: 8
107-
IndentWrappedFunctionNames: false
108-
JavaScriptQuotes: Leave
109-
JavaScriptWrapImports: true
110-
KeepEmptyLinesAtTheStartOfBlocks: false
111-
MacroBlockBegin: ''
112-
MacroBlockEnd: ''
113-
MaxEmptyLinesToKeep: 1
114-
NamespaceIndentation: Inner
115-
#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
116-
ObjCBlockIndentWidth: 8
117-
ObjCSpaceAfterProperty: true
118-
ObjCSpaceBeforeProtocolList: true
119-
120-
# Taken from git's rules
121-
#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
122-
PenaltyBreakBeforeFirstCallParameter: 30
123-
PenaltyBreakComment: 10
124-
PenaltyBreakFirstLessLess: 0
125-
PenaltyBreakString: 10
126-
PenaltyExcessCharacter: 100
127-
PenaltyReturnTypeOnItsOwnLine: 60
128-
129-
PointerAlignment: Right
130-
ReflowComments: false
131-
SortIncludes: false
132-
#SortUsingDeclarations: false # Unknown to clang-format-4.0
133-
SpaceAfterCStyleCast: false
134-
SpaceAfterTemplateKeyword: true
135-
SpaceBeforeAssignmentOperators: true
136-
#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
137-
#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
138-
SpaceBeforeParens: ControlStatements
139-
#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
140-
#BitFieldColonSpacing: BFCS_None # Supported from clang-format-12.0
141-
SpaceInEmptyParentheses: false
142-
SpacesBeforeTrailingComments: 1
143-
SpacesInAngles: false
144-
SpacesInContainerLiterals: false
145-
SpacesInCStyleCastParentheses: false
146-
SpacesInParentheses: false
147-
SpacesInSquareBrackets: false
148-
Standard: Cpp03
149-
TabWidth: 8
82+
InsertBraces: true
83+
SpaceBeforeParens: ControlStatementsExceptControlMacros
84+
SortIncludes: Never
15085
UseTab: Always
151-
...
86+
WhitespaceSensitiveMacros:
87+
- STRINGIFY
88+
- Z_STRINGIFY

0 commit comments

Comments
 (0)