forked from OSchip/llvm-project
clang-format: Understand that breaking before lambdas is fine.
Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([]( const aaaaaaaaaa &a) { return a; }); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( [](const aaaaaaaaaa &a) { return a; }); llvm-svn: 211575
This commit is contained in:
parent
ad8065f01a
commit
a2fb50f9b3
|
@ -1315,7 +1315,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
|
||||||
if (Right.is(tok::l_square)) {
|
if (Right.is(tok::l_square)) {
|
||||||
if (Style.Language == FormatStyle::LK_Proto)
|
if (Style.Language == FormatStyle::LK_Proto)
|
||||||
return 1;
|
return 1;
|
||||||
if (Right.Type != TT_ObjCMethodExpr)
|
if (Right.Type != TT_ObjCMethodExpr && Right.Type != TT_LambdaLSquare)
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
if (Right.Type == TT_StartOfName || Right.is(tok::kw_operator)) {
|
if (Right.Type == TT_StartOfName || Right.is(tok::kw_operator)) {
|
||||||
|
|
|
@ -8721,6 +8721,8 @@ TEST_F(FormatTest, FormatsLambdas) {
|
||||||
verifyFormat("void f() {\n"
|
verifyFormat("void f() {\n"
|
||||||
" SomeFunction([](decltype(x), A *a) {});\n"
|
" SomeFunction([](decltype(x), A *a) {});\n"
|
||||||
"}");
|
"}");
|
||||||
|
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
|
||||||
|
" [](const aaaaaaaaaa &a) { return a; });");
|
||||||
|
|
||||||
// Lambdas with return types.
|
// Lambdas with return types.
|
||||||
verifyFormat("int c = []() -> int { return 2; }();\n");
|
verifyFormat("int c = []() -> int { return 2; }();\n");
|
||||||
|
@ -8728,7 +8730,7 @@ TEST_F(FormatTest, FormatsLambdas) {
|
||||||
verifyFormat("Foo([]() -> std::vector<int> { return {2}; }());");
|
verifyFormat("Foo([]() -> std::vector<int> { return {2}; }());");
|
||||||
verifyFormat("auto aaaaaaaa = [](int i, // break for some reason\n"
|
verifyFormat("auto aaaaaaaa = [](int i, // break for some reason\n"
|
||||||
" int j) -> int {\n"
|
" int j) -> int {\n"
|
||||||
" return fffffffffffffffffffffffffffffffffffffff(i * j);\n"
|
" return ffffffffffffffffffffffffffffffffffffffffffff(i * j);\n"
|
||||||
"};");
|
"};");
|
||||||
|
|
||||||
// Multiple lambdas in the same parentheses change indentation rules.
|
// Multiple lambdas in the same parentheses change indentation rules.
|
||||||
|
|
Loading…
Reference in New Issue