[clang] [clang-format] Add BreakAfterOpenBracket* and BreakBeforeCloseBracket* (PR #108332)

Gedare Bloom via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 24 10:47:52 PDT 2025


https://github.com/gedare updated https://github.com/llvm/llvm-project/pull/108332

>From f28d166ad5858fb2d28d90270fda7aaf560ac86d Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Thu, 20 Jun 2024 17:35:39 -0600
Subject: [PATCH 01/48] Format: add AlignAfterControlStatement

Introduce new style option to allow overriding the breaking after the
opening parenthesis for control statements (if/for/while/switch).

Fixes #67738.
Fixes #79176.
Fixes #80123.
---
 clang/include/clang/Format/Format.h        |  17 ++
 clang/lib/Format/ContinuationIndenter.cpp  |  69 +++--
 clang/lib/Format/Format.cpp                |  13 +
 clang/lib/Format/TokenAnnotator.cpp        |   8 +-
 clang/unittests/Format/ConfigParseTest.cpp |   8 +
 clang/unittests/Format/FormatTest.cpp      | 299 +++++++++++++++++++++
 6 files changed, 392 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 3df5b92654094..c8fa6afb6af5d 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,6 +62,22 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
+  /// Different styles for breaking the parenthesis after a control statement
+  /// (``if/switch/while/for ...``).
+  /// \version 21
+  enum BreakAfterControlStatementStyle : int8_t {
+    /// Use the default behavior.
+    BACSS_Default,
+    /// Force break after the left parenthesis of a control statement only
+    /// when the expression exceeds the column limit, and align on the
+    /// ``ContinuationIndentWidth``.
+    BACSS_MultiLine,
+    /// Do not force a break after the control statment.
+    BACSS_No,
+  };
+
+  BreakAfterControlStatementStyle AlignAfterControlStatement;
+
   /// Different styles for aligning after open brackets.
   enum BracketAlignmentStyle : int8_t {
     /// Align parameters on the open bracket, e.g.:
@@ -5442,6 +5458,7 @@ struct FormatStyle {
 
   bool operator==(const FormatStyle &R) const {
     return AccessModifierOffset == R.AccessModifierOffset &&
+           AlignAfterControlStatement == R.AlignAfterControlStatement &&
            AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
            AlignArrayOfStructures == R.AlignArrayOfStructures &&
            AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 9413c13a4137e..190d2c3a97cd4 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -830,6 +830,11 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // parenthesis by disallowing any further line breaks if there is no line
   // break after the opening parenthesis. Don't break if it doesn't conserve
   // columns.
+  auto IsOtherConditional = [&](const FormatToken &Tok) {
+    return Tok.isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch) ||
+           (Style.isJavaScript() && Tok.is(Keywords.kw_await) && Tok.Previous &&
+            Tok.Previous->is(tok::kw_for));
+  };
   auto IsOpeningBracket = [&](const FormatToken &Tok) {
     auto IsStartOfBracedList = [&]() {
       return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
@@ -841,26 +846,36 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
     }
     if (!Tok.Previous)
       return true;
-    if (Tok.Previous->isIf())
-      return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak;
-    return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
-                                  tok::kw_switch) &&
-           !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await));
+    if (Tok.Previous->isIf()) {
+      /* For backward compatibility, use AlignAfterOpenBracket
+       * in case AlignAfterControlStatement is not initialized */
+      return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine ||
+             (Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
+              Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
+    }
+    if (IsOtherConditional(*Tok.Previous))
+      return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
+    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
+        Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+      return !Tok.Previous->is(TT_CastRParen) &&
+             !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
+    }
+    return false;
   };
   auto IsFunctionCallParen = [](const FormatToken &Tok) {
     return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous &&
            Tok.Previous->is(tok::identifier);
   };
-  auto IsInTemplateString = [this](const FormatToken &Tok) {
+  auto IsInTemplateString = [this](const FormatToken &Tok, bool NestBlocks) {
     if (!Style.isJavaScript())
       return false;
     for (const auto *Prev = &Tok; Prev; Prev = Prev->Previous) {
       if (Prev->is(TT_TemplateString) && Prev->opensScope())
         return true;
-      if (Prev->opensScope() ||
-          (Prev->is(TT_TemplateString) && Prev->closesScope())) {
-        break;
-      }
+      if (Prev->opensScope() && !NestBlocks)
+        return false;
+      if (Prev->is(TT_TemplateString) && Prev->closesScope())
+        return false;
     }
     return false;
   };
@@ -882,21 +897,24 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
          Tok.isOneOf(tok::ellipsis, Keywords.kw_await))) {
       return true;
     }
-    const auto *Previous = Tok.Previous;
-    if (!Previous || (!Previous->isOneOf(TT_FunctionDeclarationLParen,
-                                         TT_LambdaDefinitionLParen) &&
-                      !IsFunctionCallParen(*Previous))) {
+    const auto *Previous = TokAfterLParen.Previous;
+    assert(Previous); // IsOpeningBracket(Previous)
+    if (Previous->Previous && (Previous->Previous->isIf() ||
+                               IsOtherConditional(*Previous->Previous))) {
+      return false;
+    }
+    if (!Previous->isOneOf(TT_FunctionDeclarationLParen,
+                           TT_LambdaDefinitionLParen) &&
+        !IsFunctionCallParen(*Previous)) {
       return true;
     }
-    if (IsOpeningBracket(Tok) || IsInTemplateString(Tok))
+    if (IsOpeningBracket(Tok) || IsInTemplateString(Tok, true))
       return true;
     const auto *Next = Tok.Next;
     return !Next || Next->isMemberAccess() ||
            Next->is(TT_FunctionDeclarationLParen) || IsFunctionCallParen(*Next);
   };
-  if ((Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
-       Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) &&
-      IsOpeningBracket(Previous) && State.Column > getNewLineColumn(State) &&
+  if (IsOpeningBracket(Previous) && State.Column > getNewLineColumn(State) &&
       // Don't do this for simple (no expressions) one-argument function calls
       // as that feels like needlessly wasting whitespace, e.g.:
       //
@@ -926,7 +944,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
       !(Current.MacroParent && Previous.MacroParent) &&
       (Current.isNot(TT_LineComment) ||
        Previous.isOneOf(BK_BracedInit, TT_VerilogMultiLineListLParen)) &&
-      !IsInTemplateString(Current)) {
+      !IsInTemplateString(Current, false)) {
     CurrentState.Indent = State.Column + Spaces;
     CurrentState.IsAligned = true;
   }
@@ -1263,8 +1281,17 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
   }
 
   if (PreviousNonComment && PreviousNonComment->is(tok::l_paren)) {
-    CurrentState.BreakBeforeClosingParen =
-        Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+    auto Previous = PreviousNonComment->Previous;
+    if (Previous &&
+        (Previous->isIf() ||
+         Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch))) {
+      CurrentState.BreakBeforeClosingParen =
+          Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine &&
+          Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+    } else {
+      CurrentState.BreakBeforeClosingParen =
+          Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+    }
   }
 
   if (PreviousNonComment && PreviousNonComment->is(TT_TemplateOpener))
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b38f2810c0a74..b4685cdbb0125 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -204,6 +204,16 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
   }
 };
 
+template <>
+struct ScalarEnumerationTraits<FormatStyle::BreakAfterControlStatementStyle> {
+  static void enumeration(IO &IO,
+                          FormatStyle::BreakAfterControlStatementStyle &Value) {
+    IO.enumCase(Value, "Default", FormatStyle::BACSS_Default);
+    IO.enumCase(Value, "MultiLine", FormatStyle::BACSS_MultiLine);
+    IO.enumCase(Value, "No", FormatStyle::BACSS_No);
+  }
+};
+
 template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
   static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
     IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
@@ -1003,6 +1013,8 @@ template <> struct MappingTraits<FormatStyle> {
 
     IO.mapOptional("AccessModifierOffset", Style.AccessModifierOffset);
     IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
+    IO.mapOptional("AlignAfterControlStatement",
+                   Style.AlignAfterControlStatement);
     IO.mapOptional("AlignArrayOfStructures", Style.AlignArrayOfStructures);
     IO.mapOptional("AlignConsecutiveAssignments",
                    Style.AlignConsecutiveAssignments);
@@ -1549,6 +1561,7 @@ static void expandPresetsSpacesInParens(FormatStyle &Expanded) {
 FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   FormatStyle LLVMStyle;
   LLVMStyle.AccessModifierOffset = -2;
+  LLVMStyle.AlignAfterControlStatement = FormatStyle::BACSS_Default;
   LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
   LLVMStyle.AlignConsecutiveAssignments = {};
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 4bfb803ebedf7..6d6f8f12163b2 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -6240,7 +6240,13 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
     if (Next && Next->is(tok::l_paren))
       return false;
     const FormatToken *Previous = Right.MatchingParen->Previous;
-    return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+    if (!Previous)
+      return true;
+    if (Previous->isIf() ||
+        Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch)) {
+      return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
+    }
+    return true;
   }
 
   if (Left.isOneOf(tok::r_paren, TT_TrailingAnnotation) &&
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index bb4d38bb741ec..90f8202b182c2 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -534,6 +534,14 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma,
               FormatStyle::ETC_Remove);
 
+  Style.AlignAfterControlStatement = FormatStyle::BACSS_Default;
+  CHECK_PARSE("AlignAfterControlStatement: MultiLine",
+              AlignAfterControlStatement, FormatStyle::BACSS_MultiLine);
+  CHECK_PARSE("AlignAfterControlStatement: No", AlignAfterControlStatement,
+              FormatStyle::BACSS_No);
+  CHECK_PARSE("AlignAfterControlStatement: Default", AlignAfterControlStatement,
+              FormatStyle::BACSS_Default);
+
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
   CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
               FormatStyle::BAS_Align);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 7d550143be5df..471c1facc26b3 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9423,6 +9423,305 @@ TEST_F(FormatTest, AlignsAfterReturn) {
                "    code == a || code == b;");
 }
 
