[clang] [clang-format] Fix a bug in wrapping { after else (PR #161048)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 28 19:40:20 PDT 2025


================
@@ -4089,6 +4088,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
     }
   }
 
+  if (First->is(TT_ElseLBrace)) {
+    First->CanBreakBefore = true;
+    First->MustBreakBefore = true;
----------------
owenca wrote:

This is what I missed in #135906 (which set the `l_brace` of control statements to "wrap") because I forgot that the `l_brace` of `else` blocks was `TT_ElseLBrace` instead of `TT_ControlStatementLBrace`.

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


More information about the cfe-commits mailing list