aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format89
-rw-r--r--CONTRIBUTING.md17
2 files changed, 70 insertions, 36 deletions
diff --git a/.clang-format b/.clang-format
index 8375204a..f07bad67 100644
--- a/.clang-format
+++ b/.clang-format
@@ -14,23 +14,26 @@
# to borrow from the WebKit style. The values for such settings try to but
# are not guaranteed to coincide with the latest version of the WebKit style.
+# This file assumes ClangFormat 12 or newer
+
---
Language: Cpp
BasedOnStyle: WebKit
#AccessModifierOffset: -4
AlignAfterOpenBracket: Align
-#AlignConsecutiveMacros: false
-#AlignConsecutiveAssignments: false
-#AlignConsecutiveDeclarations: false
+#AlignArrayOfStructures: None # ClangFormat 13
+#AlignConsecutiveMacros: None
+#AlignConsecutiveAssignments: None
+#AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
-AlignOperands: true # 'Align' since ClangFormat 11
+AlignOperands: Align
#AlignTrailingComments: false
#AllowAllArgumentsOnNextLine: true
-#AllowAllConstructorInitializersOnNextLine: true
+AllowAllConstructorInitializersOnNextLine: true
#AllowAllParametersOfDeclarationOnNextLine: true
#AllowShortEnumsOnASingleLine: true
#AllowShortBlocksOnASingleLine: Empty
-#AllowShortCaseLabelsOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: true
#AllowShortFunctionsOnASingleLine: All
#AllowShortLambdasOnASingleLine: All
#AllowShortIfStatementsOnASingleLine: Never
@@ -39,41 +42,49 @@ AlignOperands: true # 'Align' since ClangFormat 11
#AlwaysBreakAfterReturnType: None
#AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
+#AttributeMacros:
+# - __capability
#BinPackArguments: true
#BinPackParameters: true
BraceWrapping:
- AfterCaseLabel: false
- AfterClass: false
- AfterControlStatement: Never # Switch to MultiLine, once https://bugs.llvm.org/show_bug.cgi?id=47936 is fixed
- AfterEnum: false
+# AfterCaseLabel: false
+# AfterClass: false
+ AfterControlStatement: Never # Switch to MultiLine with ClangFormat 14 (https://bugs.llvm.org/show_bug.cgi?id=47936)
+# AfterEnum: false
AfterFunction: true
- AfterNamespace: false
- AfterStruct: false
- AfterUnion: false
- AfterExternBlock: false
- BeforeCatch: false
- BeforeElse: false
- IndentBraces: false
+# AfterNamespace: false
+# AfterStruct: false
+# AfterUnion: false
+# AfterExternBlock: false
+# BeforeCatch: false
+# BeforeElse: false
+ BeforeLambdaBody: true
+# BeforeWhile: false
+# IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: NonAssignment
+#BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Custom
-#BreakBeforeInheritanceComma: false
+#BreakBeforeInheritanceComma: false # deprecated?
#BreakInheritanceList: BeforeColon
#BreakBeforeTernaryOperators: true
#BreakConstructorInitializersBeforeComma: false # deprecated?
#BreakConstructorInitializers: BeforeComma
#BreakStringLiterals: true
ColumnLimit: 80
+#QualifierAlignment: Leave # ClangFormat 14?
#CompactNamespaces: false
-#ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
#ConstructorInitializerIndentWidth: 4
#ContinuationIndentWidth: 4
-Cpp11BracedListStyle: false
+#Cpp11BracedListStyle: true
#DeriveLineEnding: true
#DerivePointerAlignment: false
-FixNamespaceComments: true
+#EmptyLineAfterAccessModifier: Never # ClangFormat 14
+EmptyLineBeforeAccessModifier: Always
+#FixNamespaceComments: false # See ShortNamespaces below
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<Qt.+/'
@@ -88,12 +99,17 @@ IncludeCategories:
Priority: 1
IncludeIsMainRegex: '(_test)?$'
#IncludeIsMainSourceRegex: ''
+#IndentAccessModifiers: false # ClangFormat 13
#IndentCaseLabels: false
+#IndentCaseBlocks: false
IndentGotoLabels: false
IndentPPDirectives: AfterHash
+#IndentExternBlock: AfterExternBlock
+IndentRequires: true
#IndentWidth: 4
#IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
+#LambdaBodyIndentation: Signature # ClangFormat 13
#MacroBlockBegin: ''
#MacroBlockEnd: ''
#MaxEmptyLinesToKeep: 1
@@ -102,34 +118,56 @@ PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 70
PenaltyBreakComment: 45
#PenaltyBreakFirstLessLess: 120
+#PenaltyBreakOpenParenthesis: 0 # ClangFormat 14
PenaltyBreakString: 200
#PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 40
PenaltyReturnTypeOnItsOwnLine: 150
+PenaltyIndentedWhitespace: 40
#PointerAlignment: Left
+#PPIndentWidth: -1
+#ReferenceAlignment: Pointer # ClangFormat 13
#ReflowComments: true
+#ShortNamespaceLines: 1 # ClangFormat 13 - to use with FixNamespaceComments
#SortIncludes: true
#SortUsingDeclarations: true
#SpaceAfterCStyleCast: false
#SpaceAfterLogicalNot: false
#SpaceAfterTemplateKeyword: true
#SpaceBeforeAssignmentOperators: true
-#SpaceBeforeCpp11BracedList: true
+#SpaceBeforeCaseColon: false
+SpaceBeforeCpp11BracedList: false
#SpaceBeforeCtorInitializerColon: true
#SpaceBeforeInheritanceColon: true
#SpaceBeforeParens: ControlStatements
+#SpaceBeforeParensOptions: # ClangFormat 14
+# AfterControlStatements: true
+# AfterForeachMacros: true
+# AfterFunctionDefinitionName: false
+# AfterFunctionDeclarationName: false
+# AfterIfMacros: true
+# AfterOverloadedOperator: false
+# BeforeNonEmptyParentheses: false
+SpaceAroundPointerQualifiers: After
#SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
#SpaceInEmptyParentheses: false
#SpacesBeforeTrailingComments: 1
-#SpacesInAngles: false
+#SpacesInAngles: false # 'Never' since ClangFormat 13
#SpacesInConditionalStatement: false
-#SpacesInContainerLiterals: true
+SpacesInContainerLiterals: false
#SpacesInCStyleCastParentheses: false
+#SpacesInLineCommentPrefix: # ClangFormat 13
+# Minimum: 1
+# Maximum: -1
#SpacesInParentheses: false
#SpacesInSquareBrackets: false
#SpaceBeforeSquareBrackets: false
-Standard: c++17
+#BitFieldColonSpacing: Both
+Standard: c++20
+StatementAttributeLikeMacros:
+ - Q_EMIT
+ - emit
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
@@ -137,5 +175,6 @@ StatementMacros:
TabWidth: 4
#UseCRLF: false
#UseTab: Never
+#WhitespaceSensitiveMacros: [] # Whatever's the default, not using it
...
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7a5ee079..d63864d0 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -436,11 +436,12 @@ your commit into it (with an explanation what it is about and why).
### Standard checks
-The following warnings configuration is applied with GCC and Clang when using CMake:
-`-W -Wall -Wextra -pedantic -Werror=return-type -Wno-unused-parameter -Wno-gnu-zero-variadic-macro-arguments`
-(the last one is to mute a warning triggered by Qt code for debug logging).
-We don't turn most of the warnings to errors but please treat them as such.
-If you use Qt Creator, the following line can be used with the Clang code model:
+The warnings configuration applied when using CMake can be found in
+`CMakeLists.txt`. Most warnings triggered by that configuration are not formally
+considered errors (the compiler will keep going) but please treat them as such.
+If you want to be cautious, you can use the following line for your IDE's Clang
+analyzer code model to enable as many compiler warnings as reasonable (that
+does not include `clang-tidy`/`clazy` warnings - see below on those):
`-Weverything -Werror=return-type -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-missing-prototypes -Wno-shadow-field-in-constructor -Wno-padded -Wno-weak-vtables -Wno-unknown-attributes -Wno-comma -Wno-string-conversion -Wno-return-std-move-in-c++11`.
### Continuous Integration
@@ -451,12 +452,6 @@ see the traffic lights from them on the PR page. If your PR fails
on any platform double-check that it's not your code causing it - and fix
(or ask how to fix if you don't know) if it is.
-### clang-format
-
-We strongly recommend using clang-format (version 10 or newer) or, even better,
-use an IDE that supports it. This will lay over a tedious task of following
-the assumed code style from your shoulders (and fingers) to your computer.
-
### Other tools
Recent versions of Qt Creator and CLion can automatically run your code through