diff options
author | Manuel Klimek <klimek@google.com> | 2017-09-19 09:59:30 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2017-09-19 09:59:30 +0000 |
commit | 8b3beec43959d827795128837b6adc58cae027a2 (patch) | |
tree | 8e225dfaf306cbf4e8ec854738606689c3b35be4 /unittests | |
parent | b3bac44cb354b63214b16fab24b5c0ffd392ec02 (diff) |
Fix formatting of lambda introducers with initializers.
Most of the work was already done when we introduced a look-behind based
lambda introducer detection.
This patch finishes the transition by completely relying on the simple
lambda introducer detection and simply recursing into normal
brace-parsing code to parse until the end of the introducer.
This fixes initializers in lambdas, including nested lambdas.
Before:
auto a = [b = [c = 42]{}]{};
auto b = [c = &i + 23]{};
After:
auto a = [b = [c = 42] {}] {};
auto b = [c = &i + 23] {};
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313622 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index e974550f22..34206e9e41 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -10770,6 +10770,8 @@ TEST_F(FormatTest, FormatsLambdas) { verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); }();\n"); verifyFormat("auto c = {[&a, &a, a] { [=, a, b, &c] { return b++; }(); }}\n"); verifyFormat("auto c = {[&a, &a, a] { [=, a, b, &c] {}(); }}\n"); + verifyFormat("auto c = [a = [b = 42] {}] {};\n"); + verifyFormat("auto c = [a = &i + 10, b = [] {}] {};\n"); verifyFormat("int x = f(*+[] {});"); verifyFormat("void f() {\n" " other(x.begin(), x.end(), [&](int, int) { return 1; });\n" |