clang-format: Keep empty lines and format 1-line nested blocks.

Let clang-format consistently keep up to one empty line (configured via
FormatStyle::MaxEmptyLinesToKeep) in nested blocks, e.g. lambdas. Also,
actually format single statements in nested blocks.

Before:
  DEBUG({ int     i; });
  DEBUG({
    int i;
    // an empty line here would just be removed.
    int j;
  });

After:
  DEBUG({ int i; });
  DEBUG({
    int i;

    int j;
  });

llvm-svn: 190278
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ce39c48..fe6660b 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -530,10 +530,14 @@
            I != E; ++I) {
         unsigned Indent =
             ParentIndent + ((*I)->Level - Line.Level) * Style.IndentWidth;
-        if (!DryRun)
+        if (!DryRun) {
+          unsigned Newlines = std::min((*I)->First->NewlinesBefore,
+                                       Style.MaxEmptyLinesToKeep + 1);
+          Newlines = std::max(1u, Newlines);
           Whitespaces->replaceWhitespace(
-              *(*I)->First, /*Newlines=*/1, /*Spaces=*/Indent,
+              *(*I)->First, Newlines, /*Spaces=*/Indent,
               /*StartOfTokenColumn=*/Indent, Line.InPPDirective);
+        }
         UnwrappedLineFormatter Formatter(Indenter, Whitespaces, Style, **I);
         Penalty += Formatter.format(Indent, DryRun);
       }
@@ -552,6 +556,9 @@
                                      /*Newlines=*/0, /*Spaces=*/1,
                                      /*StartOfTokenColumn=*/State.Column,
                                      State.Line->InPPDirective);
+      UnwrappedLineFormatter Formatter(Indenter, Whitespaces, Style,
+                                       *LBrace.Children[0]);
+      Penalty += Formatter.format(State.Column + 1, DryRun);
     }
 
     State.Column += 1 + LBrace.Children[0]->Last->TotalLength;