[clang] [clang-format] Disable OuterScope lambda indentation behaviour for constructor initializers (PR #66755)

Jon Phillips via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 20 03:48:18 PDT 2023


jp4a50 wrote:

> I'm not sure I understand, looking at https://clang.llvm.org/docs/ClangFormatStyleOptions.html#lambdabodyindentation it seems to explicitly state it should be at the outer function scope, can you point to a github issue this is trying to solve or is this just personal preference?

When my team originally proposed and authored this option the intention was for it to apply to expression statements within blocks such that statements such that the bodies of lambdas as function call arguments (like the example in the docs) and on the RHS of assignment expressions (etc.) would align with the start of the expression, minimizing indentation.

We just didn't think of or consider cases such as lambdas used within constructor initializers where the start of the constructor is not the start of the expression so aligning with respect to the start of the constructor is confusing.

So I'd say that this can be considered personal preference to a certain extent but also an attempt to honour the intended behaviour of the option when we proposed it.

I accept that implementing this as an edge case is clunkier than I'd like, though.

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


More information about the cfe-commits mailing list