summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFrancois Ferrand <thetypz@gmail.com>2017-06-30 20:25:55 +0000
committerFrancois Ferrand <thetypz@gmail.com>2017-06-30 20:25:55 +0000
commit0ce8b803dc6e34c9938aeb37cd2c6460e529f0e0 (patch)
tree3bcea0d2a498819324ecbc5c0d8789085b83867b /include
parent1e786d52fd3187a3f27de9b1206d3a408e2c1864 (diff)
clang-format: add options to merge empty record body
Summary: This patch introduces a few extra BraceWrapping options, similar to `SplitEmptyFunction`, to allow merging empty 'record' bodies (e.g. class, struct, union and namespace): * SplitEmptyClass * SplitEmptyStruct * SplitEmptyUnion * SplitEmptyNamespace The `SplitEmptyFunction` option name has also been simplified/ shortened (from `SplitEmptyFunctionBody`). These options are helpful when the correspond AfterXXX option is enabled, to allow merging the empty record: class Foo {}; In addition, this fixes an unexpected merging of short records, when the AfterXXXX options are used, which caused to be formatted like this: class Foo { void Foo(); }; This is now properly formatted as: class Foo { void Foo(); }; Reviewers: djasper, krasimir Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D34395 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Format/Format.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h
index 5b587a4db0..ee24c55fef 100644
--- a/include/clang/Format/Format.h
+++ b/include/clang/Format/Format.h
@@ -717,7 +717,29 @@ struct FormatStyle {
/// }
/// \endcode
///
- bool SplitEmptyFunctionBody;
+ bool SplitEmptyFunction;
+ /// \brief If ``false``, empty record (e.g. class, struct or union) body
+ /// can be put on a single line. This option is used only if the opening
+ /// brace of the record has already been wrapped, i.e. the `AfterClass`
+ /// (for classes) brace wrapping mode is set.
+ /// \code
+ /// class Foo vs. class Foo
+ /// {} {
+ /// }
+ /// \endcode
+ ///
+ bool SplitEmptyRecord;
+ /// \brief If ``false``, empty namespace body can be put on a single line.
+ /// This option is used only if the opening brace of the namespace has
+ /// already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is
+ /// set.
+ /// \code
+ /// namespace Foo vs. namespace Foo
+ /// {} {
+ /// }
+ /// \endcode
+ ///
+ bool SplitEmptyNamespace;
};
/// \brief Control of individual brace wrapping cases.