Skip to content

Commit 54a0ade

Browse files
Leon Romanovskydsahern
Leon Romanovsky
authored andcommitted
clang-format: add configuration file
The codebase of iproute2 follows Linux kernel coding style, so it will be very helpful to reuse existing clang configuration file to reliably format code. For more information see kernel commit d4ef8d3ff005 ("clang-format: add configuration file"). Updated upto commit v5.0-rc1 with small number of ForEachMacros. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: David Ahern <dsahern@gmail.com>
1 parent 3d14706 commit 54a0ade

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed

.clang-format

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# clang-format configuration file. Intended for clang-format >= 4.
4+
#
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
10+
#
11+
---
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
21+
AllowShortCaseLabelsOnASingleLine: false
22+
AllowShortFunctionsOnASingleLine: None
23+
AllowShortIfStatementsOnASingleLine: false
24+
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
55+
ColumnLimit: 80
56+
CommentPragmas: '^ IWYU pragma:'
57+
#CompactNamespaces: false # Unknown to clang-format-4.0
58+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
59+
ConstructorInitializerIndentWidth: 8
60+
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
71+
ForEachMacros:
72+
- 'list_for_each_entry'
73+
- 'list_for_each_entry_safe'
74+
- 'mnl_attr_for_each_nested'
75+
- 'hlist_for_each'
76+
- 'hlist_for_each_safe'
77+
- 'hlist_for_each_entry'
78+
79+
#IncludeBlocks: Preserve # Unknown to clang-format-5.0
80+
IncludeCategories:
81+
- Regex: '.*'
82+
Priority: 1
83+
IncludeIsMainRegex: '(Test)?$'
84+
IndentCaseLabels: false
85+
#IndentPPDirectives: None # Unknown to clang-format-5.0
86+
IndentWidth: 8
87+
IndentWrappedFunctionNames: false
88+
JavaScriptQuotes: Leave
89+
JavaScriptWrapImports: true
90+
KeepEmptyLinesAtTheStartOfBlocks: false
91+
MacroBlockBegin: ''
92+
MacroBlockEnd: ''
93+
MaxEmptyLinesToKeep: 1
94+
NamespaceIndentation: Inner
95+
#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
96+
ObjCBlockIndentWidth: 8
97+
ObjCSpaceAfterProperty: true
98+
ObjCSpaceBeforeProtocolList: true
99+
100+
# Taken from git's rules
101+
#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
102+
PenaltyBreakBeforeFirstCallParameter: 30
103+
PenaltyBreakComment: 10
104+
PenaltyBreakFirstLessLess: 0
105+
PenaltyBreakString: 10
106+
PenaltyExcessCharacter: 100
107+
PenaltyReturnTypeOnItsOwnLine: 60
108+
109+
PointerAlignment: Right
110+
ReflowComments: false
111+
SortIncludes: false
112+
#SortUsingDeclarations: false # Unknown to clang-format-4.0
113+
SpaceAfterCStyleCast: false
114+
SpaceAfterTemplateKeyword: true
115+
SpaceBeforeAssignmentOperators: true
116+
#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
117+
#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
118+
SpaceBeforeParens: ControlStatements
119+
#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
120+
SpaceInEmptyParentheses: false
121+
SpacesBeforeTrailingComments: 1
122+
SpacesInAngles: false
123+
SpacesInContainerLiterals: false
124+
SpacesInCStyleCastParentheses: false
125+
SpacesInParentheses: false
126+
SpacesInSquareBrackets: false
127+
Standard: Cpp03
128+
TabWidth: 8
129+
UseTab: Always
130+
...

0 commit comments

Comments
 (0)