[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 11 20:18:24 PST 2025


owenca wrote:

> > I think this should be covered by BlockIndent
> 
> My understanding from looking at past PRs to clang-format was that backwards compatibility was a top requirement. If I changed the behavior of BlockIndent to put the `>` on the next line, that would change a lot of existing behavior/codebases/tests.

The default behavior of `AlignAfterOpenBracket` is `Align` for `LLVM` style, and the breaking for template angles seems to have the same default behavior. Unfortunately, `WebKit` style has `DontAlign` as its default. So let's keep this new option separate.

> > Call verifyFormat instead of verifyNoChange whenever possible.
> 
> I understand, but, I am testing the case where ColumnLimit = 0. When I call `verifyFormat` it removes all the newlines. So I was unable to test the behavior in the unconstrained column limit case. Note how I test that you can have a `\n` after the `template<`, or not, and this option doesn't force it either way.
> 
> In the later part of the tests, starting when I change the ColumnLimit to 40, note that all of the tests are `verifyFormat` and I don't use `verifyNoChange` anymore.

I got that as I said "whenever possible".

> I have removed a few `verifyNoChange` in my last commit.

There are still a couple of `verifyNoChange` that can be replaced with `verifyFormat` for your `ColumnLimit = 0` test cases, though.

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


More information about the cfe-commits mailing list