summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-06-03 16:16:41 +0000
committerDaniel Jasper <djasper@google.com>2013-06-03 16:16:41 +0000
commit1027c6e5dd660dada16ee589cbd321c95b1602ac (patch)
treeec8ed4d8eb419f255e1eb477e24c7d068c68c9e8 /clang/lib/Format/Format.cpp
parent91a942b93e12b6391d57ecdae932f05bafd30685 (diff)
downloadbcm5719-llvm-1027c6e5dd660dada16ee589cbd321c95b1602ac.tar.gz
bcm5719-llvm-1027c6e5dd660dada16ee589cbd321c95b1602ac.zip
Let clang-format remove empty lines before "}".
These lines almost never aid readability. Before: void f() { int i; // some variable } After: void f() { int i; // some variable } llvm-svn: 183112
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index aa42bdb643a..63bf09317e3 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1592,6 +1592,11 @@ private:
bool InPPDirective) {
unsigned Newlines =
std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
+ // Remove empty lines before "}" where applicable.
+ if (RootToken.is(tok::r_brace) &&
+ (!RootToken.Next ||
+ (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+ Newlines = std::min(Newlines, 1u);
if (Newlines == 0 && !RootToken.IsFirst)
Newlines = 1;
OpenPOWER on IntegriCloud