<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54374>54374</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Format] Function ref-qualifier inconsistenly spaced
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JohelEGP
</td>
</tr>
</table>
<pre>
I don't think there's an option for affecting this. Here's the diff after upgrading from ff50e81b5 to ae7c6647f, with some context for testing purposes below. The larger diff shows that only functions that weren't a single line long are affected, which results in an inconsistent spacing.
```diff
@@ -51,7 +51,7 @@ export template<reference R, number N> struct quantity {
constexpr quantity& operator*=(const compound_scalar_for<N> auto& s) & { return void(number *= s), *this; }
constexpr quantity& operator/=(const compound_scalar_for<N> auto& s) & { return void(number /= s), *this; }
constexpr quantity& operator%=(const compound_modulus_for<N> auto& d) & { return void(number %= d), *this; }
- template<compound_modulus_for<N> N2> constexpr quantity& operator%=(const quantity<R, N2>& r) & {
+ template<compound_modulus_for<N> N2> constexpr quantity& operator%=(const quantity<R, N2>& r)& {
return void(number %= r.number), *this;
}
```
```C++
struct quantity {
constexpr quantity& operator%=(const compound_modulus_for<N> auto& d) & { return void(number %= d), *this; }
template<compound_modulus_for<N> N2> constexpr quantity& operator%=(const quantity<R, N2>& r)& {
return void(number %= r.number), *this;
}
};
```
`.clang-format`:
```yaml
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: None
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeConceptDeclarations: Allowed
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 120
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
FixNamespaceComments: true
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '<(experimental/)?[a-z_]+>' # C++ standard library
Priority: 1
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PackConstructorInitializers: NextLine
PointerAlignment: Left
PPIndentWidth: -1
QualifierAlignment: Custom
QualifierOrder: ["static", "inline", "constexpr", "const", "volatile", "type"]
ReferenceAlignment: Pointer
ReflowComments: true
RequiresClausePosition: SingleLine
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 0
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
SpaceAfterLogicalNot: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: 1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 2
UseCRLF: false
UseTab: Never
```
```diff
diff --git a/sources/waarudo.geometries.cpp b/sources/waarudo.geometries.cpp
index 576806c..8655e1b 100644
--- a/sources/waarudo.geometries.cpp
+++ b/sources/waarudo.geometries.cpp
@@ -49,11 +49,11 @@ export template<scalar_quantity Q> struct cartesian_vector2d {
[[nodiscard]] constexpr cartesian_vector2d<decltype(-Q{})> operator-() const { return {-x, -y}; }
template<compound_relative_quantity_for<Q> Q2>
- constexpr cartesian_vector2d& operator+=(const cartesian_vector2d<Q2>& r) & {
+ constexpr cartesian_vector2d& operator+=(const cartesian_vector2d<Q2>& r)& {
return x += r.x, void(y += r.y), *this;
}
template<compound_relative_quantity_for<Q> Q2>
- constexpr cartesian_vector2d& operator-=(const cartesian_vector2d<Q2>& r) & {
+ constexpr cartesian_vector2d& operator-=(const cartesian_vector2d<Q2>& r)& {
return x -= r.x, void(y -= r.y), *this;
}
@@ -120,11 +120,11 @@ export template<origin_point O, scalar_quantity Q> struct cartesian_point2d {
}
template<compound_relative_quantity_for<Q> Q2>
- constexpr cartesian_point2d& operator+=(const cartesian_vector2d<Q2>& r) & {
+ constexpr cartesian_point2d& operator+=(const cartesian_vector2d<Q2>& r)& {
return x += r.x, void(y += r.y), *this;
}
template<compound_relative_quantity_for<Q> Q2>
- constexpr cartesian_point2d& operator-=(const cartesian_vector2d<Q2>& r) & {
+ constexpr cartesian_point2d& operator-=(const cartesian_vector2d<Q2>& r)& {
return x -= r.x, void(y -= r.y), *this;
}
diff --git a/sources/waarudo.quantities.cpp b/sources/waarudo.quantities.cpp
index a3a1814..374c13b 100644
--- a/sources/waarudo.quantities.cpp
+++ b/sources/waarudo.quantities.cpp
@@ -28,10 +28,10 @@ export template<reference R, number N> struct quantity {
[[nodiscard]] constexpr quantity operator++(int) & requires number_line<N> { return {number++}; }
[[nodiscard]] constexpr quantity operator--(int) & requires number_line<N> { return {number--}; }
- template<compound_relative_quantity_for<N> N2> constexpr quantity& operator+=(const quantity<R, N2>& r) & {
+ template<compound_relative_quantity_for<N> N2> constexpr quantity& operator+=(const quantity<R, N2>& r)& {
return void(number += r.number), *this;
}
- template<compound_relative_quantity_for<N> N2> constexpr quantity& operator-=(const quantity<R, N2>& r) & {
+ template<compound_relative_quantity_for<N> N2> constexpr quantity& operator-=(const quantity<R, N2>& r)& {
return void(number -= r.number), *this;
}
@@ -51,7 +51,7 @@ export template<reference R, number N> struct quantity {
constexpr quantity& operator*=(const compound_scalar_for<N> auto& s) & { return void(number *= s), *this; }
constexpr quantity& operator/=(const compound_scalar_for<N> auto& s) & { return void(number /= s), *this; }
constexpr quantity& operator%=(const compound_modulus_for<N> auto& d) & { return void(number %= d), *this; }
- template<compound_modulus_for<N> N2> constexpr quantity& operator%=(const quantity<R, N2>& r) & {
+ template<compound_modulus_for<N> N2> constexpr quantity& operator%=(const quantity<R, N2>& r)& {
return void(number %= r.number), *this;
}
@@ -100,10 +100,10 @@ export template<origin_point O, reference R, number N> struct quantity_point {
[[nodiscard]] constexpr quantity_point operator++(int) & requires number_line<N> { return {number++}; }
[[nodiscard]] constexpr quantity_point operator--(int) & requires number_line<N> { return {number--}; }
- template<compound_relative_quantity_for<N> N2> constexpr quantity_point& operator+=(const quantity<R, N2>& r) & {
+ template<compound_relative_quantity_for<N> N2> constexpr quantity_point& operator+=(const quantity<R, N2>& r)& {
return void(number += r.number), *this;
}
- template<compound_relative_quantity_for<N> N2> constexpr quantity_point& operator-=(const quantity<R, N2>& r) & {
+ template<compound_relative_quantity_for<N> N2> constexpr quantity_point& operator-=(const quantity<R, N2>& r)& {
return void(number -= r.number), *this;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llv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