[clang] [clang-format] Allow array alignment on non-rectangular arrays (PR #143781)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 17 09:01:55 PDT 2025


================
@@ -4249,11 +4253,40 @@ FormatToken *TokenAnnotator::calculateInitializerColumnList(
       ++Depth;
     else if (CurrentToken->is(tok::r_brace))
       --Depth;
+
+    // Ensure each outer array element starts on its own line
+    if (Depth == 1 && CurrentToken->is(tok::comma)) {
+      auto *NextNonComment = CurrentToken->getNextNonComment();
+      if (NextNonComment)
----------------
HazardyKnusperkeks wrote:

```suggestion
      if (auto *NextNonComment = CurrentToken->getNextNonComment())
```

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


More information about the cfe-commits mailing list