[clang] [clang-format] Fix breaking enum braces when combined with export (PR #189128)

via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 28 01:15:50 PDT 2026


================
@@ -3875,26 +3875,40 @@ bool UnwrappedLineParser::parseEnum() {
     return true;
   }
 
+  const bool ManageWhitesmithsBraces =
+      Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths;
+
   if (!Style.AllowShortEnumsOnASingleLine &&
       ShouldBreakBeforeBrace(Style, InitialToken,
                              Tokens->peekNextToken()->is(tok::r_brace))) {
     addUnwrappedLine();
+
+    // If we're in Whitesmiths mode, indent the brace if we're not indenting
+    // the whole block.
+    if (ManageWhitesmithsBraces)
+      ++Line->Level;
   }
   // Parse enum body.
   nextToken();
   if (!Style.AllowShortEnumsOnASingleLine) {
     addUnwrappedLine();
-    Line->Level += 1;
+    if (!ManageWhitesmithsBraces)
+      ++Line->Level;
   }
+  const size_t OpeningLineIndex = CurrentLines->empty()
----------------
owenca wrote:

```suggestion
  const auto OpeningLineIndex = CurrentLines->empty()
```

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


More information about the cfe-commits mailing list