-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang-format #91
Closed
Closed
clang-format #91
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# | ||
# clang-format configuration file. Intended for clang-format >= 12. | ||
# | ||
# 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: 90 | ||
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:]]*foreach[^[:space:]]*(' \ | ||
# | sed "s,^#define \([^[:space:]]*foreach[^[:space:]]*\)(.*$, - '\1'," \ | ||
# | LC_ALL=C sort -u | ||
ForEachMacros: | ||
- 'kmod_list_foreach' | ||
- 'kmod_list_foreach_reverse' | ||
|
||
# Taken from: | ||
# git grep -h '^#define .*__attribute__' \ | ||
# | cut -d' ' -f2 \ | ||
# | sed -e 's/(.*//' -e 's/^/ - /' \ | ||
# | LC_ALL=C sort -u | ||
AttributeMacros: | ||
- KMOD_EXPORT | ||
- TS_EXPORT | ||
- __noreturn | ||
- _always_inline_ | ||
- _cleanup_ | ||
- _must_check_ | ||
- _printf_format_ | ||
- _unused_ | ||
- noreturn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for another day: the above could use some cleanup. Huge thanks for finding this trick o/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cleanup was incorporated in #114 |
||
|
||
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: 100 | ||
PenaltyBreakComment: 10 | ||
PenaltyBreakFirstLessLess: 0 | ||
PenaltyBreakString: 10 | ||
PenaltyExcessCharacter: 50 | ||
PenaltyReturnTypeOnItsOwnLine: 110 | ||
|
||
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 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh noooo, I can no longer have two panes side-by-side :-P
Semi-joking aside (I do use ^^) - if we do this, the
.editorconfig
also needs an update.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope your pane is modern enough in 2024 to have horizontal scroll for the eventual lines going over 80 :). What I find annoying with auto format is that we don't have a good option for "prefer 80, but don't bother breaking it up if it's slightly over" - IMO we should be able to define soft and hard limits for autoformat tools. I think the Penalty* settings in clang get close, but I still see it doing some horrible changes because of column limit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2x 80 (with a few extra symbols) just happens to be comfortably sized on my 13inch laptop. Any other device or single (tmux) pane is fine. Hope it was clear I was joking
Cannot agree more on the hard vs soft limits. If we keep different values in .clang-format vs .editorconfig, clang-format is likely to repeatedly re-format my patches ;-)