[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:57:00 PDT 2023
================
@@ -22537,10 +22537,12 @@ TEST_F(FormatTest, FormatsLambdas) {
" }\n"
"}",
Style);
- verifyFormat("std::sort(v.begin(), v.end(),\n"
- " [](const auto &foo, const auto &bar) {\n"
- " return foo.baz < bar.baz;\n"
- "});",
----------------
jp4a50 wrote:
I can add this back in but the reason I removed it in favour of putting the equivalent code inside block scope is because the code in this example is a violation of C++ grammar given it is not actually a declaration but is at namespace/global scope. As such, the new logic incorrectly assumes that this is a declaration and would therefore would **not** indent the lambda body wrt. the start of the expression, which I think would be misleading to readers.
Simply putting this code inside block scope captures the intention of original test case, I think.
https://github.com/llvm/llvm-project/pull/66755
More information about the cfe-commits
mailing list