[clang] [clang-format] Adjust requires clause wrapping (#101550) (PR #102078)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 9 08:13:30 PDT 2024


================
@@ -5682,12 +5683,15 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
            (Style.BreakTemplateDeclarations == FormatStyle::BTDS_Leave &&
             Right.NewlinesBefore > 0);
   }
-  if (Left.ClosesRequiresClause && Right.isNot(tok::semi) &&
-      Right.isNot(tok::l_brace)) {
+  if (Left.ClosesRequiresClause && Right.isNot(tok::semi)) {
     switch (Style.RequiresClausePosition) {
     case FormatStyle::RCPS_OwnLine:
     case FormatStyle::RCPS_WithPreceding:
       return true;
+    case FormatStyle::RCPS_OwnLineWithBrace:
+      if (Right.isNot(tok::l_brace))
+        return true;
+      break;
----------------
HazardyKnusperkeks wrote:

```suggestion
      return Right.isNot(tok::l_brace);
```

When it's not a brace you want it to break.

I'm sure you can find a test case which fails without this change and passes with.

https://github.com/llvm/llvm-project/pull/102078


More information about the cfe-commits mailing list