From 1f14184ac30196c33bdd85df140d31e38663df65 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 25 Oct 2023 14:38:26 +0200 Subject: [PATCH] style: clang-format updated to clang 17 --- .clang-format | 22 +++++++++++++++------- .pre-commit-config.yaml | 2 +- src/core/include/mp-units/quantity.h | 18 +++++++++--------- src/core/include/mp-units/quantity_point.h | 8 ++++---- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.clang-format b/.clang-format index 4938ef9b7..ea1166d33 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,3 @@ -######################################################################################## -# NOTE: At least clang-format-16 is needed to format the code of this project correctly -######################################################################################## --- BasedOnStyle: Google --- @@ -32,6 +29,11 @@ AccessModifierOffset: -2 # AcrossComments: false # AlignCompound: false # PadOperators: false +# AlignConsecutiveShortCaseStatements: +# Enabled: false +# AcrossEmptyLines: false +# AcrossComments: false +# AlignCaseColons: false # AlignEscapedNewlines: Left # AlignOperands: Align # AlignTrailingComments: @@ -140,6 +142,7 @@ IncludeCategories: # JavaScriptQuotes: Leave # JavaScriptWrapImports: true # KeepEmptyLinesAtTheStartOfBlocks: false +# KeepEmptyLinesAtEOF: false # LambdaBodyIndentation: Signature # LineEnding: DeriveLF # MacroBlockBegin: '' @@ -198,6 +201,7 @@ QualifierAlignment: Left # ReferenceAlignment: Pointer # ReflowComments: true # RemoveBracesLLVM: false +# RemoveParentheses: Leave # RemoveSemicolon: false # RequiresClausePosition: OwnLine # RequiresExpressionIndentation: OuterScope @@ -215,6 +219,7 @@ SpaceAfterTemplateKeyword: false # SpaceBeforeCpp11BracedList: false # SpaceBeforeCtorInitializerColon: true # SpaceBeforeInheritanceColon: true +# SpaceBeforeJsonColon: false # SpaceBeforeParens: ControlStatements SpaceBeforeParensOptions: # AfterControlStatements: true @@ -229,16 +234,18 @@ SpaceBeforeParensOptions: # SpaceBeforeRangeBasedForLoopColon: true # SpaceBeforeSquareBrackets: false # SpaceInEmptyBlock: false -# SpaceInEmptyParentheses: false # SpacesBeforeTrailingComments: 2 # SpacesInAngles: Never -# SpacesInConditionalStatement: false # SpacesInContainerLiterals: true -# SpacesInCStyleCastParentheses: false # SpacesInLineCommentPrefix: # Minimum: 1 # Maximum: -1 -# SpacesInParentheses: false +# SpacesInParens: Never +# SpacesInParensOptions: +# InCStyleCasts: false +# InConditionalStatements: false +# InEmptyParentheses: false +# Other: false # SpacesInSquareBrackets: false # Standard: Auto # StatementAttributeLikeMacros: @@ -248,6 +255,7 @@ SpaceBeforeParensOptions: # - QT_REQUIRE_VERSION # TabWidth: 8 # UseTab: Never +# VerilogBreakBetweenInstancePorts: true # WhitespaceSensitiveMacros: # - BOOST_PP_STRINGIZE # - CF_SWIFT_NAME diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 110c5e6ab..2254f2221 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v16.0.6 + rev: v17.0.3 hooks: - id: clang-format - repo: https://github.com/cheshirekow/cmake-format-precommit diff --git a/src/core/include/mp-units/quantity.h b/src/core/include/mp-units/quantity.h index f4a2273f4..3feacdcb6 100644 --- a/src/core/include/mp-units/quantity.h +++ b/src/core/include/mp-units/quantity.h @@ -252,7 +252,7 @@ class quantity { } template - friend constexpr decltype(auto) operator++(Q&& q) + friend constexpr decltype(auto) operator++(Q && q) requires std::derived_from, quantity> && requires(rep v) { { ++v @@ -274,7 +274,7 @@ class quantity { } template - friend constexpr decltype(auto) operator--(Q&& q) + friend constexpr decltype(auto) operator--(Q && q) requires std::derived_from, quantity> && requires(rep v) { { --v @@ -302,7 +302,7 @@ class quantity { a += b } -> std::same_as; } - friend constexpr decltype(auto) operator+=(Q&& lhs, const quantity& rhs) + friend constexpr decltype(auto) operator+=(Q && lhs, const quantity & rhs) { lhs.numerical_value_is_an_implementation_detail_ += rhs.numerical_value_is_an_implementation_detail_; return std::forward(lhs); @@ -314,7 +314,7 @@ class quantity { a -= b } -> std::same_as; } - friend constexpr decltype(auto) operator-=(Q&& lhs, const quantity& rhs) + friend constexpr decltype(auto) operator-=(Q && lhs, const quantity & rhs) { lhs.numerical_value_is_an_implementation_detail_ -= rhs.numerical_value_is_an_implementation_detail_; return std::forward(lhs); @@ -327,7 +327,7 @@ class quantity { a %= b } -> std::same_as; } - friend constexpr decltype(auto) operator%=(Q&& lhs, const quantity& rhs) + friend constexpr decltype(auto) operator%=(Q && lhs, const quantity & rhs) { gsl_ExpectsAudit(rhs != zero()); @@ -342,7 +342,7 @@ class quantity { a *= b } -> std::same_as; } - friend constexpr decltype(auto) operator*=(Q&& lhs, const Value& v) + friend constexpr decltype(auto) operator*=(Q && lhs, const Value & v) { lhs.numerical_value_is_an_implementation_detail_ *= v; return std::forward(lhs); @@ -355,7 +355,7 @@ class quantity { a *= b } -> std::same_as; } - friend constexpr decltype(auto) operator*=(Q1&& lhs, const Q2& rhs) + friend constexpr decltype(auto) operator*=(Q1 && lhs, const Q2 & rhs) { lhs.numerical_value_is_an_implementation_detail_ *= rhs.numerical_value_is_an_implementation_detail_; return std::forward(lhs); @@ -368,7 +368,7 @@ class quantity { a /= b } -> std::same_as; } - friend constexpr decltype(auto) operator/=(Q&& lhs, const Value& v) + friend constexpr decltype(auto) operator/=(Q && lhs, const Value & v) { gsl_ExpectsAudit(v != quantity_values::zero()); lhs.numerical_value_is_an_implementation_detail_ /= v; @@ -382,7 +382,7 @@ class quantity { a /= b } -> std::same_as; } - friend constexpr decltype(auto) operator/=(Q1&& lhs, const Q2& rhs) + friend constexpr decltype(auto) operator/=(Q1 && lhs, const Q2 & rhs) { gsl_ExpectsAudit(rhs != rhs.zero()); lhs.numerical_value_is_an_implementation_detail_ /= rhs.numerical_value_is_an_implementation_detail_; diff --git a/src/core/include/mp-units/quantity_point.h b/src/core/include/mp-units/quantity_point.h index 2e15ae6aa..ad842a4f4 100644 --- a/src/core/include/mp-units/quantity_point.h +++ b/src/core/include/mp-units/quantity_point.h @@ -223,7 +223,7 @@ class quantity_point { // member unary operators template - friend constexpr decltype(auto) operator++(QP&& qp) + friend constexpr decltype(auto) operator++(QP && qp) requires std::derived_from, quantity_point> && requires { ++qp.quantity_from_origin_is_an_implementation_detail_; } { @@ -238,7 +238,7 @@ class quantity_point { } template - friend constexpr decltype(auto) operator--(QP&& qp) + friend constexpr decltype(auto) operator--(QP && qp) requires std::derived_from, quantity_point> && requires { --qp.quantity_from_origin_is_an_implementation_detail_; } { @@ -256,7 +256,7 @@ class quantity_point { template requires std::derived_from, quantity_point> && requires(quantity_type q) { quantity_from_origin_is_an_implementation_detail_ += q; } - friend constexpr decltype(auto) operator+=(QP&& qp, const quantity_type& q) + friend constexpr decltype(auto) operator+=(QP && qp, const quantity_type & q) { qp.quantity_from_origin_is_an_implementation_detail_ += q; return std::forward(qp); @@ -265,7 +265,7 @@ class quantity_point { template requires std::derived_from, quantity_point> && requires(quantity_type q) { quantity_from_origin_is_an_implementation_detail_ -= q; } - friend constexpr decltype(auto) operator-=(QP&& qp, const quantity_type& q) + friend constexpr decltype(auto) operator-=(QP && qp, const quantity_type & q) { qp.quantity_from_origin_is_an_implementation_detail_ -= q; return std::forward(qp);