diff options
| author | Daniel Jasper <djasper@google.com> | 2016-06-13 07:48:45 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2016-06-13 07:48:45 +0000 |
| commit | 87448c55481fc37395fd23cb825463241d091752 (patch) | |
| tree | 9afe546c3486c559f00940c6a0332c77a795726c /clang | |
| parent | dbc9e5f598e4ac36c304f898a7fde972581fdca5 (diff) | |
| download | bcm5719-llvm-87448c55481fc37395fd23cb825463241d091752.tar.gz bcm5719-llvm-87448c55481fc37395fd23cb825463241d091752.zip | |
clang-format: Don't indent lambda body relative to its return type.
Before:
[]() //
-> int {
return 1; //
};
After:
[]() //
-> int {
return 1; //
};
llvm-svn: 272535
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 12 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 7f88eea4060..322969e4bb7 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -476,11 +476,13 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, // // code // } // - // is common and should be formatted like a free-standing function. - if (Style.Language != FormatStyle::LK_JavaScript || - Current.NestingLevel != 0 || !PreviousNonComment || - !PreviousNonComment->is(tok::equal) || - !Current.isOneOf(Keywords.kw_async, Keywords.kw_function)) + // is common and should be formatted like a free-standing function. The same + // goes for wrapping before the lambda return type arrow. + if (!Current.is(TT_LambdaArrow) && + (Style.Language != FormatStyle::LK_JavaScript || + Current.NestingLevel != 0 || !PreviousNonComment || + !PreviousNonComment->is(tok::equal) || + !Current.isOneOf(Keywords.kw_async, Keywords.kw_function))) State.Stack.back().NestedBlockIndent = State.Column; if (NextNonComment->isMemberAccess()) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index be24066b20c..d27da34d340 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -10997,6 +10997,10 @@ TEST_F(FormatTest, FormatsLambdas) { " return aaaaaaaaaaaaaaaaa;\n" " });", getLLVMStyleWithColumns(70)); + verifyFormat("[]() //\n" + " -> int {\n" + " return 1; //\n" + "};"); // Multiple lambdas in the same parentheses change indentation rules. verifyFormat("SomeFunction(\n" |

