clang-format: Prefer wrapping a lambda's body over the lambda's return type.

Before:
  aaaaaaaaaaaaaaaaaaaaaa(
      [](aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa)
          -> aaaaaaaaaaaaaaaaaaaaa { return aaaaaaaaaaaaaaaaa; });

After:
  aaaaaaaaaaaaaaaaaaaaaa(
      [](aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa) -> aaaaaaaaaaaaaaaaaaaaa {
        return aaaaaaaaaaaaaaaaa;
      });

llvm-svn: 230942
This commit is contained in:
Daniel Jasper 2015-03-02 10:35:13 +00:00
parent 63fbf10c32
commit e662316994
2 changed files with 8 additions and 0 deletions

View File

@ -1535,6 +1535,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return Style.PenaltyReturnTypeOnItsOwnLine;
return 200;
}
if (Right.is(TT_TrailingReturnArrow))
return 110;
if (Left.is(tok::equal) && Right.is(tok::l_brace))
return 150;
if (Left.is(TT_CastRParen))

View File

@ -9537,6 +9537,12 @@ TEST_F(FormatTest, FormatsLambdas) {
" int j) -> int {\n"
" return ffffffffffffffffffffffffffffffffffffffffffff(i * j);\n"
"};");
verifyFormat(
"aaaaaaaaaaaaaaaaaaaaaa(\n"
" [](aaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa) -> aaaaaaaaaaaaaaaa {\n"
" return aaaaaaaaaaaaaaaaa;\n"
" });",
getLLVMStyleWithColumns(70));
// Multiple lambdas in the same parentheses change indentation rules.
verifyFormat("SomeFunction(\n"