forked from OSchip/llvm-project
clang-format: Don't indent lambda body relative to its return type.
Before: []() // -> int { return 1; // }; After: []() // -> int { return 1; // }; llvm-svn: 272535
This commit is contained in:
parent
dbc9e5f598
commit
87448c5548
clang
|
@ -476,11 +476,13 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
|
||||||
// // code
|
// // code
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// is common and should be formatted like a free-standing function.
|
// is common and should be formatted like a free-standing function. The same
|
||||||
if (Style.Language != FormatStyle::LK_JavaScript ||
|
// goes for wrapping before the lambda return type arrow.
|
||||||
|
if (!Current.is(TT_LambdaArrow) &&
|
||||||
|
(Style.Language != FormatStyle::LK_JavaScript ||
|
||||||
Current.NestingLevel != 0 || !PreviousNonComment ||
|
Current.NestingLevel != 0 || !PreviousNonComment ||
|
||||||
!PreviousNonComment->is(tok::equal) ||
|
!PreviousNonComment->is(tok::equal) ||
|
||||||
!Current.isOneOf(Keywords.kw_async, Keywords.kw_function))
|
!Current.isOneOf(Keywords.kw_async, Keywords.kw_function)))
|
||||||
State.Stack.back().NestedBlockIndent = State.Column;
|
State.Stack.back().NestedBlockIndent = State.Column;
|
||||||
|
|
||||||
if (NextNonComment->isMemberAccess()) {
|
if (NextNonComment->isMemberAccess()) {
|
||||||
|
|
|
@ -10997,6 +10997,10 @@ TEST_F(FormatTest, FormatsLambdas) {
|
||||||
" return aaaaaaaaaaaaaaaaa;\n"
|
" return aaaaaaaaaaaaaaaaa;\n"
|
||||||
" });",
|
" });",
|
||||||
getLLVMStyleWithColumns(70));
|
getLLVMStyleWithColumns(70));
|
||||||
|
verifyFormat("[]() //\n"
|
||||||
|
" -> int {\n"
|
||||||
|
" return 1; //\n"
|
||||||
|
"};");
|
||||||
|
|
||||||
// Multiple lambdas in the same parentheses change indentation rules.
|
// Multiple lambdas in the same parentheses change indentation rules.
|
||||||
verifyFormat("SomeFunction(\n"
|
verifyFormat("SomeFunction(\n"
|
||||||
|
|
Loading…
Reference in New Issue