From aca0573bed6112279026e414675ff73b53edaf5c Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 3 Apr 2022 21:36:56 +0900 Subject: [PATCH] Bump clang-format to 14 --- .clang-format | 38 ++++++++++++++++++++++++++++++++------ doc/sources/contribute.rst | 6 +++--- src/shrpx.cc | 15 +++++++-------- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/.clang-format b/.clang-format index 22d336a6..b4380bcf 100644 --- a/.clang-format +++ b/.clang-format @@ -2,6 +2,7 @@ Language: Cpp AccessModifierOffset: -2 AlignAfterOpenBracket: Align +AlignArrayOfStructures: None AlignConsecutiveMacros: None AlignConsecutiveAssignments: None AlignConsecutiveBitFields: None @@ -10,7 +11,6 @@ AlignEscapedNewlines: Right AlignOperands: Align AlignTrailingComments: true AllowAllArgumentsOnNextLine: true -AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortEnumsOnASingleLine: true AllowShortBlocksOnASingleLine: Never @@ -58,23 +58,28 @@ BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Leave CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false +EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: NextLine +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true FixNamespaceComments: true ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH -StatementAttributeLikeMacros: - - Q_EMIT +IfMacros: + - KJ_IF_MAYBE IncludeBlocks: Preserve IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' @@ -91,6 +96,7 @@ IncludeCategories: CaseSensitive: false IncludeIsMainRegex: '$' IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false IndentCaseLabels: false IndentCaseBlocks: false IndentGotoLabels: true @@ -103,6 +109,7 @@ InsertTrailingCommas: None JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: true +LambdaBodyIndentation: Signature MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 @@ -116,14 +123,20 @@ PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PenaltyIndentedWhitespace: 0 PointerAlignment: Right +PPIndentWidth: -1 +ReferenceAlignment: Pointer ReflowComments: true -SortIncludes: false +RemoveBracesLLVM: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: Never SortJavaStaticImport: Before SortUsingDeclarations: true SpaceAfterCStyleCast: false @@ -135,20 +148,33 @@ SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + BeforeNonEmptyParentheses: false SpaceAroundPointerQualifiers: Default SpaceBeforeRangeBasedForLoopColon: true SpaceInEmptyBlock: false SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 -SpacesInAngles: false +SpacesInAngles: Never SpacesInConditionalStatement: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 SpacesInParentheses: false SpacesInSquareBrackets: false SpaceBeforeSquareBrackets: false BitFieldColonSpacing: Both Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION diff --git a/doc/sources/contribute.rst b/doc/sources/contribute.rst index a5330ec9..32f43c87 100644 --- a/doc/sources/contribute.rst +++ b/doc/sources/contribute.rst @@ -26,7 +26,7 @@ Coding style We use clang-format to format source code consistently. The clang-format configuration file .clang-format is located at the root directory. Since clang-format produces slightly different results -between versions, we currently use clang-format-12. +between versions, we currently use clang-format-14. To detect any violation to the coding style, we recommend to setup git pre-commit hook to check coding style of the changes you introduced. @@ -34,13 +34,13 @@ The pre-commit file is located at the root directory. Copy it under .git/hooks and make sure that it is executable. The pre-commit script uses clang-format-diff.py to detect any style errors. If it is not in your PATH or it exists under different name (e.g., -clang-format-diff-12 in debian), either add it to PATH variable or add +clang-format-diff-14 in debian), either add it to PATH variable or add git option ``clangformatdiff.binary`` to point to the script. For emacs users, integrating clang-format to emacs is very easy. clang-format.el should come with clang distribution. If it is not found, download it from `here -`_. +`_. And add these lines to your .emacs file: .. code-block:: lisp diff --git a/src/shrpx.cc b/src/shrpx.cc index 664edb93..f9c4e843 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -1724,17 +1724,16 @@ int event_loop() { } #endif // ENABLE_HTTP3 - auto pid = fork_worker_process( - ipc_fd + auto pid = fork_worker_process(ipc_fd #ifdef ENABLE_HTTP3 - , - quic_ipc_fd + , + quic_ipc_fd #endif // ENABLE_HTTP3 - , - {} + , + {} #ifdef ENABLE_HTTP3 - , - cid_prefixes, quic_lwps + , + cid_prefixes, quic_lwps #endif // ENABLE_HTTP3 );