Add clang-format. Update Contribution guidelines. (#6677)
* Add clang-format. Update Contribution guidelines. * Remove kernel foreach macros section. * Fix UseTab. * Update clang-format with agreed style
cosmix committed
Sep 20, 2019 at 07:44 UTC
d4213ef59fd08e0f92edffa11137e3ae5579cced
2 files changed
+119
.clang-format
new
+118
@@ -0,0 +1,118 @@
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: AlwaysBreak
14
+AlignConsecutiveAssignments: false
15
+AlignConsecutiveDeclarations: false
16
+#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
17
+AlignOperands: true
18
+AlignTrailingComments: true
19
+AllowAllParametersOfDeclarationOnNextLine: true
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: 120
56
+CommentPragmas: '^ IWYU pragma:'
57
+#CompactNamespaces: false # Unknown to clang-format-4.0
58
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
59
+ConstructorInitializerIndentWidth: 4
60
+ContinuationIndentWidth: 4
61
+Cpp11BracedListStyle: false
62
+DerivePointerAlignment: false
63
+DisableFormat: false
64
+ExperimentalAutoDetectBinPacking: false
65
+#FixNamespaceComments: false # Unknown to clang-format-4.0
66
+
67
+#IncludeBlocks: Preserve # Unknown to clang-format-5.0
68
+IncludeCategories:
69
+ - Regex: '.*'
70
+ Priority: 1
71
+IncludeIsMainRegex: '(Test)?$'
72
+IndentCaseLabels: true
73
+#IndentPPDirectives: None # Unknown to clang-format-5.0
74
+IndentWidth: 4
75
+IndentWrappedFunctionNames: false
76
+JavaScriptQuotes: Leave
77
+JavaScriptWrapImports: true
78
+KeepEmptyLinesAtTheStartOfBlocks: false
79
+MacroBlockBegin: ''
80
+MacroBlockEnd: ''
81
+MaxEmptyLinesToKeep: 1
82
+NamespaceIndentation: Inner
83
+#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
84
+ObjCBlockIndentWidth: 4
85
+ObjCSpaceAfterProperty: true
86
+ObjCSpaceBeforeProtocolList: true
87
+
88
+# Taken from git's rules
89
+#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
90
+PenaltyBreakBeforeFirstCallParameter: 30
91
+PenaltyBreakComment: 10
92
+PenaltyBreakFirstLessLess: 0
93
+PenaltyBreakString: 10
94
+PenaltyExcessCharacter: 100
95
+PenaltyReturnTypeOnItsOwnLine: 60
96
+
97
+PointerAlignment: Right
98
+ReflowComments: false
99
+SortIncludes: false
100
+#SortUsingDeclarations: false # Unknown to clang-format-4.0
101
+SpaceAfterCStyleCast: false
102
+SpaceAfterTemplateKeyword: true
103
+SpaceBeforeAssignmentOperators: true
104
+#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
105
+#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
106
+SpaceBeforeParens: ControlStatements
107
+#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
108
+SpaceInEmptyParentheses: false
109
+SpacesBeforeTrailingComments: 1
110
+SpacesInAngles: false
111
+SpacesInContainerLiterals: false
112
+SpacesInCStyleCastParentheses: false
113
+SpacesInParentheses: false
114
+SpacesInSquareBrackets: false
115
+Standard: Cpp03
116
+TabWidth: 4
117
+UseTab: Never
118
+...
CONTRIBUTING.md
+1
@@ -138,6 +138,7 @@ For C contributions in particular, we try to respect the [Linux kernel style](ht
138
- We occassionally have multiple statements on a single line (e.g. `if (a) b;`)
139
- Allow max line length of 120 chars
140
- Allow opening brace at the end of a function declaration: `function() {`.
141
+- Allow trailing comments
142
143
### Your first pull request
144