Open Quuxplusone opened 8 years ago
test_fmt_lambda.cpp
Created attachment 16756 Code example
Consider the following code, formatted by clang-format:
clang-format
int main() { int x, y;
auto l0 = [x, y](auto z) { /* ... */ }; auto l1 = [x, y](auto z) -> int { /* ... */ }; auto l2 = [ x, y ](auto z) -> auto {/* ... */};
}
Lambdas with no trailing return type are formatted as expected.
Lambdas with a non-auto trailing return type are formatted as expected.
auto
(!) Lambdas with an auto trailing return type are inconsistently formatted. A space is added in the capture list and line breaks are not respected.
Removing the -> auto or changing auto to int allows the lambda to be formatted as expected.
-> auto
int
Might be related to bug #20450: https://llvm.org/bugs/show_bug.cgi?id=20450
Attached test_fmt_lambda.cpp (186 bytes, text/x-c++src): Code example
test_fmt_lambda.cpp
(186 bytes, text/x-c++src)Created attachment 16756 Code example
Consider the following code, formatted by
clang-format
:int main() { int x, y;
}
Lambdas with no trailing return type are formatted as expected.
Lambdas with a non-
auto
trailing return type are formatted as expected.(!) Lambdas with an
auto
trailing return type are inconsistently formatted. A space is added in the capture list and line breaks are not respected.Removing the
-> auto
or changingauto
toint
allows the lambda to be formatted as expected.Might be related to bug #20450: https://llvm.org/bugs/show_bug.cgi?id=20450