Re: [PATCH v2] Add clang-format config

David Gibson <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler
Message-ID <Z1KGnQt5W9XK1Xv2@zatzit>
On Thu, Dec 05, 2024 at 07:50:02PM +0530, Ayush Singh wrote:
> Add clang-format config based on Linux kernel clang-format config.
> Allows for consistent formatting rules for all future contributions.
> 
> Signed-off-by: Ayush Singh <[email protected]>

Merged, thanks.

> ---
> Derived from the discussion in the following patch [0].
> 
> [0]: https://lore.kernel.org/devicetree-compiler/[email protected]/T/#m1f35fa93f8fa2d38d9c6c0e6eaf7718d69b4a7a0
> ---
> Changes in v2:
> - Update ForEachMacros list for dtc.
> - Also update the command to generate the ForEachMacros list. Not
>   specifying any particular folder since the dtc source is pretty small
>   and header files are spread out.
> - Link to v1: https://lore.kernel.org/r/[email protected]
> ---
>  .clang-format | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 135 insertions(+)
> 
> diff --git a/.clang-format b/.clang-format
> new file mode 100644
> index 0000000000000000000000000000000000000000..e5d1518bd42c9ff296731c1593d94511a7d82044
> --- /dev/null
> +++ b/.clang-format
> @@ -0,0 +1,135 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# clang-format configuration file. Intended for clang-format >= 11.
> +#
> +# For more information, see:
> +#
> +#   Documentation/dev-tools/clang-format.rst
> +#   https://clang.llvm.org/docs/ClangFormat.html
> +#   https://clang.llvm.org/docs/ClangFormatStyleOptions.html
> +#
> +---
> +AccessModifierOffset: -4
> +AlignAfterOpenBracket: Align
> +AlignConsecutiveAssignments: false
> +AlignConsecutiveDeclarations: false
> +AlignEscapedNewlines: Left
> +AlignOperands: true
> +AlignTrailingComments: false
> +AllowAllParametersOfDeclarationOnNextLine: false
> +AllowShortBlocksOnASingleLine: false
> +AllowShortCaseLabelsOnASingleLine: false
> +AllowShortFunctionsOnASingleLine: None
> +AllowShortIfStatementsOnASingleLine: false
> +AllowShortLoopsOnASingleLine: false
> +AlwaysBreakAfterDefinitionReturnType: None
> +AlwaysBreakAfterReturnType: None
> +AlwaysBreakBeforeMultilineStrings: false
> +AlwaysBreakTemplateDeclarations: false
> +BinPackArguments: true
> +BinPackParameters: true
> +BraceWrapping:
> +  AfterClass: false
> +  AfterControlStatement: false
> +  AfterEnum: false
> +  AfterFunction: true
> +  AfterNamespace: true
> +  AfterObjCDeclaration: false
> +  AfterStruct: false
> +  AfterUnion: false
> +  AfterExternBlock: false
> +  BeforeCatch: false
> +  BeforeElse: false
> +  IndentBraces: false
> +  SplitEmptyFunction: true
> +  SplitEmptyRecord: true
> +  SplitEmptyNamespace: true
> +BreakBeforeBinaryOperators: None
> +BreakBeforeBraces: Custom
> +BreakBeforeInheritanceComma: false
> +BreakBeforeTernaryOperators: false
> +BreakConstructorInitializersBeforeComma: false
> +BreakConstructorInitializers: BeforeComma
> +BreakAfterJavaFieldAnnotations: false
> +BreakStringLiterals: false
> +ColumnLimit: 80
> +CommentPragmas: '^ IWYU pragma:'
> +CompactNamespaces: false
> +ConstructorInitializerAllOnOneLineOrOnePerLine: false
> +ConstructorInitializerIndentWidth: 8
> +ContinuationIndentWidth: 8
> +Cpp11BracedListStyle: false
> +DerivePointerAlignment: false
> +DisableFormat: false
> +ExperimentalAutoDetectBinPacking: false
> +FixNamespaceComments: false
> +
> +# Taken from:
> +#   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \
> +#   | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$,  - '\1'," \
> +#   | LC_ALL=C sort -u
> +ForEachMacros:
> +  - 'fdt_for_each_property_offset'
> +  - 'fdt_for_each_subnode'
> +  - 'for_each_child'
> +  - 'for_each_child_withdel'
> +  - 'for_each_label'
> +  - 'for_each_label_withdel'
> +  - 'for_each_marker'
> +  - 'for_each_marker_of_type'
> +  - 'for_each_property'
> +  - 'for_each_property_withdel'
> +
> +IncludeBlocks: Preserve
> +IncludeCategories:
> +  - Regex: '.*'
> +    Priority: 1
> +IncludeIsMainRegex: '(Test)?$'
> +IndentCaseLabels: false
> +IndentGotoLabels: false
> +IndentPPDirectives: None
> +IndentWidth: 8
> +IndentWrappedFunctionNames: false
> +JavaScriptQuotes: Leave
> +JavaScriptWrapImports: true
> +KeepEmptyLinesAtTheStartOfBlocks: false
> +MacroBlockBegin: ''
> +MacroBlockEnd: ''
> +MaxEmptyLinesToKeep: 1
> +NamespaceIndentation: None
> +ObjCBinPackProtocolList: Auto
> +ObjCBlockIndentWidth: 8
> +ObjCSpaceAfterProperty: true
> +ObjCSpaceBeforeProtocolList: true
> +
> +# Taken from git's rules
> +PenaltyBreakAssignment: 10
> +PenaltyBreakBeforeFirstCallParameter: 30
> +PenaltyBreakComment: 10
> +PenaltyBreakFirstLessLess: 0
> +PenaltyBreakString: 10
> +PenaltyExcessCharacter: 100
> +PenaltyReturnTypeOnItsOwnLine: 60
> +
> +PointerAlignment: Right
> +ReflowComments: false
> +SortIncludes: false
> +SortUsingDeclarations: false
> +SpaceAfterCStyleCast: false
> +SpaceAfterTemplateKeyword: true
> +SpaceBeforeAssignmentOperators: true
> +SpaceBeforeCtorInitializerColon: true
> +SpaceBeforeInheritanceColon: true
> +SpaceBeforeParens: ControlStatementsExceptForEachMacros
> +SpaceBeforeRangeBasedForLoopColon: true
> +SpaceInEmptyParentheses: false
> +SpacesBeforeTrailingComments: 1
> +SpacesInAngles: false
> +SpacesInContainerLiterals: false
> +SpacesInCStyleCastParentheses: false
> +SpacesInParentheses: false
> +SpacesInSquareBrackets: false
> +Standard: Cpp03
> +TabWidth: 8
> +UseTab: Always
> +...
> 
> ---
> base-commit: 6f183c7d9246bde8f05d2edbc31fdd497c4a8702
> change-id: 20241204-clang-format-2536dd18a7c5
> 
> Best regards,

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmdShp0ACgkQzQJF27ox
2GeWJg/9GPs3hZKVJBjJHB7tyiFKbdaYtTHZg5KkqQiX+l1ONIF7GnWoum7OgsJG
wgGJlgzNpEmyANW/ZJpYOUHyOnSTCWc0YCnCd3eshmJ/p8Fa4sZHsy6oXJmkPiQi
cNLnIKjo3inhSKg4GMeOTmgT+wxM5gyelXtqO2ZpP1IGmyufB/XuXhw4kqIyiWBs
Ls6pQjKd6r/aFMEg26ov+uBDXz+VIEAJ4aMmspTNTAmqpnStE4moMGO2Ux9cu3uU
uLCgeHLG+hxFFWxbfveeJNdAbw7mJDPSqr2JWS52772B1hGeJPVweynDjXcYErfw
BS/Xzyuaz6KNoGgzzBMNbVIa3C8kuITFA5YjAr4W5vc6vD+Z2ql/ErYy4Xv/wj0K
Wx4M7mbbYxzGbKeoaP9NDlEzPZaSj1g5IhJBbaNLDxgEk8OmoU8R5FhIodAvDGQy
+x3die9+9tveu/kCvWLWUQ3X8CjivCXfizVTFHx3B/BIqQrYVb4PC2MCwKeveMu3
9OJNBESGPn32hrhioSzqFGut/kQs3oekfOjsSEhr2YAmXALGfG79RfI0WsC9EA/a
LmmREKva0TA7wjpa/L7+dLDbiwAtX9uxbo8m4UEvj/3L7jrX4/f7O6x6D/F6Kw0k
2JPbFtSYBFLIuPTycoNlJx0dqVqF8BcytaWgPHvq/YxyqhwsySk=
=G3m7
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.