[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 2 02:05:19 PDT 2023


owenpan added a comment.

In D146042#4204651 <https://reviews.llvm.org/D146042#4204651>, @jp4a50 wrote:

> I'm confident that the patch will indent all those examples correctly when they are at block scope which is the only place those snippets will actually be valid code. I added an exception (see comment in ContinuationIndenter.cpp) to the code to disable `OuterScope`'s behaviour when the line's indentation level is 0 (i.e. statements at namespace scope) because otherwise you can end up with things like:
>
>   Namespace::Foo::Foo(
>     Arg arg1, Arg arg2,
>     Arg arg3, Arg arg4)
>     : init1{arg1},
>       init2{[arg2]() {
>     return arg2;
>   }},
>       init3{arg3},
>       init4{arg4} {}

Sorry that I missed it.



================
Comment at: clang/include/clang/Format/Format.h:2652-2656
   /// containing the lambda signature. For callback-heavy code, it may improve
   /// readability to have the signature indented two levels and to use
   /// ``OuterScope``. The KJ style guide requires ``OuterScope``.
   /// `KJ style guide
   /// <https://github.com/capnproto/capnproto/blob/master/style-guide.md>`_
----------------
We might as well clean it up a bit.


================
Comment at: clang/unittests/Format/FormatTest.cpp:21997
+               "  })));\n"
+               "}\n",
+               Style);
----------------
Ditto below.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146042/new/

https://reviews.llvm.org/D146042



More information about the cfe-commits mailing list