clang-format: Prefer not to put lambdas on a single line.

Before:
  string abc =
      SomeFunction(aaaaaaaaaaaaa, aaaaa,
                   []() { SomeOtherFunctioooooooooooooooooooooooooon(); });

After:
  string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() {
    SomeOtherFunctioooooooooooooooooooooooooon();
  });

llvm-svn: 215197
This commit is contained in:
Daniel Jasper 2014-08-08 12:00:13 +00:00
parent b911bf84dc
commit a5621202c4
2 changed files with 5 additions and 0 deletions

View File

@ -1420,6 +1420,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return 100;
if (Left.is(tok::equal) && InFunctionDecl)
return 110;
if (Right.is(tok::r_brace))
return 1;
if (Left.opensScope())
return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter
: 19;

View File

@ -8819,6 +8819,9 @@ TEST_F(FormatTest, FormatsLambdas) {
"}");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" [](const aaaaaaaaaa &a) { return a; });");
verifyFormat("string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() {\n"
" SomeOtherFunctioooooooooooooooooooooooooon();\n"
"});");
// Lambdas with return types.
verifyFormat("int c = []() -> int { return 2; }();\n");