diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-26 13:10:34 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-26 13:10:34 +0000 |
commit | 1ef81d57fbcc26080c98e140e7c82db6d2aeba87 (patch) | |
tree | 2b2e4a53bd27b567282ce6f5b8a5ac77ccbb1daf /lib/Format/Format.cpp | |
parent | 0fb382bfbfbfee73763a213b2257042ed342c4b0 (diff) |
Only keep empty lines in unwrapped lines if they preceed a line comment.
Empty lines followed by line comments are often used to highlight the
comment. Empty lines somewhere else are usually left over from manual or
automatic formatting and should probably be removed.
Before (clang-format would keep):
S s = {
a,
b
};
After:
S s = { a, b };
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176086 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 7687aa347b..8bc414cd02 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -518,9 +518,11 @@ private: State.Stack.back().BreakBeforeParameter = false; if (!DryRun) { - unsigned NewLines = - std::max(1u, std::min(Current.FormatTok.NewlinesBefore, - Style.MaxEmptyLinesToKeep + 1)); + unsigned NewLines = 1; + if (Current.Type == TT_LineComment) + NewLines = + std::max(NewLines, std::min(Current.FormatTok.NewlinesBefore, + Style.MaxEmptyLinesToKeep + 1)); if (!Line.InPPDirective) Whitespaces.replaceWhitespace(Current, NewLines, State.Column, WhitespaceStartColumn, Style); |