]> granicus.if.org Git - clang/commit
Make formatting of empty blocks more consistent.
authorDaniel Jasper <djasper@google.com>
Fri, 31 May 2013 14:56:20 +0000 (14:56 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 31 May 2013 14:56:20 +0000 (14:56 +0000)
commit8893b8a28d32359a5c778d9308780200a09402ba
treeb10ca300b151094b0e237ed7e56106c566c5a507
parentc01897c3f6139304ed25e3f673bef77be209617f
Make formatting of empty blocks more consistent.

With this patch, the simplified rule is:
If the block is part of a declaration (class, namespace, function,
enum, ..), merge an empty block onto a single line. Otherwise
(specifically for the compound statements of if, for, while, ...),
keep the braces on two separate lines.

The reasons are:
- Mostly the formatting of empty blocks does not matter much.
- Empty compound statements are really rare and are usually just
  inserted while still working on the code. If they are on two lines,
  inserting code is easier. Also, overlooking the "{}" of an
  "if (...) {}" can be really bad.
- Empty declarations are not uncommon, e.g. empty constructors. Putting
  them on one line saves vertical space at no loss of readability.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183008 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/Format.cpp
unittests/Format/FormatTest.cpp