Page MenuHomePhabricator

[clang-format] Fix BreakBeforeBraces: Attach ignored with trailing requires-expression of function.
Changes PlannedPublic

Authored by curdeius on Dec 19 2021, 12:50 PM.

Diff Detail

Unit TestsFailed

TimeTest
50 msx64 debian > LLVM.Bindings/Go::go.test
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llvm-go go=/usr/bin/go test llvm.org/llvm/bindings/go/llvm

Event Timeline

curdeius requested review of this revision.Dec 19 2021, 12:50 PM
curdeius created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2021, 12:50 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
This revision is now accepted and ready to land.Dec 20 2021, 12:30 AM
MyDeveloperDay accepted this revision.Dec 20 2021, 3:09 AM

Thank you for doing this.

With the patch, I get this diff:

diff
diff --git a/sources/details/waarudo.details.utilities.cpp b/sources/details/waarudo.details.utilities.cpp
index 0b3680e..6e234ac 100644
--- a/sources/details/waarudo.details.utilities.cpp
+++ b/sources/details/waarudo.details.utilities.cpp
@@ -7,8 +7,8 @@ namespace waarudo {
 
 export template<class T, template<class...> class U> concept specialization_of = //
   (requires(T v) {
-    []<class... V>(U<V...>) requires std::same_as<T, U<V...>> { }
-    (v);
+    []<class... V>(U<V...>) requires std::same_as<T, U<V...>> {
+    }(v);
   });
 
 template<class T, class U> concept value_trait_for = //
diff --git a/sources/waarudo.quantities.cpp b/sources/waarudo.quantities.cpp
index 83a17db..fdc4c53 100644
--- a/sources/waarudo.quantities.cpp
+++ b/sources/waarudo.quantities.cpp
@@ -52,12 +52,20 @@ export template<class Id, number Number> struct quantity {
     requires std::convertible_to<const Number&, Number2>
   [[nodiscard]] constexpr operator quantity<Id, Number2>() const { return {number}; }
 
-  constexpr quantity& operator++() & requires ordered_number<Number> { return ++number, *this; }
-  constexpr quantity& operator--() & requires ordered_number<Number> { return --number, *this; }
-  [[nodiscard]] constexpr quantity operator++(int) & requires ordered_number<Number> { return {number++}; }
-  [[nodiscard]] constexpr quantity operator--(int) & requires ordered_number<Number> { return {number--}; }
+  constexpr quantity& operator++() & requires ordered_number<Number> {
+    return ++number, *this;
+  } constexpr quantity& operator--() & requires ordered_number<Number> {
+    return --number, *this;
+  } [[nodiscard]] constexpr quantity operator++(int) & requires ordered_number<Number> {
+    return {number++};
+  } [[nodiscard]] constexpr quantity operator--(int) & requires ordered_number<Number> {
+    return {number--};
+  }
 
-  constexpr quantity& operator+=(const relative_quantity_for<quantity> auto& d) & { return number += d.number, *this; }
+  constexpr quantity&
+  operator+=(const relative_quantity_for<quantity> auto& d) & {
+    return number += d.number, *this;
+  }
   constexpr quantity& operator-=(const relative_quantity_for<quantity> auto& d) & { return number -= d.number, *this; }
 
   template<relative_quantity_for<quantity> Q>

Here's how it looks without the patch:

namespace waarudo {

export template<class T, template<class...> class U> concept specialization_of = //
  (requires(T v) {
    []<class... V>(U<V...>) requires std::same_as<T, U<V...>> { }
    (v);
  });

struct x {
  constexpr quantity& operator++() & requires ordered_number<Number> { return ++number, *this; }
  constexpr quantity& operator--() & requires ordered_number<Number> { return --number, *this; }
  [[nodiscard]] constexpr quantity operator++(int) & requires ordered_number<Number> { return {number++}; }
  [[nodiscard]] constexpr quantity operator--(int) & requires ordered_number<Number> { return {number--}; }

  constexpr quantity& operator+=(const relative_quantity_for<quantity> auto& d) & { return number += d.number, *this; }
  constexpr quantity& operator-=(const relative_quantity_for<quantity> auto& d) & { return number -= d.number, *this; }
};

} // namespace waarudo

Here's my .clang-format:

AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: None
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: 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: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
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
IndentRequires: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PointerAlignment: Left
PPIndentWidth: -1
ReflowComments: true
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: false
SpacesInConditionalStatement: false
SpacesInLineCommentPrefix:
  Minimum: 1
  Maximum: 1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 2
UseCRLF: false
UseTab: Never

The second file in the diff, sources/waarudo.quantities.cpp, has a problem. The problem is that I've built my .clang-format to minimize line breaks, but for some reason, what fit on a line before, now doesn't.
On inspection, its first diff does not insert a line break before the start of new functions. Its second diff changes just the first function. If I remove the lines in the previous diff so that x only has operators += and -=, they remain unchanged.

Ok, I'll have a look on it. Thanks for reporting.

curdeius planned changes to this revision.Dec 21 2021, 11:12 PM