+TEST_F(FormatTest, AlignAfterConditionalStatements) {
+  FormatStyle Style = getLLVMStyle();
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
+
+  verifyFormat("void foo() {\n"
+               "  if constexpr (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               "bbb) == 0) {\n"
+               "    return;\n"
+               "  } else if (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
+               "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               "bbb) == 0) {\n"
+               "    return;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  switch (\n"
+               "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
+               "  default:\n"
+               "    break;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat(
+      "void foo() {\n"
+      "  for (\n"
+      "      aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
+      "      (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
+      "          aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
+      "      aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
+      "    ;\n"
+      "  }\n"
+      "}",
+      Style);
+
+  verifyFormat(
+      "void foo() {\n"
+      "  while (\n"
+      "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+      "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) "
+      "{\n"
+      "    continue;\n"
+      "  }\n"
+      "}",
+      Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
+
+  verifyFormat("void foo() {\n"
+               "  if constexpr (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               ") == 0) {\n"
+               "    return;\n"
+               "  } else if (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
+               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               ") == 0) {\n"
+               "    return;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  switch (\n"
+               "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
+               "  default:\n"
+               "    break;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  for (\n"
+               "      aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
+               "       aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
+               "      aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
+               "    ;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  while (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) "
+               "{\n"
+               "    continue;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
+
+  verifyFormat("void foo() {\n"
+               "  if constexpr (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               ") == 0) {\n"
+               "    return;\n"
+               "  } else if (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
+               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               ") == 0) {\n"
+               "    return;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  switch (\n"
+               "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
+               "  default:\n"
+               "    break;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  for (\n"
+               "      aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
+               "       aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
+               "      aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
+               "    ;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  while (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) "
+               "{\n"
+               "    continue;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.AlignAfterControlStatement = FormatStyle::BACSS_No;
+
+  verifyFormat("void foo() {\n"
+               "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "                 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               "bbbbbbbbbb) ==\n"
+               "                0) {\n"
+               "    return;\n"
+               "  } else if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
+               "              bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               "bbbbbbb) == 0) {\n"
+               "    return;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  switch (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
+               "  default:\n"
+               "    break;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat(
+      "void foo() {\n"
+      "  for (aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
+      "       (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
+      "        aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
+      "       aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
+      "    ;\n"
+      "  }\n"
+      "}",
+      Style);
+
+  verifyFormat(
+      "void foo() {\n"
+      "  while ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+      "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) "
+      "{\n"
+      "    continue;\n"
+      "  }\n"
+      "}",
+      Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
+
+  verifyFormat(
+      "void foo() {\n"
+      "  if constexpr (\n"
+      "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+      "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0\n"
+      "  ) {\n"
+      "    return;\n"
+      "  } else if (\n"
+      "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
+      "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0\n"
+      "  ) {\n"
+      "    return;\n"
+      "  }\n"
+      "}",
+      Style);
+
+  verifyFormat("void foo() {\n"
+               "  switch (\n"
+               "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | "
+               "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"
+               "  ) {\n"
+               "  default:\n"
+               "    break;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  for (\n"
+               "      aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
+               "       aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
+               "      aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next\n"
+               "  ) {\n"
+               "    ;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  while (\n"
+               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0\n"
+               "  ) {\n"
+               "    continue;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.AlignAfterControlStatement = FormatStyle::BACSS_No;
+
+  verifyFormat("void foo() {\n"
+               "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "                 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               "bbbbbbbbbb) ==\n"
+               "                0) {\n"
+               "    return;\n"
+               "  } else if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
+               "              bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               "bbbbbbb) == 0) {\n"
+               "    return;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  switch (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
+               "  default:\n"
+               "    break;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  verifyFormat(
+      "void foo() {\n"
+      "  for (aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
+      "       (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
+      "        aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
+      "       aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
+      "    ;\n"
+      "  }\n"
+      "}",
+      Style);
+
+  verifyFormat(
+      "void foo() {\n"
+      "  while ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+      "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) {\n"
+      "    continue;\n"
+      "  }\n"
+      "}",
+      Style);
+}
+
+>>>>>>> 5823461e9528 (Format: add AlignAfterControlStatement)
 TEST_F(FormatTest, BreaksConditionalExpressions) {
   verifyFormat(
       "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa\n"

>From c17c3d36bb56bec19b8255406189204260b8b7f3 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Wed, 21 May 2025 16:11:23 -0600
Subject: [PATCH 02/48] updates

---
 clang/include/clang/Format/Format.h        | 178 +++++++++++++++++++--
 clang/lib/Format/ContinuationIndenter.cpp  |  59 ++++---
 clang/lib/Format/Format.cpp                |  91 +++++++++--
 clang/lib/Format/TokenAnnotator.cpp        |  37 ++++-
 clang/unittests/Format/ConfigParseTest.cpp |  56 ++++++-
 clang/unittests/Format/FormatTest.cpp      |  30 +++-
 6 files changed, 386 insertions(+), 65 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index c8fa6afb6af5d..2106b358a57da 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,21 +62,86 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
-  /// Different styles for breaking the parenthesis after a control statement
-  /// (``if/switch/while/for ...``).
+  /// Different styles for breaking the parenthesis after ``if/else if``.
   /// \version 21
-  enum BreakAfterControlStatementStyle : int8_t {
-    /// Use the default behavior.
-    BACSS_Default,
-    /// Force break after the left parenthesis of a control statement only
-    /// when the expression exceeds the column limit, and align on the
-    /// ``ContinuationIndentWidth``.
-    BACSS_MultiLine,
-    /// Do not force a break after the control statment.
-    BACSS_No,
+  enum BreakAfterOpenBracketIfStyle : int8_t {
+    /// Always break the opening parenthesis of an if statement, e.g.:
+    /// \code
+    ///   if constexpr (
+    ///                 a)
+    /// \endcode
+    BAOBIS_Always,
+    /// Force break after the left parenthesis of an if statement only
+    /// when the expression exceeds the column limit, e.g..:
+    /// \code
+    ///   if constexpr (
+    ///                 a ||
+    ///                 b)
+    /// \endcode
+    BAOBIS_MultiLine,
+    /// Do not force a break after the control statement.
+    /// \code
+    ///   if constexpr (a ||
+    ///                 b
+    /// \endcode
+    BAOBIS_No,
+  };
+
+  BreakAfterOpenBracketIfStyle BreakAfterOpenBracketIf;
+
+  /// Different styles for breaking the parenthesis after loops ``(for/while)``.
+  /// \version 21
+  enum BreakAfterOpenBracketLoopStyle : int8_t {
+    /// Always break the opening parenthesis of a loop statement, e.g.:
+    /// \code
+    ///   while (
+    ///          a) {
+    /// \endcode
+    BAOBLS_Always,
+    /// Force break after the left parenthesis of a loop only
+    /// when the expression exceeds the column limit, e.g..:
+    /// \code
+    ///   while (
+    ///          a &&
+    ///          b) {
+    /// \endcode
+    BAOBLS_MultiLine,
+    /// Do not force a break after the control statement.
+    /// \code
+    ///   while (a &&
+    ///          b) {
+    /// \endcode
+    BAOBLS_No,
+  };
+
+  BreakAfterOpenBracketLoopStyle BreakAfterOpenBracketLoop;
+
+  /// Different styles for breaking the parenthesis after ``switch``.
+  /// \version 21
+  enum BreakAfterOpenBracketSwitchStyle : int8_t {
+    /// Always break the opening parenthesis of a switch statement, e.g.:
+    /// \code
+    ///   switch (
+    ///           a) {
+    /// \endcode
+    BAOBSS_Always,
+    /// Force break after the left parenthesis of a switch only
+    /// when the expression exceeds the column limit, e.g..:
+    /// \code
+    ///   switch (
+    ///           a &&
+    ///           b) {
+    /// \endcode
+    BAOBSS_MultiLine,
+    /// Do not force a break after the control statement.
+    /// \code
+    ///   switch (a &&
+    ///           b) {
+    /// \endcode
+    BAOBSS_No,
   };
 
-  BreakAfterControlStatementStyle AlignAfterControlStatement;
+  BreakAfterOpenBracketSwitchStyle BreakAfterOpenBracketSwitch;
 
   /// Different styles for aligning after open brackets.
   enum BracketAlignmentStyle : int8_t {
@@ -2237,6 +2302,88 @@ struct FormatStyle {
   /// \version 3.7
   BraceBreakingStyle BreakBeforeBraces;
 
+  /// Different styles for breaking before ``if/else if`` closing parenthesis.
+  /// \version 21
+  enum BreakBeforeCloseBracketIfStyle : int8_t {
+    /// Always break the closing parenthesis of an if statement, e.g.:
+    /// \code
+    ///   if constexpr (a
+    ///                )
+    /// \endcode
+    BBCBIS_Always,
+    /// Force break before the closing parenthesis of an if statement only
+    /// when the expression exceeds the column limit, e.g..:
+    /// \code
+    ///   if constexpr (a ||
+    ///                 b
+    ///                )
+    /// \endcode
+    BBCBIS_MultiLine,
+    /// Do not force a break before closing the if control statement.
+    /// \code
+    ///   if constexpr (a ||
+    ///                 b)
+    /// \endcode
+    BBCBIS_No,
+  };
+
+  BreakBeforeCloseBracketIfStyle BreakBeforeCloseBracketIf;
+
+  /// Different styles for breaking before loop ``(for/while)`` closing
+  /// parenthesis.
+  /// \version 21
+  enum BreakBeforeCloseBracketLoopStyle : int8_t {
+    /// Always break the closing parenthesis of a loop statement, e.g.:
+    /// \code
+    ///   while (a
+    ///         ) {
+    /// \endcode
+    BBCBLS_Always,
+    /// Force break before the closing parenthesis of a loop only
+    /// when the expression exceeds the column limit, e.g..:
+    /// \code
+    ///   while (a &&
+    ///          b
+    ///         ) {
+    /// \endcode
+    BBCBLS_MultiLine,
+    /// Do not force a break before closing the loop control statement.
+    /// \code
+    ///   while (a &&
+    ///          b) {
+    /// \endcode
+    BBCBLS_No,
+  };
+
+  BreakBeforeCloseBracketLoopStyle BreakBeforeCloseBracketLoop;
+
+  /// Different styles for breaking before ``switch`` closing parenthesis.
+  /// \version 21
+  enum BreakBeforeCloseBracketSwitchStyle : int8_t {
+    /// Always break before the closing parenthesis of a switch statement, e.g.:
+    /// \code
+    ///   switch (a
+    ///          )  {
+    /// \endcode
+    BBCBSS_Always,
+    /// Force break before the closing parenthesis of a switch only
+    /// when the expression exceeds the column limit, e.g..:
+    /// \code
+    ///   switch (a &&
+    ///           b
+    ///           ) {
+    /// \endcode
+    BBCBSS_MultiLine,
+    /// Do not force a break before closing the switch control statement.
+    /// \code
+    ///   switch (a &&
+    ///           b) {
+    /// \endcode
+    BBCBSS_No,
+  };
+
+  BreakBeforeCloseBracketSwitchStyle BreakBeforeCloseBracketSwitch;
+
   /// Different ways to break before concept declarations.
   enum BreakBeforeConceptDeclarationsStyle : int8_t {
     /// Keep the template declaration line together with ``concept``.
@@ -5458,7 +5605,6 @@ struct FormatStyle {
 
   bool operator==(const FormatStyle &R) const {
     return AccessModifierOffset == R.AccessModifierOffset &&
-           AlignAfterControlStatement == R.AlignAfterControlStatement &&
            AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
            AlignArrayOfStructures == R.AlignArrayOfStructures &&
            AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
@@ -5509,10 +5655,16 @@ struct FormatStyle {
            BreakAdjacentStringLiterals == R.BreakAdjacentStringLiterals &&
            BreakAfterAttributes == R.BreakAfterAttributes &&
            BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
+           BreakAfterOpenBracketIf == R.BreakAfterOpenBracketIf &&
+           BreakAfterOpenBracketLoop == R.BreakAfterOpenBracketLoop &&
+           BreakAfterOpenBracketSwitch == R.BreakAfterOpenBracketSwitch &&
            BreakAfterReturnType == R.BreakAfterReturnType &&
            BreakArrays == R.BreakArrays &&
            BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
            BreakBeforeBraces == R.BreakBeforeBraces &&
+           BreakBeforeCloseBracketIf == R.BreakBeforeCloseBracketIf &&
+           BreakBeforeCloseBracketLoop == R.BreakBeforeCloseBracketLoop &&
+           BreakBeforeCloseBracketSwitch == R.BreakBeforeCloseBracketSwitch &&
            BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations &&
            BreakBeforeInlineASMColon == R.BreakBeforeInlineASMColon &&
            BreakBeforeTemplateCloser == R.BreakBeforeTemplateCloser &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 190d2c3a97cd4..82cc3aee410d8 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -830,8 +830,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // parenthesis by disallowing any further line breaks if there is no line
   // break after the opening parenthesis. Don't break if it doesn't conserve
   // columns.
-  auto IsOtherConditional = [&](const FormatToken &Tok) {
-    return Tok.isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch) ||
+  auto IsLoopConditional = [&](const FormatToken &Tok) {
+    return Tok.isOneOf(tok::kw_for, tok::kw_while) ||
            (Style.isJavaScript() && Tok.is(Keywords.kw_await) && Tok.Previous &&
             Tok.Previous->is(tok::kw_for));
   };
@@ -849,12 +849,18 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
     if (Tok.Previous->isIf()) {
       /* For backward compatibility, use AlignAfterOpenBracket
        * in case AlignAfterControlStatement is not initialized */
-      return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine ||
-             (Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
-              Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
+      return Style.BreakAfterOpenBracketIf == FormatStyle::BAOBIS_MultiLine ||
+             Style.BreakAfterOpenBracketIf == FormatStyle::BAOBIS_Always;
+    }
+    if (IsLoopConditional(*Tok.Previous)) {
+      return Style.BreakAfterOpenBracketLoop == FormatStyle::BAOBLS_MultiLine ||
+             Style.BreakAfterOpenBracketLoop == FormatStyle::BAOBLS_Always;
+    }
+    if (Tok.Previous->is(tok::kw_switch)) {
+      return Style.BreakAfterOpenBracketSwitch ==
+                 FormatStyle::BAOBSS_MultiLine ||
+             Style.BreakAfterOpenBracketSwitch == FormatStyle::BAOBSS_Always;
     }
-    if (IsOtherConditional(*Tok.Previous))
-      return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
     if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
         Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
       return !Tok.Previous->is(TT_CastRParen) &&
@@ -899,8 +905,9 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
     }
     const auto *Previous = TokAfterLParen.Previous;
     assert(Previous); // IsOpeningBracket(Previous)
-    if (Previous->Previous && (Previous->Previous->isIf() ||
-                               IsOtherConditional(*Previous->Previous))) {
+    if (Previous->Previous &&
+        (Previous->Previous->isIf() || IsLoopConditional(*Previous->Previous) ||
+         Previous->Previous->is(tok::kw_switch))) {
       return false;
     }
     if (!Previous->isOneOf(TT_FunctionDeclarationLParen,
@@ -1282,16 +1289,32 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
 
   if (PreviousNonComment && PreviousNonComment->is(tok::l_paren)) {
     auto Previous = PreviousNonComment->Previous;
-    if (Previous &&
-        (Previous->isIf() ||
-         Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch))) {
-      CurrentState.BreakBeforeClosingParen =
-          Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine &&
-          Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
-    } else {
-      CurrentState.BreakBeforeClosingParen =
-          Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+    if (Previous) {
+
+      auto IsLoopConditional = [&](const FormatToken &Tok) {
+        return Tok.isOneOf(tok::kw_for, tok::kw_while) ||
+               (Style.isJavaScript() && Tok.is(Keywords.kw_await) &&
+                Tok.Previous && Tok.Previous->is(tok::kw_for));
+      };
+
+      if (Previous->isIf()) {
+        CurrentState.BreakBeforeClosingParen =
+            Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_MultiLine ||
+            Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_Always;
+      } else if (IsLoopConditional(*Previous)) {
+        CurrentState.BreakBeforeClosingParen =
+            Style.BreakBeforeCloseBracketLoop ==
+                FormatStyle::BBCBLS_MultiLine ||
+            Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_Always;
+      } else if (Previous->is(tok::kw_switch)) {
+        CurrentState.BreakBeforeClosingParen =
+            Style.BreakBeforeCloseBracketSwitch ==
+                FormatStyle::BBCBSS_MultiLine ||
+            Style.BreakBeforeCloseBracketSwitch == FormatStyle::BBCBSS_Always;
+      }
     }
+    CurrentState.BreakBeforeClosingParen =
+        Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
   }
 
   if (PreviousNonComment && PreviousNonComment->is(TT_TemplateOpener))
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b4685cdbb0125..2f2e239dad0a1 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -204,16 +204,6 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
   }
 };
 
-template <>
-struct ScalarEnumerationTraits<FormatStyle::BreakAfterControlStatementStyle> {
-  static void enumeration(IO &IO,
-                          FormatStyle::BreakAfterControlStatementStyle &Value) {
-    IO.enumCase(Value, "Default", FormatStyle::BACSS_Default);
-    IO.enumCase(Value, "MultiLine", FormatStyle::BACSS_MultiLine);
-    IO.enumCase(Value, "No", FormatStyle::BACSS_No);
-  }
-};
-
 template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
   static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
     IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
@@ -243,6 +233,67 @@ struct ScalarEnumerationTraits<
   }
 };
 
+template <>
+struct ScalarEnumerationTraits<FormatStyle::BreakAfterOpenBracketIfStyle> {
+  static void enumeration(IO &IO,
+                          FormatStyle::BreakAfterOpenBracketIfStyle &Value) {
+    IO.enumCase(Value, "Always", FormatStyle::BAOBIS_Always);
+    IO.enumCase(Value, "MultiLine", FormatStyle::BAOBIS_MultiLine);
+    IO.enumCase(Value, "No", FormatStyle::BAOBIS_No);
+  }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::BreakAfterOpenBracketLoopStyle> {
+  static void enumeration(IO &IO,
+                          FormatStyle::BreakAfterOpenBracketLoopStyle &Value) {
+    IO.enumCase(Value, "Always", FormatStyle::BAOBLS_Always);
+    IO.enumCase(Value, "MultiLine", FormatStyle::BAOBLS_MultiLine);
+    IO.enumCase(Value, "No", FormatStyle::BAOBLS_No);
+  }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::BreakAfterOpenBracketSwitchStyle> {
+  static void
+  enumeration(IO &IO, FormatStyle::BreakAfterOpenBracketSwitchStyle &Value) {
+    IO.enumCase(Value, "Always", FormatStyle::BAOBSS_Always);
+    IO.enumCase(Value, "MultiLine", FormatStyle::BAOBSS_MultiLine);
+    IO.enumCase(Value, "No", FormatStyle::BAOBSS_No);
+  }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::BreakBeforeCloseBracketIfStyle> {
+  static void enumeration(IO &IO,
+                          FormatStyle::BreakBeforeCloseBracketIfStyle &Value) {
+    IO.enumCase(Value, "Always", FormatStyle::BBCBIS_Always);
+    IO.enumCase(Value, "MultiLine", FormatStyle::BBCBIS_MultiLine);
+    IO.enumCase(Value, "No", FormatStyle::BBCBIS_No);
+  }
+};
+
+template <>
+struct ScalarEnumerationTraits<FormatStyle::BreakBeforeCloseBracketLoopStyle> {
+  static void
+  enumeration(IO &IO, FormatStyle::BreakBeforeCloseBracketLoopStyle &Value) {
+    IO.enumCase(Value, "Always", FormatStyle::BBCBLS_Always);
+    IO.enumCase(Value, "MultiLine", FormatStyle::BBCBLS_MultiLine);
+    IO.enumCase(Value, "No", FormatStyle::BBCBLS_No);
+  }
+};
+
+template <>
+struct ScalarEnumerationTraits<
+    FormatStyle::BreakBeforeCloseBracketSwitchStyle> {
+  static void
+  enumeration(IO &IO, FormatStyle::BreakBeforeCloseBracketSwitchStyle &Value) {
+    IO.enumCase(Value, "Always", FormatStyle::BBCBSS_Always);
+    IO.enumCase(Value, "MultiLine", FormatStyle::BBCBSS_MultiLine);
+    IO.enumCase(Value, "No", FormatStyle::BBCBSS_No);
+  }
+};
+
 template <>
 struct ScalarEnumerationTraits<
     FormatStyle::BreakBeforeConceptDeclarationsStyle> {
@@ -1013,8 +1064,6 @@ template <> struct MappingTraits<FormatStyle> {
 
     IO.mapOptional("AccessModifierOffset", Style.AccessModifierOffset);
     IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
-    IO.mapOptional("AlignAfterControlStatement",
-                   Style.AlignAfterControlStatement);
     IO.mapOptional("AlignArrayOfStructures", Style.AlignArrayOfStructures);
     IO.mapOptional("AlignConsecutiveAssignments",
                    Style.AlignConsecutiveAssignments);
@@ -1079,10 +1128,21 @@ template <> struct MappingTraits<FormatStyle> {
     IO.mapOptional("BreakAfterAttributes", Style.BreakAfterAttributes);
     IO.mapOptional("BreakAfterJavaFieldAnnotations",
                    Style.BreakAfterJavaFieldAnnotations);
+    IO.mapOptional("BreakAfterOpenBracketIf", Style.BreakAfterOpenBracketIf);
+    IO.mapOptional("BreakAfterOpenBracketLoop",
+                   Style.BreakAfterOpenBracketLoop);
+    IO.mapOptional("BreakAfterOpenBracketSwitch",
+                   Style.BreakAfterOpenBracketSwitch);
     IO.mapOptional("BreakAfterReturnType", Style.BreakAfterReturnType);
     IO.mapOptional("BreakArrays", Style.BreakArrays);
     IO.mapOptional("BreakBeforeBinaryOperators",
                    Style.BreakBeforeBinaryOperators);
+    IO.mapOptional("BreakBeforeCloseBracketIf",
+                   Style.BreakBeforeCloseBracketIf);
+    IO.mapOptional("BreakBeforeCloseBracketLoop",
+                   Style.BreakBeforeCloseBracketLoop);
+    IO.mapOptional("BreakBeforeCloseBracketSwitch",
+                   Style.BreakBeforeCloseBracketSwitch);
     IO.mapOptional("BreakBeforeConceptDeclarations",
                    Style.BreakBeforeConceptDeclarations);
     IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces);
@@ -1561,7 +1621,6 @@ static void expandPresetsSpacesInParens(FormatStyle &Expanded) {
 FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   FormatStyle LLVMStyle;
   LLVMStyle.AccessModifierOffset = -2;
-  LLVMStyle.AlignAfterControlStatement = FormatStyle::BACSS_Default;
   LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
   LLVMStyle.AlignConsecutiveAssignments = {};
@@ -1622,10 +1681,16 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   LLVMStyle.BreakAdjacentStringLiterals = true;
   LLVMStyle.BreakAfterAttributes = FormatStyle::ABS_Leave;
   LLVMStyle.BreakAfterJavaFieldAnnotations = false;
+  LLVMStyle.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_No;
+  LLVMStyle.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_No;
+  LLVMStyle.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_No;
   LLVMStyle.BreakAfterReturnType = FormatStyle::RTBS_None;
   LLVMStyle.BreakArrays = true;
   LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
+  LLVMStyle.BreakBeforeCloseBracketIf = FormatStyle::BBCBIS_No;
+  LLVMStyle.BreakBeforeCloseBracketLoop = FormatStyle::BBCBLS_No;
+  LLVMStyle.BreakBeforeCloseBracketSwitch = FormatStyle::BBCBSS_No;
   LLVMStyle.BreakBeforeConceptDeclarations = FormatStyle::BBCDS_Always;
   LLVMStyle.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
   LLVMStyle.BreakBeforeTemplateCloser = false;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 6d6f8f12163b2..3be16b31cf2d0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -6230,10 +6230,16 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
 
   // We only break before r_paren if we're in a block indented context.
   if (Right.is(tok::r_paren)) {
-    if (Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent ||
-        !Right.MatchingParen) {
+    bool might_break =
+        Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_Always ||
+        Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_MultiLine ||
+        Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_Always ||
+        Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_MultiLine ||
+        Style.BreakBeforeCloseBracketSwitch == FormatStyle::BBCBSS_Always ||
+        Style.BreakBeforeCloseBracketSwitch == FormatStyle::BBCBSS_MultiLine ||
+        Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+    if (!might_break || !Right.MatchingParen)
       return false;
-    }
     auto Next = Right.Next;
     if (Next && Next->is(tok::r_paren))
       Next = Next->Next;
@@ -6242,11 +6248,28 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
     const FormatToken *Previous = Right.MatchingParen->Previous;
     if (!Previous)
       return true;
-    if (Previous->isIf() ||
-        Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch)) {
-      return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
+    if (Previous->isIf()) {
+      return Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_Always ||
+             Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_MultiLine;
+    }
+    auto IsLoopConditional = [&](const FormatToken &Tok) {
+      return Tok.isOneOf(tok::kw_for, tok::kw_while) ||
+             (Style.isJavaScript() && Tok.is(Keywords.kw_await) &&
+              Tok.Previous && Tok.Previous->is(tok::kw_for));
+    };
+
+    if (IsLoopConditional(*Previous)) {
+      return Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_Always ||
+             Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_MultiLine;
     }
-    return true;
+
+    if (Previous->is(tok::kw_switch)) {
+      return Style.BreakBeforeCloseBracketSwitch ==
+                 FormatStyle::BBCBSS_Always ||
+             Style.BreakBeforeCloseBracketSwitch ==
+                 FormatStyle::BBCBSS_MultiLine;
+    }
+    return Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
   }
 
   if (Left.isOneOf(tok::r_paren, TT_TrailingAnnotation) &&
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 90f8202b182c2..2d9ba339bcbd8 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -534,14 +534,6 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma,
               FormatStyle::ETC_Remove);
 
-  Style.AlignAfterControlStatement = FormatStyle::BACSS_Default;
-  CHECK_PARSE("AlignAfterControlStatement: MultiLine",
-              AlignAfterControlStatement, FormatStyle::BACSS_MultiLine);
-  CHECK_PARSE("AlignAfterControlStatement: No", AlignAfterControlStatement,
-              FormatStyle::BACSS_No);
-  CHECK_PARSE("AlignAfterControlStatement: Default", AlignAfterControlStatement,
-              FormatStyle::BACSS_Default);
-
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
   CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
               FormatStyle::BAS_Align);
@@ -778,6 +770,30 @@ TEST(ConfigParseTest, ParsesConfiguration) {
               "  AfterControlStatement: false",
               BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Never);
 
+  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_No;
+  CHECK_PARSE("BreakAfterOpenBracketIf: MultiLine", BreakAfterOpenBracketIf,
+              FormatStyle::BAOBIS_MultiLine);
+  CHECK_PARSE("BreakAfterOpenBracketIf: No", BreakAfterOpenBracketIf,
+              FormatStyle::BAOBIS_No);
+  CHECK_PARSE("BreakAfterOpenBracketIf: Always", BreakAfterOpenBracketIf,
+              FormatStyle::BAOBIS_Always);
+
+  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_No;
+  CHECK_PARSE("BreakAfterOpenBracketLoop: MultiLine", BreakAfterOpenBracketLoop,
+              FormatStyle::BAOBLS_MultiLine);
+  CHECK_PARSE("BreakAfterOpenBracketLoop: No", BreakAfterOpenBracketLoop,
+              FormatStyle::BAOBLS_No);
+  CHECK_PARSE("BreakAfterOpenBracketLoop: Always", BreakAfterOpenBracketLoop,
+              FormatStyle::BAOBLS_Always);
+
+  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_No;
+  CHECK_PARSE("BreakAfterOpenBracketSwitch: MultiLine",
+              BreakAfterOpenBracketSwitch, FormatStyle::BAOBSS_MultiLine);
+  CHECK_PARSE("BreakAfterOpenBracketSwitch: No", BreakAfterOpenBracketSwitch,
+              FormatStyle::BAOBSS_No);
+  CHECK_PARSE("BreakAfterOpenBracketSwitch: Always",
+              BreakAfterOpenBracketSwitch, FormatStyle::BAOBSS_Always);
+
   Style.BreakAfterReturnType = FormatStyle::RTBS_All;
   CHECK_PARSE("BreakAfterReturnType: None", BreakAfterReturnType,
               FormatStyle::RTBS_None);
@@ -1092,6 +1108,30 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("RequiresClausePosition: OwnLine", RequiresClausePosition,
               FormatStyle::RCPS_OwnLine);
 
+  Style.BreakBeforeCloseBracketIf = FormatStyle::BBCBIS_No;
+  CHECK_PARSE("BreakBeforeCloseBracketIf: MultiLine", BreakBeforeCloseBracketIf,
+              FormatStyle::BBCBIS_MultiLine);
+  CHECK_PARSE("BreakBeforeCloseBracketIf: No", BreakBeforeCloseBracketIf,
+              FormatStyle::BBCBIS_No);
+  CHECK_PARSE("BreakBeforeCloseBracketIf: Always", BreakBeforeCloseBracketIf,
+              FormatStyle::BBCBIS_Always);
+
+  Style.BreakBeforeCloseBracketLoop = FormatStyle::BBCBLS_No;
+  CHECK_PARSE("BreakBeforeCloseBracketLoop: MultiLine",
+              BreakBeforeCloseBracketLoop, FormatStyle::BBCBLS_MultiLine);
+  CHECK_PARSE("BreakBeforeCloseBracketLoop: No", BreakBeforeCloseBracketLoop,
+              FormatStyle::BBCBLS_No);
+  CHECK_PARSE("BreakBeforeCloseBracketLoop: Always",
+              BreakBeforeCloseBracketLoop, FormatStyle::BBCBLS_Always);
+
+  Style.BreakBeforeCloseBracketSwitch = FormatStyle::BBCBSS_No;
+  CHECK_PARSE("BreakBeforeCloseBracketSwitch: MultiLine",
+              BreakBeforeCloseBracketSwitch, FormatStyle::BBCBSS_MultiLine);
+  CHECK_PARSE("BreakBeforeCloseBracketSwitch: No",
+              BreakBeforeCloseBracketSwitch, FormatStyle::BBCBSS_No);
+  CHECK_PARSE("BreakBeforeCloseBracketSwitch: Always",
+              BreakBeforeCloseBracketSwitch, FormatStyle::BBCBSS_Always);
+
   CHECK_PARSE("BreakBeforeConceptDeclarations: Never",
               BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Never);
   CHECK_PARSE("BreakBeforeConceptDeclarations: Always",
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 471c1facc26b3..91b5544e16803 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9427,7 +9427,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
   FormatStyle Style = getLLVMStyle();
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
+  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_MultiLine;
+  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_MultiLine;
+  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_MultiLine;
 
   verifyFormat("void foo() {\n"
                "  if constexpr (\n"
@@ -9478,7 +9480,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
       Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
+  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_MultiLine;
+  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_MultiLine;
+  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_MultiLine;
 
   verifyFormat("void foo() {\n"
                "  if constexpr (\n"
@@ -9527,7 +9531,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
                Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
+  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_MultiLine;
+  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_MultiLine;
+  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_MultiLine;
 
   verifyFormat("void foo() {\n"
                "  if constexpr (\n"
@@ -9576,7 +9582,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
                Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  Style.AlignAfterControlStatement = FormatStyle::BACSS_No;
+  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_No;
+  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_No;
+  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_No;
 
   verifyFormat("void foo() {\n"
                "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
@@ -9623,7 +9631,12 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
       Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
-  Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
+  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_MultiLine;
+  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_MultiLine;
+  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_MultiLine;
+  Style.BreakBeforeCloseBracketIf = FormatStyle::BBCBIS_MultiLine;
+  Style.BreakBeforeCloseBracketLoop = FormatStyle::BBCBLS_MultiLine;
+  Style.BreakBeforeCloseBracketSwitch = FormatStyle::BBCBSS_MultiLine;
 
   verifyFormat(
       "void foo() {\n"
@@ -9675,7 +9688,12 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
                Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
-  Style.AlignAfterControlStatement = FormatStyle::BACSS_No;
+  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_No;
+  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_No;
+  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_No;
+  Style.BreakBeforeCloseBracketIf = FormatStyle::BBCBIS_No;
+  Style.BreakBeforeCloseBracketLoop = FormatStyle::BBCBLS_No;
+  Style.BreakBeforeCloseBracketSwitch = FormatStyle::BBCBSS_No;
 
   verifyFormat("void foo() {\n"
                "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"

>From 965d82971bb5399daddf02accdbceacf3e440225 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Wed, 21 May 2025 16:44:48 -0600
Subject: [PATCH 03/48] Change to use bool options for each control statement

---
 clang/include/clang/Format/Format.h        | 205 ++++++---------------
 clang/lib/Format/ContinuationIndenter.cpp  |  47 ++---
 clang/lib/Format/Format.cpp                |  76 +-------
 clang/lib/Format/TokenAnnotator.cpp        |  37 +---
 clang/unittests/Format/ConfigParseTest.cpp |  54 +-----
 clang/unittests/Format/FormatTest.cpp      |  48 ++---
 6 files changed, 121 insertions(+), 346 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 2106b358a57da..9f637878c80e7 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,86 +62,38 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
-  /// Different styles for breaking the parenthesis after ``if/else if``.
+  /// Force break after the left parenthesis of an if control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   if constexpr (          vs.       if constexpr (a ||
+  ///                 a ||                              b)
+  ///                 b)
+  /// \endcode
   /// \version 21
-  enum BreakAfterOpenBracketIfStyle : int8_t {
-    /// Always break the opening parenthesis of an if statement, e.g.:
-    /// \code
-    ///   if constexpr (
-    ///                 a)
-    /// \endcode
-    BAOBIS_Always,
-    /// Force break after the left parenthesis of an if statement only
-    /// when the expression exceeds the column limit, e.g..:
-    /// \code
-    ///   if constexpr (
-    ///                 a ||
-    ///                 b)
-    /// \endcode
-    BAOBIS_MultiLine,
-    /// Do not force a break after the control statement.
-    /// \code
-    ///   if constexpr (a ||
-    ///                 b
-    /// \endcode
-    BAOBIS_No,
-  };
-
-  BreakAfterOpenBracketIfStyle BreakAfterOpenBracketIf;
+  bool BreakAfterOpenBracketIf;
 
-  /// Different styles for breaking the parenthesis after loops ``(for/while)``.
+  /// Force break after the left parenthesis of a loop control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   while (                  vs.      while (a &&
+  ///          a &&                              b) {
+  ///          b) {
+  /// \endcode
   /// \version 21
-  enum BreakAfterOpenBracketLoopStyle : int8_t {
-    /// Always break the opening parenthesis of a loop statement, e.g.:
-    /// \code
-    ///   while (
-    ///          a) {
-    /// \endcode
-    BAOBLS_Always,
-    /// Force break after the left parenthesis of a loop only
-    /// when the expression exceeds the column limit, e.g..:
-    /// \code
-    ///   while (
-    ///          a &&
-    ///          b) {
-    /// \endcode
-    BAOBLS_MultiLine,
-    /// Do not force a break after the control statement.
-    /// \code
-    ///   while (a &&
-    ///          b) {
-    /// \endcode
-    BAOBLS_No,
-  };
+  bool BreakAfterOpenBracketLoop;
 
-  BreakAfterOpenBracketLoopStyle BreakAfterOpenBracketLoop;
-
-  /// Different styles for breaking the parenthesis after ``switch``.
+  /// Force break after the left parenthesis of a switch control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   switch (                 vs.      switch (a &&
+  ///           a &&                              b) {
+  ///           b) {
+  /// \endcode
   /// \version 21
-  enum BreakAfterOpenBracketSwitchStyle : int8_t {
-    /// Always break the opening parenthesis of a switch statement, e.g.:
-    /// \code
-    ///   switch (
-    ///           a) {
-    /// \endcode
-    BAOBSS_Always,
-    /// Force break after the left parenthesis of a switch only
-    /// when the expression exceeds the column limit, e.g..:
-    /// \code
-    ///   switch (
-    ///           a &&
-    ///           b) {
-    /// \endcode
-    BAOBSS_MultiLine,
-    /// Do not force a break after the control statement.
-    /// \code
-    ///   switch (a &&
-    ///           b) {
-    /// \endcode
-    BAOBSS_No,
-  };
-
-  BreakAfterOpenBracketSwitchStyle BreakAfterOpenBracketSwitch;
+  bool BreakAfterOpenBracketSwitch;
 
   /// Different styles for aligning after open brackets.
   enum BracketAlignmentStyle : int8_t {
@@ -2302,87 +2254,38 @@ struct FormatStyle {
   /// \version 3.7
   BraceBreakingStyle BreakBeforeBraces;
 
-  /// Different styles for breaking before ``if/else if`` closing parenthesis.
+  /// Force break before the right parenthesis of an if control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   if constexpr (a ||      vs.       if constexpr (a ||
+  ///                 b                                 b)
+  ///                 )
+  /// \endcode
   /// \version 21
-  enum BreakBeforeCloseBracketIfStyle : int8_t {
-    /// Always break the closing parenthesis of an if statement, e.g.:
-    /// \code
-    ///   if constexpr (a
-    ///                )
-    /// \endcode
-    BBCBIS_Always,
-    /// Force break before the closing parenthesis of an if statement only
-    /// when the expression exceeds the column limit, e.g..:
-    /// \code
-    ///   if constexpr (a ||
-    ///                 b
-    ///                )
-    /// \endcode
-    BBCBIS_MultiLine,
-    /// Do not force a break before closing the if control statement.
-    /// \code
-    ///   if constexpr (a ||
-    ///                 b)
-    /// \endcode
-    BBCBIS_No,
-  };
-
-  BreakBeforeCloseBracketIfStyle BreakBeforeCloseBracketIf;
+  bool BreakBeforeCloseBracketIf;
 
-  /// Different styles for breaking before loop ``(for/while)`` closing
-  /// parenthesis.
+  /// Force break before the right parenthesis of a loop control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   while (a &&              vs.      while (a &&
+  ///          b                                 b) {
+  ///          ) {
+  /// \endcode
   /// \version 21
-  enum BreakBeforeCloseBracketLoopStyle : int8_t {
-    /// Always break the closing parenthesis of a loop statement, e.g.:
-    /// \code
-    ///   while (a
-    ///         ) {
-    /// \endcode
-    BBCBLS_Always,
-    /// Force break before the closing parenthesis of a loop only
-    /// when the expression exceeds the column limit, e.g..:
-    /// \code
-    ///   while (a &&
-    ///          b
-    ///         ) {
-    /// \endcode
-    BBCBLS_MultiLine,
-    /// Do not force a break before closing the loop control statement.
-    /// \code
-    ///   while (a &&
-    ///          b) {
-    /// \endcode
-    BBCBLS_No,
-  };
+  bool BreakBeforeCloseBracketLoop;
 
-  BreakBeforeCloseBracketLoopStyle BreakBeforeCloseBracketLoop;
-
-  /// Different styles for breaking before ``switch`` closing parenthesis.
+  /// Force break before the right parenthesis of a switch control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   switch (a &&             vs.      switch (a &&
+  ///           b                                 b) {
+  ///           ) {
+  /// \endcode
   /// \version 21
-  enum BreakBeforeCloseBracketSwitchStyle : int8_t {
-    /// Always break before the closing parenthesis of a switch statement, e.g.:
-    /// \code
-    ///   switch (a
-    ///          )  {
-    /// \endcode
-    BBCBSS_Always,
-    /// Force break before the closing parenthesis of a switch only
-    /// when the expression exceeds the column limit, e.g..:
-    /// \code
-    ///   switch (a &&
-    ///           b
-    ///           ) {
-    /// \endcode
-    BBCBSS_MultiLine,
-    /// Do not force a break before closing the switch control statement.
-    /// \code
-    ///   switch (a &&
-    ///           b) {
-    /// \endcode
-    BBCBSS_No,
-  };
-
-  BreakBeforeCloseBracketSwitchStyle BreakBeforeCloseBracketSwitch;
+  bool BreakBeforeCloseBracketSwitch;
 
   /// Different ways to break before concept declarations.
   enum BreakBeforeConceptDeclarationsStyle : int8_t {
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 82cc3aee410d8..4f8da85887f15 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -358,10 +358,13 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
 
   // Allow breaking before the right parens with block indentation if there was
   // a break after the left parens, which is tracked by BreakBeforeClosingParen.
-  if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent &&
-      Current.is(tok::r_paren)) {
+  bool might_break_before =
+      Style.BreakBeforeCloseBracketIf || Style.BreakBeforeCloseBracketLoop ||
+      Style.BreakBeforeCloseBracketSwitch ||
+      Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+
+  if (might_break_before && Current.is(tok::r_paren))
     return CurrentState.BreakBeforeClosingParen;
-  }
 
   if (Style.BreakBeforeTemplateCloser && Current.is(TT_TemplateCloser))
     return CurrentState.BreakBeforeClosingAngle;
@@ -846,21 +849,12 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
     }
     if (!Tok.Previous)
       return true;
-    if (Tok.Previous->isIf()) {
-      /* For backward compatibility, use AlignAfterOpenBracket
-       * in case AlignAfterControlStatement is not initialized */
-      return Style.BreakAfterOpenBracketIf == FormatStyle::BAOBIS_MultiLine ||
-             Style.BreakAfterOpenBracketIf == FormatStyle::BAOBIS_Always;
-    }
-    if (IsLoopConditional(*Tok.Previous)) {
-      return Style.BreakAfterOpenBracketLoop == FormatStyle::BAOBLS_MultiLine ||
-             Style.BreakAfterOpenBracketLoop == FormatStyle::BAOBLS_Always;
-    }
-    if (Tok.Previous->is(tok::kw_switch)) {
-      return Style.BreakAfterOpenBracketSwitch ==
-                 FormatStyle::BAOBSS_MultiLine ||
-             Style.BreakAfterOpenBracketSwitch == FormatStyle::BAOBSS_Always;
-    }
+    if (Tok.Previous->isIf())
+      return Style.BreakAfterOpenBracketIf;
+    if (IsLoopConditional(*Tok.Previous))
+      return Style.BreakAfterOpenBracketLoop;
+    if (Tok.Previous->is(tok::kw_switch))
+      return Style.BreakAfterOpenBracketSwitch;
     if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
         Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
       return !Tok.Previous->is(TT_CastRParen) &&
@@ -1298,23 +1292,18 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
       };
 
       if (Previous->isIf()) {
-        CurrentState.BreakBeforeClosingParen =
-            Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_MultiLine ||
-            Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_Always;
+        CurrentState.BreakBeforeClosingParen = Style.BreakBeforeCloseBracketIf;
       } else if (IsLoopConditional(*Previous)) {
         CurrentState.BreakBeforeClosingParen =
-            Style.BreakBeforeCloseBracketLoop ==
-                FormatStyle::BBCBLS_MultiLine ||
-            Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_Always;
+            Style.BreakBeforeCloseBracketLoop;
       } else if (Previous->is(tok::kw_switch)) {
         CurrentState.BreakBeforeClosingParen =
-            Style.BreakBeforeCloseBracketSwitch ==
-                FormatStyle::BBCBSS_MultiLine ||
-            Style.BreakBeforeCloseBracketSwitch == FormatStyle::BBCBSS_Always;
+            Style.BreakBeforeCloseBracketSwitch;
+      } else {
+        CurrentState.BreakBeforeClosingParen =
+            Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
       }
     }
-    CurrentState.BreakBeforeClosingParen =
-        Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
   }
 
   if (PreviousNonComment && PreviousNonComment->is(TT_TemplateOpener))
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f2e239dad0a1..a6019c6a1e431 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -233,67 +233,6 @@ struct ScalarEnumerationTraits<
   }
 };
 
-template <>
-struct ScalarEnumerationTraits<FormatStyle::BreakAfterOpenBracketIfStyle> {
-  static void enumeration(IO &IO,
-                          FormatStyle::BreakAfterOpenBracketIfStyle &Value) {
-    IO.enumCase(Value, "Always", FormatStyle::BAOBIS_Always);
-    IO.enumCase(Value, "MultiLine", FormatStyle::BAOBIS_MultiLine);
-    IO.enumCase(Value, "No", FormatStyle::BAOBIS_No);
-  }
-};
-
-template <>
-struct ScalarEnumerationTraits<FormatStyle::BreakAfterOpenBracketLoopStyle> {
-  static void enumeration(IO &IO,
-                          FormatStyle::BreakAfterOpenBracketLoopStyle &Value) {
-    IO.enumCase(Value, "Always", FormatStyle::BAOBLS_Always);
-    IO.enumCase(Value, "MultiLine", FormatStyle::BAOBLS_MultiLine);
-    IO.enumCase(Value, "No", FormatStyle::BAOBLS_No);
-  }
-};
-
-template <>
-struct ScalarEnumerationTraits<FormatStyle::BreakAfterOpenBracketSwitchStyle> {
-  static void
-  enumeration(IO &IO, FormatStyle::BreakAfterOpenBracketSwitchStyle &Value) {
-    IO.enumCase(Value, "Always", FormatStyle::BAOBSS_Always);
-    IO.enumCase(Value, "MultiLine", FormatStyle::BAOBSS_MultiLine);
-    IO.enumCase(Value, "No", FormatStyle::BAOBSS_No);
-  }
-};
-
-template <>
-struct ScalarEnumerationTraits<FormatStyle::BreakBeforeCloseBracketIfStyle> {
-  static void enumeration(IO &IO,
-                          FormatStyle::BreakBeforeCloseBracketIfStyle &Value) {
-    IO.enumCase(Value, "Always", FormatStyle::BBCBIS_Always);
-    IO.enumCase(Value, "MultiLine", FormatStyle::BBCBIS_MultiLine);
-    IO.enumCase(Value, "No", FormatStyle::BBCBIS_No);
-  }
-};
-
-template <>
-struct ScalarEnumerationTraits<FormatStyle::BreakBeforeCloseBracketLoopStyle> {
-  static void
-  enumeration(IO &IO, FormatStyle::BreakBeforeCloseBracketLoopStyle &Value) {
-    IO.enumCase(Value, "Always", FormatStyle::BBCBLS_Always);
-    IO.enumCase(Value, "MultiLine", FormatStyle::BBCBLS_MultiLine);
-    IO.enumCase(Value, "No", FormatStyle::BBCBLS_No);
-  }
-};
-
-template <>
-struct ScalarEnumerationTraits<
-    FormatStyle::BreakBeforeCloseBracketSwitchStyle> {
-  static void
-  enumeration(IO &IO, FormatStyle::BreakBeforeCloseBracketSwitchStyle &Value) {
-    IO.enumCase(Value, "Always", FormatStyle::BBCBSS_Always);
-    IO.enumCase(Value, "MultiLine", FormatStyle::BBCBSS_MultiLine);
-    IO.enumCase(Value, "No", FormatStyle::BBCBSS_No);
-  }
-};
-
 template <>
 struct ScalarEnumerationTraits<
     FormatStyle::BreakBeforeConceptDeclarationsStyle> {
@@ -1681,16 +1620,16 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   LLVMStyle.BreakAdjacentStringLiterals = true;
   LLVMStyle.BreakAfterAttributes = FormatStyle::ABS_Leave;
   LLVMStyle.BreakAfterJavaFieldAnnotations = false;
-  LLVMStyle.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_No;
-  LLVMStyle.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_No;
-  LLVMStyle.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_No;
+  LLVMStyle.BreakAfterOpenBracketIf = false;
+  LLVMStyle.BreakAfterOpenBracketLoop = false;
+  LLVMStyle.BreakAfterOpenBracketSwitch = false;
   LLVMStyle.BreakAfterReturnType = FormatStyle::RTBS_None;
   LLVMStyle.BreakArrays = true;
   LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
-  LLVMStyle.BreakBeforeCloseBracketIf = FormatStyle::BBCBIS_No;
-  LLVMStyle.BreakBeforeCloseBracketLoop = FormatStyle::BBCBLS_No;
-  LLVMStyle.BreakBeforeCloseBracketSwitch = FormatStyle::BBCBSS_No;
+  LLVMStyle.BreakBeforeCloseBracketIf = false;
+  LLVMStyle.BreakBeforeCloseBracketLoop = false;
+  LLVMStyle.BreakBeforeCloseBracketSwitch = false;
   LLVMStyle.BreakBeforeConceptDeclarations = FormatStyle::BBCDS_Always;
   LLVMStyle.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
   LLVMStyle.BreakBeforeTemplateCloser = false;
@@ -1956,6 +1895,9 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
     GoogleStyle.SpacesBeforeTrailingComments = 1;
   } else if (Language == FormatStyle::LK_JavaScript) {
     GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+    GoogleStyle.BreakAfterOpenBracketIf = true;
+    GoogleStyle.BreakAfterOpenBracketLoop = false;
+    GoogleStyle.BreakAfterOpenBracketSwitch = false;
     GoogleStyle.AlignOperands = FormatStyle::OAS_DontAlign;
     GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
     // TODO: still under discussion whether to switch to SLS_All.
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 3be16b31cf2d0..8004346b1f5d9 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -6228,17 +6228,10 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
                                    (Right.isBlockIndentedInitRBrace(Style)));
   }
 
-  // We only break before r_paren if we're in a block indented context.
+  // We can break before r_paren if we're in a block indented context or
+  // a control statement with an explicit style option.
   if (Right.is(tok::r_paren)) {
-    bool might_break =
-        Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_Always ||
-        Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_MultiLine ||
-        Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_Always ||
-        Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_MultiLine ||
-        Style.BreakBeforeCloseBracketSwitch == FormatStyle::BBCBSS_Always ||
-        Style.BreakBeforeCloseBracketSwitch == FormatStyle::BBCBSS_MultiLine ||
-        Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
-    if (!might_break || !Right.MatchingParen)
+    if (!Right.MatchingParen)
       return false;
     auto Next = Right.Next;
     if (Next && Next->is(tok::r_paren))
@@ -6247,28 +6240,18 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
       return false;
     const FormatToken *Previous = Right.MatchingParen->Previous;
     if (!Previous)
-      return true;
-    if (Previous->isIf()) {
-      return Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_Always ||
-             Style.BreakBeforeCloseBracketIf == FormatStyle::BBCBIS_MultiLine;
-    }
+      return false;
+    if (Previous->isIf())
+      return Style.BreakBeforeCloseBracketIf;
     auto IsLoopConditional = [&](const FormatToken &Tok) {
       return Tok.isOneOf(tok::kw_for, tok::kw_while) ||
              (Style.isJavaScript() && Tok.is(Keywords.kw_await) &&
               Tok.Previous && Tok.Previous->is(tok::kw_for));
     };
-
-    if (IsLoopConditional(*Previous)) {
-      return Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_Always ||
-             Style.BreakBeforeCloseBracketLoop == FormatStyle::BBCBLS_MultiLine;
-    }
-
-    if (Previous->is(tok::kw_switch)) {
-      return Style.BreakBeforeCloseBracketSwitch ==
-                 FormatStyle::BBCBSS_Always ||
-             Style.BreakBeforeCloseBracketSwitch ==
-                 FormatStyle::BBCBSS_MultiLine;
-    }
+    if (IsLoopConditional(*Previous))
+      return Style.BreakBeforeCloseBracketLoop;
+    if (Previous->is(tok::kw_switch))
+      return Style.BreakBeforeCloseBracketSwitch;
     return Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
   }
 
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 2d9ba339bcbd8..1f49eda98d4b8 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -172,6 +172,12 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
   CHECK_PARSE_BOOL(BinPackLongBracedList);
   CHECK_PARSE_BOOL(BreakAdjacentStringLiterals);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
+  CHECK_PARSE_BOOL(BreakAfterOpenBracketIf);
+  CHECK_PARSE_BOOL(BreakAfterOpenBracketLoop);
+  CHECK_PARSE_BOOL(BreakAfterOpenBracketSwitch);
+  CHECK_PARSE_BOOL(BreakBeforeCloseBracketIf);
+  CHECK_PARSE_BOOL(BreakBeforeCloseBracketLoop);
+  CHECK_PARSE_BOOL(BreakBeforeCloseBracketSwitch);
   CHECK_PARSE_BOOL(BreakBeforeTemplateCloser);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
@@ -770,30 +776,6 @@ TEST(ConfigParseTest, ParsesConfiguration) {
               "  AfterControlStatement: false",
               BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Never);
 
-  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_No;
-  CHECK_PARSE("BreakAfterOpenBracketIf: MultiLine", BreakAfterOpenBracketIf,
-              FormatStyle::BAOBIS_MultiLine);
-  CHECK_PARSE("BreakAfterOpenBracketIf: No", BreakAfterOpenBracketIf,
-              FormatStyle::BAOBIS_No);
-  CHECK_PARSE("BreakAfterOpenBracketIf: Always", BreakAfterOpenBracketIf,
-              FormatStyle::BAOBIS_Always);
-
-  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_No;
-  CHECK_PARSE("BreakAfterOpenBracketLoop: MultiLine", BreakAfterOpenBracketLoop,
-              FormatStyle::BAOBLS_MultiLine);
-  CHECK_PARSE("BreakAfterOpenBracketLoop: No", BreakAfterOpenBracketLoop,
-              FormatStyle::BAOBLS_No);
-  CHECK_PARSE("BreakAfterOpenBracketLoop: Always", BreakAfterOpenBracketLoop,
-              FormatStyle::BAOBLS_Always);
-
-  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_No;
-  CHECK_PARSE("BreakAfterOpenBracketSwitch: MultiLine",
-              BreakAfterOpenBracketSwitch, FormatStyle::BAOBSS_MultiLine);
-  CHECK_PARSE("BreakAfterOpenBracketSwitch: No", BreakAfterOpenBracketSwitch,
-              FormatStyle::BAOBSS_No);
-  CHECK_PARSE("BreakAfterOpenBracketSwitch: Always",
-              BreakAfterOpenBracketSwitch, FormatStyle::BAOBSS_Always);
-
   Style.BreakAfterReturnType = FormatStyle::RTBS_All;
   CHECK_PARSE("BreakAfterReturnType: None", BreakAfterReturnType,
               FormatStyle::RTBS_None);
@@ -1108,30 +1090,6 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("RequiresClausePosition: OwnLine", RequiresClausePosition,
               FormatStyle::RCPS_OwnLine);
 
-  Style.BreakBeforeCloseBracketIf = FormatStyle::BBCBIS_No;
-  CHECK_PARSE("BreakBeforeCloseBracketIf: MultiLine", BreakBeforeCloseBracketIf,
-              FormatStyle::BBCBIS_MultiLine);
-  CHECK_PARSE("BreakBeforeCloseBracketIf: No", BreakBeforeCloseBracketIf,
-              FormatStyle::BBCBIS_No);
-  CHECK_PARSE("BreakBeforeCloseBracketIf: Always", BreakBeforeCloseBracketIf,
-              FormatStyle::BBCBIS_Always);
-
-  Style.BreakBeforeCloseBracketLoop = FormatStyle::BBCBLS_No;
-  CHECK_PARSE("BreakBeforeCloseBracketLoop: MultiLine",
-              BreakBeforeCloseBracketLoop, FormatStyle::BBCBLS_MultiLine);
-  CHECK_PARSE("BreakBeforeCloseBracketLoop: No", BreakBeforeCloseBracketLoop,
-              FormatStyle::BBCBLS_No);
-  CHECK_PARSE("BreakBeforeCloseBracketLoop: Always",
-              BreakBeforeCloseBracketLoop, FormatStyle::BBCBLS_Always);
-
-  Style.BreakBeforeCloseBracketSwitch = FormatStyle::BBCBSS_No;
-  CHECK_PARSE("BreakBeforeCloseBracketSwitch: MultiLine",
-              BreakBeforeCloseBracketSwitch, FormatStyle::BBCBSS_MultiLine);
-  CHECK_PARSE("BreakBeforeCloseBracketSwitch: No",
-              BreakBeforeCloseBracketSwitch, FormatStyle::BBCBSS_No);
-  CHECK_PARSE("BreakBeforeCloseBracketSwitch: Always",
-              BreakBeforeCloseBracketSwitch, FormatStyle::BBCBSS_Always);
-
   CHECK_PARSE("BreakBeforeConceptDeclarations: Never",
               BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Never);
   CHECK_PARSE("BreakBeforeConceptDeclarations: Always",
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 91b5544e16803..c9e6d3864f8c3 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9427,9 +9427,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
   FormatStyle Style = getLLVMStyle();
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_MultiLine;
-  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_MultiLine;
-  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_MultiLine;
+  Style.BreakAfterOpenBracketIf = true;
+  Style.BreakAfterOpenBracketLoop = true;
+  Style.BreakAfterOpenBracketSwitch = true;
 
   verifyFormat("void foo() {\n"
                "  if constexpr (\n"
@@ -9480,9 +9480,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
       Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_MultiLine;
-  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_MultiLine;
-  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_MultiLine;
+  Style.BreakAfterOpenBracketIf = true;
+  Style.BreakAfterOpenBracketLoop = true;
+  Style.BreakAfterOpenBracketSwitch = true;
 
   verifyFormat("void foo() {\n"
                "  if constexpr (\n"
@@ -9531,9 +9531,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
                Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_MultiLine;
-  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_MultiLine;
-  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_MultiLine;
+  Style.BreakAfterOpenBracketIf = true;
+  Style.BreakAfterOpenBracketLoop = true;
+  Style.BreakAfterOpenBracketSwitch = true;
 
   verifyFormat("void foo() {\n"
                "  if constexpr (\n"
@@ -9582,9 +9582,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
                Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_No;
-  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_No;
-  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_No;
+  Style.BreakAfterOpenBracketIf = false;
+  Style.BreakAfterOpenBracketLoop = false;
+  Style.BreakAfterOpenBracketSwitch = false;
 
   verifyFormat("void foo() {\n"
                "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
@@ -9631,12 +9631,12 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
       Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
-  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_MultiLine;
-  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_MultiLine;
-  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_MultiLine;
-  Style.BreakBeforeCloseBracketIf = FormatStyle::BBCBIS_MultiLine;
-  Style.BreakBeforeCloseBracketLoop = FormatStyle::BBCBLS_MultiLine;
-  Style.BreakBeforeCloseBracketSwitch = FormatStyle::BBCBSS_MultiLine;
+  Style.BreakAfterOpenBracketIf = true;
+  Style.BreakAfterOpenBracketLoop = true;
+  Style.BreakAfterOpenBracketSwitch = true;
+  Style.BreakBeforeCloseBracketIf = true;
+  Style.BreakBeforeCloseBracketLoop = true;
+  Style.BreakBeforeCloseBracketSwitch = true;
 
   verifyFormat(
       "void foo() {\n"
@@ -9688,12 +9688,12 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
                Style);
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
-  Style.BreakAfterOpenBracketIf = FormatStyle::BAOBIS_No;
-  Style.BreakAfterOpenBracketLoop = FormatStyle::BAOBLS_No;
-  Style.BreakAfterOpenBracketSwitch = FormatStyle::BAOBSS_No;
-  Style.BreakBeforeCloseBracketIf = FormatStyle::BBCBIS_No;
-  Style.BreakBeforeCloseBracketLoop = FormatStyle::BBCBLS_No;
-  Style.BreakBeforeCloseBracketSwitch = FormatStyle::BBCBSS_No;
+  Style.BreakAfterOpenBracketIf = false;
+  Style.BreakAfterOpenBracketLoop = false;
+  Style.BreakAfterOpenBracketSwitch = false;
+  Style.BreakBeforeCloseBracketIf = false;
+  Style.BreakBeforeCloseBracketLoop = false;
+  Style.BreakBeforeCloseBracketSwitch = false;
 
   verifyFormat("void foo() {\n"
                "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"

>From a576f70d6bf364e8a5d1471a997a0c8aead5b9fd Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Wed, 21 May 2025 17:39:58 -0600
Subject: [PATCH 04/48] update clang-format-style

---
 clang/docs/ClangFormatStyleOptions.rst | 78 ++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index b746df5dab264..9c34af0f75778 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2746,6 +2746,45 @@ the configuration (without a prefix: ``Auto``).
      @Mock
      DataLoad loader;
 
+.. _BreakAfterOpenBracketIf:
+
+**BreakAfterOpenBracketIf** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakAfterOpenBracketIf>`
+  Force break after the left parenthesis of an if control statement
+  when the expression exceeds the column limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    if constexpr (          vs.       if constexpr (a ||
+                  a ||                              b)
+                  b)
+
+.. _BreakAfterOpenBracketLoop:
+
+**BreakAfterOpenBracketLoop** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakAfterOpenBracketLoop>`
+  Force break after the left parenthesis of a loop control statement
+  when the expression exceeds the column limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    while (                  vs.      while (a &&
+           a &&                              b) {
+           b) {
+
+.. _BreakAfterOpenBracketSwitch:
+
+**BreakAfterOpenBracketSwitch** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakAfterOpenBracketSwitch>`
+  Force break after the left parenthesis of a switch control statement
+  when the expression exceeds the column limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    switch (                 vs.      switch (a &&
+            a &&                              b) {
+            b) {
+
 .. _BreakAfterReturnType:
 
 **BreakAfterReturnType** (``ReturnTypeBreakingStyle``) :versionbadge:`clang-format 19` :ref:`¶ <BreakAfterReturnType>`
@@ -3383,6 +3422,45 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+.. _BreakBeforeCloseBracketIf:
+
+**BreakBeforeCloseBracketIf** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakBeforeCloseBracketIf>`
+  Force break before the right parenthesis of an if control statement
+  when the expression exceeds the column limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    if constexpr (a ||      vs.       if constexpr (a ||
+                  b                                 b)
+                  )
+
+.. _BreakBeforeCloseBracketLoop:
+
+**BreakBeforeCloseBracketLoop** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakBeforeCloseBracketLoop>`
+  Force break before the right parenthesis of a loop control statement
+  when the expression exceeds the column limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    while (a &&              vs.      while (a &&
+           b                                 b) {
+           ) {
+
+.. _BreakBeforeCloseBracketSwitch:
+
+**BreakBeforeCloseBracketSwitch** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakBeforeCloseBracketSwitch>`
+  Force break before the right parenthesis of a switch control statement
+  when the expression exceeds the column limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    switch (a &&             vs.      switch (a &&
+            b                                 b) {
+            ) {
+
 .. _BreakBeforeConceptDeclarations:
 
 **BreakBeforeConceptDeclarations** (``BreakBeforeConceptDeclarationsStyle``) :versionbadge:`clang-format 12` :ref:`¶ <BreakBeforeConceptDeclarations>`

>From f0be35d548f7fcaa59a02739ba5a3bad965873a2 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Wed, 21 May 2025 17:47:09 -0600
Subject: [PATCH 05/48] update tests

---
 clang/unittests/Format/FormatTest.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index c9e6d3864f8c3..491cbe93e26fe 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9498,6 +9498,20 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
                "  }\n"
                "}",
                Style);
+  Style.BreakAfterOpenBracketIf = false;
+  verifyFormat("void foo() {\n"
+               "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
+               "                 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               "bbbbbbbbbb) ==\n"
+               "                0) {\n"
+               "    return;\n"
+               "  } else if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
+               "              bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+               "bbbbbbb) == 0) {\n"
+               "    return;\n"
+               "  }\n"
+               "}",
+               Style);
 
   verifyFormat("void foo() {\n"
                "  switch (\n"

>From fbf73858785c83021586dab43ca86cc9807e8810 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Wed, 21 May 2025 20:59:10 -0600
Subject: [PATCH 06/48] updates

---
 clang/include/clang/Format/Format.h       | 39 ++++++++++++-----------
 clang/lib/Format/ContinuationIndenter.cpp |  5 +++
 clang/unittests/Format/FormatTest.cpp     |  3 ++
 3 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 9f637878c80e7..13e8248eee01a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -67,8 +67,7 @@ struct FormatStyle {
   /// \code
   ///   true:                             false:
   ///   if constexpr (          vs.       if constexpr (a ||
-  ///                 a ||                              b)
-  ///                 b)
+  ///      a || b)                                      b)
   /// \endcode
   /// \version 21
   bool BreakAfterOpenBracketIf;
@@ -78,8 +77,7 @@ struct FormatStyle {
   /// \code
   ///   true:                             false:
   ///   while (                  vs.      while (a &&
-  ///          a &&                              b) {
-  ///          b) {
+  ///      a && b) {                             b) {
   /// \endcode
   /// \version 21
   bool BreakAfterOpenBracketLoop;
@@ -89,8 +87,7 @@ struct FormatStyle {
   /// \code
   ///   true:                             false:
   ///   switch (                 vs.      switch (a &&
-  ///           a &&                              b) {
-  ///           b) {
+  ///      a && b) {                              b) {
   /// \endcode
   /// \version 21
   bool BreakAfterOpenBracketSwitch;
@@ -2255,34 +2252,40 @@ struct FormatStyle {
   BraceBreakingStyle BreakBeforeBraces;
 
   /// Force break before the right parenthesis of an if control statement
-  /// when the expression exceeds the column limit.
+  /// when the expression exceeds the column limit. The break before the
+  /// closing parenthesis is only made if there is a break after the opening
+  /// parenthesis.
   /// \code
   ///   true:                             false:
-  ///   if constexpr (a ||      vs.       if constexpr (a ||
-  ///                 b                                 b)
-  ///                 )
+  ///   if constexpr (          vs.       if constexpr (a ||
+  ///      a || b                                       b)
+  ///   )              
   /// \endcode
   /// \version 21
   bool BreakBeforeCloseBracketIf;
 
   /// Force break before the right parenthesis of a loop control statement
-  /// when the expression exceeds the column limit.
+  /// when the expression exceeds the column limit. The break before the
+  /// closing parenthesis is only made if there is a break after the opening
+  /// parenthesis.
   /// \code
   ///   true:                             false:
-  ///   while (a &&              vs.      while (a &&
-  ///          b                                 b) {
-  ///          ) {
+  ///   while (                  vs.      while (a &&
+  ///      a && b                                b) {
+  ///   ) {       
   /// \endcode
   /// \version 21
   bool BreakBeforeCloseBracketLoop;
 
   /// Force break before the right parenthesis of a switch control statement
-  /// when the expression exceeds the column limit.
+  /// when the expression exceeds the column limit. The break before the
+  /// closing parenthesis is only made if there is a break after the opening
+  /// parenthesis.
   /// \code
   ///   true:                             false:
-  ///   switch (a &&             vs.      switch (a &&
-  ///           b                                 b) {
-  ///           ) {
+  ///   switch (                 vs.      switch (a &&
+  ///      a && b                                 b) {
+  ///   ) {   
   /// \endcode
   /// \version 21
   bool BreakBeforeCloseBracketSwitch;
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 4f8da85887f15..54c1079cd4567 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1453,6 +1453,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
       State.Stack.size() > 1) {
     return State.Stack[State.Stack.size() - 2].LastSpace;
   }
+  if ((Style.BreakBeforeCloseBracketIf || Style.BreakBeforeCloseBracketLoop ||
+       Style.BreakBeforeCloseBracketSwitch) &&
+      Current.is(tok::r_paren) && State.Stack.size() > 1) {
+    return State.Stack[State.Stack.size() - 2].LastSpace;
+  }
   if (Style.BreakBeforeTemplateCloser && Current.is(TT_TemplateCloser) &&
       State.Stack.size() > 1) {
     return State.Stack[State.Stack.size() - 2].LastSpace;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 491cbe93e26fe..189883ae02f5b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9483,6 +9483,9 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
   Style.BreakAfterOpenBracketIf = true;
   Style.BreakAfterOpenBracketLoop = true;
   Style.BreakAfterOpenBracketSwitch = true;
+  Style.BreakBeforeCloseBracketIf = false;
+  Style.BreakBeforeCloseBracketLoop = false;
+  Style.BreakBeforeCloseBracketSwitch = false;
 
   verifyFormat("void foo() {\n"
                "  if constexpr (\n"

>From a5f77cf683b759995dc371dd474de226e57b7990 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Thu, 22 May 2025 07:57:03 -0600
Subject: [PATCH 07/48] fix format

---
 clang/include/clang/Format/Format.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 13e8248eee01a..f4d4cc155283e 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2259,7 +2259,7 @@ struct FormatStyle {
   ///   true:                             false:
   ///   if constexpr (          vs.       if constexpr (a ||
   ///      a || b                                       b)
-  ///   )              
+  ///   )
   /// \endcode
   /// \version 21
   bool BreakBeforeCloseBracketIf;
@@ -2272,7 +2272,7 @@ struct FormatStyle {
   ///   true:                             false:
   ///   while (                  vs.      while (a &&
   ///      a && b                                b) {
-  ///   ) {       
+  ///   ) {
   /// \endcode
   /// \version 21
   bool BreakBeforeCloseBracketLoop;
@@ -2285,7 +2285,7 @@ struct FormatStyle {
   ///   true:                             false:
   ///   switch (                 vs.      switch (a &&
   ///      a && b                                 b) {
-  ///   ) {   
+  ///   ) {
   /// \endcode
   /// \version 21
   bool BreakBeforeCloseBracketSwitch;

>From 139a24fca670a02eb6f7be64d5199066409b192c Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Thu, 22 May 2025 08:07:59 -0600
Subject: [PATCH 08/48] Fix false case examples

---
 clang/include/clang/Format/Format.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index f4d4cc155283e..9c552fe94e6c3 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2257,8 +2257,8 @@ struct FormatStyle {
   /// parenthesis.
   /// \code
   ///   true:                             false:
-  ///   if constexpr (          vs.       if constexpr (a ||
-  ///      a || b                                       b)
+  ///   if constexpr (          vs.       if constexpr (
+  ///      a || b                            a || b )
   ///   )
   /// \endcode
   /// \version 21
@@ -2270,8 +2270,8 @@ struct FormatStyle {
   /// parenthesis.
   /// \code
   ///   true:                             false:
-  ///   while (                  vs.      while (a &&
-  ///      a && b                                b) {
+  ///   while (                  vs.      while (
+  ///      a && b                            a && b) {
   ///   ) {
   /// \endcode
   /// \version 21
@@ -2283,8 +2283,8 @@ struct FormatStyle {
   /// parenthesis.
   /// \code
   ///   true:                             false:
-  ///   switch (                 vs.      switch (a &&
-  ///      a && b                                 b) {
+  ///   switch (                 vs.      switch (
+  ///      a && b                            a && b) {
   ///   ) {
   /// \endcode
   /// \version 21

>From 1340633ccc5f1341a153de1fa93f4346d2b64254 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 22 Aug 2025 10:43:12 -0600
Subject: [PATCH 09/48] update version numbers to 22

---
 clang/include/clang/Format/Format.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 9c552fe94e6c3..c06fc277e0660 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -69,7 +69,7 @@ struct FormatStyle {
   ///   if constexpr (          vs.       if constexpr (a ||
   ///      a || b)                                      b)
   /// \endcode
-  /// \version 21
+  /// \version 22
   bool BreakAfterOpenBracketIf;
 
   /// Force break after the left parenthesis of a loop control statement
@@ -79,7 +79,7 @@ struct FormatStyle {
   ///   while (                  vs.      while (a &&
   ///      a && b) {                             b) {
   /// \endcode
-  /// \version 21
+  /// \version 22
   bool BreakAfterOpenBracketLoop;
 
   /// Force break after the left parenthesis of a switch control statement
@@ -89,7 +89,7 @@ struct FormatStyle {
   ///   switch (                 vs.      switch (a &&
   ///      a && b) {                              b) {
   /// \endcode
-  /// \version 21
+  /// \version 22
   bool BreakAfterOpenBracketSwitch;
 
   /// Different styles for aligning after open brackets.
@@ -2261,7 +2261,7 @@ struct FormatStyle {
   ///      a || b                            a || b )
   ///   )
   /// \endcode
-  /// \version 21
+  /// \version 22
   bool BreakBeforeCloseBracketIf;
 
   /// Force break before the right parenthesis of a loop control statement
@@ -2274,7 +2274,7 @@ struct FormatStyle {
   ///      a && b                            a && b) {
   ///   ) {
   /// \endcode
-  /// \version 21
+  /// \version 22
   bool BreakBeforeCloseBracketLoop;
 
   /// Force break before the right parenthesis of a switch control statement
@@ -2287,7 +2287,7 @@ struct FormatStyle {
   ///      a && b                            a && b) {
   ///   ) {
   /// \endcode
-  /// \version 21
+  /// \version 22
   bool BreakBeforeCloseBracketSwitch;
 
   /// Different ways to break before concept declarations.

>From 3b195c4fd4d23dac1c82df26dc5385cc14e8e835 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 22 Aug 2025 13:53:24 -0600
Subject: [PATCH 10/48] add support for braced list initializers

---
 clang/include/clang/Format/Format.h        |  28 ++
 clang/lib/Format/ContinuationIndenter.cpp  |  14 +-
 clang/lib/Format/Format.cpp                |   7 +
 clang/lib/Format/FormatToken.cpp           |   2 +-
 clang/unittests/Format/ConfigParseTest.cpp |   2 +
 clang/unittests/Format/FormatTest.cpp      | 409 ++++++++++++++++++++-
 6 files changed, 453 insertions(+), 9 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index c06fc277e0660..5045ed3cfba91 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,6 +62,17 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
+  /// Force break after the left bracket of a braced initializer list (when
+  ///  ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  /// limit.
+  /// \code
+  ///   true:                             false:
+  ///   vector<int> x {         vs.       vector<int> x {1,
+  ///      1, 2, 3}                            2, 3}
+  /// \endcode
+  /// \version 22
+  bool BreakAfterOpenBracketBracedList;
+
   /// Force break after the left parenthesis of an if control statement
   /// when the expression exceeds the column limit.
   /// \code
@@ -2251,6 +2262,19 @@ struct FormatStyle {
   /// \version 3.7
   BraceBreakingStyle BreakBeforeBraces;
 
+  /// Force break before the right bracket of a braced initializer list (when
+  ///  ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  /// limit. The break before the right bracket is only made if there is a
+  /// break after the opening bracket.
+  /// \code
+  ///   true:                             false:
+  ///   vector<int> x {         vs.       vector<int> x {
+  ///      1, 2, 3                           1, 2, 3}
+  ///   }
+  /// \endcode
+  /// \version 22
+  bool BreakBeforeCloseBracketBracedList;
+
   /// Force break before the right parenthesis of an if control statement
   /// when the expression exceeds the column limit. The break before the
   /// closing parenthesis is only made if there is a break after the opening
@@ -5561,6 +5585,8 @@ struct FormatStyle {
            BreakAdjacentStringLiterals == R.BreakAdjacentStringLiterals &&
            BreakAfterAttributes == R.BreakAfterAttributes &&
            BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
+           BreakAfterOpenBracketBracedList ==
+               R.BreakAfterOpenBracketBracedList &&
            BreakAfterOpenBracketIf == R.BreakAfterOpenBracketIf &&
            BreakAfterOpenBracketLoop == R.BreakAfterOpenBracketLoop &&
            BreakAfterOpenBracketSwitch == R.BreakAfterOpenBracketSwitch &&
@@ -5568,6 +5594,8 @@ struct FormatStyle {
            BreakArrays == R.BreakArrays &&
            BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
            BreakBeforeBraces == R.BreakBeforeBraces &&
+           BreakBeforeCloseBracketBracedList ==
+               R.BreakBeforeCloseBracketBracedList &&
            BreakBeforeCloseBracketIf == R.BreakBeforeCloseBracketIf &&
            BreakBeforeCloseBracketLoop == R.BreakBeforeCloseBracketLoop &&
            BreakBeforeCloseBracketSwitch == R.BreakBeforeCloseBracketSwitch &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 54c1079cd4567..78c835c98f24c 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -843,10 +843,10 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
       return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
              Style.Cpp11BracedListStyle;
     };
-    if (!Tok.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
-        !IsStartOfBracedList()) {
+    if (IsStartOfBracedList())
+      return Style.BreakAfterOpenBracketBracedList;
+    if (!Tok.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square))
       return false;
-    }
     if (!Tok.Previous)
       return true;
     if (Tok.Previous->isIf())
@@ -1447,9 +1447,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
     return State.Stack[State.Stack.size() - 2].LastSpace;
   }
   if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent &&
-      (Current.is(tok::r_paren) ||
-       (Current.is(tok::r_brace) && Current.MatchingParen &&
-        Current.MatchingParen->is(BK_BracedInit))) &&
+      Current.is(tok::r_paren) && State.Stack.size() > 1) {
+    return State.Stack[State.Stack.size() - 2].LastSpace;
+  }
+  if (Style.BreakBeforeCloseBracketBracedList && Current.is(tok::r_brace) &&
+      Current.MatchingParen && Current.MatchingParen->is(BK_BracedInit) &&
       State.Stack.size() > 1) {
     return State.Stack[State.Stack.size() - 2].LastSpace;
   }
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index a6019c6a1e431..5cbee5f0c938f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1067,6 +1067,8 @@ template <> struct MappingTraits<FormatStyle> {
     IO.mapOptional("BreakAfterAttributes", Style.BreakAfterAttributes);
     IO.mapOptional("BreakAfterJavaFieldAnnotations",
                    Style.BreakAfterJavaFieldAnnotations);
+    IO.mapOptional("BreakAfterOpenBracketBracedList",
+                   Style.BreakAfterOpenBracketBracedList);
     IO.mapOptional("BreakAfterOpenBracketIf", Style.BreakAfterOpenBracketIf);
     IO.mapOptional("BreakAfterOpenBracketLoop",
                    Style.BreakAfterOpenBracketLoop);
@@ -1076,6 +1078,8 @@ template <> struct MappingTraits<FormatStyle> {
     IO.mapOptional("BreakArrays", Style.BreakArrays);
     IO.mapOptional("BreakBeforeBinaryOperators",
                    Style.BreakBeforeBinaryOperators);
+    IO.mapOptional("BreakBeforeCloseBracketBracedList",
+                   Style.BreakBeforeCloseBracketBracedList);
     IO.mapOptional("BreakBeforeCloseBracketIf",
                    Style.BreakBeforeCloseBracketIf);
     IO.mapOptional("BreakBeforeCloseBracketLoop",
@@ -1620,6 +1624,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   LLVMStyle.BreakAdjacentStringLiterals = true;
   LLVMStyle.BreakAfterAttributes = FormatStyle::ABS_Leave;
   LLVMStyle.BreakAfterJavaFieldAnnotations = false;
+  LLVMStyle.BreakAfterOpenBracketBracedList = false;
   LLVMStyle.BreakAfterOpenBracketIf = false;
   LLVMStyle.BreakAfterOpenBracketLoop = false;
   LLVMStyle.BreakAfterOpenBracketSwitch = false;
@@ -1627,6 +1632,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   LLVMStyle.BreakArrays = true;
   LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
+  LLVMStyle.BreakBeforeCloseBracketBracedList = false;
   LLVMStyle.BreakBeforeCloseBracketIf = false;
   LLVMStyle.BreakBeforeCloseBracketLoop = false;
   LLVMStyle.BreakBeforeCloseBracketSwitch = false;
@@ -1895,6 +1901,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
     GoogleStyle.SpacesBeforeTrailingComments = 1;
   } else if (Language == FormatStyle::LK_JavaScript) {
     GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+    GoogleStyle.BreakAfterOpenBracketBracedList = true;
     GoogleStyle.BreakAfterOpenBracketIf = true;
     GoogleStyle.BreakAfterOpenBracketLoop = false;
     GoogleStyle.BreakAfterOpenBracketSwitch = false;
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index c60ae8f0d2852..514b1f0bbe09f 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -67,7 +67,7 @@ bool FormatToken::isTypeOrIdentifier(const LangOptions &LangOpts) const {
 bool FormatToken::isBlockIndentedInitRBrace(const FormatStyle &Style) const {
   assert(is(tok::r_brace));
   if (!Style.Cpp11BracedListStyle ||
-      Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent) {
+      Style.BreakBeforeCloseBracketBracedList == false) {
     return false;
   }
   const auto *LBrace = MatchingParen;
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 1f49eda98d4b8..96e46653f6ac2 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -172,9 +172,11 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
   CHECK_PARSE_BOOL(BinPackLongBracedList);
   CHECK_PARSE_BOOL(BreakAdjacentStringLiterals);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
+  CHECK_PARSE_BOOL(BreakAfterOpenBracketBracedList);
   CHECK_PARSE_BOOL(BreakAfterOpenBracketIf);
   CHECK_PARSE_BOOL(BreakAfterOpenBracketLoop);
   CHECK_PARSE_BOOL(BreakAfterOpenBracketSwitch);
+  CHECK_PARSE_BOOL(BreakBeforeCloseBracketBracedList);
   CHECK_PARSE_BOOL(BreakBeforeCloseBracketIf);
   CHECK_PARSE_BOOL(BreakBeforeCloseBracketLoop);
   CHECK_PARSE_BOOL(BreakBeforeCloseBracketSwitch);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 189883ae02f5b..4a56764f9f04b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5106,6 +5106,7 @@ TEST_F(FormatTest, BracedInitializerIndentWidth) {
   auto Style = getLLVMStyleWithColumns(60);
   Style.BinPackArguments = true;
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketBracedList = true;
   Style.BracedInitializerIndentWidth = 6;
 
   // Non-initializing braces are unaffected by BracedInitializerIndentWidth.
@@ -5282,6 +5283,7 @@ TEST_F(FormatTest, BracedInitializerIndentWidth) {
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
   Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.BreakAfterOpenBracketBracedList = false;
   verifyFormat("SomeStruct s{\"xxxxxxxxxxxxx\", \"yyyyyyyyyyyyy\",\n"
                "             \"zzzzzzzzzzzzz\"};",
                Style);
@@ -9423,7 +9425,7 @@ TEST_F(FormatTest, AlignsAfterReturn) {
                "    code == a || code == b;");
 }
 
-TEST_F(FormatTest, AlignAfterConditionalStatements) {
+TEST_F(FormatTest, AlignAndBreakControlStatements) {
   FormatStyle Style = getLLVMStyle();
 
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
@@ -14615,7 +14617,7 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
                "};",
                NoBinPacking);
 
-  NoBinPacking.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  NoBinPacking.BreakAfterOpenBracketBracedList = true;
   verifyFormat("static uint8 CddDp83848Reg[] = {\n"
                "    CDDDP83848_BMCR_REGISTER,\n"
                "    CDDDP83848_BMSR_REGISTER,\n"
@@ -27632,6 +27634,409 @@ TEST_F(FormatTest, MultilineLambdaInConditional) {
                Style);
 }
 
+<<<<<<< HEAD
+=======
+TEST_F(FormatTest, AlignAfterOpenBracketBlockIndent) {
+  auto Style = getLLVMStyle();
+
+  StringRef Short = "functionCall(paramA, paramB, paramC);\n"
+                    "void functionDecl(int a, int b, int c);";
+
+  StringRef Medium = "functionCall(paramA, paramB, paramC, paramD, paramE, "
+                     "paramF, paramG, paramH, paramI);\n"
+                     "void functionDecl(int argumentA, int argumentB, int "
+                     "argumentC, int argumentD, int argumentE);";
+
+  verifyFormat(Short, Style);
+
+  StringRef NoBreak = "functionCall(paramA, paramB, paramC, paramD, paramE, "
+                      "paramF, paramG, paramH,\n"
+                      "             paramI);\n"
+                      "void functionDecl(int argumentA, int argumentB, int "
+                      "argumentC, int argumentD,\n"
+                      "                  int argumentE);";
+
+  verifyFormat(NoBreak, Medium, Style);
+  verifyFormat(NoBreak,
+               "functionCall(\n"
+               "    paramA,\n"
+               "    paramB,\n"
+               "    paramC,\n"
+               "    paramD,\n"
+               "    paramE,\n"
+               "    paramF,\n"
+               "    paramG,\n"
+               "    paramH,\n"
+               "    paramI\n"
+               ");\n"
+               "void functionDecl(\n"
+               "    int argumentA,\n"
+               "    int argumentB,\n"
+               "    int argumentC,\n"
+               "    int argumentD,\n"
+               "    int argumentE\n"
+               ");",
+               Style);
+
+  verifyFormat("outerFunctionCall(nestedFunctionCall(argument1),\n"
+               "                  nestedLongFunctionCall(argument1, "
+               "argument2, argument3,\n"
+               "                                         argument4, "
+               "argument5));",
+               Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+
+  verifyFormat(Short, Style);
+  verifyFormat(
+      "functionCall(\n"
+      "    paramA, paramB, paramC, paramD, paramE, paramF, paramG, paramH, "
+      "paramI\n"
+      ");\n"
+      "void functionDecl(\n"
+      "    int argumentA, int argumentB, int argumentC, int argumentD, int "
+      "argumentE\n"
+      ");",
+      Medium, Style);
+
+  Style.AllowAllArgumentsOnNextLine = false;
+  Style.AllowAllParametersOfDeclarationOnNextLine = false;
+
+  verifyFormat(Short, Style);
+  verifyFormat(
+      "functionCall(\n"
+      "    paramA, paramB, paramC, paramD, paramE, paramF, paramG, paramH, "
+      "paramI\n"
+      ");\n"
+      "void functionDecl(\n"
+      "    int argumentA, int argumentB, int argumentC, int argumentD, int "
+      "argumentE\n"
+      ");",
+      Medium, Style);
+
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
+
+  verifyFormat(Short, Style);
+
+  verifyFormat("functionCall(\n"
+               "    paramA,\n"
+               "    paramB,\n"
+               "    paramC,\n"
+               "    paramD,\n"
+               "    paramE,\n"
+               "    paramF,\n"
+               "    paramG,\n"
+               "    paramH,\n"
+               "    paramI\n"
+               ");\n"
+               "void functionDecl(\n"
+               "    int argumentA,\n"
+               "    int argumentB,\n"
+               "    int argumentC,\n"
+               "    int argumentD,\n"
+               "    int argumentE\n"
+               ");",
+               Medium, Style);
+
+  verifyFormat("outerFunctionCall(\n"
+               "    nestedFunctionCall(argument1),\n"
+               "    nestedLongFunctionCall(\n"
+               "        argument1,\n"
+               "        argument2,\n"
+               "        argument3,\n"
+               "        argument4,\n"
+               "        argument5\n"
+               "    )\n"
+               ");",
+               Style);
+
+  verifyFormat("int a = (int)b;", Style);
+  verifyFormat("int a = (int)b;",
+               "int a = (\n"
+               "    int\n"
+               ") b;",
+               Style);
+
+  verifyFormat("return (true);", Style);
+  verifyFormat("return (true);",
+               "return (\n"
+               "    true\n"
+               ");",
+               Style);
+
+  verifyFormat("void foo();", Style);
+  verifyFormat("void foo();",
+               "void foo(\n"
+               ");",
+               Style);
+
+  verifyFormat("void foo() {}", Style);
+  verifyFormat("void foo() {}",
+               "void foo(\n"
+               ") {\n"
+               "}",
+               Style);
+
+  verifyFormat("auto string = std::string();", Style);
+  verifyFormat("auto string = std::string();",
+               "auto string = std::string(\n"
+               ");",
+               Style);
+
+  verifyFormat("void (*functionPointer)() = nullptr;", Style);
+  verifyFormat("void (*functionPointer)() = nullptr;",
+               "void (\n"
+               "    *functionPointer\n"
+               ")\n"
+               "(\n"
+               ") = nullptr;",
+               Style);
+}
+
+TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentIfStatement) {
+  auto Style = getLLVMStyle();
+
+  verifyFormat("if (foo()) {\n"
+               "  return;\n"
+               "}",
+               Style);
+
+  verifyFormat("if (quiteLongArg !=\n"
+               "    (alsoLongArg - 1)) { // ABC is a very longgggggggggggg "
+               "comment\n"
+               "  return;\n"
+               "}",
+               Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+
+  verifyFormat("if (foo()) {\n"
+               "  return;\n"
+               "}",
+               Style);
+
+  verifyFormat("if (quiteLongArg !=\n"
+               "    (alsoLongArg - 1)) { // ABC is a very longgggggggggggg "
+               "comment\n"
+               "  return;\n"
+               "}",
+               Style);
+
+  verifyFormat("void foo() {\n"
+               "  if (camelCaseName < alsoLongName ||\n"
+               "      anotherEvenLongerName <=\n"
+               "          thisReallyReallyReallyReallyReallyReallyLongerName ||"
+               "\n"
+               "      otherName < thisLastName) {\n"
+               "    return;\n"
+               "  } else if (quiteLongName < alsoLongName ||\n"
+               "             anotherEvenLongerName <=\n"
+               "                 thisReallyReallyReallyReallyReallyReallyLonger"
+               "Name ||\n"
+               "             otherName < thisLastName) {\n"
+               "    return;\n"
+               "  }\n"
+               "}",
+               Style);
+
+  Style.ContinuationIndentWidth = 2;
+  verifyFormat("void foo() {\n"
+               "  if (ThisIsRatherALongIfClause && thatIExpectToBeBroken ||\n"
+               "      ontoMultipleLines && whenFormattedCorrectly) {\n"
+               "    if (false) {\n"
+               "      return;\n"
+               "    } else if (thisIsRatherALongIfClause && "
+               "thatIExpectToBeBroken ||\n"
+               "               ontoMultipleLines && whenFormattedCorrectly) {\n"
+               "      return;\n"
+               "    }\n"
+               "  }\n"
+               "}",
+               Style);
+}
+
+TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentForStatement) {
+  auto Style = getLLVMStyle();
+
+  verifyFormat("for (int i = 0; i < 5; ++i) {\n"
+               "  doSomething();\n"
+               "}",
+               Style);
+
+  verifyFormat("for (int myReallyLongCountVariable = 0; "
+               "myReallyLongCountVariable < count;\n"
+               "     myReallyLongCountVariable++) {\n"
+               "  doSomething();\n"
+               "}",
+               Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+
+  verifyFormat("for (int i = 0; i < 5; ++i) {\n"
+               "  doSomething();\n"
+               "}",
+               Style);
+
+  verifyFormat("for (int myReallyLongCountVariable = 0; "
+               "myReallyLongCountVariable < count;\n"
+               "     myReallyLongCountVariable++) {\n"
+               "  doSomething();\n"
+               "}",
+               Style);
+}
+
+TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentInitializers) {
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.BreakAfterOpenBracketBracedList = true;
+  Style.BreakBeforeCloseBracketBracedList = true;
+  // Aggregate initialization.
+  verifyFormat("int LooooooooooooooooooooooooongVariable[2] = {\n"
+               "    10000000, 20000000\n"
+               "};",
+               Style);
+  verifyFormat("SomeStruct s{\n"
+               "    \"xxxxxxxxxxxxxxxx\", \"yyyyyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzzzzz\"\n"
+               "};",
+               Style);
+  // Designated initializers.
+  verifyFormat("int LooooooooooooooooooooooooongVariable[2] = {\n"
+               "    [0] = 10000000, [1] = 20000000\n"
+               "};",
+               Style);
+  verifyFormat("SomeStruct s{\n"
+               "    .foo = \"xxxxxxxxxxxxx\",\n"
+               "    .bar = \"yyyyyyyyyyyyy\",\n"
+               "    .baz = \"zzzzzzzzzzzzz\"\n"
+               "};",
+               Style);
+  // List initialization.
+  verifyFormat("SomeStruct s{\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "};",
+               Style);
+  verifyFormat("SomeStruct{\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "};",
+               Style);
+  verifyFormat("new SomeStruct{\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "};",
+               Style);
+  // Member initializer.
+  verifyFormat("class SomeClass {\n"
+               "  SomeStruct s{\n"
+               "      \"xxxxxxxxxxxxx\",\n"
+               "      \"yyyyyyyyyyyyy\",\n"
+               "      \"zzzzzzzzzzzzz\",\n"
+               "  };\n"
+               "};",
+               Style);
+  // Constructor member initializer.
+  verifyFormat("SomeClass::SomeClass : strct{\n"
+               "                           \"xxxxxxxxxxxxx\",\n"
+               "                           \"yyyyyyyyyyyyy\",\n"
+               "                           \"zzzzzzzzzzzzz\",\n"
+               "                       } {}",
+               Style);
+  // Copy initialization.
+  verifyFormat("SomeStruct s = SomeStruct{\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "};",
+               Style);
+  // Copy list initialization.
+  verifyFormat("SomeStruct s = {\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "};",
+               Style);
+  // Assignment operand initialization.
+  verifyFormat("s = {\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "};",
+               Style);
+  // Returned object initialization.
+  verifyFormat("return {\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "};",
+               Style);
+  // Initializer list.
+  verifyFormat("auto initializerList = {\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "};",
+               Style);
+  // Function parameter initialization.
+  verifyFormat("func({\n"
+               "    \"xxxxxxxxxxxxx\",\n"
+               "    \"yyyyyyyyyyyyy\",\n"
+               "    \"zzzzzzzzzzzzz\",\n"
+               "});",
+               Style);
+  // Nested init lists.
+  verifyFormat("SomeStruct s = {\n"
+               "    {{init1, init2, init3, init4, init5},\n"
+               "     {init1, init2, init3, init4, init5}}\n"
+               "};",
+               Style);
+  verifyFormat("SomeStruct s = {\n"
+               "    {{\n"
+               "         .init1 = 1,\n"
+               "         .init2 = 2,\n"
+               "         .init3 = 3,\n"
+               "         .init4 = 4,\n"
+               "         .init5 = 5,\n"
+               "     },\n"
+               "     {init1, init2, init3, init4, init5}}\n"
+               "};",
+               Style);
+  verifyFormat("SomeArrayT a[3] = {\n"
+               "    {\n"
+               "        foo,\n"
+               "        bar,\n"
+               "    },\n"
+               "    {\n"
+               "        foo,\n"
+               "        bar,\n"
+               "    },\n"
+               "    SomeArrayT{},\n"
+               "};",
+               Style);
+  verifyFormat("SomeArrayT a[3] = {\n"
+               "    {foo},\n"
+               "    {\n"
+               "        {\n"
+               "            init1,\n"
+               "            init2,\n"
+               "            init3,\n"
+               "        },\n"
+               "        {\n"
+               "            init1,\n"
+               "            init2,\n"
+               "            init3,\n"
+               "        },\n"
+               "    },\n"
+               "    {baz},\n"
+               "};",
+               Style);
+}
+
+>>>>>>> cbd14c5d622a (add support for braced list initializers)
 TEST_F(FormatTest, UnderstandsDigraphs) {
   verifyFormat("int arr<:5:> = {};");
   verifyFormat("int arr[5] = <%%>;");

>From b535bc74c069cc29ceac08fbda87bd0e008f071f Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 22 Aug 2025 14:41:46 -0600
Subject: [PATCH 11/48] Add support for functions and replace AlwaysBreak,
 BlockIndent

---
 clang/include/clang/Format/Format.h          |  24 +
 clang/lib/Format/ContinuationIndenter.cpp    |  20 +-
 clang/lib/Format/Format.cpp                  |   4 +-
 clang/lib/Format/TokenAnnotator.cpp          |   4 +-
 clang/unittests/Format/AlignBracketsTest.cpp |  33 +-
 clang/unittests/Format/ConfigParseTest.cpp   |   2 +
 clang/unittests/Format/FormatTest.cpp        | 496 +++----------------
 clang/unittests/Format/FormatTestJS.cpp      |   2 +-
 8 files changed, 139 insertions(+), 446 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 5045ed3cfba91..6927acf08cdc8 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -73,6 +73,16 @@ struct FormatStyle {
   /// \version 22
   bool BreakAfterOpenBracketBracedList;
 
+  /// Force break after the left parenthesis of a function (declaration,
+  /// definition, call) when the parameters exceed the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   foo (                   vs.       foo (a ||
+  ///      a || b)                             b)
+  /// \endcode
+  /// \version 22
+  bool BreakAfterOpenBracketFunction;
+
   /// Force break after the left parenthesis of an if control statement
   /// when the expression exceeds the column limit.
   /// \code
@@ -2275,6 +2285,17 @@ struct FormatStyle {
   /// \version 22
   bool BreakBeforeCloseBracketBracedList;
 
+  /// Force break before the right parenthesis of a function (declaration,
+  /// definition, call) when the parameters exceed the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   foo (                   vs.       foo (
+  ///      a || b                            a || b)
+  ///   )
+  /// \endcode
+  /// \version 22
+  bool BreakBeforeCloseBracketFunction;
+
   /// Force break before the right parenthesis of an if control statement
   /// when the expression exceeds the column limit. The break before the
   /// closing parenthesis is only made if there is a break after the opening
@@ -5587,6 +5608,7 @@ struct FormatStyle {
            BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
            BreakAfterOpenBracketBracedList ==
                R.BreakAfterOpenBracketBracedList &&
+           BreakAfterOpenBracketFunction == R.BreakAfterOpenBracketFunction &&
            BreakAfterOpenBracketIf == R.BreakAfterOpenBracketIf &&
            BreakAfterOpenBracketLoop == R.BreakAfterOpenBracketLoop &&
            BreakAfterOpenBracketSwitch == R.BreakAfterOpenBracketSwitch &&
@@ -5596,6 +5618,8 @@ struct FormatStyle {
            BreakBeforeBraces == R.BreakBeforeBraces &&
            BreakBeforeCloseBracketBracedList ==
                R.BreakBeforeCloseBracketBracedList &&
+           BreakBeforeCloseBracketFunction ==
+               R.BreakBeforeCloseBracketFunction &&
            BreakBeforeCloseBracketIf == R.BreakBeforeCloseBracketIf &&
            BreakBeforeCloseBracketLoop == R.BreakBeforeCloseBracketLoop &&
            BreakBeforeCloseBracketSwitch == R.BreakBeforeCloseBracketSwitch &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 78c835c98f24c..b6cdb39d54293 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -358,10 +358,10 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
 
   // Allow breaking before the right parens with block indentation if there was
   // a break after the left parens, which is tracked by BreakBeforeClosingParen.
-  bool might_break_before =
-      Style.BreakBeforeCloseBracketIf || Style.BreakBeforeCloseBracketLoop ||
-      Style.BreakBeforeCloseBracketSwitch ||
-      Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+  bool might_break_before = Style.BreakBeforeCloseBracketFunction ||
+                            Style.BreakBeforeCloseBracketIf ||
+                            Style.BreakBeforeCloseBracketLoop ||
+                            Style.BreakBeforeCloseBracketSwitch;
 
   if (might_break_before && Current.is(tok::r_paren))
     return CurrentState.BreakBeforeClosingParen;
@@ -855,8 +855,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
       return Style.BreakAfterOpenBracketLoop;
     if (Tok.Previous->is(tok::kw_switch))
       return Style.BreakAfterOpenBracketSwitch;
-    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
-        Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+    if (Style.BreakAfterOpenBracketFunction) {
       return !Tok.Previous->is(TT_CastRParen) &&
              !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
     }
@@ -1301,7 +1300,7 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
             Style.BreakBeforeCloseBracketSwitch;
       } else {
         CurrentState.BreakBeforeClosingParen =
-            Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+            Style.BreakBeforeCloseBracketFunction;
       }
     }
   }
@@ -1446,16 +1445,13 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
       State.Stack.size() > 1) {
     return State.Stack[State.Stack.size() - 2].LastSpace;
   }
-  if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent &&
-      Current.is(tok::r_paren) && State.Stack.size() > 1) {
-    return State.Stack[State.Stack.size() - 2].LastSpace;
-  }
   if (Style.BreakBeforeCloseBracketBracedList && Current.is(tok::r_brace) &&
       Current.MatchingParen && Current.MatchingParen->is(BK_BracedInit) &&
       State.Stack.size() > 1) {
     return State.Stack[State.Stack.size() - 2].LastSpace;
   }
-  if ((Style.BreakBeforeCloseBracketIf || Style.BreakBeforeCloseBracketLoop ||
+  if ((Style.BreakBeforeCloseBracketFunction ||
+       Style.BreakBeforeCloseBracketIf || Style.BreakBeforeCloseBracketLoop ||
        Style.BreakBeforeCloseBracketSwitch) &&
       Current.is(tok::r_paren) && State.Stack.size() > 1) {
     return State.Stack[State.Stack.size() - 2].LastSpace;
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 5cbee5f0c938f..6a46da1733d8c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1625,6 +1625,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   LLVMStyle.BreakAfterAttributes = FormatStyle::ABS_Leave;
   LLVMStyle.BreakAfterJavaFieldAnnotations = false;
   LLVMStyle.BreakAfterOpenBracketBracedList = false;
+  LLVMStyle.BreakAfterOpenBracketFunction = false;
   LLVMStyle.BreakAfterOpenBracketIf = false;
   LLVMStyle.BreakAfterOpenBracketLoop = false;
   LLVMStyle.BreakAfterOpenBracketSwitch = false;
@@ -1633,6 +1634,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
   LLVMStyle.BreakBeforeCloseBracketBracedList = false;
+  LLVMStyle.BreakBeforeCloseBracketFunction = false;
   LLVMStyle.BreakBeforeCloseBracketIf = false;
   LLVMStyle.BreakBeforeCloseBracketLoop = false;
   LLVMStyle.BreakBeforeCloseBracketSwitch = false;
@@ -1900,8 +1902,8 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
     GoogleStyle.SpaceAfterCStyleCast = true;
     GoogleStyle.SpacesBeforeTrailingComments = 1;
   } else if (Language == FormatStyle::LK_JavaScript) {
-    GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
     GoogleStyle.BreakAfterOpenBracketBracedList = true;
+    GoogleStyle.BreakAfterOpenBracketFunction = true;
     GoogleStyle.BreakAfterOpenBracketIf = true;
     GoogleStyle.BreakAfterOpenBracketLoop = false;
     GoogleStyle.BreakAfterOpenBracketSwitch = false;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 8004346b1f5d9..d144f0e66a86a 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -6252,12 +6252,12 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
       return Style.BreakBeforeCloseBracketLoop;
     if (Previous->is(tok::kw_switch))
       return Style.BreakBeforeCloseBracketSwitch;
-    return Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
+    return Style.BreakBeforeCloseBracketFunction;
   }
 
   if (Left.isOneOf(tok::r_paren, TT_TrailingAnnotation) &&
       Right.is(TT_TrailingAnnotation) &&
-      Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+      Style.BreakBeforeCloseBracketFunction) {
     return false;
   }
 
diff --git a/clang/unittests/Format/AlignBracketsTest.cpp b/clang/unittests/Format/AlignBracketsTest.cpp
index c4380ae415751..c280a4b84d615 100644
--- a/clang/unittests/Format/AlignBracketsTest.cpp
+++ b/clang/unittests/Format/AlignBracketsTest.cpp
@@ -64,7 +64,7 @@ TEST_F(AlignBracketsTest, AlignsAfterOpenBracket) {
                Style);
   Style.ColumnLimit = 80;
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   Style.BinPackArguments = false;
   Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
   verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
@@ -115,7 +115,9 @@ TEST_F(AlignBracketsTest, AlignsAfterOpenBracket) {
       "    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZZZZZZZZZZZZZ()));",
       Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BreakAfterOpenBracketFunction = true;
+  Style.BreakBeforeCloseBracketFunction = true;
+  Style.BreakBeforeCloseBracketBracedList = true;
   Style.BinPackArguments = false;
   Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
   verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
@@ -254,7 +256,8 @@ TEST_F(AlignBracketsTest, AlignAfterOpenBracketBlockIndent) {
                "argument5));",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BreakAfterOpenBracketFunction = true;
+  Style.BreakBeforeCloseBracketFunction = true;
 
   verifyFormat(Short, Style);
   verifyFormat(
@@ -378,7 +381,8 @@ TEST_F(AlignBracketsTest, AlignAfterOpenBracketBlockIndentIfStatement) {
                "}",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BreakAfterOpenBracketFunction = true;
+  Style.BreakBeforeCloseBracketFunction = true;
 
   verifyFormat("if (foo()) {\n"
                "  return;\n"
@@ -440,7 +444,8 @@ TEST_F(AlignBracketsTest, AlignAfterOpenBracketBlockIndentForStatement) {
                "}",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BreakAfterOpenBracketFunction = true;
+  Style.BreakBeforeCloseBracketFunction = true;
 
   verifyFormat("for (int i = 0; i < 5; ++i) {\n"
                "  doSomething();\n"
@@ -457,7 +462,8 @@ TEST_F(AlignBracketsTest, AlignAfterOpenBracketBlockIndentForStatement) {
 
 TEST_F(AlignBracketsTest, AlignAfterOpenBracketBlockIndentInitializers) {
   auto Style = getLLVMStyleWithColumns(60);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BreakAfterOpenBracketBracedList = true;
+  Style.BreakBeforeCloseBracketBracedList = true;
   // Aggregate initialization.
   verifyFormat("int LooooooooooooooooooooooooongVariable[2] = {\n"
                "    10000000, 20000000\n"
@@ -625,13 +631,14 @@ TEST_F(AlignBracketsTest, AllowAllArgumentsOnNextLineDontAlign) {
                Input, Style);
   // However, BAS_AlwaysBreak and BAS_BlockIndent should take precedence over
   // AllowAllArgumentsOnNextLine.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   verifyFormat(StringRef("functionCall(\n"
                          "    paramA, paramB, paramC);\n"
                          "void functionDecl(\n"
                          "    int A, int B, int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BreakAfterOpenBracketFunction = true;
+  Style.BreakBeforeCloseBracketFunction = true;
   verifyFormat("functionCall(\n"
                "    paramA, paramB, paramC\n"
                ");\n"
@@ -678,13 +685,14 @@ TEST_F(AlignBracketsTest, FormatsDeclarationBreakAlways) {
 
   // Ensure AlignAfterOpenBracket interacts correctly with BinPackParameters set
   // to BPPS_AlwaysOnePerLine.
-  BreakAlways.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  BreakAlways.BreakAfterOpenBracketFunction = true;
   verifyFormat(
       "void someLongFunctionName(\n"
       "    int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
       "    int b);",
       BreakAlways);
-  BreakAlways.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  BreakAlways.BreakAfterOpenBracketFunction = true;
+  BreakAlways.BreakBeforeCloseBracketFunction = true;
   verifyFormat(
       "void someLongFunctionName(\n"
       "    int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
@@ -734,7 +742,7 @@ TEST_F(AlignBracketsTest, FormatsDefinitionBreakAlways) {
 
   // Ensure AlignAfterOpenBracket interacts correctly with BinPackParameters set
   // to BPPS_AlwaysOnePerLine.
-  BreakAlways.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  BreakAlways.BreakAfterOpenBracketFunction = true;
   verifyFormat(
       "void someLongFunctionName(\n"
       "    int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
@@ -743,7 +751,8 @@ TEST_F(AlignBracketsTest, FormatsDefinitionBreakAlways) {
       "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, b);\n"
       "}",
       BreakAlways);
-  BreakAlways.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  BreakAlways.BreakAfterOpenBracketFunction = true;
+  BreakAlways.BreakBeforeCloseBracketFunction = true;
   verifyFormat(
       "void someLongFunctionName(\n"
       "    int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 96e46653f6ac2..81ec2090cb448 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -173,10 +173,12 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
   CHECK_PARSE_BOOL(BreakAdjacentStringLiterals);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
   CHECK_PARSE_BOOL(BreakAfterOpenBracketBracedList);
+  CHECK_PARSE_BOOL(BreakAfterOpenBracketFunction);
   CHECK_PARSE_BOOL(BreakAfterOpenBracketIf);
   CHECK_PARSE_BOOL(BreakAfterOpenBracketLoop);
   CHECK_PARSE_BOOL(BreakAfterOpenBracketSwitch);
   CHECK_PARSE_BOOL(BreakBeforeCloseBracketBracedList);
+  CHECK_PARSE_BOOL(BreakBeforeCloseBracketFunction);
   CHECK_PARSE_BOOL(BreakBeforeCloseBracketIf);
   CHECK_PARSE_BOOL(BreakBeforeCloseBracketLoop);
   CHECK_PARSE_BOOL(BreakBeforeCloseBracketSwitch);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 4a56764f9f04b..32f17be0cd981 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5105,7 +5105,7 @@ TEST_F(FormatTest, DesignatedInitializers) {
 TEST_F(FormatTest, BracedInitializerIndentWidth) {
   auto Style = getLLVMStyleWithColumns(60);
   Style.BinPackArguments = true;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   Style.BreakAfterOpenBracketBracedList = true;
   Style.BracedInitializerIndentWidth = 6;
 
@@ -7451,7 +7451,7 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
                Style);
 
   Style = getLLVMStyleWithColumns(20);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
   Style.ContinuationIndentWidth = 2;
@@ -8110,6 +8110,71 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
                Style);
 }
 
+TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
+  // Check that AllowAllArgumentsOnNextLine is respected for both BAS_DontAlign
+  // and BAS_Align.
+  FormatStyle Style = getLLVMStyleWithColumns(35);
+  StringRef Input = "functionCall(paramA, paramB, paramC);\n"
+                    "void functionDecl(int A, int B, int C);";
+  Style.AllowAllArgumentsOnNextLine = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  verifyFormat(StringRef("functionCall(paramA, paramB,\n"
+                         "    paramC);\n"
+                         "void functionDecl(int A, int B,\n"
+                         "    int C);"),
+               Input, Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  verifyFormat(StringRef("functionCall(paramA, paramB,\n"
+                         "             paramC);\n"
+                         "void functionDecl(int A, int B,\n"
+                         "                  int C);"),
+               Input, Style);
+  // However, BreakAfterOpenBracketFunction should take precedence over
+  // AllowAllArgumentsOnNextLine.
+  Style.BreakAfterOpenBracketFunction = true;
+  verifyFormat(StringRef("functionCall(\n"
+                         "    paramA, paramB, paramC);\n"
+                         "void functionDecl(\n"
+                         "    int A, int B, int C);"),
+               Input, Style);
+  Style.BreakAfterOpenBracketFunction = true;
+  Style.BreakBeforeCloseBracketFunction = true;
+  verifyFormat("functionCall(\n"
+               "    paramA, paramB, paramC\n"
+               ");\n"
+               "void functionDecl(\n"
+               "    int A, int B, int C\n"
+               ");",
+               Input, Style);
+
+  // When AllowAllArgumentsOnNextLine is set, we prefer breaking before the
+  // first argument.
+  Style.AllowAllArgumentsOnNextLine = true;
+  Style.BreakAfterOpenBracketFunction = true;
+  Style.BreakBeforeCloseBracketFunction = false;
+  verifyFormat(StringRef("functionCall(\n"
+                         "    paramA, paramB, paramC);\n"
+                         "void functionDecl(\n"
+                         "    int A, int B, int C);"),
+               Input, Style);
+  // It wouldn't fit on one line with aligned parameters so this setting
+  // doesn't change anything for BAS_Align.
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.BreakAfterOpenBracketFunction = false;
+  verifyFormat(StringRef("functionCall(paramA, paramB,\n"
+                         "             paramC);\n"
+                         "void functionDecl(int A, int B,\n"
+                         "                  int C);"),
+               Input, Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  verifyFormat(StringRef("functionCall(\n"
+                         "    paramA, paramB, paramC);\n"
+                         "void functionDecl(\n"
+                         "    int A, int B, int C);"),
+               Input, Style);
+}
+
+>>>>>>> d1e73bcfe430 (Add support for functions and replace AlwaysBreak, BlockIndent)
 TEST_F(FormatTest, BreakFunctionDefinitionParameters) {
   StringRef Input = "void functionDecl(paramA, paramB, paramC);\n"
                     "void emptyFunctionDefinition() {}\n"
@@ -9481,7 +9546,7 @@ TEST_F(FormatTest, AlignAndBreakControlStatements) {
       "}",
       Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   Style.BreakAfterOpenBracketIf = true;
   Style.BreakAfterOpenBracketLoop = true;
   Style.BreakAfterOpenBracketSwitch = true;
@@ -9549,7 +9614,6 @@ TEST_F(FormatTest, AlignAndBreakControlStatements) {
                "}",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
   Style.BreakAfterOpenBracketIf = true;
   Style.BreakAfterOpenBracketLoop = true;
   Style.BreakAfterOpenBracketSwitch = true;
@@ -9600,7 +9664,6 @@ TEST_F(FormatTest, AlignAndBreakControlStatements) {
                "}",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
   Style.BreakAfterOpenBracketIf = false;
   Style.BreakAfterOpenBracketLoop = false;
   Style.BreakAfterOpenBracketSwitch = false;
@@ -9649,7 +9712,6 @@ TEST_F(FormatTest, AlignAndBreakControlStatements) {
       "}",
       Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
   Style.BreakAfterOpenBracketIf = true;
   Style.BreakAfterOpenBracketLoop = true;
   Style.BreakAfterOpenBracketSwitch = true;
@@ -9706,7 +9768,6 @@ TEST_F(FormatTest, AlignAndBreakControlStatements) {
                "}",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
   Style.BreakAfterOpenBracketIf = false;
   Style.BreakAfterOpenBracketLoop = false;
   Style.BreakAfterOpenBracketSwitch = false;
@@ -11579,7 +11640,7 @@ TEST_F(FormatTest, WrapsTemplateParameters) {
       "    aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>\n"
       "    y;",
       Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   verifyFormat("template <typename... a> struct s {};\n"
                "extern s<\n"
@@ -11589,7 +11650,7 @@ TEST_F(FormatTest, WrapsTemplateParameters) {
                "aaaaaaaaaaaaaaaaaaaaaa>\n"
                "    y;",
                Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
   verifyFormat("template <typename... a> struct t {};\n"
                "extern t<\n"
@@ -16287,13 +16348,14 @@ TEST_F(FormatTest, BreaksStringLiteralOperands) {
   // In a function call with two operands, with AlignAfterOpenBracket enabled,
   // the first must be broken with a line break before it.
   FormatStyle Style = getLLVMStyleWithColumns(25);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   verifyFormat("someFunction(\n"
                "    \"long long long \"\n"
                "    \"long\",\n"
                "    a);",
                "someFunction(\"long long long long\", a);", Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BreakAfterOpenBracketFunction = true;
+  Style.BreakBeforeCloseBracketFunction = true;
   verifyFormat("someFunction(\n"
                "    \"long long long \"\n"
                "    \"long\",\n"
@@ -18088,7 +18150,7 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
 
   Spaces.ColumnLimit = 80;
   Spaces.IndentWidth = 4;
-  Spaces.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Spaces.BreakAfterOpenBracketFunction = true;
   verifyFormat("void foo( ) {\n"
                "    size_t foo = (*(function))(\n"
                "        Foooo, Barrrrr, Foooo, Barrrr, FoooooooooLooooong, "
@@ -18113,7 +18175,8 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
                "}",
                Spaces);
 
-  Spaces.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Spaces.BreakAfterOpenBracketFunction = true;
+  Spaces.BreakBeforeCloseBracketFunction = true;
   verifyFormat("void foo( ) {\n"
                "    size_t foo = (*(function))(\n"
                "        Foooo, Barrrrr, Foooo, Barrrr, FoooooooooLooooong, "
@@ -23033,7 +23096,7 @@ TEST_F(FormatTest, ConstructorInitializerIndentWidth) {
       ": aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa),\n"
       "  aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {}",
       Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   verifyFormat(
       "SomeLongTemplateVariableName<\n"
       "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>",
@@ -24288,7 +24351,7 @@ TEST_F(FormatTest, FormatsLambdas) {
                "      return aFunkyFunctionCall(qux);\n"
                "    }} {}",
                Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   // FIXME: The following test should pass, but fails at the time of writing.
 #if 0
   // As long as all the non-lambda arguments fit on a single line, AlwaysBreak
@@ -27634,409 +27697,6 @@ TEST_F(FormatTest, MultilineLambdaInConditional) {
                Style);
 }
 
-<<<<<<< HEAD
-=======
-TEST_F(FormatTest, AlignAfterOpenBracketBlockIndent) {
-  auto Style = getLLVMStyle();
-
-  StringRef Short = "functionCall(paramA, paramB, paramC);\n"
-                    "void functionDecl(int a, int b, int c);";
-
-  StringRef Medium = "functionCall(paramA, paramB, paramC, paramD, paramE, "
-                     "paramF, paramG, paramH, paramI);\n"
-                     "void functionDecl(int argumentA, int argumentB, int "
-                     "argumentC, int argumentD, int argumentE);";
-
-  verifyFormat(Short, Style);
-
-  StringRef NoBreak = "functionCall(paramA, paramB, paramC, paramD, paramE, "
-                      "paramF, paramG, paramH,\n"
-                      "             paramI);\n"
-                      "void functionDecl(int argumentA, int argumentB, int "
-                      "argumentC, int argumentD,\n"
-                      "                  int argumentE);";
-
-  verifyFormat(NoBreak, Medium, Style);
-  verifyFormat(NoBreak,
-               "functionCall(\n"
-               "    paramA,\n"
-               "    paramB,\n"
-               "    paramC,\n"
-               "    paramD,\n"
-               "    paramE,\n"
-               "    paramF,\n"
-               "    paramG,\n"
-               "    paramH,\n"
-               "    paramI\n"
-               ");\n"
-               "void functionDecl(\n"
-               "    int argumentA,\n"
-               "    int argumentB,\n"
-               "    int argumentC,\n"
-               "    int argumentD,\n"
-               "    int argumentE\n"
-               ");",
-               Style);
-
-  verifyFormat("outerFunctionCall(nestedFunctionCall(argument1),\n"
-               "                  nestedLongFunctionCall(argument1, "
-               "argument2, argument3,\n"
-               "                                         argument4, "
-               "argument5));",
-               Style);
-
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
-
-  verifyFormat(Short, Style);
-  verifyFormat(
-      "functionCall(\n"
-      "    paramA, paramB, paramC, paramD, paramE, paramF, paramG, paramH, "
-      "paramI\n"
-      ");\n"
-      "void functionDecl(\n"
-      "    int argumentA, int argumentB, int argumentC, int argumentD, int "
-      "argumentE\n"
-      ");",
-      Medium, Style);
-
-  Style.AllowAllArgumentsOnNextLine = false;
-  Style.AllowAllParametersOfDeclarationOnNextLine = false;
-
-  verifyFormat(Short, Style);
-  verifyFormat(
-      "functionCall(\n"
-      "    paramA, paramB, paramC, paramD, paramE, paramF, paramG, paramH, "
-      "paramI\n"
-      ");\n"
-      "void functionDecl(\n"
-      "    int argumentA, int argumentB, int argumentC, int argumentD, int "
-      "argumentE\n"
-      ");",
-      Medium, Style);
-
-  Style.BinPackArguments = false;
-  Style.BinPackParameters = FormatStyle::BPPS_OnePerLine;
-
-  verifyFormat(Short, Style);
-
-  verifyFormat("functionCall(\n"
-               "    paramA,\n"
-               "    paramB,\n"
-               "    paramC,\n"
-               "    paramD,\n"
-               "    paramE,\n"
-               "    paramF,\n"
-               "    paramG,\n"
-               "    paramH,\n"
-               "    paramI\n"
-               ");\n"
-               "void functionDecl(\n"
-               "    int argumentA,\n"
-               "    int argumentB,\n"
-               "    int argumentC,\n"
-               "    int argumentD,\n"
-               "    int argumentE\n"
-               ");",
-               Medium, Style);
-
-  verifyFormat("outerFunctionCall(\n"
-               "    nestedFunctionCall(argument1),\n"
-               "    nestedLongFunctionCall(\n"
-               "        argument1,\n"
-               "        argument2,\n"
-               "        argument3,\n"
-               "        argument4,\n"
-               "        argument5\n"
-               "    )\n"
-               ");",
-               Style);
-
-  verifyFormat("int a = (int)b;", Style);
-  verifyFormat("int a = (int)b;",
-               "int a = (\n"
-               "    int\n"
-               ") b;",
-               Style);
-
-  verifyFormat("return (true);", Style);
-  verifyFormat("return (true);",
-               "return (\n"
-               "    true\n"
-               ");",
-               Style);
-
-  verifyFormat("void foo();", Style);
-  verifyFormat("void foo();",
-               "void foo(\n"
-               ");",
-               Style);
-
-  verifyFormat("void foo() {}", Style);
-  verifyFormat("void foo() {}",
-               "void foo(\n"
-               ") {\n"
-               "}",
-               Style);
-
-  verifyFormat("auto string = std::string();", Style);
-  verifyFormat("auto string = std::string();",
-               "auto string = std::string(\n"
-               ");",
-               Style);
-
-  verifyFormat("void (*functionPointer)() = nullptr;", Style);
-  verifyFormat("void (*functionPointer)() = nullptr;",
-               "void (\n"
-               "    *functionPointer\n"
-               ")\n"
-               "(\n"
-               ") = nullptr;",
-               Style);
-}
-
-TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentIfStatement) {
-  auto Style = getLLVMStyle();
-
-  verifyFormat("if (foo()) {\n"
-               "  return;\n"
-               "}",
-               Style);
-
-  verifyFormat("if (quiteLongArg !=\n"
-               "    (alsoLongArg - 1)) { // ABC is a very longgggggggggggg "
-               "comment\n"
-               "  return;\n"
-               "}",
-               Style);
-
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
-
-  verifyFormat("if (foo()) {\n"
-               "  return;\n"
-               "}",
-               Style);
-
-  verifyFormat("if (quiteLongArg !=\n"
-               "    (alsoLongArg - 1)) { // ABC is a very longgggggggggggg "
-               "comment\n"
-               "  return;\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  if (camelCaseName < alsoLongName ||\n"
-               "      anotherEvenLongerName <=\n"
-               "          thisReallyReallyReallyReallyReallyReallyLongerName ||"
-               "\n"
-               "      otherName < thisLastName) {\n"
-               "    return;\n"
-               "  } else if (quiteLongName < alsoLongName ||\n"
-               "             anotherEvenLongerName <=\n"
-               "                 thisReallyReallyReallyReallyReallyReallyLonger"
-               "Name ||\n"
-               "             otherName < thisLastName) {\n"
-               "    return;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  Style.ContinuationIndentWidth = 2;
-  verifyFormat("void foo() {\n"
-               "  if (ThisIsRatherALongIfClause && thatIExpectToBeBroken ||\n"
-               "      ontoMultipleLines && whenFormattedCorrectly) {\n"
-               "    if (false) {\n"
-               "      return;\n"
-               "    } else if (thisIsRatherALongIfClause && "
-               "thatIExpectToBeBroken ||\n"
-               "               ontoMultipleLines && whenFormattedCorrectly) {\n"
-               "      return;\n"
-               "    }\n"
-               "  }\n"
-               "}",
-               Style);
-}
-
-TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentForStatement) {
-  auto Style = getLLVMStyle();
-
-  verifyFormat("for (int i = 0; i < 5; ++i) {\n"
-               "  doSomething();\n"
-               "}",
-               Style);
-
-  verifyFormat("for (int myReallyLongCountVariable = 0; "
-               "myReallyLongCountVariable < count;\n"
-               "     myReallyLongCountVariable++) {\n"
-               "  doSomething();\n"
-               "}",
-               Style);
-
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
-
-  verifyFormat("for (int i = 0; i < 5; ++i) {\n"
-               "  doSomething();\n"
-               "}",
-               Style);
-
-  verifyFormat("for (int myReallyLongCountVariable = 0; "
-               "myReallyLongCountVariable < count;\n"
-               "     myReallyLongCountVariable++) {\n"
-               "  doSomething();\n"
-               "}",
-               Style);
-}
-
-TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentInitializers) {
-  auto Style = getLLVMStyleWithColumns(60);
-  Style.BreakAfterOpenBracketBracedList = true;
-  Style.BreakBeforeCloseBracketBracedList = true;
-  // Aggregate initialization.
-  verifyFormat("int LooooooooooooooooooooooooongVariable[2] = {\n"
-               "    10000000, 20000000\n"
-               "};",
-               Style);
-  verifyFormat("SomeStruct s{\n"
-               "    \"xxxxxxxxxxxxxxxx\", \"yyyyyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzzzzz\"\n"
-               "};",
-               Style);
-  // Designated initializers.
-  verifyFormat("int LooooooooooooooooooooooooongVariable[2] = {\n"
-               "    [0] = 10000000, [1] = 20000000\n"
-               "};",
-               Style);
-  verifyFormat("SomeStruct s{\n"
-               "    .foo = \"xxxxxxxxxxxxx\",\n"
-               "    .bar = \"yyyyyyyyyyyyy\",\n"
-               "    .baz = \"zzzzzzzzzzzzz\"\n"
-               "};",
-               Style);
-  // List initialization.
-  verifyFormat("SomeStruct s{\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "};",
-               Style);
-  verifyFormat("SomeStruct{\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "};",
-               Style);
-  verifyFormat("new SomeStruct{\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "};",
-               Style);
-  // Member initializer.
-  verifyFormat("class SomeClass {\n"
-               "  SomeStruct s{\n"
-               "      \"xxxxxxxxxxxxx\",\n"
-               "      \"yyyyyyyyyyyyy\",\n"
-               "      \"zzzzzzzzzzzzz\",\n"
-               "  };\n"
-               "};",
-               Style);
-  // Constructor member initializer.
-  verifyFormat("SomeClass::SomeClass : strct{\n"
-               "                           \"xxxxxxxxxxxxx\",\n"
-               "                           \"yyyyyyyyyyyyy\",\n"
-               "                           \"zzzzzzzzzzzzz\",\n"
-               "                       } {}",
-               Style);
-  // Copy initialization.
-  verifyFormat("SomeStruct s = SomeStruct{\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "};",
-               Style);
-  // Copy list initialization.
-  verifyFormat("SomeStruct s = {\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "};",
-               Style);
-  // Assignment operand initialization.
-  verifyFormat("s = {\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "};",
-               Style);
-  // Returned object initialization.
-  verifyFormat("return {\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "};",
-               Style);
-  // Initializer list.
-  verifyFormat("auto initializerList = {\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "};",
-               Style);
-  // Function parameter initialization.
-  verifyFormat("func({\n"
-               "    \"xxxxxxxxxxxxx\",\n"
-               "    \"yyyyyyyyyyyyy\",\n"
-               "    \"zzzzzzzzzzzzz\",\n"
-               "});",
-               Style);
-  // Nested init lists.
-  verifyFormat("SomeStruct s = {\n"
-               "    {{init1, init2, init3, init4, init5},\n"
-               "     {init1, init2, init3, init4, init5}}\n"
-               "};",
-               Style);
-  verifyFormat("SomeStruct s = {\n"
-               "    {{\n"
-               "         .init1 = 1,\n"
-               "         .init2 = 2,\n"
-               "         .init3 = 3,\n"
-               "         .init4 = 4,\n"
-               "         .init5 = 5,\n"
-               "     },\n"
-               "     {init1, init2, init3, init4, init5}}\n"
-               "};",
-               Style);
-  verifyFormat("SomeArrayT a[3] = {\n"
-               "    {\n"
-               "        foo,\n"
-               "        bar,\n"
-               "    },\n"
-               "    {\n"
-               "        foo,\n"
-               "        bar,\n"
-               "    },\n"
-               "    SomeArrayT{},\n"
-               "};",
-               Style);
-  verifyFormat("SomeArrayT a[3] = {\n"
-               "    {foo},\n"
-               "    {\n"
-               "        {\n"
-               "            init1,\n"
-               "            init2,\n"
-               "            init3,\n"
-               "        },\n"
-               "        {\n"
-               "            init1,\n"
-               "            init2,\n"
-               "            init3,\n"
-               "        },\n"
-               "    },\n"
-               "    {baz},\n"
-               "};",
-               Style);
-}
-
->>>>>>> cbd14c5d622a (add support for braced list initializers)
 TEST_F(FormatTest, UnderstandsDigraphs) {
   verifyFormat("int arr<:5:> = {};");
   verifyFormat("int arr[5] = <%%>;");
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 91577b9a49167..4847151c14b33 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -2883,7 +2883,7 @@ TEST_F(FormatTestJS, DontBreakFieldsAsGoToLabels) {
 
 TEST_F(FormatTestJS, BreakAfterOpenBracket) {
   auto Style = getGoogleStyle(FormatStyle::LK_JavaScript);
-  EXPECT_EQ(Style.AlignAfterOpenBracket, FormatStyle::BAS_AlwaysBreak);
+  EXPECT_EQ(Style.BreakAfterOpenBracketFunction, true);
   verifyFormat("ctrl.onCopy(/** @type {!WizEvent}*/ (\n"
                "    {event, targetElement: {el: () => selectedElement}}));",
                Style);

>From 6ea6f46c4a4026a9a6bf39453aa919a37c1aab93 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 22 Aug 2025 14:50:43 -0600
Subject: [PATCH 12/48] deprecate AlwaysBreak and BlockIndent

---
 clang/include/clang/Format/Format.h | 28 ++++++++---------------
 clang/lib/Format/Format.cpp         | 35 +++++++++++++++++++++++++++--
 2 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 6927acf08cdc8..38e6a00046da1 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -127,26 +127,16 @@ struct FormatStyle {
     ///       argument2);
     /// \endcode
     BAS_DontAlign,
-    /// Always break after an open bracket, if the parameters don't fit
-    /// on a single line, e.g.:
-    /// \code
-    ///   someLongFunction(
-    ///       argument1, argument2);
-    /// \endcode
+    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     BAS_AlwaysBreak,
-    /// Always break after an open bracket, if the parameters don't fit
-    /// on a single line. Closing brackets will be placed on a new line.
-    /// E.g.:
-    /// \code
-    ///   someLongFunction(
-    ///       argument1, argument2
-    ///   )
-    /// \endcode
-    ///
-    /// \note
-    ///  This currently only applies to braced initializer lists (when
-    ///  ``Cpp11BracedListStyle`` is ``true``) and parentheses.
-    /// \endnote
+    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    /// in combination with ``BreakBeforeCloseBracketBracedList``,
+    /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
+    /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
     BAS_BlockIndent,
   };
 
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 6a46da1733d8c..316735914beac 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -208,12 +208,12 @@ template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
   static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
     IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
     IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign);
-    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak);
-    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BlockIndent);
 
     // For backward compatibility.
     IO.enumCase(Value, "true", FormatStyle::BAS_Align);
     IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
+    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak);
+    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BlockIndent);
   }
 };
 
@@ -1275,6 +1275,37 @@ template <> struct MappingTraits<FormatStyle> {
     IO.mapOptional("WrapNamespaceBodyWithEmptyLines",
                    Style.WrapNamespaceBodyWithEmptyLines);
 
+    // If AlwaysBreak or BlockIndent were specified but individual
+    // options for BreakAfterOpenBracket* (CloseAfterOpenBracket*),
+    // initialize the latter to preserve backwards compatibility.
+    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak) {
+      if (!Style.BreakAfterOpenBracketBracedList &&
+          !Style.BreakAfterOpenBracketFunction &&
+          !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
+          !Style.BreakAfterOpenBracketSwitch) {
+        Style.BreakAfterOpenBracketBracedList = true;
+        Style.BreakAfterOpenBracketFunction = true;
+        Style.BreakAfterOpenBracketIf = true;
+      }
+    } else if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+      if (!Style.BreakAfterOpenBracketBracedList &&
+          !Style.BreakAfterOpenBracketFunction &&
+          !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
+          !Style.BreakAfterOpenBracketSwitch &&
+          !Style.BreakBeforeCloseBracketBracedList &&
+          !Style.BreakBeforeCloseBracketFunction &&
+          !Style.BreakBeforeCloseBracketIf &&
+          !Style.BreakBeforeCloseBracketLoop &&
+          !Style.BreakBeforeCloseBracketSwitch) {
+        Style.BreakAfterOpenBracketBracedList = true;
+        Style.BreakAfterOpenBracketFunction = true;
+        Style.BreakAfterOpenBracketIf = true;
+        Style.BreakBeforeCloseBracketBracedList = true;
+        Style.BreakBeforeCloseBracketFunction = true;
+        Style.BreakBeforeCloseBracketIf = true;
+      }
+    }
+
     // If AlwaysBreakAfterDefinitionReturnType was specified but
     // BreakAfterReturnType was not, initialize the latter from the former for
     // backwards compatibility.

>From 48466f15fcc5561da140021b51f3abf5713af9e6 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Wed, 21 May 2025 20:59:31 -0600
Subject: [PATCH 13/48] dump format style

---
 clang/docs/ClangFormatStyleOptions.rst | 135 ++++++++++++++++---------
 clang/lib/Format/Format.cpp            |   4 +
 2 files changed, 93 insertions(+), 46 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 9c34af0f75778..5f2182d680974 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -222,30 +222,17 @@ the configuration (without a prefix: ``Auto``).
           argument2);
 
   * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
-    Always break after an open bracket, if the parameters don't fit
-    on a single line, e.g.:
-
-    .. code-block:: c++
-
-      someLongFunction(
-          argument1, argument2);
+    This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
 
   * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``)
-    Always break after an open bracket, if the parameters don't fit
-    on a single line. Closing brackets will be placed on a new line.
-    E.g.:
-
-    .. code-block:: c++
-
-      someLongFunction(
-          argument1, argument2
-      )
-
-
-    .. note::
-
-     This currently only applies to braced initializer lists (when
-     ``Cpp11BracedListStyle`` is ``true``) and parentheses.
+    This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    in combination with ``BreakBeforeCloseBracketBracedList``,
+    ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
+    ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
 
 
 
@@ -2746,9 +2733,34 @@ the configuration (without a prefix: ``Auto``).
      @Mock
      DataLoad loader;
 
+.. _BreakAfterOpenBracketBracedList:
+
+**BreakAfterOpenBracketBracedList** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketBracedList>`
+  Force break after the left bracket of a braced initializer list (when
+   ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    vector<int> x {         vs.       vector<int> x {1,
+       1, 2, 3}                            2, 3}
+
+.. _BreakAfterOpenBracketFunction:
+
+**BreakAfterOpenBracketFunction** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketFunction>`
+  Force break after the left parenthesis of a function (declaration,
+  definition, call) when the parameters exceed the column limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    foo (                   vs.       foo (a ||
+       a || b)                             b)
+
 .. _BreakAfterOpenBracketIf:
 
-**BreakAfterOpenBracketIf** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakAfterOpenBracketIf>`
+**BreakAfterOpenBracketIf** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketIf>`
   Force break after the left parenthesis of an if control statement
   when the expression exceeds the column limit.
 
@@ -2756,12 +2768,11 @@ the configuration (without a prefix: ``Auto``).
 
     true:                             false:
     if constexpr (          vs.       if constexpr (a ||
-                  a ||                              b)
-                  b)
+       a || b)                                      b)
 
 .. _BreakAfterOpenBracketLoop:
 
-**BreakAfterOpenBracketLoop** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakAfterOpenBracketLoop>`
+**BreakAfterOpenBracketLoop** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketLoop>`
   Force break after the left parenthesis of a loop control statement
   when the expression exceeds the column limit.
 
@@ -2769,12 +2780,11 @@ the configuration (without a prefix: ``Auto``).
 
     true:                             false:
     while (                  vs.      while (a &&
-           a &&                              b) {
-           b) {
+       a && b) {                             b) {
 
 .. _BreakAfterOpenBracketSwitch:
 
-**BreakAfterOpenBracketSwitch** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakAfterOpenBracketSwitch>`
+**BreakAfterOpenBracketSwitch** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketSwitch>`
   Force break after the left parenthesis of a switch control statement
   when the expression exceeds the column limit.
 
@@ -2782,8 +2792,7 @@ the configuration (without a prefix: ``Auto``).
 
     true:                             false:
     switch (                 vs.      switch (a &&
-            a &&                              b) {
-            b) {
+       a && b) {                              b) {
 
 .. _BreakAfterReturnType:
 
@@ -3422,44 +3431,78 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+.. _BreakBeforeCloseBracketBracedList:
+
+**BreakBeforeCloseBracketBracedList** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketBracedList>`
+  Force break before the right bracket of a braced initializer list (when
+   ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  limit. The break before the right bracket is only made if there is a
+  break after the opening bracket.
+
+  .. code-block:: c++
+
+    true:                             false:
+    vector<int> x {         vs.       vector<int> x {
+       1, 2, 3                           1, 2, 3}
+    }
+
+.. _BreakBeforeCloseBracketFunction:
+
+**BreakBeforeCloseBracketFunction** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketFunction>`
+  Force break before the right parenthesis of a function (declaration,
+  definition, call) when the parameters exceed the column limit.
+
+  .. code-block:: c++
+
+    true:                             false:
+    foo (                   vs.       foo (
+       a || b                            a || b)
+    )
+
 .. _BreakBeforeCloseBracketIf:
 
-**BreakBeforeCloseBracketIf** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakBeforeCloseBracketIf>`
+**BreakBeforeCloseBracketIf** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketIf>`
   Force break before the right parenthesis of an if control statement
-  when the expression exceeds the column limit.
+  when the expression exceeds the column limit. The break before the
+  closing parenthesis is only made if there is a break after the opening
+  parenthesis.
 
   .. code-block:: c++
 
     true:                             false:
-    if constexpr (a ||      vs.       if constexpr (a ||
-                  b                                 b)
-                  )
+    if constexpr (          vs.       if constexpr (
+       a || b                            a || b )
+    )
 
 .. _BreakBeforeCloseBracketLoop:
 
-**BreakBeforeCloseBracketLoop** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakBeforeCloseBracketLoop>`
+**BreakBeforeCloseBracketLoop** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketLoop>`
   Force break before the right parenthesis of a loop control statement
-  when the expression exceeds the column limit.
+  when the expression exceeds the column limit. The break before the
+  closing parenthesis is only made if there is a break after the opening
+  parenthesis.
 
   .. code-block:: c++
 
     true:                             false:
-    while (a &&              vs.      while (a &&
-           b                                 b) {
-           ) {
+    while (                  vs.      while (
+       a && b                            a && b) {
+    ) {
 
 .. _BreakBeforeCloseBracketSwitch:
 
-**BreakBeforeCloseBracketSwitch** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ <BreakBeforeCloseBracketSwitch>`
+**BreakBeforeCloseBracketSwitch** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketSwitch>`
   Force break before the right parenthesis of a switch control statement
-  when the expression exceeds the column limit.
+  when the expression exceeds the column limit. The break before the
+  closing parenthesis is only made if there is a break after the opening
+  parenthesis.
 
   .. code-block:: c++
 
     true:                             false:
-    switch (a &&             vs.      switch (a &&
-            b                                 b) {
-            ) {
+    switch (                 vs.      switch (
+       a && b                            a && b) {
+    ) {
 
 .. _BreakBeforeConceptDeclarations:
 
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 316735914beac..6fe33ef13d18b 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1069,6 +1069,8 @@ template <> struct MappingTraits<FormatStyle> {
                    Style.BreakAfterJavaFieldAnnotations);
     IO.mapOptional("BreakAfterOpenBracketBracedList",
                    Style.BreakAfterOpenBracketBracedList);
+    IO.mapOptional("BreakAfterOpenBracketFunction",
+                   Style.BreakAfterOpenBracketFunction);
     IO.mapOptional("BreakAfterOpenBracketIf", Style.BreakAfterOpenBracketIf);
     IO.mapOptional("BreakAfterOpenBracketLoop",
                    Style.BreakAfterOpenBracketLoop);
@@ -1080,6 +1082,8 @@ template <> struct MappingTraits<FormatStyle> {
                    Style.BreakBeforeBinaryOperators);
     IO.mapOptional("BreakBeforeCloseBracketBracedList",
                    Style.BreakBeforeCloseBracketBracedList);
+    IO.mapOptional("BreakBeforeCloseBracketFunction",
+                   Style.BreakBeforeCloseBracketFunction);
     IO.mapOptional("BreakBeforeCloseBracketIf",
                    Style.BreakBeforeCloseBracketIf);
     IO.mapOptional("BreakBeforeCloseBracketLoop",

>From d9ea7f8c64f7e30cc402ed13f6f3b743d3e6ee3a Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 22 Aug 2025 16:54:11 -0600
Subject: [PATCH 14/48] fix leading whitespace

---
 clang/include/clang/Format/Format.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 38e6a00046da1..7a403beea284c 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -63,7 +63,7 @@ struct FormatStyle {
   int AccessModifierOffset;
 
   /// Force break after the left bracket of a braced initializer list (when
-  ///  ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  /// ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
   /// limit.
   /// \code
   ///   true:                             false:

>From eec50dc945170b73f9bfa58a7aeb24927324d354 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 22 Aug 2025 16:54:21 -0600
Subject: [PATCH 15/48] dump style

---
 clang/docs/ClangFormatStyleOptions.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 5f2182d680974..02c712f8332a4 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2737,7 +2737,7 @@ the configuration (without a prefix: ``Auto``).
 
 **BreakAfterOpenBracketBracedList** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketBracedList>`
   Force break after the left bracket of a braced initializer list (when
-   ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
   limit.
 
   .. code-block:: c++

>From a6ef2e9efca3d870e656fb571b193f41836dff8c Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 22 Aug 2025 18:09:56 -0600
Subject: [PATCH 16/48] fix leading whitespace

---
 clang/include/clang/Format/Format.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 7a403beea284c..75c3a2b48c5b0 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2263,7 +2263,7 @@ struct FormatStyle {
   BraceBreakingStyle BreakBeforeBraces;
 
   /// Force break before the right bracket of a braced initializer list (when
-  ///  ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  /// ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
   /// limit. The break before the right bracket is only made if there is a
   /// break after the opening bracket.
   /// \code

>From aa88c9091f6f64b10702423e165005a1aab00911 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 22 Aug 2025 18:10:26 -0600
Subject: [PATCH 17/48] dump style

---
 clang/docs/ClangFormatStyleOptions.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 02c712f8332a4..e8477bf622f55 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3435,7 +3435,7 @@ the configuration (without a prefix: ``Auto``).
 
 **BreakBeforeCloseBracketBracedList** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketBracedList>`
   Force break before the right bracket of a braced initializer list (when
-   ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
   limit. The break before the right bracket is only made if there is a
   break after the opening bracket.
 

>From 339cabe97df704e2c93e6422513568beb200f3b5 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 08:38:49 -0600
Subject: [PATCH 18/48] Format.h: update examples and sort options

---
 clang/include/clang/Format/Format.h | 106 ++++++++++++++--------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 75c3a2b48c5b0..c33a6193c2a26 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,57 +62,6 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
-  /// Force break after the left bracket of a braced initializer list (when
-  /// ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
-  /// limit.
-  /// \code
-  ///   true:                             false:
-  ///   vector<int> x {         vs.       vector<int> x {1,
-  ///      1, 2, 3}                            2, 3}
-  /// \endcode
-  /// \version 22
-  bool BreakAfterOpenBracketBracedList;
-
-  /// Force break after the left parenthesis of a function (declaration,
-  /// definition, call) when the parameters exceed the column limit.
-  /// \code
-  ///   true:                             false:
-  ///   foo (                   vs.       foo (a ||
-  ///      a || b)                             b)
-  /// \endcode
-  /// \version 22
-  bool BreakAfterOpenBracketFunction;
-
-  /// Force break after the left parenthesis of an if control statement
-  /// when the expression exceeds the column limit.
-  /// \code
-  ///   true:                             false:
-  ///   if constexpr (          vs.       if constexpr (a ||
-  ///      a || b)                                      b)
-  /// \endcode
-  /// \version 22
-  bool BreakAfterOpenBracketIf;
-
-  /// Force break after the left parenthesis of a loop control statement
-  /// when the expression exceeds the column limit.
-  /// \code
-  ///   true:                             false:
-  ///   while (                  vs.      while (a &&
-  ///      a && b) {                             b) {
-  /// \endcode
-  /// \version 22
-  bool BreakAfterOpenBracketLoop;
-
-  /// Force break after the left parenthesis of a switch control statement
-  /// when the expression exceeds the column limit.
-  /// \code
-  ///   true:                             false:
-  ///   switch (                 vs.      switch (a &&
-  ///      a && b) {                              b) {
-  /// \endcode
-  /// \version 22
-  bool BreakAfterOpenBracketSwitch;
-
   /// Different styles for aligning after open brackets.
   enum BracketAlignmentStyle : int8_t {
     /// Align parameters on the open bracket, e.g.:
@@ -1749,6 +1698,57 @@ struct FormatStyle {
   /// \version 16
   AttributeBreakingStyle BreakAfterAttributes;
 
+  /// Force break after the left bracket of a braced initializer list (when
+  /// ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column
+  /// limit.
+  /// \code
+  ///   true:                             false:
+  ///   vector<int> x {         vs.       vector<int> x {1,
+  ///      1, 2, 3}                            2, 3}
+  /// \endcode
+  /// \version 22
+  bool BreakAfterOpenBracketBracedList;
+
+  /// Force break after the left parenthesis of a function (declaration,
+  /// definition, call) when the parameters exceed the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   foo (                   vs.       foo (a,
+  ///      a , b)                              b)
+  /// \endcode
+  /// \version 22
+  bool BreakAfterOpenBracketFunction;
+
+  /// Force break after the left parenthesis of an if control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   if constexpr (          vs.       if constexpr (a ||
+  ///      a || b)                                      b)
+  /// \endcode
+  /// \version 22
+  bool BreakAfterOpenBracketIf;
+
+  /// Force break after the left parenthesis of a loop control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   while (                  vs.      while (a &&
+  ///      a && b) {                             b) {
+  /// \endcode
+  /// \version 22
+  bool BreakAfterOpenBracketLoop;
+
+  /// Force break after the left parenthesis of a switch control statement
+  /// when the expression exceeds the column limit.
+  /// \code
+  ///   true:                             false:
+  ///   switch (                 vs.      switch (a +
+  ///      a + b) {                               b) {
+  /// \endcode
+  /// \version 22
+  bool BreakAfterOpenBracketSwitch;
+
   /// The function declaration return type breaking style to use.
   /// \version 19
   ReturnTypeBreakingStyle BreakAfterReturnType;
@@ -2280,7 +2280,7 @@ struct FormatStyle {
   /// \code
   ///   true:                             false:
   ///   foo (                   vs.       foo (
-  ///      a || b                            a || b)
+  ///      a , b                             a , b)
   ///   )
   /// \endcode
   /// \version 22
@@ -2319,7 +2319,7 @@ struct FormatStyle {
   /// \code
   ///   true:                             false:
   ///   switch (                 vs.      switch (
-  ///      a && b                            a && b) {
+  ///      a + b                             a + b) {
   ///   ) {
   /// \endcode
   /// \version 22

>From 400bcdf65cdac249405aee7adca7b5d79531059d Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 08:39:03 -0600
Subject: [PATCH 19/48] dump format style

---
 clang/docs/ClangFormatStyleOptions.rst | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index e8477bf622f55..4cd63ec2d556d 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2755,8 +2755,8 @@ the configuration (without a prefix: ``Auto``).
   .. code-block:: c++
 
     true:                             false:
-    foo (                   vs.       foo (a ||
-       a || b)                             b)
+    foo (                   vs.       foo (a,
+       a , b)                              b)
 
 .. _BreakAfterOpenBracketIf:
 
@@ -2791,8 +2791,8 @@ the configuration (without a prefix: ``Auto``).
   .. code-block:: c++
 
     true:                             false:
-    switch (                 vs.      switch (a &&
-       a && b) {                              b) {
+    switch (                 vs.      switch (a +
+       a + b) {                               b) {
 
 .. _BreakAfterReturnType:
 
@@ -3456,7 +3456,7 @@ the configuration (without a prefix: ``Auto``).
 
     true:                             false:
     foo (                   vs.       foo (
-       a || b                            a || b)
+       a , b                             a , b)
     )
 
 .. _BreakBeforeCloseBracketIf:
@@ -3501,7 +3501,7 @@ the configuration (without a prefix: ``Auto``).
 
     true:                             false:
     switch (                 vs.      switch (
-       a && b                            a && b) {
+       a + b                             a + b) {
     ) {
 
 .. _BreakBeforeConceptDeclarations:

>From f235712edbd25b26eb84028b466562463de1a27b Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 08:58:22 -0600
Subject: [PATCH 20/48] refactor conditionals from comments

---
 clang/lib/Format/ContinuationIndenter.cpp | 15 +++++++--------
 clang/lib/Format/FormatToken.cpp          |  4 +---
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index b6cdb39d54293..a994d6b380d29 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -356,15 +356,14 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
     return CurrentState.BreakBeforeClosingBrace;
   }
 
-  // Allow breaking before the right parens with block indentation if there was
-  // a break after the left parens, which is tracked by BreakBeforeClosingParen.
-  bool might_break_before = Style.BreakBeforeCloseBracketFunction ||
-                            Style.BreakBeforeCloseBracketIf ||
-                            Style.BreakBeforeCloseBracketLoop ||
-                            Style.BreakBeforeCloseBracketSwitch;
-
-  if (might_break_before && Current.is(tok::r_paren))
+  // Check need to break before the right parens if there was a break after
+  // the left parens, which is tracked by BreakBeforeClosingParen.
+  if ((Style.BreakBeforeCloseBracketFunction ||
+       Style.BreakBeforeCloseBracketIf || Style.BreakBeforeCloseBracketLoop ||
+       Style.BreakBeforeCloseBracketSwitch) &&
+      Current.is(tok::r_paren)) {
     return CurrentState.BreakBeforeClosingParen;
+  }
 
   if (Style.BreakBeforeTemplateCloser && Current.is(TT_TemplateCloser))
     return CurrentState.BreakBeforeClosingAngle;
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index 514b1f0bbe09f..bd35c705fbec0 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -66,10 +66,8 @@ bool FormatToken::isTypeOrIdentifier(const LangOptions &LangOpts) const {
 
 bool FormatToken::isBlockIndentedInitRBrace(const FormatStyle &Style) const {
   assert(is(tok::r_brace));
-  if (!Style.Cpp11BracedListStyle ||
-      Style.BreakBeforeCloseBracketBracedList == false) {
+  if (!Style.Cpp11BracedListStyle || !Style.BreakBeforeCloseBracketBracedList)
     return false;
-  }
   const auto *LBrace = MatchingParen;
   assert(LBrace && LBrace->is(tok::l_brace));
   if (LBrace->is(BK_BracedInit))

>From f7ebecca646416b98ddd3d6f7b65228f3b997495 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 09:58:23 -0600
Subject: [PATCH 21/48] refactor lambda to FormatToken::isLoop

---
 clang/lib/Format/ContinuationIndenter.cpp | 17 +++--------------
 clang/lib/Format/FormatToken.h            |  6 ++++++
 clang/lib/Format/TokenAnnotator.cpp       |  7 +------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index a994d6b380d29..213b96089ffa3 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -832,11 +832,6 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // parenthesis by disallowing any further line breaks if there is no line
   // break after the opening parenthesis. Don't break if it doesn't conserve
   // columns.
-  auto IsLoopConditional = [&](const FormatToken &Tok) {
-    return Tok.isOneOf(tok::kw_for, tok::kw_while) ||
-           (Style.isJavaScript() && Tok.is(Keywords.kw_await) && Tok.Previous &&
-            Tok.Previous->is(tok::kw_for));
-  };
   auto IsOpeningBracket = [&](const FormatToken &Tok) {
     auto IsStartOfBracedList = [&]() {
       return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
@@ -850,7 +845,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
       return true;
     if (Tok.Previous->isIf())
       return Style.BreakAfterOpenBracketIf;
-    if (IsLoopConditional(*Tok.Previous))
+    if (Tok.Previous->isLoop(Style))
       return Style.BreakAfterOpenBracketLoop;
     if (Tok.Previous->is(tok::kw_switch))
       return Style.BreakAfterOpenBracketSwitch;
@@ -898,7 +893,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
     const auto *Previous = TokAfterLParen.Previous;
     assert(Previous); // IsOpeningBracket(Previous)
     if (Previous->Previous &&
-        (Previous->Previous->isIf() || IsLoopConditional(*Previous->Previous) ||
+        (Previous->Previous->isIf() || Previous->Previous->isLoop(Style) ||
          Previous->Previous->is(tok::kw_switch))) {
       return false;
     }
@@ -1283,15 +1278,9 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
     auto Previous = PreviousNonComment->Previous;
     if (Previous) {
 
-      auto IsLoopConditional = [&](const FormatToken &Tok) {
-        return Tok.isOneOf(tok::kw_for, tok::kw_while) ||
-               (Style.isJavaScript() && Tok.is(Keywords.kw_await) &&
-                Tok.Previous && Tok.Previous->is(tok::kw_for));
-      };
-
       if (Previous->isIf()) {
         CurrentState.BreakBeforeClosingParen = Style.BreakBeforeCloseBracketIf;
-      } else if (IsLoopConditional(*Previous)) {
+      } else if (Previous->isLoop(Style)) {
         CurrentState.BreakBeforeClosingParen =
             Style.BreakBeforeCloseBracketLoop;
       } else if (Previous->is(tok::kw_switch)) {
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index e04b0e7af10c0..bfd917b8b7c51 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -651,6 +651,12 @@ struct FormatToken {
            (endsSequence(tok::identifier, tok::kw_if) && AllowConstexprMacro);
   }
 
+  bool isLoop(const FormatStyle &Style) const {
+    return this->isOneOf(tok::kw_for, tok::kw_while) ||
+           (Style.isJavaScript() && this->isNot(tok::l_paren) &&
+            this->Previous && this->Previous->is(tok::kw_for));
+  }
+
   bool closesScopeAfterBlock() const {
     if (getBlockKind() == BK_Block)
       return true;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index d144f0e66a86a..f38577238e73f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -6243,12 +6243,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
       return false;
     if (Previous->isIf())
       return Style.BreakBeforeCloseBracketIf;
-    auto IsLoopConditional = [&](const FormatToken &Tok) {
-      return Tok.isOneOf(tok::kw_for, tok::kw_while) ||
-             (Style.isJavaScript() && Tok.is(Keywords.kw_await) &&
-              Tok.Previous && Tok.Previous->is(tok::kw_for));
-    };
-    if (IsLoopConditional(*Previous))
+    if (Previous->isLoop(Style))
       return Style.BreakBeforeCloseBracketLoop;
     if (Previous->is(tok::kw_switch))
       return Style.BreakBeforeCloseBracketSwitch;

>From e5151a847bb8ac304e6edb59af756f240f3750b6 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 10:27:56 -0600
Subject: [PATCH 22/48] remove deprecated sub-options for AlwaysBreak and
 BlockIndent

---
 clang/include/clang/Format/Format.h        |  4 +--
 clang/lib/Format/Format.cpp                | 33 ----------------------
 clang/unittests/Format/ConfigParseTest.cpp |  7 ++---
 3 files changed, 4 insertions(+), 40 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index c33a6193c2a26..e10c5503e8f30 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -79,14 +79,14 @@ struct FormatStyle {
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    BAS_AlwaysBreak,
+    /// BAS_AlwaysBreak,
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     /// in combination with ``BreakBeforeCloseBracketBracedList``,
     /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    BAS_BlockIndent,
+    /// BAS_BlockIndent,
   };
 
   /// If ``true``, horizontally aligns arguments after an open bracket.
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 6fe33ef13d18b..b1b2c74ff8969 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -212,8 +212,6 @@ template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
     // For backward compatibility.
     IO.enumCase(Value, "true", FormatStyle::BAS_Align);
     IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
-    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak);
-    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BlockIndent);
   }
 };
 
@@ -1279,37 +1277,6 @@ template <> struct MappingTraits<FormatStyle> {
     IO.mapOptional("WrapNamespaceBodyWithEmptyLines",
                    Style.WrapNamespaceBodyWithEmptyLines);
 
-    // If AlwaysBreak or BlockIndent were specified but individual
-    // options for BreakAfterOpenBracket* (CloseAfterOpenBracket*),
-    // initialize the latter to preserve backwards compatibility.
-    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak) {
-      if (!Style.BreakAfterOpenBracketBracedList &&
-          !Style.BreakAfterOpenBracketFunction &&
-          !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
-          !Style.BreakAfterOpenBracketSwitch) {
-        Style.BreakAfterOpenBracketBracedList = true;
-        Style.BreakAfterOpenBracketFunction = true;
-        Style.BreakAfterOpenBracketIf = true;
-      }
-    } else if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
-      if (!Style.BreakAfterOpenBracketBracedList &&
-          !Style.BreakAfterOpenBracketFunction &&
-          !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
-          !Style.BreakAfterOpenBracketSwitch &&
-          !Style.BreakBeforeCloseBracketBracedList &&
-          !Style.BreakBeforeCloseBracketFunction &&
-          !Style.BreakBeforeCloseBracketIf &&
-          !Style.BreakBeforeCloseBracketLoop &&
-          !Style.BreakBeforeCloseBracketSwitch) {
-        Style.BreakAfterOpenBracketBracedList = true;
-        Style.BreakAfterOpenBracketFunction = true;
-        Style.BreakAfterOpenBracketIf = true;
-        Style.BreakBeforeCloseBracketBracedList = true;
-        Style.BreakBeforeCloseBracketFunction = true;
-        Style.BreakBeforeCloseBracketIf = true;
-      }
-    }
-
     // If AlwaysBreakAfterDefinitionReturnType was specified but
     // BreakAfterReturnType was not, initialize the latter from the former for
     // backwards compatibility.
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 81ec2090cb448..070fd37f3ead1 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -544,15 +544,12 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma,
               FormatStyle::ETC_Remove);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
               FormatStyle::BAS_Align);
   CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
               FormatStyle::BAS_DontAlign);
-  CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,
-              FormatStyle::BAS_AlwaysBreak);
-  CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket,
-              FormatStyle::BAS_BlockIndent);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   // For backward compatibility:
   CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,
               FormatStyle::BAS_DontAlign);

>From 4a1c12efa3f71645ce5d86ad1293a88a67f8893a Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 10:52:07 -0600
Subject: [PATCH 23/48] deprecate and remove BAS_Align and BAS_DontAlign

---
 clang/include/clang/Format/Format.h          |  42 +--
 clang/lib/Format/ContinuationIndenter.cpp    |   9 +-
 clang/lib/Format/Format.cpp                  |  17 +-
 clang/lib/Format/FormatToken.cpp             |   2 +-
 clang/lib/Format/TokenAnnotator.cpp          |   6 +-
 clang/unittests/Format/AlignBracketsTest.cpp |  16 +-
 clang/unittests/Format/ConfigParseTest.cpp   |  13 +-
 clang/unittests/Format/FormatTest.cpp        | 352 +------------------
 8 files changed, 44 insertions(+), 413 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index e10c5503e8f30..c2cc4e2cfd22d 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,39 +62,25 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
-  /// Different styles for aligning after open brackets.
-  enum BracketAlignmentStyle : int8_t {
-    /// Align parameters on the open bracket, e.g.:
-    /// \code
-    ///   someLongFunction(argument1,
-    ///                    argument2);
-    /// \endcode
-    BAS_Align,
-    /// Don't align, instead use ``ContinuationIndentWidth``, e.g.:
-    /// \code
-    ///   someLongFunction(argument1,
-    ///       argument2);
-    /// \endcode
-    BAS_DontAlign,
-    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    /// BAS_AlwaysBreak,
-    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    /// in combination with ``BreakBeforeCloseBracketBracedList``,
-    /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
-    /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    /// BAS_BlockIndent,
-  };
-
   /// If ``true``, horizontally aligns arguments after an open bracket.
   ///
+  /// \code
+  ///   true:                               false:
+  ///   someLongFunction(argument1,   vs.   someLongFunction(argument1,
+  ///                    argument2);            argument2);
+  /// \endcode
+  ///
+  /// The values ``BAS_Align`` (configuration: ``Align``), ``BAS_DontAlign``
+  /// (configuration ``DontAlign``), ``BAS_Always`` (configuration:
+  /// ``Always``), and ``BAS_BlockIndent`` (configuration: ``BlockIndent``)
+  /// are *deprecated*. Individual control over breaking after open brackets
+  /// and before close brackets are provided by separate style options, e.g.,
+  /// ``BreakAfterOpenBracketFunction``, ``BreakBeforeCloseBracketFunction``.
+  ///
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
   /// \version 3.8
-  BracketAlignmentStyle AlignAfterOpenBracket;
+  bool AlignAfterOpenBracket;
 
   /// Different style for aligning array initializers.
   enum ArrayInitializerAlignmentStyle : int8_t {
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 213b96089ffa3..d1d898601653a 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -930,7 +930,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // Note: This doesn't apply to macro expansion lines, which are MACRO( , , )
   // with args as children of the '(' and ',' tokens. It does not make sense to
   // align the commas with the opening paren.
-  if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
+  if (Style.AlignAfterOpenBracket &&
       !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
       Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
       Previous.isNot(TT_TableGenDAGArgOpener) &&
@@ -1864,8 +1864,8 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
          PrecedenceLevel < prec::Assignment) &&
         (!Previous || Previous->isNot(tok::kw_return) ||
          (!Style.isJava() && PrecedenceLevel > 0)) &&
-        (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
-         PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
+        (Style.AlignAfterOpenBracket || PrecedenceLevel > prec::Comma ||
+         Current.NestingLevel == 0) &&
         (!Style.isTableGen() ||
          (Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
                                         TT_TableGenDAGArgListCommaToBreak)))) {
@@ -1905,8 +1905,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
     if (PrecedenceLevel > prec::Unknown)
       NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
     if (PrecedenceLevel != prec::Conditional &&
-        Current.isNot(TT_UnaryOperator) &&
-        Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
+        Current.isNot(TT_UnaryOperator) && Style.AlignAfterOpenBracket) {
       NewParenState.StartOfFunctionCall = State.Column;
     }
 
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b1b2c74ff8969..4ba51aceef925 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -204,17 +204,6 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
   }
 };
 
-template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
-  static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
-    IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
-    IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign);
-
-    // For backward compatibility.
-    IO.enumCase(Value, "true", FormatStyle::BAS_Align);
-    IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
-  }
-};
-
 template <>
 struct ScalarEnumerationTraits<
     FormatStyle::BraceWrappingAfterControlStatementStyle> {
@@ -1566,7 +1555,7 @@ static void expandPresetsSpacesInParens(FormatStyle &Expanded) {
 FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   FormatStyle LLVMStyle;
   LLVMStyle.AccessModifierOffset = -2;
-  LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  LLVMStyle.AlignAfterOpenBracket = true;
   LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
   LLVMStyle.AlignConsecutiveAssignments = {};
   LLVMStyle.AlignConsecutiveAssignments.PadOperators = true;
@@ -1892,7 +1881,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
   GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 200;
 
   if (Language == FormatStyle::LK_Java) {
-    GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+    GoogleStyle.AlignAfterOpenBracket = false;
     GoogleStyle.AlignOperands = FormatStyle::OAS_DontAlign;
     GoogleStyle.AlignTrailingComments = {};
     GoogleStyle.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
@@ -2045,7 +2034,7 @@ FormatStyle getMozillaStyle() {
 FormatStyle getWebKitStyle() {
   FormatStyle Style = getLLVMStyle();
   Style.AccessModifierOffset = -4;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.AlignTrailingComments = {};
   Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index bd35c705fbec0..6607560aeaf07 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -194,7 +194,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
     return;
 
   // Column format doesn't really make sense if we don't align after brackets.
-  if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign)
+  if (!Style.AlignAfterOpenBracket)
     return;
 
   FormatToken *ItemBegin = Token->Next;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index f38577238e73f..4b121a1abb5a4 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4429,10 +4429,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
 
   if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
     return Style.PenaltyBreakOpenParenthesis;
-  if (Left.is(tok::l_paren) && InFunctionDecl &&
-      Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
+  if (Left.is(tok::l_paren) && InFunctionDecl && Style.AlignAfterOpenBracket)
     return 100;
-  }
   if (Left.is(tok::l_paren) && Left.Previous &&
       (Left.Previous->isOneOf(tok::kw_for, tok::kw__Generic) ||
        Left.Previous->isIf())) {
@@ -4448,7 +4446,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
     // If we aren't aligning after opening parens/braces we can always break
     // here unless the style does not want us to place all arguments on the
     // next line.
-    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign &&
+    if (!Style.AlignAfterOpenBracket &&
         (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) {
       return 0;
     }
diff --git a/clang/unittests/Format/AlignBracketsTest.cpp b/clang/unittests/Format/AlignBracketsTest.cpp
index c280a4b84d615..359bb354eaf32 100644
--- a/clang/unittests/Format/AlignBracketsTest.cpp
+++ b/clang/unittests/Format/AlignBracketsTest.cpp
@@ -28,7 +28,7 @@ TEST_F(AlignBracketsTest, AlignsAfterOpenBracket) {
       "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n"
       "                                             aaaaaaaaaaaaaaaaaaaaa));");
   FormatStyle Style = getLLVMStyle();
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
                "    aaaaaaaaaaa aaaaaaaa, aaaaaaaaa aaaaaaa) {}",
                Style);
@@ -617,13 +617,13 @@ TEST_F(AlignBracketsTest, AllowAllArgumentsOnNextLineDontAlign) {
   StringRef Input = "functionCall(paramA, paramB, paramC);\n"
                     "void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "    paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "    int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
@@ -658,13 +658,13 @@ TEST_F(AlignBracketsTest, AllowAllArgumentsOnNextLineDontAlign) {
                Input, Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "                  int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat(StringRef("functionCall(\n"
                          "    paramA, paramB, paramC);\n"
                          "void functionDecl(\n"
@@ -770,17 +770,17 @@ TEST_F(AlignBracketsTest, ParenthesesAndOperandAlignment) {
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_Align;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "    bbbbbbbbbbbbbbbbbbbbbb);",
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 070fd37f3ead1..1b30a006e589f 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -159,6 +159,7 @@ TEST(ConfigParseTest, GetsCorrectBasedOnStyle) {
 TEST(ConfigParseTest, ParsesConfigurationBools) {
   FormatStyle Style = {};
   Style.Language = FormatStyle::LK_Cpp;
+  CHECK_PARSE_BOOL(AlignAfterOpenBracket);
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowBreakBeforeQtProperty);
@@ -544,18 +545,6 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma,
               FormatStyle::ETC_Remove);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
-  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
-              FormatStyle::BAS_DontAlign);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  // For backward compatibility:
-  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,
-              FormatStyle::BAS_DontAlign);
-  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
-
   Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;
   CHECK_PARSE("AlignEscapedNewlines: DontAlign", AlignEscapedNewlines,
               FormatStyle::ENAS_DontAlign);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 32f17be0cd981..c999c1a67aa0e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5282,7 +5282,7 @@ TEST_F(FormatTest, BracedInitializerIndentWidth) {
                Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   Style.BreakAfterOpenBracketBracedList = false;
   verifyFormat("SomeStruct s{\"xxxxxxxxxxxxx\", \"yyyyyyyyyyyyy\",\n"
                "             \"zzzzzzzzzzzzz\"};",
@@ -7440,7 +7440,7 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
   Style.IndentWidth = 4;
   Style.TabWidth = 4;
   Style.UseTab = FormatStyle::UT_Always;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("return someVeryVeryLongConditionThatBarelyFitsOnALine\n"
                "\t&& (someOtherLongishConditionPart1\n"
@@ -7613,7 +7613,7 @@ TEST_F(FormatTest, NoOperandAlignment) {
                "        * cccccccccccccccccccccccccccccccccccc;",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat("return (a > b\n"
                "    // comment1\n"
                "    // comment2\n"
@@ -8111,19 +8111,19 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
 }
 
 TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
-  // Check that AllowAllArgumentsOnNextLine is respected for both BAS_DontAlign
-  // and BAS_Align.
+  // Check that AllowAllArgumentsOnNextLine is respected for
+  // AlignAfterOpenBracket.
   FormatStyle Style = getLLVMStyleWithColumns(35);
   StringRef Input = "functionCall(paramA, paramB, paramC);\n"
                     "void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "    paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "    int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
@@ -8159,14 +8159,14 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
                Input, Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   Style.BreakAfterOpenBracketFunction = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "                  int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat(StringRef("functionCall(\n"
                          "    paramA, paramB, paramC);\n"
                          "void functionDecl(\n"
@@ -9490,336 +9490,6 @@ TEST_F(FormatTest, AlignsAfterReturn) {
                "    code == a || code == b;");
 }
 
-TEST_F(FormatTest, AlignAndBreakControlStatements) {
-  FormatStyle Style = getLLVMStyle();
-
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  Style.BreakAfterOpenBracketIf = true;
-  Style.BreakAfterOpenBracketLoop = true;
-  Style.BreakAfterOpenBracketSwitch = true;
-
-  verifyFormat("void foo() {\n"
-               "  if constexpr (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               "bbb) == 0) {\n"
-               "    return;\n"
-               "  } else if (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
-               "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               "bbb) == 0) {\n"
-               "    return;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  switch (\n"
-               "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
-               "  default:\n"
-               "    break;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat(
-      "void foo() {\n"
-      "  for (\n"
-      "      aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
-      "      (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
-      "          aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
-      "      aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
-      "    ;\n"
-      "  }\n"
-      "}",
-      Style);
-
-  verifyFormat(
-      "void foo() {\n"
-      "  while (\n"
-      "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-      "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) "
-      "{\n"
-      "    continue;\n"
-      "  }\n"
-      "}",
-      Style);
-
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  Style.BreakAfterOpenBracketIf = true;
-  Style.BreakAfterOpenBracketLoop = true;
-  Style.BreakAfterOpenBracketSwitch = true;
-  Style.BreakBeforeCloseBracketIf = false;
-  Style.BreakBeforeCloseBracketLoop = false;
-  Style.BreakBeforeCloseBracketSwitch = false;
-
-  verifyFormat("void foo() {\n"
-               "  if constexpr (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               ") == 0) {\n"
-               "    return;\n"
-               "  } else if (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
-               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               ") == 0) {\n"
-               "    return;\n"
-               "  }\n"
-               "}",
-               Style);
-  Style.BreakAfterOpenBracketIf = false;
-  verifyFormat("void foo() {\n"
-               "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "                 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               "bbbbbbbbbb) ==\n"
-               "                0) {\n"
-               "    return;\n"
-               "  } else if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
-               "              bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               "bbbbbbb) == 0) {\n"
-               "    return;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  switch (\n"
-               "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
-               "  default:\n"
-               "    break;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  for (\n"
-               "      aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
-               "       aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
-               "      aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
-               "    ;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  while (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) "
-               "{\n"
-               "    continue;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  Style.BreakAfterOpenBracketIf = true;
-  Style.BreakAfterOpenBracketLoop = true;
-  Style.BreakAfterOpenBracketSwitch = true;
-
-  verifyFormat("void foo() {\n"
-               "  if constexpr (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               ") == 0) {\n"
-               "    return;\n"
-               "  } else if (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
-               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               ") == 0) {\n"
-               "    return;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  switch (\n"
-               "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
-               "  default:\n"
-               "    break;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  for (\n"
-               "      aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
-               "       aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
-               "      aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
-               "    ;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  while (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) "
-               "{\n"
-               "    continue;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  Style.BreakAfterOpenBracketIf = false;
-  Style.BreakAfterOpenBracketLoop = false;
-  Style.BreakAfterOpenBracketSwitch = false;
-
-  verifyFormat("void foo() {\n"
-               "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "                 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               "bbbbbbbbbb) ==\n"
-               "                0) {\n"
-               "    return;\n"
-               "  } else if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
-               "              bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               "bbbbbbb) == 0) {\n"
-               "    return;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  switch (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
-               "  default:\n"
-               "    break;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat(
-      "void foo() {\n"
-      "  for (aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
-      "       (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
-      "        aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
-      "       aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
-      "    ;\n"
-      "  }\n"
-      "}",
-      Style);
-
-  verifyFormat(
-      "void foo() {\n"
-      "  while ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-      "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) "
-      "{\n"
-      "    continue;\n"
-      "  }\n"
-      "}",
-      Style);
-
-  Style.BreakAfterOpenBracketIf = true;
-  Style.BreakAfterOpenBracketLoop = true;
-  Style.BreakAfterOpenBracketSwitch = true;
-  Style.BreakBeforeCloseBracketIf = true;
-  Style.BreakBeforeCloseBracketLoop = true;
-  Style.BreakBeforeCloseBracketSwitch = true;
-
-  verifyFormat(
-      "void foo() {\n"
-      "  if constexpr (\n"
-      "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-      "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0\n"
-      "  ) {\n"
-      "    return;\n"
-      "  } else if (\n"
-      "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
-      "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0\n"
-      "  ) {\n"
-      "    return;\n"
-      "  }\n"
-      "}",
-      Style);
-
-  verifyFormat("void foo() {\n"
-               "  switch (\n"
-               "      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | "
-               "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"
-               "  ) {\n"
-               "  default:\n"
-               "    break;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  for (\n"
-               "      aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
-               "       aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
-               "      aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next\n"
-               "  ) {\n"
-               "    ;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  while (\n"
-               "      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0\n"
-               "  ) {\n"
-               "    continue;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  Style.BreakAfterOpenBracketIf = false;
-  Style.BreakAfterOpenBracketLoop = false;
-  Style.BreakAfterOpenBracketSwitch = false;
-  Style.BreakBeforeCloseBracketIf = false;
-  Style.BreakBeforeCloseBracketLoop = false;
-  Style.BreakBeforeCloseBracketSwitch = false;
-
-  verifyFormat("void foo() {\n"
-               "  if constexpr ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "                 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               "bbbbbbbbbb) ==\n"
-               "                0) {\n"
-               "    return;\n"
-               "  } else if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &\n"
-               "              bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-               "bbbbbbb) == 0) {\n"
-               "    return;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat("void foo() {\n"
-               "  switch (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-               "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n"
-               "  default:\n"
-               "    break;\n"
-               "  }\n"
-               "}",
-               Style);
-
-  verifyFormat(
-      "void foo() {\n"
-      "  for (aaaaaaaaaaaaaaaaaaaaaa = 0;\n"
-      "       (aaaaaaaaaaaaaaaaaaaaaa->bbbbbbbbbbbbbb |\n"
-      "        aaaaaaaaaaaaaaaaaaaaaa->ccccccccccccccccccccccc) == 0;\n"
-      "       aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaa->next) {\n"
-      "    ;\n"
-      "  }\n"
-      "}",
-      Style);
-
-  verifyFormat(
-      "void foo() {\n"
-      "  while ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |\n"
-      "          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) == 0) {\n"
-      "    continue;\n"
-      "  }\n"
-      "}",
-      Style);
-}
-
->>>>>>> 5823461e9528 (Format: add AlignAfterControlStatement)
 TEST_F(FormatTest, BreaksConditionalExpressions) {
   verifyFormat(
       "aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa\n"
@@ -11624,7 +11294,7 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
 
 TEST_F(FormatTest, WrapsTemplateParameters) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   verifyFormat(
       "template <typename... a> struct q {};\n"
@@ -11632,7 +11302,7 @@ TEST_F(FormatTest, WrapsTemplateParameters) {
       "    aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>\n"
       "    y;",
       Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
   verifyFormat(
       "template <typename... a> struct r {};\n"

>From 2e43212f54ea847e50c47c20b581c7d6c52b887d Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 10:52:50 -0600
Subject: [PATCH 24/48] dump style

---
 clang/docs/ClangFormatStyleOptions.rst | 45 ++++++++------------------
 1 file changed, 13 insertions(+), 32 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 4cd63ec2d556d..5ced2ba3aea08 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -197,44 +197,25 @@ the configuration (without a prefix: ``Auto``).
 
 .. _AlignAfterOpenBracket:
 
-**AlignAfterOpenBracket** (``BracketAlignmentStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>`
+**AlignAfterOpenBracket** (``Boolean``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>`
   If ``true``, horizontally aligns arguments after an open bracket.
 
-  This applies to round brackets (parentheses), angle brackets and square
-  brackets.
-
-  Possible values:
-
-  * ``BAS_Align`` (in configuration: ``Align``)
-    Align parameters on the open bracket, e.g.:
-
-    .. code-block:: c++
-
-      someLongFunction(argument1,
-                       argument2);
 
-  * ``BAS_DontAlign`` (in configuration: ``DontAlign``)
-    Don't align, instead use ``ContinuationIndentWidth``, e.g.:
-
-    .. code-block:: c++
-
-      someLongFunction(argument1,
-          argument2);
-
-  * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
-    This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+  .. code-block:: c++
 
-  * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``)
-    This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    in combination with ``BreakBeforeCloseBracketBracedList``,
-    ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
-    ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
+    true:                               false:
+    someLongFunction(argument1,   vs.   someLongFunction(argument1,
+                     argument2);            argument2);
 
+  The values ``BAS_Align`` (configuration: ``Align``), ``BAS_DontAlign``
+  (configuration ``DontAlign``), ``BAS_Always`` (configuration:
+  ``Always``), and ``BAS_BlockIndent`` (configuration: ``BlockIndent``)
+  are *deprecated*. Individual control over breaking after open brackets
+  and before close brackets are provided by separate style options, e.g.,
+  ``BreakAfterOpenBracketFunction``, ``BreakBeforeCloseBracketFunction``.
 
+  This applies to round brackets (parentheses), angle brackets and square
+  brackets.
 
 .. _AlignArrayOfStructures:
 

>From 615c6159dec03819bd2949e7a72524c90b3795c6 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 13:19:49 -0600
Subject: [PATCH 25/48] drop the this

---
 clang/lib/Format/FormatToken.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index bfd917b8b7c51..9107ac9f1522a 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -652,9 +652,9 @@ struct FormatToken {
   }
 
   bool isLoop(const FormatStyle &Style) const {
-    return this->isOneOf(tok::kw_for, tok::kw_while) ||
-           (Style.isJavaScript() && this->isNot(tok::l_paren) &&
-            this->Previous && this->Previous->is(tok::kw_for));
+    return isOneOf(tok::kw_for, tok::kw_while) ||
+           (Style.isJavaScript() && isNot(tok::l_paren) && Previous &&
+            Previous->is(tok::kw_for));
   }
 
   bool closesScopeAfterBlock() const {

>From 3283e0e499dbe809d5c9afab8628bef5cfc02d53 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 13:46:45 -0600
Subject: [PATCH 26/48] Revert "deprecate and remove BAS_Align and
 BAS_DontAlign"

This reverts commit 4062b608d728723ae55082e7922017ba84daba14.
---
 clang/include/clang/Format/Format.h        | 42 ++++++++++++++--------
 clang/lib/Format/ContinuationIndenter.cpp  |  9 ++---
 clang/lib/Format/Format.cpp                | 17 +++++++--
 clang/lib/Format/FormatToken.cpp           |  2 +-
 clang/lib/Format/TokenAnnotator.cpp        |  6 ++--
 clang/unittests/Format/ConfigParseTest.cpp | 13 ++++++-
 clang/unittests/Format/FormatTest.cpp      | 22 ++++++------
 7 files changed, 75 insertions(+), 36 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index c2cc4e2cfd22d..e10c5503e8f30 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,25 +62,39 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
+  /// Different styles for aligning after open brackets.
+  enum BracketAlignmentStyle : int8_t {
+    /// Align parameters on the open bracket, e.g.:
+    /// \code
+    ///   someLongFunction(argument1,
+    ///                    argument2);
+    /// \endcode
+    BAS_Align,
+    /// Don't align, instead use ``ContinuationIndentWidth``, e.g.:
+    /// \code
+    ///   someLongFunction(argument1,
+    ///       argument2);
+    /// \endcode
+    BAS_DontAlign,
+    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    /// BAS_AlwaysBreak,
+    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    /// in combination with ``BreakBeforeCloseBracketBracedList``,
+    /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
+    /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
+    /// BAS_BlockIndent,
+  };
+
   /// If ``true``, horizontally aligns arguments after an open bracket.
   ///
-  /// \code
-  ///   true:                               false:
-  ///   someLongFunction(argument1,   vs.   someLongFunction(argument1,
-  ///                    argument2);            argument2);
-  /// \endcode
-  ///
-  /// The values ``BAS_Align`` (configuration: ``Align``), ``BAS_DontAlign``
-  /// (configuration ``DontAlign``), ``BAS_Always`` (configuration:
-  /// ``Always``), and ``BAS_BlockIndent`` (configuration: ``BlockIndent``)
-  /// are *deprecated*. Individual control over breaking after open brackets
-  /// and before close brackets are provided by separate style options, e.g.,
-  /// ``BreakAfterOpenBracketFunction``, ``BreakBeforeCloseBracketFunction``.
-  ///
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
   /// \version 3.8
-  bool AlignAfterOpenBracket;
+  BracketAlignmentStyle AlignAfterOpenBracket;
 
   /// Different style for aligning array initializers.
   enum ArrayInitializerAlignmentStyle : int8_t {
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index d1d898601653a..213b96089ffa3 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -930,7 +930,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // Note: This doesn't apply to macro expansion lines, which are MACRO( , , )
   // with args as children of the '(' and ',' tokens. It does not make sense to
   // align the commas with the opening paren.
-  if (Style.AlignAfterOpenBracket &&
+  if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
       !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
       Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
       Previous.isNot(TT_TableGenDAGArgOpener) &&
@@ -1864,8 +1864,8 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
          PrecedenceLevel < prec::Assignment) &&
         (!Previous || Previous->isNot(tok::kw_return) ||
          (!Style.isJava() && PrecedenceLevel > 0)) &&
-        (Style.AlignAfterOpenBracket || PrecedenceLevel > prec::Comma ||
-         Current.NestingLevel == 0) &&
+        (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
+         PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
         (!Style.isTableGen() ||
          (Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
                                         TT_TableGenDAGArgListCommaToBreak)))) {
@@ -1905,7 +1905,8 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
     if (PrecedenceLevel > prec::Unknown)
       NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
     if (PrecedenceLevel != prec::Conditional &&
-        Current.isNot(TT_UnaryOperator) && Style.AlignAfterOpenBracket) {
+        Current.isNot(TT_UnaryOperator) &&
+        Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
       NewParenState.StartOfFunctionCall = State.Column;
     }
 
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 4ba51aceef925..b1b2c74ff8969 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -204,6 +204,17 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
   }
 };
 
+template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
+  static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
+    IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
+    IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign);
+
+    // For backward compatibility.
+    IO.enumCase(Value, "true", FormatStyle::BAS_Align);
+    IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
+  }
+};
+
 template <>
 struct ScalarEnumerationTraits<
     FormatStyle::BraceWrappingAfterControlStatementStyle> {
@@ -1555,7 +1566,7 @@ static void expandPresetsSpacesInParens(FormatStyle &Expanded) {
 FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   FormatStyle LLVMStyle;
   LLVMStyle.AccessModifierOffset = -2;
-  LLVMStyle.AlignAfterOpenBracket = true;
+  LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
   LLVMStyle.AlignConsecutiveAssignments = {};
   LLVMStyle.AlignConsecutiveAssignments.PadOperators = true;
@@ -1881,7 +1892,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
   GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 200;
 
   if (Language == FormatStyle::LK_Java) {
-    GoogleStyle.AlignAfterOpenBracket = false;
+    GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
     GoogleStyle.AlignOperands = FormatStyle::OAS_DontAlign;
     GoogleStyle.AlignTrailingComments = {};
     GoogleStyle.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
@@ -2034,7 +2045,7 @@ FormatStyle getMozillaStyle() {
 FormatStyle getWebKitStyle() {
   FormatStyle Style = getLLVMStyle();
   Style.AccessModifierOffset = -4;
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.AlignTrailingComments = {};
   Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index 6607560aeaf07..bd35c705fbec0 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -194,7 +194,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
     return;
 
   // Column format doesn't really make sense if we don't align after brackets.
-  if (!Style.AlignAfterOpenBracket)
+  if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign)
     return;
 
   FormatToken *ItemBegin = Token->Next;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 4b121a1abb5a4..f38577238e73f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4429,8 +4429,10 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
 
   if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
     return Style.PenaltyBreakOpenParenthesis;
-  if (Left.is(tok::l_paren) && InFunctionDecl && Style.AlignAfterOpenBracket)
+  if (Left.is(tok::l_paren) && InFunctionDecl &&
+      Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
     return 100;
+  }
   if (Left.is(tok::l_paren) && Left.Previous &&
       (Left.Previous->isOneOf(tok::kw_for, tok::kw__Generic) ||
        Left.Previous->isIf())) {
@@ -4446,7 +4448,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
     // If we aren't aligning after opening parens/braces we can always break
     // here unless the style does not want us to place all arguments on the
     // next line.
-    if (!Style.AlignAfterOpenBracket &&
+    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign &&
         (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) {
       return 0;
     }
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 1b30a006e589f..070fd37f3ead1 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -159,7 +159,6 @@ TEST(ConfigParseTest, GetsCorrectBasedOnStyle) {
 TEST(ConfigParseTest, ParsesConfigurationBools) {
   FormatStyle Style = {};
   Style.Language = FormatStyle::LK_Cpp;
-  CHECK_PARSE_BOOL(AlignAfterOpenBracket);
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowBreakBeforeQtProperty);
@@ -545,6 +544,18 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma,
               FormatStyle::ETC_Remove);
 
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
+  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
+              FormatStyle::BAS_DontAlign);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  // For backward compatibility:
+  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,
+              FormatStyle::BAS_DontAlign);
+  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
+
   Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;
   CHECK_PARSE("AlignEscapedNewlines: DontAlign", AlignEscapedNewlines,
               FormatStyle::ENAS_DontAlign);
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index c999c1a67aa0e..880763dcfc38d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5282,7 +5282,7 @@ TEST_F(FormatTest, BracedInitializerIndentWidth) {
                Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   Style.BreakAfterOpenBracketBracedList = false;
   verifyFormat("SomeStruct s{\"xxxxxxxxxxxxx\", \"yyyyyyyyyyyyy\",\n"
                "             \"zzzzzzzzzzzzz\"};",
@@ -7440,7 +7440,7 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
   Style.IndentWidth = 4;
   Style.TabWidth = 4;
   Style.UseTab = FormatStyle::UT_Always;
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("return someVeryVeryLongConditionThatBarelyFitsOnALine\n"
                "\t&& (someOtherLongishConditionPart1\n"
@@ -7613,7 +7613,7 @@ TEST_F(FormatTest, NoOperandAlignment) {
                "        * cccccccccccccccccccccccccccccccccccc;",
                Style);
 
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   verifyFormat("return (a > b\n"
                "    // comment1\n"
                "    // comment2\n"
@@ -8111,19 +8111,19 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
 }
 
 TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
-  // Check that AllowAllArgumentsOnNextLine is respected for
-  // AlignAfterOpenBracket.
+  // Check that AllowAllArgumentsOnNextLine is respected for both BAS_DontAlign
+  // and BAS_Align.
   FormatStyle Style = getLLVMStyleWithColumns(35);
   StringRef Input = "functionCall(paramA, paramB, paramC);\n"
                     "void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "    paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "    int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
@@ -8159,14 +8159,14 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
                Input, Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   Style.BreakAfterOpenBracketFunction = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "                  int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   verifyFormat(StringRef("functionCall(\n"
                          "    paramA, paramB, paramC);\n"
                          "void functionDecl(\n"
@@ -11294,7 +11294,7 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
 
 TEST_F(FormatTest, WrapsTemplateParameters) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   verifyFormat(
       "template <typename... a> struct q {};\n"
@@ -11302,7 +11302,7 @@ TEST_F(FormatTest, WrapsTemplateParameters) {
       "    aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>\n"
       "    y;",
       Style);
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
   verifyFormat(
       "template <typename... a> struct r {};\n"

>From cd353c2252da09003029da554f0eefd86ee65e2d Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 14:12:57 -0600
Subject: [PATCH 27/48] handle backward compatibility for clang-format users

---
 clang/include/clang/Format/Format.h        |  4 +++
 clang/lib/Format/Format.cpp                | 35 ++++++++++++++++++++++
 clang/unittests/Format/ConfigParseTest.cpp |  6 +++-
 3 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index e10c5503e8f30..dcdcba7de18c8 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -80,6 +80,8 @@ struct FormatStyle {
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     /// BAS_AlwaysBreak,
+    /// For backward compatibility. Do not use.
+    BAS_ABDeprecated,
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
@@ -87,6 +89,8 @@ struct FormatStyle {
     /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
     /// BAS_BlockIndent,
+    /// For backward compatibility. Do not use.
+    BAS_BIDeprecated,
   };
 
   /// If ``true``, horizontally aligns arguments after an open bracket.
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b1b2c74ff8969..8f2de45cb3da5 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -212,6 +212,8 @@ template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
     // For backward compatibility.
     IO.enumCase(Value, "true", FormatStyle::BAS_Align);
     IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
+    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_ABDeprecated);
+    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BIDeprecated);
   }
 };
 
@@ -1277,6 +1279,39 @@ template <> struct MappingTraits<FormatStyle> {
     IO.mapOptional("WrapNamespaceBodyWithEmptyLines",
                    Style.WrapNamespaceBodyWithEmptyLines);
 
+    // If AlwaysBreak or BlockIndent were specified but individual
+    // options for BreakAfterOpenBracket* (CloseAfterOpenBracket*),
+    // initialize the latter to preserve backwards compatibility.
+    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_ABDeprecated) {
+      if (!Style.BreakAfterOpenBracketBracedList &&
+          !Style.BreakAfterOpenBracketFunction &&
+          !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
+          !Style.BreakAfterOpenBracketSwitch) {
+        Style.BreakAfterOpenBracketBracedList = true;
+        Style.BreakAfterOpenBracketFunction = true;
+        Style.BreakAfterOpenBracketIf = true;
+      }
+      Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+    } else if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BIDeprecated) {
+      if (!Style.BreakAfterOpenBracketBracedList &&
+          !Style.BreakAfterOpenBracketFunction &&
+          !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
+          !Style.BreakAfterOpenBracketSwitch &&
+          !Style.BreakBeforeCloseBracketBracedList &&
+          !Style.BreakBeforeCloseBracketFunction &&
+          !Style.BreakBeforeCloseBracketIf &&
+          !Style.BreakBeforeCloseBracketLoop &&
+          !Style.BreakBeforeCloseBracketSwitch) {
+        Style.BreakAfterOpenBracketBracedList = true;
+        Style.BreakAfterOpenBracketFunction = true;
+        Style.BreakAfterOpenBracketIf = true;
+        Style.BreakBeforeCloseBracketBracedList = true;
+        Style.BreakBeforeCloseBracketFunction = true;
+        Style.BreakBeforeCloseBracketIf = true;
+      }
+      Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+    }
+
     // If AlwaysBreakAfterDefinitionReturnType was specified but
     // BreakAfterReturnType was not, initialize the latter from the former for
     // backwards compatibility.
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 070fd37f3ead1..9a6537dac4175 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -549,10 +549,14 @@ TEST(ConfigParseTest, ParsesConfiguration) {
               FormatStyle::BAS_Align);
   CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
               FormatStyle::BAS_DontAlign);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   // For backward compatibility:
+  CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
   CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,
               FormatStyle::BAS_DontAlign);
+  CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket,
               FormatStyle::BAS_Align);
 

>From b00a3c77069041ef44b64cab3d2082ef569f3467 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 14:16:14 -0600
Subject: [PATCH 28/48] update Format.h

---
 clang/include/clang/Format/Format.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index dcdcba7de18c8..88b1f04758d45 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -76,19 +76,19 @@ struct FormatStyle {
     ///       argument2);
     /// \endcode
     BAS_DontAlign,
+    /// ``BAS_AlwaysBreak``
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    /// BAS_AlwaysBreak,
     /// For backward compatibility. Do not use.
     BAS_ABDeprecated,
+    /// ``BAS_BlockIndent``
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     /// in combination with ``BreakBeforeCloseBracketBracedList``,
     /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    /// BAS_BlockIndent,
     /// For backward compatibility. Do not use.
     BAS_BIDeprecated,
   };

>From 9169525b879d1350797e2f61f125ea33a111115e Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 25 Aug 2025 14:16:18 -0600
Subject: [PATCH 29/48] dump style

---
 clang/docs/ClangFormatStyleOptions.rst | 49 +++++++++++++++++++-------
 1 file changed, 36 insertions(+), 13 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 5ced2ba3aea08..f86b9c13a4cad 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -197,25 +197,48 @@ the configuration (without a prefix: ``Auto``).
 
 .. _AlignAfterOpenBracket:
 
-**AlignAfterOpenBracket** (``Boolean``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>`
+**AlignAfterOpenBracket** (``BracketAlignmentStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>`
   If ``true``, horizontally aligns arguments after an open bracket.
 
+  This applies to round brackets (parentheses), angle brackets and square
+  brackets.
 
-  .. code-block:: c++
+  Possible values:
 
-    true:                               false:
-    someLongFunction(argument1,   vs.   someLongFunction(argument1,
-                     argument2);            argument2);
+  * ``BAS_Align`` (in configuration: ``Align``)
+    Align parameters on the open bracket, e.g.:
+
+    .. code-block:: c++
+
+      someLongFunction(argument1,
+                       argument2);
+
+  * ``BAS_DontAlign`` (in configuration: ``DontAlign``)
+    Don't align, instead use ``ContinuationIndentWidth``, e.g.:
+
+    .. code-block:: c++
+
+      someLongFunction(argument1,
+          argument2);
+
+  * ``BAS_ABDeprecated`` (in configuration: ``ABDeprecated``)
+    ``BAS_AlwaysBreak``
+    This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    For backward compatibility. Do not use.
+
+  * ``BAS_BIDeprecated`` (in configuration: ``BIDeprecated``)
+    ``BAS_BlockIndent``
+    This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    in combination with ``BreakBeforeCloseBracketBracedList``,
+    ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
+    ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
+    For backward compatibility. Do not use.
 
-  The values ``BAS_Align`` (configuration: ``Align``), ``BAS_DontAlign``
-  (configuration ``DontAlign``), ``BAS_Always`` (configuration:
-  ``Always``), and ``BAS_BlockIndent`` (configuration: ``BlockIndent``)
-  are *deprecated*. Individual control over breaking after open brackets
-  and before close brackets are provided by separate style options, e.g.,
-  ``BreakAfterOpenBracketFunction``, ``BreakBeforeCloseBracketFunction``.
 
-  This applies to round brackets (parentheses), angle brackets and square
-  brackets.
 
 .. _AlignArrayOfStructures:
 

>From 90f63a8792ca8fe4bd864d817299c98dc3a1aca7 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Tue, 26 Aug 2025 10:11:57 -0600
Subject: [PATCH 30/48] try to handle bool for the public api

---
 clang/docs/ClangFormatStyleOptions.rst     |  8 ++---
 clang/include/clang/Format/Format.h        | 12 +++----
 clang/lib/Format/ContinuationIndenter.cpp  |  6 ++--
 clang/lib/Format/Format.cpp                | 38 ++++++++++++----------
 clang/lib/Format/FormatToken.cpp           |  2 +-
 clang/lib/Format/TokenAnnotator.cpp        |  4 +--
 clang/unittests/Format/ConfigParseTest.cpp | 22 +++++--------
 clang/unittests/Format/FormatTest.cpp      | 18 +++++-----
 8 files changed, 51 insertions(+), 59 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index f86b9c13a4cad..4cd63ec2d556d 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -221,22 +221,18 @@ the configuration (without a prefix: ``Auto``).
       someLongFunction(argument1,
           argument2);
 
-  * ``BAS_ABDeprecated`` (in configuration: ``ABDeprecated``)
-    ``BAS_AlwaysBreak``
+  * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
     This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    For backward compatibility. Do not use.
 
-  * ``BAS_BIDeprecated`` (in configuration: ``BIDeprecated``)
-    ``BAS_BlockIndent``
+  * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``)
     This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     in combination with ``BreakBeforeCloseBracketBracedList``,
     ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    For backward compatibility. Do not use.
 
 
 
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 88b1f04758d45..1a9cdf8fa082b 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,7 +62,9 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
+  /*
   /// Different styles for aligning after open brackets.
+  /// This is **deprecated**. For backward compatibility only.
   enum BracketAlignmentStyle : int8_t {
     /// Align parameters on the open bracket, e.g.:
     /// \code
@@ -76,22 +78,20 @@ struct FormatStyle {
     ///       argument2);
     /// \endcode
     BAS_DontAlign,
-    /// ``BAS_AlwaysBreak``
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    /// For backward compatibility. Do not use.
-    BAS_ABDeprecated,
-    /// ``BAS_BlockIndent``
+    BAS_AlwaysBreak,
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     /// in combination with ``BreakBeforeCloseBracketBracedList``,
     /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    /// For backward compatibility. Do not use.
-    BAS_BIDeprecated,
+    BAS_BlockIndent,
   };
+  */
+  LLVM_YAML_STRONG_TYPEDEF(bool, BracketAlignmentStyle)
 
   /// If ``true``, horizontally aligns arguments after an open bracket.
   ///
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 213b96089ffa3..ee1a9cac82239 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -930,7 +930,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // Note: This doesn't apply to macro expansion lines, which are MACRO( , , )
   // with args as children of the '(' and ',' tokens. It does not make sense to
   // align the commas with the opening paren.
-  if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
+  if (Style.AlignAfterOpenBracket != false &&
       !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
       Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
       Previous.isNot(TT_TableGenDAGArgOpener) &&
@@ -1864,7 +1864,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
          PrecedenceLevel < prec::Assignment) &&
         (!Previous || Previous->isNot(tok::kw_return) ||
          (!Style.isJava() && PrecedenceLevel > 0)) &&
-        (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
+        (Style.AlignAfterOpenBracket != false ||
          PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
         (!Style.isTableGen() ||
          (Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
@@ -1906,7 +1906,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
       NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
     if (PrecedenceLevel != prec::Conditional &&
         Current.isNot(TT_UnaryOperator) &&
-        Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
+        Style.AlignAfterOpenBracket != false) {
       NewParenState.StartOfFunctionCall = State.Column;
     }
 
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8f2de45cb3da5..551ae6d190803 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -204,16 +204,18 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
   }
 };
 
-template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
-  static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
-    IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
-    IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign);
-
-    // For backward compatibility.
-    IO.enumCase(Value, "true", FormatStyle::BAS_Align);
-    IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
-    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_ABDeprecated);
-    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BIDeprecated);
+// For backward compatibility.
+template <> struct MappingTraits<FormatStyle::BracketAlignmentStyle> {
+  static void enumInput(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
+    IO.enumCase(Value, "Align", FormatStyle::BracketAlignmentStyle(true));
+    IO.enumCase(Value, "DontAlign", FormatStyle::BracketAlignmentStyle(false));
+    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BracketAlignmentStyle(true));
+    IO.enumCase(Value, "BlockIndent", FormatStyle::BracketAlignmentStyle(true));
+    IO.enumCase(Value, "true", FormatStyle::BracketAlignmentStyle(true));
+    IO.enumCase(Value, "false", FormatStyle::BracketAlignmentStyle(true));
+  }
+  static void mapping(IO &IO, FormatStyle::BracketAlignmentStyle &BAS) {
+    IO.mapOptional("AlignAfterOpenBracket", BAS.value);
   }
 };
 
@@ -1002,7 +1004,6 @@ template <> struct MappingTraits<FormatStyle> {
     }
 
     IO.mapOptional("AccessModifierOffset", Style.AccessModifierOffset);
-    IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
     IO.mapOptional("AlignArrayOfStructures", Style.AlignArrayOfStructures);
     IO.mapOptional("AlignConsecutiveAssignments",
                    Style.AlignConsecutiveAssignments);
@@ -1282,7 +1283,8 @@ template <> struct MappingTraits<FormatStyle> {
     // If AlwaysBreak or BlockIndent were specified but individual
     // options for BreakAfterOpenBracket* (CloseAfterOpenBracket*),
     // initialize the latter to preserve backwards compatibility.
-    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_ABDeprecated) {
+    bool set = false;
+    if (set) {
       if (!Style.BreakAfterOpenBracketBracedList &&
           !Style.BreakAfterOpenBracketFunction &&
           !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
@@ -1291,8 +1293,9 @@ template <> struct MappingTraits<FormatStyle> {
         Style.BreakAfterOpenBracketFunction = true;
         Style.BreakAfterOpenBracketIf = true;
       }
-      Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-    } else if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BIDeprecated) {
+      set = false;
+    }
+    if (set) {
       if (!Style.BreakAfterOpenBracketBracedList &&
           !Style.BreakAfterOpenBracketFunction &&
           !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
@@ -1309,7 +1312,6 @@ template <> struct MappingTraits<FormatStyle> {
         Style.BreakBeforeCloseBracketFunction = true;
         Style.BreakBeforeCloseBracketIf = true;
       }
-      Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
     }
 
     // If AlwaysBreakAfterDefinitionReturnType was specified but
@@ -1601,7 +1603,7 @@ static void expandPresetsSpacesInParens(FormatStyle &Expanded) {
 FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   FormatStyle LLVMStyle;
   LLVMStyle.AccessModifierOffset = -2;
-  LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  LLVMStyle.AlignAfterOpenBracket = true;
   LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
   LLVMStyle.AlignConsecutiveAssignments = {};
   LLVMStyle.AlignConsecutiveAssignments.PadOperators = true;
@@ -1927,7 +1929,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
   GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 200;
 
   if (Language == FormatStyle::LK_Java) {
-    GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+    GoogleStyle.AlignAfterOpenBracket = false;
     GoogleStyle.AlignOperands = FormatStyle::OAS_DontAlign;
     GoogleStyle.AlignTrailingComments = {};
     GoogleStyle.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
@@ -2080,7 +2082,7 @@ FormatStyle getMozillaStyle() {
 FormatStyle getWebKitStyle() {
   FormatStyle Style = getLLVMStyle();
   Style.AccessModifierOffset = -4;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.AlignTrailingComments = {};
   Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index bd35c705fbec0..60693750a9952 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -194,7 +194,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
     return;
 
   // Column format doesn't really make sense if we don't align after brackets.
-  if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign)
+  if (Style.AlignAfterOpenBracket == false)
     return;
 
   FormatToken *ItemBegin = Token->Next;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index f38577238e73f..ff4573e5a09a1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4430,7 +4430,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
   if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
     return Style.PenaltyBreakOpenParenthesis;
   if (Left.is(tok::l_paren) && InFunctionDecl &&
-      Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
+      Style.AlignAfterOpenBracket != false) {
     return 100;
   }
   if (Left.is(tok::l_paren) && Left.Previous &&
@@ -4448,7 +4448,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
     // If we aren't aligning after opening parens/braces we can always break
     // here unless the style does not want us to place all arguments on the
     // next line.
-    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign &&
+    if (Style.AlignAfterOpenBracket == false &&
         (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) {
       return 0;
     }
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 9a6537dac4175..6f3fe097c9ab2 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -544,21 +544,15 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma,
               FormatStyle::ETC_Remove);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
-  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
-              FormatStyle::BAS_DontAlign);
+  Style.AlignAfterOpenBracket = false;
+  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket, true);
+  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket, false);
   // For backward compatibility:
-  CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
-  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,
-              FormatStyle::BAS_DontAlign);
-  CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
+  CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket, true);
+  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket, false);
+  CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket, true);
+  Style.AlignAfterOpenBracket = false;
+  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket, true);
 
   Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;
   CHECK_PARSE("AlignEscapedNewlines: DontAlign", AlignEscapedNewlines,
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 880763dcfc38d..21f27dddc3072 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5282,7 +5282,7 @@ TEST_F(FormatTest, BracedInitializerIndentWidth) {
                Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   Style.BreakAfterOpenBracketBracedList = false;
   verifyFormat("SomeStruct s{\"xxxxxxxxxxxxx\", \"yyyyyyyyyyyyy\",\n"
                "             \"zzzzzzzzzzzzz\"};",
@@ -7440,7 +7440,7 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
   Style.IndentWidth = 4;
   Style.TabWidth = 4;
   Style.UseTab = FormatStyle::UT_Always;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("return someVeryVeryLongConditionThatBarelyFitsOnALine\n"
                "\t&& (someOtherLongishConditionPart1\n"
@@ -7613,7 +7613,7 @@ TEST_F(FormatTest, NoOperandAlignment) {
                "        * cccccccccccccccccccccccccccccccccccc;",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat("return (a > b\n"
                "    // comment1\n"
                "    // comment2\n"
@@ -8117,13 +8117,13 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
   StringRef Input = "functionCall(paramA, paramB, paramC);\n"
                     "void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "    paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "    int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
@@ -8159,14 +8159,14 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
                Input, Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   Style.BreakAfterOpenBracketFunction = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "                  int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat(StringRef("functionCall(\n"
                          "    paramA, paramB, paramC);\n"
                          "void functionDecl(\n"
@@ -11294,7 +11294,7 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
 
 TEST_F(FormatTest, WrapsTemplateParameters) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   verifyFormat(
       "template <typename... a> struct q {};\n"
@@ -11302,7 +11302,7 @@ TEST_F(FormatTest, WrapsTemplateParameters) {
       "    aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>\n"
       "    y;",
       Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
   verifyFormat(
       "template <typename... a> struct r {};\n"

>From 5b542ad05d750c552b658526868f56120bb18523 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Tue, 26 Aug 2025 10:32:23 -0600
Subject: [PATCH 31/48] wip

---
 clang/include/clang/Format/Format.h | 32 +-----------------
 clang/lib/Format/Format.cpp         | 50 ++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 1a9cdf8fa082b..951a0babefcf4 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,42 +62,12 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
-  /*
-  /// Different styles for aligning after open brackets.
-  /// This is **deprecated**. For backward compatibility only.
-  enum BracketAlignmentStyle : int8_t {
-    /// Align parameters on the open bracket, e.g.:
-    /// \code
-    ///   someLongFunction(argument1,
-    ///                    argument2);
-    /// \endcode
-    BAS_Align,
-    /// Don't align, instead use ``ContinuationIndentWidth``, e.g.:
-    /// \code
-    ///   someLongFunction(argument1,
-    ///       argument2);
-    /// \endcode
-    BAS_DontAlign,
-    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    BAS_AlwaysBreak,
-    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    /// in combination with ``BreakBeforeCloseBracketBracedList``,
-    /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
-    /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    BAS_BlockIndent,
-  };
-  */
-  LLVM_YAML_STRONG_TYPEDEF(bool, BracketAlignmentStyle)
-
   /// If ``true``, horizontally aligns arguments after an open bracket.
   ///
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
   /// \version 3.8
+  LLVM_YAML_STRONG_TYPEDEF(bool, BracketAlignmentStyle)
   BracketAlignmentStyle AlignAfterOpenBracket;
 
   /// Different style for aligning array initializers.
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 551ae6d190803..913618e408fdf 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -206,6 +206,52 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
 
 // For backward compatibility.
 template <> struct MappingTraits<FormatStyle::BracketAlignmentStyle> {
+
+  class NormalizedBracketAlignmentStyle {
+  public:
+
+    NormalizedBracketAlignmentStyle(IO &IO,
+        FormatStyle::BracketAlignmentStyle &BAS) :
+      AlignAfterOpenBracket(BAS.value == true ? BAS_Align : BAS_DontAlign) {
+    }
+
+    FormatStyle::BracketAlignmentStyle denormalize(IO &IO) {
+      if (AlignAfterOpenBracket == BAS_DontAlign)
+        return FormatStyle::BracketAlignmentStyle(false);
+      return true;
+    }
+
+    /// Different styles for aligning after open brackets.
+    /// This is **deprecated**. For backward compatibility only.
+    enum BracketAlignmentStyleEnum : int8_t {
+      /// Align parameters on the open bracket, e.g.:
+      /// \code
+      ///   someLongFunction(argument1,
+      ///                    argument2);
+      /// \endcode
+      BAS_Align,
+      /// Don't align, instead use ``ContinuationIndentWidth``, e.g.:
+      /// \code
+      ///   someLongFunction(argument1,
+      ///       argument2);
+      /// \endcode
+      BAS_DontAlign,
+      /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+      /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+      /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+      BAS_AlwaysBreak,
+      /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+      /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+      /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+      /// in combination with ``BreakBeforeCloseBracketBracedList``,
+      /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
+      /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
+      BAS_BlockIndent,
+    };
+
+    BracketAlignmentStyleEnum AlignAfterOpenBracket; 
+  };
+
   static void enumInput(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
     IO.enumCase(Value, "Align", FormatStyle::BracketAlignmentStyle(true));
     IO.enumCase(Value, "DontAlign", FormatStyle::BracketAlignmentStyle(false));
@@ -215,7 +261,9 @@ template <> struct MappingTraits<FormatStyle::BracketAlignmentStyle> {
     IO.enumCase(Value, "false", FormatStyle::BracketAlignmentStyle(true));
   }
   static void mapping(IO &IO, FormatStyle::BracketAlignmentStyle &BAS) {
-    IO.mapOptional("AlignAfterOpenBracket", BAS.value);
+    MappingNormalization<NormalizedBracketAlignmentStyle,
+                         FormatStyle::BracketAlignmentStyle> keys(IO, BAS);
+    IO.mapOptional("AlignAfterOpenBracket", keys->AlignAfterOpenBracket);
   }
 };
 

>From 722235c23458f0e20136595a019adbf5591ad582 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Tue, 26 Aug 2025 10:32:41 -0600
Subject: [PATCH 32/48] Revert "wip"

This reverts commit 8dc407986190c8c4260b61a67709265a00ef5777.
---
 clang/include/clang/Format/Format.h | 32 +++++++++++++++++-
 clang/lib/Format/Format.cpp         | 50 +----------------------------
 2 files changed, 32 insertions(+), 50 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 951a0babefcf4..1a9cdf8fa082b 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,12 +62,42 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
+  /*
+  /// Different styles for aligning after open brackets.
+  /// This is **deprecated**. For backward compatibility only.
+  enum BracketAlignmentStyle : int8_t {
+    /// Align parameters on the open bracket, e.g.:
+    /// \code
+    ///   someLongFunction(argument1,
+    ///                    argument2);
+    /// \endcode
+    BAS_Align,
+    /// Don't align, instead use ``ContinuationIndentWidth``, e.g.:
+    /// \code
+    ///   someLongFunction(argument1,
+    ///       argument2);
+    /// \endcode
+    BAS_DontAlign,
+    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    BAS_AlwaysBreak,
+    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
+    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
+    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    /// in combination with ``BreakBeforeCloseBracketBracedList``,
+    /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
+    /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
+    BAS_BlockIndent,
+  };
+  */
+  LLVM_YAML_STRONG_TYPEDEF(bool, BracketAlignmentStyle)
+
   /// If ``true``, horizontally aligns arguments after an open bracket.
   ///
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
   /// \version 3.8
-  LLVM_YAML_STRONG_TYPEDEF(bool, BracketAlignmentStyle)
   BracketAlignmentStyle AlignAfterOpenBracket;
 
   /// Different style for aligning array initializers.
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 913618e408fdf..551ae6d190803 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -206,52 +206,6 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
 
 // For backward compatibility.
 template <> struct MappingTraits<FormatStyle::BracketAlignmentStyle> {
-
-  class NormalizedBracketAlignmentStyle {
-  public:
-
-    NormalizedBracketAlignmentStyle(IO &IO,
-        FormatStyle::BracketAlignmentStyle &BAS) :
-      AlignAfterOpenBracket(BAS.value == true ? BAS_Align : BAS_DontAlign) {
-    }
-
-    FormatStyle::BracketAlignmentStyle denormalize(IO &IO) {
-      if (AlignAfterOpenBracket == BAS_DontAlign)
-        return FormatStyle::BracketAlignmentStyle(false);
-      return true;
-    }
-
-    /// Different styles for aligning after open brackets.
-    /// This is **deprecated**. For backward compatibility only.
-    enum BracketAlignmentStyleEnum : int8_t {
-      /// Align parameters on the open bracket, e.g.:
-      /// \code
-      ///   someLongFunction(argument1,
-      ///                    argument2);
-      /// \endcode
-      BAS_Align,
-      /// Don't align, instead use ``ContinuationIndentWidth``, e.g.:
-      /// \code
-      ///   someLongFunction(argument1,
-      ///       argument2);
-      /// \endcode
-      BAS_DontAlign,
-      /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-      /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-      /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-      BAS_AlwaysBreak,
-      /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-      /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-      /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-      /// in combination with ``BreakBeforeCloseBracketBracedList``,
-      /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
-      /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-      BAS_BlockIndent,
-    };
-
-    BracketAlignmentStyleEnum AlignAfterOpenBracket; 
-  };
-
   static void enumInput(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
     IO.enumCase(Value, "Align", FormatStyle::BracketAlignmentStyle(true));
     IO.enumCase(Value, "DontAlign", FormatStyle::BracketAlignmentStyle(false));
@@ -261,9 +215,7 @@ template <> struct MappingTraits<FormatStyle::BracketAlignmentStyle> {
     IO.enumCase(Value, "false", FormatStyle::BracketAlignmentStyle(true));
   }
   static void mapping(IO &IO, FormatStyle::BracketAlignmentStyle &BAS) {
-    MappingNormalization<NormalizedBracketAlignmentStyle,
-                         FormatStyle::BracketAlignmentStyle> keys(IO, BAS);
-    IO.mapOptional("AlignAfterOpenBracket", keys->AlignAfterOpenBracket);
+    IO.mapOptional("AlignAfterOpenBracket", BAS.value);
   }
 };
 

>From 69f5d8335a856dcc70949c5cbc38db540cd147b9 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Tue, 26 Aug 2025 10:42:40 -0600
Subject: [PATCH 33/48] Revert "try to handle bool for the public api"

This reverts commit 49e7415ff029d9a6b12df0f523fa7a866209c099.
---
 clang/docs/ClangFormatStyleOptions.rst     |  8 +++--
 clang/include/clang/Format/Format.h        | 12 +++----
 clang/lib/Format/ContinuationIndenter.cpp  |  6 ++--
 clang/lib/Format/Format.cpp                | 38 ++++++++++------------
 clang/lib/Format/FormatToken.cpp           |  2 +-
 clang/lib/Format/TokenAnnotator.cpp        |  4 +--
 clang/unittests/Format/ConfigParseTest.cpp | 22 ++++++++-----
 clang/unittests/Format/FormatTest.cpp      | 18 +++++-----
 8 files changed, 59 insertions(+), 51 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 4cd63ec2d556d..f86b9c13a4cad 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -221,18 +221,22 @@ the configuration (without a prefix: ``Auto``).
       someLongFunction(argument1,
           argument2);
 
-  * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
+  * ``BAS_ABDeprecated`` (in configuration: ``ABDeprecated``)
+    ``BAS_AlwaysBreak``
     This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
+    For backward compatibility. Do not use.
 
-  * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``)
+  * ``BAS_BIDeprecated`` (in configuration: ``BIDeprecated``)
+    ``BAS_BlockIndent``
     This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     in combination with ``BreakBeforeCloseBracketBracedList``,
     ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
+    For backward compatibility. Do not use.
 
 
 
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 1a9cdf8fa082b..88b1f04758d45 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,9 +62,7 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
-  /*
   /// Different styles for aligning after open brackets.
-  /// This is **deprecated**. For backward compatibility only.
   enum BracketAlignmentStyle : int8_t {
     /// Align parameters on the open bracket, e.g.:
     /// \code
@@ -78,20 +76,22 @@ struct FormatStyle {
     ///       argument2);
     /// \endcode
     BAS_DontAlign,
+    /// ``BAS_AlwaysBreak``
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    BAS_AlwaysBreak,
+    /// For backward compatibility. Do not use.
+    BAS_ABDeprecated,
+    /// ``BAS_BlockIndent``
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     /// in combination with ``BreakBeforeCloseBracketBracedList``,
     /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    BAS_BlockIndent,
+    /// For backward compatibility. Do not use.
+    BAS_BIDeprecated,
   };
-  */
-  LLVM_YAML_STRONG_TYPEDEF(bool, BracketAlignmentStyle)
 
   /// If ``true``, horizontally aligns arguments after an open bracket.
   ///
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index ee1a9cac82239..213b96089ffa3 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -930,7 +930,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // Note: This doesn't apply to macro expansion lines, which are MACRO( , , )
   // with args as children of the '(' and ',' tokens. It does not make sense to
   // align the commas with the opening paren.
-  if (Style.AlignAfterOpenBracket != false &&
+  if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
       !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
       Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
       Previous.isNot(TT_TableGenDAGArgOpener) &&
@@ -1864,7 +1864,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
          PrecedenceLevel < prec::Assignment) &&
         (!Previous || Previous->isNot(tok::kw_return) ||
          (!Style.isJava() && PrecedenceLevel > 0)) &&
-        (Style.AlignAfterOpenBracket != false ||
+        (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
          PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
         (!Style.isTableGen() ||
          (Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
@@ -1906,7 +1906,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
       NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
     if (PrecedenceLevel != prec::Conditional &&
         Current.isNot(TT_UnaryOperator) &&
-        Style.AlignAfterOpenBracket != false) {
+        Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
       NewParenState.StartOfFunctionCall = State.Column;
     }
 
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 551ae6d190803..8f2de45cb3da5 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -204,18 +204,16 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
   }
 };
 
-// For backward compatibility.
-template <> struct MappingTraits<FormatStyle::BracketAlignmentStyle> {
-  static void enumInput(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
-    IO.enumCase(Value, "Align", FormatStyle::BracketAlignmentStyle(true));
-    IO.enumCase(Value, "DontAlign", FormatStyle::BracketAlignmentStyle(false));
-    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BracketAlignmentStyle(true));
-    IO.enumCase(Value, "BlockIndent", FormatStyle::BracketAlignmentStyle(true));
-    IO.enumCase(Value, "true", FormatStyle::BracketAlignmentStyle(true));
-    IO.enumCase(Value, "false", FormatStyle::BracketAlignmentStyle(true));
-  }
-  static void mapping(IO &IO, FormatStyle::BracketAlignmentStyle &BAS) {
-    IO.mapOptional("AlignAfterOpenBracket", BAS.value);
+template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
+  static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
+    IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
+    IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign);
+
+    // For backward compatibility.
+    IO.enumCase(Value, "true", FormatStyle::BAS_Align);
+    IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
+    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_ABDeprecated);
+    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BIDeprecated);
   }
 };
 
@@ -1004,6 +1002,7 @@ template <> struct MappingTraits<FormatStyle> {
     }
 
     IO.mapOptional("AccessModifierOffset", Style.AccessModifierOffset);
+    IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
     IO.mapOptional("AlignArrayOfStructures", Style.AlignArrayOfStructures);
     IO.mapOptional("AlignConsecutiveAssignments",
                    Style.AlignConsecutiveAssignments);
@@ -1283,8 +1282,7 @@ template <> struct MappingTraits<FormatStyle> {
     // If AlwaysBreak or BlockIndent were specified but individual
     // options for BreakAfterOpenBracket* (CloseAfterOpenBracket*),
     // initialize the latter to preserve backwards compatibility.
-    bool set = false;
-    if (set) {
+    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_ABDeprecated) {
       if (!Style.BreakAfterOpenBracketBracedList &&
           !Style.BreakAfterOpenBracketFunction &&
           !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
@@ -1293,9 +1291,8 @@ template <> struct MappingTraits<FormatStyle> {
         Style.BreakAfterOpenBracketFunction = true;
         Style.BreakAfterOpenBracketIf = true;
       }
-      set = false;
-    }
-    if (set) {
+      Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+    } else if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BIDeprecated) {
       if (!Style.BreakAfterOpenBracketBracedList &&
           !Style.BreakAfterOpenBracketFunction &&
           !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
@@ -1312,6 +1309,7 @@ template <> struct MappingTraits<FormatStyle> {
         Style.BreakBeforeCloseBracketFunction = true;
         Style.BreakBeforeCloseBracketIf = true;
       }
+      Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
     }
 
     // If AlwaysBreakAfterDefinitionReturnType was specified but
@@ -1603,7 +1601,7 @@ static void expandPresetsSpacesInParens(FormatStyle &Expanded) {
 FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   FormatStyle LLVMStyle;
   LLVMStyle.AccessModifierOffset = -2;
-  LLVMStyle.AlignAfterOpenBracket = true;
+  LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
   LLVMStyle.AlignConsecutiveAssignments = {};
   LLVMStyle.AlignConsecutiveAssignments.PadOperators = true;
@@ -1929,7 +1927,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
   GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 200;
 
   if (Language == FormatStyle::LK_Java) {
-    GoogleStyle.AlignAfterOpenBracket = false;
+    GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
     GoogleStyle.AlignOperands = FormatStyle::OAS_DontAlign;
     GoogleStyle.AlignTrailingComments = {};
     GoogleStyle.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
@@ -2082,7 +2080,7 @@ FormatStyle getMozillaStyle() {
 FormatStyle getWebKitStyle() {
   FormatStyle Style = getLLVMStyle();
   Style.AccessModifierOffset = -4;
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.AlignTrailingComments = {};
   Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index 60693750a9952..bd35c705fbec0 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -194,7 +194,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
     return;
 
   // Column format doesn't really make sense if we don't align after brackets.
-  if (Style.AlignAfterOpenBracket == false)
+  if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign)
     return;
 
   FormatToken *ItemBegin = Token->Next;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index ff4573e5a09a1..f38577238e73f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4430,7 +4430,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
   if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
     return Style.PenaltyBreakOpenParenthesis;
   if (Left.is(tok::l_paren) && InFunctionDecl &&
-      Style.AlignAfterOpenBracket != false) {
+      Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
     return 100;
   }
   if (Left.is(tok::l_paren) && Left.Previous &&
@@ -4448,7 +4448,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
     // If we aren't aligning after opening parens/braces we can always break
     // here unless the style does not want us to place all arguments on the
     // next line.
-    if (Style.AlignAfterOpenBracket == false &&
+    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign &&
         (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) {
       return 0;
     }
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 6f3fe097c9ab2..9a6537dac4175 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -544,15 +544,21 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma,
               FormatStyle::ETC_Remove);
 
-  Style.AlignAfterOpenBracket = false;
-  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket, true);
-  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket, false);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
+  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
+              FormatStyle::BAS_DontAlign);
   // For backward compatibility:
-  CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket, true);
-  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket, false);
-  CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket, true);
-  Style.AlignAfterOpenBracket = false;
-  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket, true);
+  CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
+  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,
+              FormatStyle::BAS_DontAlign);
+  CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket,
+              FormatStyle::BAS_Align);
 
   Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;
   CHECK_PARSE("AlignEscapedNewlines: DontAlign", AlignEscapedNewlines,
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 21f27dddc3072..880763dcfc38d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5282,7 +5282,7 @@ TEST_F(FormatTest, BracedInitializerIndentWidth) {
                Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   Style.BreakAfterOpenBracketBracedList = false;
   verifyFormat("SomeStruct s{\"xxxxxxxxxxxxx\", \"yyyyyyyyyyyyy\",\n"
                "             \"zzzzzzzzzzzzz\"};",
@@ -7440,7 +7440,7 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
   Style.IndentWidth = 4;
   Style.TabWidth = 4;
   Style.UseTab = FormatStyle::UT_Always;
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("return someVeryVeryLongConditionThatBarelyFitsOnALine\n"
                "\t&& (someOtherLongishConditionPart1\n"
@@ -7613,7 +7613,7 @@ TEST_F(FormatTest, NoOperandAlignment) {
                "        * cccccccccccccccccccccccccccccccccccc;",
                Style);
 
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   verifyFormat("return (a > b\n"
                "    // comment1\n"
                "    // comment2\n"
@@ -8117,13 +8117,13 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
   StringRef Input = "functionCall(paramA, paramB, paramC);\n"
                     "void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "    paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "    int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
@@ -8159,14 +8159,14 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
                Input, Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   Style.BreakAfterOpenBracketFunction = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "                  int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   verifyFormat(StringRef("functionCall(\n"
                          "    paramA, paramB, paramC);\n"
                          "void functionDecl(\n"
@@ -11294,7 +11294,7 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
 
 TEST_F(FormatTest, WrapsTemplateParameters) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   verifyFormat(
       "template <typename... a> struct q {};\n"
@@ -11302,7 +11302,7 @@ TEST_F(FormatTest, WrapsTemplateParameters) {
       "    aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>\n"
       "    y;",
       Style);
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
   verifyFormat(
       "template <typename... a> struct r {};\n"

>From 3c935bedaa3eec63a37c1254e854c38b8fcccf54 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Tue, 26 Aug 2025 10:45:00 -0600
Subject: [PATCH 34/48] Get back to previous state

---
 clang/include/clang/Format/Format.h | 8 ++------
 clang/lib/Format/Format.cpp         | 8 ++++----
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 88b1f04758d45..1194c77db22ed 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -76,21 +76,17 @@ struct FormatStyle {
     ///       argument2);
     /// \endcode
     BAS_DontAlign,
-    /// ``BAS_AlwaysBreak``
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    /// For backward compatibility. Do not use.
-    BAS_ABDeprecated,
-    /// ``BAS_BlockIndent``
+    BAS_AlwaysBreak,
     /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     /// in combination with ``BreakBeforeCloseBracketBracedList``,
     /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    /// For backward compatibility. Do not use.
-    BAS_BIDeprecated,
+    BAS_BlockIndent
   };
 
   /// If ``true``, horizontally aligns arguments after an open bracket.
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8f2de45cb3da5..8aabe916f942a 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -212,8 +212,8 @@ template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
     // For backward compatibility.
     IO.enumCase(Value, "true", FormatStyle::BAS_Align);
     IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
-    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_ABDeprecated);
-    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BIDeprecated);
+    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak);
+    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BlockIndent);
   }
 };
 
@@ -1282,7 +1282,7 @@ template <> struct MappingTraits<FormatStyle> {
     // If AlwaysBreak or BlockIndent were specified but individual
     // options for BreakAfterOpenBracket* (CloseAfterOpenBracket*),
     // initialize the latter to preserve backwards compatibility.
-    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_ABDeprecated) {
+    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak) {
       if (!Style.BreakAfterOpenBracketBracedList &&
           !Style.BreakAfterOpenBracketFunction &&
           !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
@@ -1292,7 +1292,7 @@ template <> struct MappingTraits<FormatStyle> {
         Style.BreakAfterOpenBracketIf = true;
       }
       Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-    } else if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BIDeprecated) {
+    } else if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
       if (!Style.BreakAfterOpenBracketBracedList &&
           !Style.BreakAfterOpenBracketFunction &&
           !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&

>From ea84fb39a19356a6b257b8d48c537cbb8f65d589 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Tue, 26 Aug 2025 10:45:30 -0600
Subject: [PATCH 35/48] dump style

---
 clang/docs/ClangFormatStyleOptions.rst | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index f86b9c13a4cad..4cd63ec2d556d 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -221,22 +221,18 @@ the configuration (without a prefix: ``Auto``).
       someLongFunction(argument1,
           argument2);
 
-  * ``BAS_ABDeprecated`` (in configuration: ``ABDeprecated``)
-    ``BAS_AlwaysBreak``
+  * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
     This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    For backward compatibility. Do not use.
 
-  * ``BAS_BIDeprecated`` (in configuration: ``BIDeprecated``)
-    ``BAS_BlockIndent``
+  * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``)
     This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
     ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
     ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
     in combination with ``BreakBeforeCloseBracketBracedList``,
     ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
     ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    For backward compatibility. Do not use.
 
 
 

>From fddc59009ad18107e7d9c2fe6d97667c12e304ba Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Tue, 26 Aug 2025 11:06:33 -0600
Subject: [PATCH 36/48] clean up test

---
 clang/unittests/Format/AlignBracketsTest.cpp | 20 +++---
 clang/unittests/Format/FormatTest.cpp        | 65 --------------------
 2 files changed, 11 insertions(+), 74 deletions(-)

diff --git a/clang/unittests/Format/AlignBracketsTest.cpp b/clang/unittests/Format/AlignBracketsTest.cpp
index 359bb354eaf32..1d9200a77441a 100644
--- a/clang/unittests/Format/AlignBracketsTest.cpp
+++ b/clang/unittests/Format/AlignBracketsTest.cpp
@@ -28,7 +28,7 @@ TEST_F(AlignBracketsTest, AlignsAfterOpenBracket) {
       "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n"
       "                                             aaaaaaaaaaaaaaaaaaaaa));");
   FormatStyle Style = getLLVMStyle();
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
                "    aaaaaaaaaaa aaaaaaaa, aaaaaaaaa aaaaaaa) {}",
                Style);
@@ -617,13 +617,13 @@ TEST_F(AlignBracketsTest, AllowAllArgumentsOnNextLineDontAlign) {
   StringRef Input = "functionCall(paramA, paramB, paramC);\n"
                     "void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "    paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "    int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
@@ -646,11 +646,12 @@ TEST_F(AlignBracketsTest, AllowAllArgumentsOnNextLineDontAlign) {
                "    int A, int B, int C\n"
                ");",
                Input, Style);
+  Style.BreakBeforeCloseBracketFunction = false;
 
   // When AllowAllArgumentsOnNextLine is set, we prefer breaking before the
   // first argument.
   Style.AllowAllArgumentsOnNextLine = true;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakAfterOpenBracketFunction = true;
   verifyFormat(StringRef("functionCall(\n"
                          "    paramA, paramB, paramC);\n"
                          "void functionDecl(\n"
@@ -658,13 +659,14 @@ TEST_F(AlignBracketsTest, AllowAllArgumentsOnNextLineDontAlign) {
                Input, Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.BreakAfterOpenBracketFunction = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "                  int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = false;
+  Style.BreakAfterOpenBracketFunction = true;
   verifyFormat(StringRef("functionCall(\n"
                          "    paramA, paramB, paramC);\n"
                          "void functionDecl(\n"
@@ -770,17 +772,17 @@ TEST_F(AlignBracketsTest, ParenthesesAndOperandAlignment) {
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.AlignOperands = FormatStyle::OAS_Align;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = false;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "    bbbbbbbbbbbbbbbbbbbbbb);",
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 880763dcfc38d..f664dcdcda258 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8110,71 +8110,6 @@ TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
                Style);
 }
 
-TEST_F(FormatTest, AllowAllArgumentsOnNextLineDontAlign) {
-  // Check that AllowAllArgumentsOnNextLine is respected for both BAS_DontAlign
-  // and BAS_Align.
-  FormatStyle Style = getLLVMStyleWithColumns(35);
-  StringRef Input = "functionCall(paramA, paramB, paramC);\n"
-                    "void functionDecl(int A, int B, int C);";
-  Style.AllowAllArgumentsOnNextLine = false;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  verifyFormat(StringRef("functionCall(paramA, paramB,\n"
-                         "    paramC);\n"
-                         "void functionDecl(int A, int B,\n"
-                         "    int C);"),
-               Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  verifyFormat(StringRef("functionCall(paramA, paramB,\n"
-                         "             paramC);\n"
-                         "void functionDecl(int A, int B,\n"
-                         "                  int C);"),
-               Input, Style);
-  // However, BreakAfterOpenBracketFunction should take precedence over
-  // AllowAllArgumentsOnNextLine.
-  Style.BreakAfterOpenBracketFunction = true;
-  verifyFormat(StringRef("functionCall(\n"
-                         "    paramA, paramB, paramC);\n"
-                         "void functionDecl(\n"
-                         "    int A, int B, int C);"),
-               Input, Style);
-  Style.BreakAfterOpenBracketFunction = true;
-  Style.BreakBeforeCloseBracketFunction = true;
-  verifyFormat("functionCall(\n"
-               "    paramA, paramB, paramC\n"
-               ");\n"
-               "void functionDecl(\n"
-               "    int A, int B, int C\n"
-               ");",
-               Input, Style);
-
-  // When AllowAllArgumentsOnNextLine is set, we prefer breaking before the
-  // first argument.
-  Style.AllowAllArgumentsOnNextLine = true;
-  Style.BreakAfterOpenBracketFunction = true;
-  Style.BreakBeforeCloseBracketFunction = false;
-  verifyFormat(StringRef("functionCall(\n"
-                         "    paramA, paramB, paramC);\n"
-                         "void functionDecl(\n"
-                         "    int A, int B, int C);"),
-               Input, Style);
-  // It wouldn't fit on one line with aligned parameters so this setting
-  // doesn't change anything for BAS_Align.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  Style.BreakAfterOpenBracketFunction = false;
-  verifyFormat(StringRef("functionCall(paramA, paramB,\n"
-                         "             paramC);\n"
-                         "void functionDecl(int A, int B,\n"
-                         "                  int C);"),
-               Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  verifyFormat(StringRef("functionCall(\n"
-                         "    paramA, paramB, paramC);\n"
-                         "void functionDecl(\n"
-                         "    int A, int B, int C);"),
-               Input, Style);
-}
-
->>>>>>> d1e73bcfe430 (Add support for functions and replace AlwaysBreak, BlockIndent)
 TEST_F(FormatTest, BreakFunctionDefinitionParameters) {
   StringRef Input = "void functionDecl(paramA, paramB, paramC);\n"
                     "void emptyFunctionDefinition() {}\n"

>From d6e73509d532fad458cfc8d4c035e9c8823ea770 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 29 Aug 2025 19:48:12 -0600
Subject: [PATCH 37/48] Trying Hazardy's suggestions

---
 clang/include/clang/Format/Format.h          | 34 ++-----
 clang/lib/Format/ContinuationIndenter.cpp    |  6 +-
 clang/lib/Format/Format.cpp                  | 99 +++++++++++---------
 clang/lib/Format/FormatToken.cpp             |  2 +-
 clang/lib/Format/TokenAnnotator.cpp          |  4 +-
 clang/unittests/Format/AlignBracketsTest.cpp | 14 +--
 clang/unittests/Format/ConfigParseTest.cpp   | 19 ++--
 clang/unittests/Format/FormatTest.cpp        | 10 +-
 8 files changed, 86 insertions(+), 102 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 1194c77db22ed..5e443fa3aea9f 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,39 +62,17 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
-  /// Different styles for aligning after open brackets.
-  enum BracketAlignmentStyle : int8_t {
-    /// Align parameters on the open bracket, e.g.:
-    /// \code
-    ///   someLongFunction(argument1,
-    ///                    argument2);
-    /// \endcode
-    BAS_Align,
-    /// Don't align, instead use ``ContinuationIndentWidth``, e.g.:
-    /// \code
-    ///   someLongFunction(argument1,
-    ///       argument2);
-    /// \endcode
-    BAS_DontAlign,
-    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    BAS_AlwaysBreak,
-    /// This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    /// ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    /// ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    /// in combination with ``BreakBeforeCloseBracketBracedList``,
-    /// ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
-    /// ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
-    BAS_BlockIndent
-  };
-
   /// If ``true``, horizontally aligns arguments after an open bracket.
   ///
+  /// \code
+  ///   true:                         vs.   false
+  ///   someLongFunction(argument1,         someLongFunction(argument1,
+  ///                    argument2);            argument2);
+  /// \endcode
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
   /// \version 3.8
-  BracketAlignmentStyle AlignAfterOpenBracket;
+  bool AlignAfterOpenBracket;
 
   /// Different style for aligning array initializers.
   enum ArrayInitializerAlignmentStyle : int8_t {
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 213b96089ffa3..ee1a9cac82239 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -930,7 +930,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // Note: This doesn't apply to macro expansion lines, which are MACRO( , , )
   // with args as children of the '(' and ',' tokens. It does not make sense to
   // align the commas with the opening paren.
-  if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&
+  if (Style.AlignAfterOpenBracket != false &&
       !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
       Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
       Previous.isNot(TT_TableGenDAGArgOpener) &&
@@ -1864,7 +1864,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
          PrecedenceLevel < prec::Assignment) &&
         (!Previous || Previous->isNot(tok::kw_return) ||
          (!Style.isJava() && PrecedenceLevel > 0)) &&
-        (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
+        (Style.AlignAfterOpenBracket != false ||
          PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
         (!Style.isTableGen() ||
          (Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
@@ -1906,7 +1906,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
       NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
     if (PrecedenceLevel != prec::Conditional &&
         Current.isNot(TT_UnaryOperator) &&
-        Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
+        Style.AlignAfterOpenBracket != false) {
       NewParenState.StartOfFunctionCall = State.Column;
     }
 
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8aabe916f942a..1329fad2d9b3f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -31,6 +31,12 @@
 using clang::format::FormatStyle;
 
 LLVM_YAML_IS_SEQUENCE_VECTOR(FormatStyle::RawStringFormat)
+enum BracketAlignmentStyle : int8_t {
+  BAS_Align,
+  BAS_DontAlign,
+  BAS_AlwaysBreak,
+  BAS_BlockIndent
+};
 
 namespace llvm {
 namespace yaml {
@@ -204,16 +210,16 @@ template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
   }
 };
 
-template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
-  static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) {
-    IO.enumCase(Value, "Align", FormatStyle::BAS_Align);
-    IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign);
+template <> struct ScalarEnumerationTraits<BracketAlignmentStyle> {
+  static void enumeration(IO &IO, BracketAlignmentStyle &Value) {
+    IO.enumCase(Value, "Align", BAS_Align);
+    IO.enumCase(Value, "DontAlign", BAS_DontAlign);
 
     // For backward compatibility.
-    IO.enumCase(Value, "true", FormatStyle::BAS_Align);
-    IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign);
-    IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak);
-    IO.enumCase(Value, "BlockIndent", FormatStyle::BAS_BlockIndent);
+    IO.enumCase(Value, "true", BAS_Align);
+    IO.enumCase(Value, "false", BAS_DontAlign);
+    IO.enumCase(Value, "AlwaysBreak", BAS_AlwaysBreak);
+    IO.enumCase(Value, "BlockIndent", BAS_BlockIndent);
   }
 };
 
@@ -967,6 +973,43 @@ template <> struct MappingTraits<FormatStyle> {
     bool SpacesInCStyleCastParentheses = false;
     bool SpacesInParentheses = false;
 
+    if (IO.outputting()) {
+      IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
+    } else {
+      // For backward compatibility.
+      BracketAlignmentStyle local;
+      IO.mapOptional("AlignAfterOpenBracket", local);
+      Style.BreakAfterOpenBracketBracedList = false;
+      Style.BreakAfterOpenBracketFunction = false;
+      Style.BreakAfterOpenBracketIf = false;
+      Style.BreakAfterOpenBracketLoop = false;
+      Style.BreakAfterOpenBracketSwitch = false;
+      Style.BreakBeforeCloseBracketBracedList = false;
+      Style.BreakBeforeCloseBracketFunction = false;
+      Style.BreakBeforeCloseBracketIf = false;
+      Style.BreakBeforeCloseBracketLoop = false;
+      Style.BreakBeforeCloseBracketSwitch = false;
+
+      if (local == BAS_Align)
+        Style.AlignAfterOpenBracket = true;
+      else if (local == BAS_DontAlign)
+        Style.AlignAfterOpenBracket = false;
+      else if (local == BAS_AlwaysBreak) {
+        Style.BreakAfterOpenBracketBracedList = true;
+        Style.BreakAfterOpenBracketFunction = true;
+        Style.BreakAfterOpenBracketIf = true;
+        Style.AlignAfterOpenBracket = true;
+      } else if (local == BAS_BlockIndent) {
+        Style.BreakAfterOpenBracketBracedList = true;
+        Style.BreakAfterOpenBracketFunction = true;
+        Style.BreakAfterOpenBracketIf = true;
+        Style.BreakBeforeCloseBracketBracedList = true;
+        Style.BreakBeforeCloseBracketFunction = true;
+        Style.BreakBeforeCloseBracketIf = true;
+        Style.AlignAfterOpenBracket = true;
+      }
+    }
+
     // For backward compatibility.
     if (!IO.outputting()) {
       IO.mapOptional("AlignEscapedNewlinesLeft", Style.AlignEscapedNewlines);
@@ -1002,7 +1045,6 @@ template <> struct MappingTraits<FormatStyle> {
     }
 
     IO.mapOptional("AccessModifierOffset", Style.AccessModifierOffset);
-    IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
     IO.mapOptional("AlignArrayOfStructures", Style.AlignArrayOfStructures);
     IO.mapOptional("AlignConsecutiveAssignments",
                    Style.AlignConsecutiveAssignments);
@@ -1279,39 +1321,6 @@ template <> struct MappingTraits<FormatStyle> {
     IO.mapOptional("WrapNamespaceBodyWithEmptyLines",
                    Style.WrapNamespaceBodyWithEmptyLines);
 
-    // If AlwaysBreak or BlockIndent were specified but individual
-    // options for BreakAfterOpenBracket* (CloseAfterOpenBracket*),
-    // initialize the latter to preserve backwards compatibility.
-    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak) {
-      if (!Style.BreakAfterOpenBracketBracedList &&
-          !Style.BreakAfterOpenBracketFunction &&
-          !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
-          !Style.BreakAfterOpenBracketSwitch) {
-        Style.BreakAfterOpenBracketBracedList = true;
-        Style.BreakAfterOpenBracketFunction = true;
-        Style.BreakAfterOpenBracketIf = true;
-      }
-      Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-    } else if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
-      if (!Style.BreakAfterOpenBracketBracedList &&
-          !Style.BreakAfterOpenBracketFunction &&
-          !Style.BreakAfterOpenBracketIf && !Style.BreakAfterOpenBracketLoop &&
-          !Style.BreakAfterOpenBracketSwitch &&
-          !Style.BreakBeforeCloseBracketBracedList &&
-          !Style.BreakBeforeCloseBracketFunction &&
-          !Style.BreakBeforeCloseBracketIf &&
-          !Style.BreakBeforeCloseBracketLoop &&
-          !Style.BreakBeforeCloseBracketSwitch) {
-        Style.BreakAfterOpenBracketBracedList = true;
-        Style.BreakAfterOpenBracketFunction = true;
-        Style.BreakAfterOpenBracketIf = true;
-        Style.BreakBeforeCloseBracketBracedList = true;
-        Style.BreakBeforeCloseBracketFunction = true;
-        Style.BreakBeforeCloseBracketIf = true;
-      }
-      Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-    }
-
     // If AlwaysBreakAfterDefinitionReturnType was specified but
     // BreakAfterReturnType was not, initialize the latter from the former for
     // backwards compatibility.
@@ -1601,7 +1610,7 @@ static void expandPresetsSpacesInParens(FormatStyle &Expanded) {
 FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   FormatStyle LLVMStyle;
   LLVMStyle.AccessModifierOffset = -2;
-  LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  LLVMStyle.AlignAfterOpenBracket = true;
   LLVMStyle.AlignArrayOfStructures = FormatStyle::AIAS_None;
   LLVMStyle.AlignConsecutiveAssignments = {};
   LLVMStyle.AlignConsecutiveAssignments.PadOperators = true;
@@ -1927,7 +1936,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
   GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 200;
 
   if (Language == FormatStyle::LK_Java) {
-    GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+    GoogleStyle.AlignAfterOpenBracket = false;
     GoogleStyle.AlignOperands = FormatStyle::OAS_DontAlign;
     GoogleStyle.AlignTrailingComments = {};
     GoogleStyle.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
@@ -2080,7 +2089,7 @@ FormatStyle getMozillaStyle() {
 FormatStyle getWebKitStyle() {
   FormatStyle Style = getLLVMStyle();
   Style.AccessModifierOffset = -4;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.AlignTrailingComments = {};
   Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index bd35c705fbec0..60693750a9952 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -194,7 +194,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
     return;
 
   // Column format doesn't really make sense if we don't align after brackets.
-  if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign)
+  if (Style.AlignAfterOpenBracket == false)
     return;
 
   FormatToken *ItemBegin = Token->Next;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index f38577238e73f..ff4573e5a09a1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4430,7 +4430,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
   if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
     return Style.PenaltyBreakOpenParenthesis;
   if (Left.is(tok::l_paren) && InFunctionDecl &&
-      Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) {
+      Style.AlignAfterOpenBracket != false) {
     return 100;
   }
   if (Left.is(tok::l_paren) && Left.Previous &&
@@ -4448,7 +4448,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
     // If we aren't aligning after opening parens/braces we can always break
     // here unless the style does not want us to place all arguments on the
     // next line.
-    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign &&
+    if (Style.AlignAfterOpenBracket == false &&
         (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) {
       return 0;
     }
diff --git a/clang/unittests/Format/AlignBracketsTest.cpp b/clang/unittests/Format/AlignBracketsTest.cpp
index 1d9200a77441a..514a26607d7fa 100644
--- a/clang/unittests/Format/AlignBracketsTest.cpp
+++ b/clang/unittests/Format/AlignBracketsTest.cpp
@@ -28,7 +28,7 @@ TEST_F(AlignBracketsTest, AlignsAfterOpenBracket) {
       "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n"
       "                                             aaaaaaaaaaaaaaaaaaaaa));");
   FormatStyle Style = getLLVMStyle();
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
                "    aaaaaaaaaaa aaaaaaaa, aaaaaaaaa aaaaaaa) {}",
                Style);
@@ -617,13 +617,13 @@ TEST_F(AlignBracketsTest, AllowAllArgumentsOnNextLineDontAlign) {
   StringRef Input = "functionCall(paramA, paramB, paramC);\n"
                     "void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "    paramC);\n"
                          "void functionDecl(int A, int B,\n"
                          "    int C);"),
                Input, Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
                          "void functionDecl(int A, int B,\n"
@@ -659,7 +659,7 @@ TEST_F(AlignBracketsTest, AllowAllArgumentsOnNextLineDontAlign) {
                Input, Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   Style.BreakAfterOpenBracketFunction = false;
   verifyFormat(StringRef("functionCall(paramA, paramB,\n"
                          "             paramC);\n"
@@ -772,17 +772,17 @@ TEST_F(AlignBracketsTest, ParenthesesAndOperandAlignment) {
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_Align;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "          bbbbbbbbbbbbbbbbbbbbbb);",
                Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("int a = f(aaaaaaaaaaaaaaaaaaaaaa &&\n"
                "    bbbbbbbbbbbbbbbbbbbbbb);",
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 9a6537dac4175..4e4c08b0bae95 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -544,21 +544,18 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma,
               FormatStyle::ETC_Remove);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
+  Style.AlignAfterOpenBracket = false;
+  CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket, true);
   CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
-              FormatStyle::BAS_DontAlign);
+              false);
   // For backward compatibility:
   CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
-  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket,
-              FormatStyle::BAS_DontAlign);
+              true);
+  CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket, false);
   CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket,
-              FormatStyle::BAS_Align);
+              true);
+  Style.AlignAfterOpenBracket = false;
+  CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket, true);
 
   Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;
   CHECK_PARSE("AlignEscapedNewlines: DontAlign", AlignEscapedNewlines,
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index f664dcdcda258..8e9251a9d4341 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5282,7 +5282,7 @@ TEST_F(FormatTest, BracedInitializerIndentWidth) {
                Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
+  Style.AlignAfterOpenBracket = true;
   Style.BreakAfterOpenBracketBracedList = false;
   verifyFormat("SomeStruct s{\"xxxxxxxxxxxxx\", \"yyyyyyyyyyyyy\",\n"
                "             \"zzzzzzzzzzzzz\"};",
@@ -7440,7 +7440,7 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
   Style.IndentWidth = 4;
   Style.TabWidth = 4;
   Style.UseTab = FormatStyle::UT_Always;
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   verifyFormat("return someVeryVeryLongConditionThatBarelyFitsOnALine\n"
                "\t&& (someOtherLongishConditionPart1\n"
@@ -7613,7 +7613,7 @@ TEST_F(FormatTest, NoOperandAlignment) {
                "        * cccccccccccccccccccccccccccccccccccc;",
                Style);
 
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   verifyFormat("return (a > b\n"
                "    // comment1\n"
                "    // comment2\n"
@@ -11229,7 +11229,7 @@ TEST_F(FormatTest, BreakBeforeTemplateCloser) {
 
 TEST_F(FormatTest, WrapsTemplateParameters) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   verifyFormat(
       "template <typename... a> struct q {};\n"
@@ -11237,7 +11237,7 @@ TEST_F(FormatTest, WrapsTemplateParameters) {
       "    aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>\n"
       "    y;",
       Style);
-  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.AlignAfterOpenBracket = false;
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
   verifyFormat(
       "template <typename... a> struct r {};\n"

>From c664da955bf5a47d61988ca43c46faa1bb6ee9b6 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 29 Aug 2025 19:48:33 -0600
Subject: [PATCH 38/48] dump style

---
 clang/docs/ClangFormatStyleOptions.rst | 41 +++++---------------------
 1 file changed, 7 insertions(+), 34 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 4cd63ec2d556d..946e886962f56 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -197,44 +197,17 @@ the configuration (without a prefix: ``Auto``).
 
 .. _AlignAfterOpenBracket:
 
-**AlignAfterOpenBracket** (``BracketAlignmentStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>`
+**AlignAfterOpenBracket** (``Boolean``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>`
   If ``true``, horizontally aligns arguments after an open bracket.
 
-  This applies to round brackets (parentheses), angle brackets and square
-  brackets.
-
-  Possible values:
-
-  * ``BAS_Align`` (in configuration: ``Align``)
-    Align parameters on the open bracket, e.g.:
-
-    .. code-block:: c++
-
-      someLongFunction(argument1,
-                       argument2);
-
-  * ``BAS_DontAlign`` (in configuration: ``DontAlign``)
-    Don't align, instead use ``ContinuationIndentWidth``, e.g.:
-
-    .. code-block:: c++
-
-      someLongFunction(argument1,
-          argument2);
-
-  * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
-    This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-
-  * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``)
-    This is **deprecated**. See ``BreakAfterOpenBracketBracedList``,
-    ``BreakAfterOpenBracketFunction``, ``BreakAfterOpenBracketIf``,
-    ``BreakAfterOpenBracketLoop``, ``BreakAfterOpenBracketSwitch``.
-    in combination with ``BreakBeforeCloseBracketBracedList``,
-    ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
-    ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch``.
 
+  .. code-block:: c++
 
+    true:                         vs.   false
+    someLongFunction(argument1,         someLongFunction(argument1,
+                     argument2);            argument2);
+  This applies to round brackets (parentheses), angle brackets and square
+  brackets.
 
 .. _AlignArrayOfStructures:
 

>From 073b8a5ee0975c92de491e24bc83bdb2b35ccfc0 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Tue, 2 Sep 2025 14:11:43 -0600
Subject: [PATCH 39/48] Fix defaults for BasedOnStyle

---
 clang/lib/Format/Format.cpp                | 18 ++++++++++++------
 clang/unittests/Format/ConfigParseTest.cpp |  3 +--
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 1329fad2d9b3f..f2c26a5a670f7 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -977,7 +977,15 @@ template <> struct MappingTraits<FormatStyle> {
       IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
     } else {
       // For backward compatibility.
-      BracketAlignmentStyle local;
+      BracketAlignmentStyle local = BAS_Align;
+      if (IsGoogleOrChromium) {
+        if (Style.Language == FormatStyle::LK_JavaScript)
+          local = BAS_AlwaysBreak;
+        else if (Style.Language == FormatStyle::LK_Java)
+          local = BAS_DontAlign;
+      } else if (BasedOnStyle.equals_insensitive("webkit")) {
+        local = BAS_DontAlign;
+      }
       IO.mapOptional("AlignAfterOpenBracket", local);
       Style.BreakAfterOpenBracketBracedList = false;
       Style.BreakAfterOpenBracketFunction = false;
@@ -990,11 +998,11 @@ template <> struct MappingTraits<FormatStyle> {
       Style.BreakBeforeCloseBracketLoop = false;
       Style.BreakBeforeCloseBracketSwitch = false;
 
-      if (local == BAS_Align)
+      if (local == BAS_Align) {
         Style.AlignAfterOpenBracket = true;
-      else if (local == BAS_DontAlign)
+      } else if (local == BAS_DontAlign) {
         Style.AlignAfterOpenBracket = false;
-      else if (local == BAS_AlwaysBreak) {
+      } else if (local == BAS_AlwaysBreak) {
         Style.BreakAfterOpenBracketBracedList = true;
         Style.BreakAfterOpenBracketFunction = true;
         Style.BreakAfterOpenBracketIf = true;
@@ -1951,8 +1959,6 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
     GoogleStyle.BreakAfterOpenBracketBracedList = true;
     GoogleStyle.BreakAfterOpenBracketFunction = true;
     GoogleStyle.BreakAfterOpenBracketIf = true;
-    GoogleStyle.BreakAfterOpenBracketLoop = false;
-    GoogleStyle.BreakAfterOpenBracketSwitch = false;
     GoogleStyle.AlignOperands = FormatStyle::OAS_DontAlign;
     GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
     // TODO: still under discussion whether to switch to SLS_All.
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 4e4c08b0bae95..59c9d5ad11aea 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -546,8 +546,7 @@ TEST(ConfigParseTest, ParsesConfiguration) {
 
   Style.AlignAfterOpenBracket = false;
   CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket, true);
-  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket,
-              false);
+  CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket, false);
   // For backward compatibility:
   CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,
               true);

>From 53bc5a8e97e449bd4ed3444da4a8223966dab97f Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Thu, 4 Sep 2025 10:54:11 -0600
Subject: [PATCH 40/48] fix style

---
 clang/include/clang/Format/Format.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 5e443fa3aea9f..66f5638dfe948 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -69,6 +69,7 @@ struct FormatStyle {
   ///   someLongFunction(argument1,         someLongFunction(argument1,
   ///                    argument2);            argument2);
   /// \endcode
+  ///
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
   /// \version 3.8

>From 86e37d7f22c6086769706374816b50916f2bf84e Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Thu, 4 Sep 2025 10:54:18 -0600
Subject: [PATCH 41/48] dump style

---
 clang/docs/ClangFormatStyleOptions.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 946e886962f56..21386f60c0107 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -206,6 +206,7 @@ the configuration (without a prefix: ``Auto``).
     true:                         vs.   false
     someLongFunction(argument1,         someLongFunction(argument1,
                      argument2);            argument2);
+
   This applies to round brackets (parentheses), angle brackets and square
   brackets.
 

>From 97b4f2a2377f957a1358bb608b74b141e92aa93d Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Thu, 4 Sep 2025 11:04:50 -0600
Subject: [PATCH 42/48] address review comments

---
 clang/lib/Format/ContinuationIndenter.cpp  |  9 +++--
 clang/lib/Format/Format.cpp                | 39 +++++++++++-----------
 clang/lib/Format/FormatToken.cpp           |  2 +-
 clang/lib/Format/TokenAnnotator.cpp        |  6 ++--
 clang/unittests/Format/ConfigParseTest.cpp |  6 ++++
 5 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index ee1a9cac82239..d1d898601653a 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -930,7 +930,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   // Note: This doesn't apply to macro expansion lines, which are MACRO( , , )
   // with args as children of the '(' and ',' tokens. It does not make sense to
   // align the commas with the opening paren.
-  if (Style.AlignAfterOpenBracket != false &&
+  if (Style.AlignAfterOpenBracket &&
       !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
       Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
       Previous.isNot(TT_TableGenDAGArgOpener) &&
@@ -1864,8 +1864,8 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
          PrecedenceLevel < prec::Assignment) &&
         (!Previous || Previous->isNot(tok::kw_return) ||
          (!Style.isJava() && PrecedenceLevel > 0)) &&
-        (Style.AlignAfterOpenBracket != false ||
-         PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
+        (Style.AlignAfterOpenBracket || PrecedenceLevel > prec::Comma ||
+         Current.NestingLevel == 0) &&
         (!Style.isTableGen() ||
          (Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
                                         TT_TableGenDAGArgListCommaToBreak)))) {
@@ -1905,8 +1905,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
     if (PrecedenceLevel > prec::Unknown)
       NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
     if (PrecedenceLevel != prec::Conditional &&
-        Current.isNot(TT_UnaryOperator) &&
-        Style.AlignAfterOpenBracket != false) {
+        Current.isNot(TT_UnaryOperator) && Style.AlignAfterOpenBracket) {
       NewParenState.StartOfFunctionCall = State.Column;
     }
 
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f2c26a5a670f7..3f6f1328eac1d 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -977,16 +977,17 @@ template <> struct MappingTraits<FormatStyle> {
       IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
     } else {
       // For backward compatibility.
-      BracketAlignmentStyle local = BAS_Align;
+      BracketAlignmentStyle LocalBAS = BAS_Align;
       if (IsGoogleOrChromium) {
-        if (Style.Language == FormatStyle::LK_JavaScript)
-          local = BAS_AlwaysBreak;
-        else if (Style.Language == FormatStyle::LK_Java)
-          local = BAS_DontAlign;
+        if (Style.Language == FormatStyle::LK_JavaScript) {
+          LocalBAS = BAS_AlwaysBreak;
+        } else if (Style.Language == FormatStyle::LK_Java) {
+          LocalBAS = BAS_DontAlign;
+        }
       } else if (BasedOnStyle.equals_insensitive("webkit")) {
-        local = BAS_DontAlign;
+        LocalBAS = BAS_DontAlign;
       }
-      IO.mapOptional("AlignAfterOpenBracket", local);
+      IO.mapOptional("AlignAfterOpenBracket", LocalBAS);
       Style.BreakAfterOpenBracketBracedList = false;
       Style.BreakAfterOpenBracketFunction = false;
       Style.BreakAfterOpenBracketIf = false;
@@ -998,23 +999,23 @@ template <> struct MappingTraits<FormatStyle> {
       Style.BreakBeforeCloseBracketLoop = false;
       Style.BreakBeforeCloseBracketSwitch = false;
 
-      if (local == BAS_Align) {
-        Style.AlignAfterOpenBracket = true;
-      } else if (local == BAS_DontAlign) {
+      switch (LocalBAS) {
+      case BAS_DontAlign:
         Style.AlignAfterOpenBracket = false;
-      } else if (local == BAS_AlwaysBreak) {
-        Style.BreakAfterOpenBracketBracedList = true;
-        Style.BreakAfterOpenBracketFunction = true;
-        Style.BreakAfterOpenBracketIf = true;
-        Style.AlignAfterOpenBracket = true;
-      } else if (local == BAS_BlockIndent) {
-        Style.BreakAfterOpenBracketBracedList = true;
-        Style.BreakAfterOpenBracketFunction = true;
-        Style.BreakAfterOpenBracketIf = true;
+        break;
+      case BAS_BlockIndent:
         Style.BreakBeforeCloseBracketBracedList = true;
         Style.BreakBeforeCloseBracketFunction = true;
         Style.BreakBeforeCloseBracketIf = true;
+        [[fallthrough]];
+      case BAS_AlwaysBreak:
+        Style.BreakAfterOpenBracketBracedList = true;
+        Style.BreakAfterOpenBracketFunction = true;
+        Style.BreakAfterOpenBracketIf = true;
+        [[fallthrough]];
+      case BAS_Align:
         Style.AlignAfterOpenBracket = true;
+        break;
       }
     }
 
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index 60693750a9952..6607560aeaf07 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -194,7 +194,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
     return;
 
   // Column format doesn't really make sense if we don't align after brackets.
-  if (Style.AlignAfterOpenBracket == false)
+  if (!Style.AlignAfterOpenBracket)
     return;
 
   FormatToken *ItemBegin = Token->Next;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index ff4573e5a09a1..4b121a1abb5a4 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4429,10 +4429,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
 
   if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
     return Style.PenaltyBreakOpenParenthesis;
-  if (Left.is(tok::l_paren) && InFunctionDecl &&
-      Style.AlignAfterOpenBracket != false) {
+  if (Left.is(tok::l_paren) && InFunctionDecl && Style.AlignAfterOpenBracket)
     return 100;
-  }
   if (Left.is(tok::l_paren) && Left.Previous &&
       (Left.Previous->isOneOf(tok::kw_for, tok::kw__Generic) ||
        Left.Previous->isIf())) {
@@ -4448,7 +4446,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
     // If we aren't aligning after opening parens/braces we can always break
     // here unless the style does not want us to place all arguments on the
     // next line.
-    if (Style.AlignAfterOpenBracket == false &&
+    if (!Style.AlignAfterOpenBracket &&
         (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) {
       return 0;
     }
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 59c9d5ad11aea..30b55a4f87b4f 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -550,6 +550,12 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   // For backward compatibility:
   CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket,
               true);
+  CHECK_PARSE(
+      "AlignAfterOpenBracket: AlwaysBreak\nBreakAfterOpenBracketIf: false",
+      BreakAfterOpenBracketIf, false);
+  CHECK_PARSE(
+      "BreakAfterOpenBracketLoop: true\nAlignAfterOpenBracket: AlwaysBreak",
+      BreakAfterOpenBracketLoop, true);
   CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket, false);
   CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket,
               true);

>From e891a0363bfab32d2edc997bf9d799e82cb090a3 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Thu, 4 Sep 2025 14:26:45 -0600
Subject: [PATCH 43/48] Fix basedonstyle parsing

---
 clang/lib/Format/Format.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 3f6f1328eac1d..87e2b66d83670 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -979,9 +979,13 @@ template <> struct MappingTraits<FormatStyle> {
       // For backward compatibility.
       BracketAlignmentStyle LocalBAS = BAS_Align;
       if (IsGoogleOrChromium) {
-        if (Style.Language == FormatStyle::LK_JavaScript) {
+        FormatStyle::LanguageKind Language =
+            ((FormatStyle *)IO.getContext())->Language;
+        if (Style.Language == FormatStyle::LK_JavaScript ||
+            Language == FormatStyle::LK_JavaScript) {
           LocalBAS = BAS_AlwaysBreak;
-        } else if (Style.Language == FormatStyle::LK_Java) {
+        } else if (Style.Language == FormatStyle::LK_Java ||
+                   Language == FormatStyle::LK_Java) {
           LocalBAS = BAS_DontAlign;
         }
       } else if (BasedOnStyle.equals_insensitive("webkit")) {

>From 99779d9a9188d04199d53e6e22cf28c1124943bb Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Thu, 4 Sep 2025 14:58:27 -0600
Subject: [PATCH 44/48] narrow the logic

---
 clang/lib/Format/Format.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 87e2b66d83670..47b06f20228e2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -982,10 +982,12 @@ template <> struct MappingTraits<FormatStyle> {
         FormatStyle::LanguageKind Language =
             ((FormatStyle *)IO.getContext())->Language;
         if (Style.Language == FormatStyle::LK_JavaScript ||
-            Language == FormatStyle::LK_JavaScript) {
+            (Style.Language == FormatStyle::LK_None &&
+             Language == FormatStyle::LK_JavaScript)) {
           LocalBAS = BAS_AlwaysBreak;
         } else if (Style.Language == FormatStyle::LK_Java ||
-                   Language == FormatStyle::LK_Java) {
+                   (Style.Language == FormatStyle::LK_None &&
+                    Language == FormatStyle::LK_Java)) {
           LocalBAS = BAS_DontAlign;
         }
       } else if (BasedOnStyle.equals_insensitive("webkit")) {

>From e9645ee36cc9a5e39e1fd0898196b8dedc59f965 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Fri, 5 Sep 2025 15:32:33 -0600
Subject: [PATCH 45/48] refactor

---
 clang/lib/Format/Format.cpp | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 47b06f20228e2..c758fd800f7c9 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -979,17 +979,13 @@ template <> struct MappingTraits<FormatStyle> {
       // For backward compatibility.
       BracketAlignmentStyle LocalBAS = BAS_Align;
       if (IsGoogleOrChromium) {
-        FormatStyle::LanguageKind Language =
-            ((FormatStyle *)IO.getContext())->Language;
-        if (Style.Language == FormatStyle::LK_JavaScript ||
-            (Style.Language == FormatStyle::LK_None &&
-             Language == FormatStyle::LK_JavaScript)) {
+        FormatStyle::LanguageKind Language = Style.Language;
+        if (Language == FormatStyle::LK_None)
+          Language = ((FormatStyle *)IO.getContext())->Language;
+        if (Language == FormatStyle::LK_JavaScript)
           LocalBAS = BAS_AlwaysBreak;
-        } else if (Style.Language == FormatStyle::LK_Java ||
-                   (Style.Language == FormatStyle::LK_None &&
-                    Language == FormatStyle::LK_Java)) {
+        else if (Language == FormatStyle::LK_Java)
           LocalBAS = BAS_DontAlign;
-        }
       } else if (BasedOnStyle.equals_insensitive("webkit")) {
         LocalBAS = BAS_DontAlign;
       }

>From 3598dbe91e0d2c40b185a3e76c7821e0ce310715 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 8 Sep 2025 18:19:05 -0600
Subject: [PATCH 46/48] address review comments

---
 clang/include/clang/Format/Format.h       | 10 ++++++++++
 clang/lib/Format/ContinuationIndenter.cpp |  4 +---
 clang/lib/Format/Format.cpp               |  1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 66f5638dfe948..d2037a759ce5a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -70,6 +70,16 @@ struct FormatStyle {
   ///                    argument2);            argument2);
   /// \endcode
   ///
+  /// \note
+  ///   As of clang-format 22 this option is a bool with the previous
+  ///   option of ``Align`` replaced with ``true``, ``DontAlign`` replaced
+  ///   with ``false``, and the options of ``AlwaysBreak`` and ``BlockIndent``
+  ///   replaced with ``true`` and with setting of new style options using
+  ///   ``BreakAfterOpenBracketBracedList``, ``BreakAfterOpenBracketFunction``,
+  ///   ``BreakAfterOpenBracketIf``, ``BreakBeforeCloseBracketBracedList``,
+  ///   ``BreakBeforeCloseBracketFunction``, and ``BreakAfterOpenBracketIf``.
+  /// \endnote
+  ///
   /// This applies to round brackets (parentheses), angle brackets and square
   /// brackets.
   /// \version 3.8
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index d1d898601653a..8620691cf9255 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1275,9 +1275,7 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
   }
 
   if (PreviousNonComment && PreviousNonComment->is(tok::l_paren)) {
-    auto Previous = PreviousNonComment->Previous;
-    if (Previous) {
-
+    if (auto Previous = PreviousNonComment->Previous) {
       if (Previous->isIf()) {
         CurrentState.BreakBeforeClosingParen = Style.BreakBeforeCloseBracketIf;
       } else if (Previous->isLoop(Style)) {
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index c758fd800f7c9..0ba2d4f478356 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -31,6 +31,7 @@
 using clang::format::FormatStyle;
 
 LLVM_YAML_IS_SEQUENCE_VECTOR(FormatStyle::RawStringFormat)
+
 enum BracketAlignmentStyle : int8_t {
   BAS_Align,
   BAS_DontAlign,

>From 4a9594cbd80c306ca106db1d3a4589727262b5f9 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Mon, 8 Sep 2025 18:19:32 -0600
Subject: [PATCH 47/48] dump style

---
 clang/docs/ClangFormatStyleOptions.rst | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 21386f60c0107..11f782f06248b 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -207,6 +207,17 @@ the configuration (without a prefix: ``Auto``).
     someLongFunction(argument1,         someLongFunction(argument1,
                      argument2);            argument2);
 
+
+  .. note::
+
+    As of clang-format 22 this option is a bool with the previous
+    option of ``Align`` replaced with ``true``, ``DontAlign`` replaced
+    with ``false``, and the options of ``AlwaysBreak`` and ``BlockIndent``
+    replaced with ``true`` and with setting of new style options using
+    ``BreakAfterOpenBracketBracedList``, ``BreakAfterOpenBracketFunction``,
+    ``BreakAfterOpenBracketIf``, ``BreakBeforeCloseBracketBracedList``,
+    ``BreakBeforeCloseBracketFunction``, and ``BreakAfterOpenBracketIf``.
+
   This applies to round brackets (parentheses), angle brackets and square
   brackets.
 

>From 434b10e390a33ee3a79ae75a0f96551cbefb419b Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare at rtems.org>
Date: Wed, 11 Sep 2024 22:48:12 -0600
Subject: [PATCH 48/48] Update release notes

---
 clang/docs/ReleaseNotes.rst | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 70c82b090107a..b20e0c81ae6e0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -536,6 +536,14 @@ clang-format
   literals.
 - Add ``Leave`` suboption to ``IndentPPDirectives``.
 - Add ``AllowBreakBeforeQtProperty`` option.
+- Add ``BreakAfterOpenBracketBracedList'', ``BreakAfterOpenBracketFunction'',
+  ``BreakAfterOpenBracketIf``, ``BreakAfterOpenBracketLoop``,
+  ``BreakAfterOpenBracketSwitch``, ``BreakBeforeCloseBracketBracedList'',
+  ``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
+  ``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch`` options.
+- Deprecate ``AlwaysBreak`` and ``BlockIndent`` suboptions from the
+  ``AlignAfterOpenBracket`` option, and make ``AlignAfterOpenBracket`` a
+  ``bool`` type.
 
 libclang
 --------



More information about the cfe-commits mailing list