[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2025-01-29 Thread James Grant via cfe-commits
https://github.com/jamesg-nz edited https://github.com/llvm/llvm-project/pull/76673 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2025-01-29 Thread James Grant via cfe-commits
https://github.com/jamesg-nz updated https://github.com/llvm/llvm-project/pull/76673 >From 04885844162b5390d8041a44a1895ad6ac160228 Mon Sep 17 00:00:00 2001 From: James Grant <42079499+jamesg...@users.noreply.github.com> Date: Mon, 1 Jan 2024 20:27:41 +1300 Subject: [PATCH 1/2] [clang-format] Fi

[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2025-01-29 Thread James Grant via cfe-commits
@@ -366,8 +366,14 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { const auto &CurrentState = State.Stack.back(); if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore && Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) { -

[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits
https://github.com/jamesg-nz edited https://github.com/llvm/llvm-project/pull/76673 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits
@@ -366,8 +366,14 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { const auto &CurrentState = State.Stack.back(); if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore && Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) { -

[clang] [clang-format] Don't apply severe penalty if no possible column formats (PR #76675)

2024-01-01 Thread James Grant via cfe-commits
jamesg-nz wrote: > I think that's not the right way to fix the issue. > > Why are the 2 lines formatted differently? It seems to me that this fixes the > symptom, not the cause. Because for the line where brackets are used it meets the condition in the next `if` statement down: https://githu

[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits
@@ -22965,6 +22965,84 @@ TEST_F(FormatTest, EmptyLinesInLambdas) { "};"); } +TEST_F(FormatTest, BreakBeforeLambdaBodyWrapping) { + verifyFormat("connect([]() {\n" + " foo();\n" + " bar();\n" + "});"); + + auto Style

[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits
https://github.com/jamesg-nz updated https://github.com/llvm/llvm-project/pull/76673 >From 04885844162b5390d8041a44a1895ad6ac160228 Mon Sep 17 00:00:00 2001 From: James Grant <42079499+jamesg...@users.noreply.github.com> Date: Mon, 1 Jan 2024 20:27:41 +1300 Subject: [PATCH 1/2] [clang-format] Fi

[clang] [clang-format] Don't apply severe penalty if no possible column formats (PR #76675)

2024-01-01 Thread James Grant via cfe-commits
jamesg-nz wrote: Running debug build clang-format with `-debug` parameter against code provided in #56350 (and its duplicate #58469) you see `Penalty for line: 1`. So pretty obvious the [severe penalty](https://github.com/llvm/llvm-project/blob/703e83611cd8bb7174ae76ba2e301f5a5e88b905/clan

[clang] [clang-format] Don't apply severe penalty if no possible column formats (PR #76675)

2024-01-01 Thread James Grant via cfe-commits
https://github.com/jamesg-nz created https://github.com/llvm/llvm-project/pull/76675 If there are possible column formats, but they weren't selected because they don't fit within remaining characters for the current path then applying severe penalty to induce column layout by selection of a di

[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits
jamesg-nz wrote: n.b. there's relevant test coverage provided by existing `LambdaWithLineComments` test. https://github.com/llvm/llvm-project/pull/76673 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/li

[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits
https://github.com/jamesg-nz created https://github.com/llvm/llvm-project/pull/76673 Firstly, must check ColumnLimit > 0 before comparing calculated columns to the limit. Otherwise it always breaks before the brace if ColumnLimit = 0 (no limit). Fixes #50275 Secondly, the lambda body length a