clang-format: Improve format of lambdas in ctor initializers.

Before:
  Constructor()
      : Constructor([] { // comment
        int i;
      }) {}

After:
  Constructor()
      : Constructor([] { // comment
          int i;
        }) {}

llvm-svn: 225625
This commit is contained in:
Daniel Jasper 2015-01-12 10:23:24 +00:00
parent 19acc3d351
commit d6a1cab1bc
2 changed files with 5 additions and 0 deletions

View File

@ -632,6 +632,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
// ^ line up here.
State.Stack.back().Indent =
State.Column + (Style.BreakConstructorInitializersBeforeComma ? 0 : 2);
State.Stack.back().NestedBlockIndent = State.Stack.back().Indent;
if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
State.Stack.back().AvoidBinPacking = true;
State.Stack.back().BreakBeforeParameter = false;

View File

@ -9380,6 +9380,10 @@ TEST_F(FormatTest, FormatsLambdas) {
verifyFormat("string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() {\n"
" SomeOtherFunctioooooooooooooooooooooooooon();\n"
"});");
verifyFormat("Constructor()\n"
" : Field([] { // comment\n"
" int i;\n"
" }) {}");
// Lambdas with return types.
verifyFormat("int c = []() -> int { return 2; }();\n");