summaryrefslogtreecommitdiff
path: root/include/clang/Format
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-06-14 08:01:09 +0000
committerHans Wennborg <hans@hanshq.net>2018-06-14 08:01:09 +0000
commit590084b80ff2cceeeef9ad8ccb9826f2033f275b (patch)
tree84bd7533658d1810d70393478090c2d1e46326a2 /include/clang/Format
parent747fefe4691d4b30b5f9859027f80f69cb9ed01d (diff)
downloadclang-590084b80ff2cceeeef9ad8ccb9826f2033f275b.tar.gz
[clang-format] Add SpaceBeforeCpp11BracedList option.
WebKit C++ style for object initialization is as follows: Foo foo { bar }; Yet using clang-format -style=webkit changes this to: Foo foo{ bar }; As there is no existing combination of rules that will ensure a space before a braced list in this fashion, this patch adds a new SpaceBeforeCpp11BracedList rule. Patch by Ross Kirsling! Differential Revision: https://reviews.llvm.org/D46024 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Format')
-rw-r--r--include/clang/Format/Format.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h
index 66b7762893..efc7cf643b 100644
--- a/include/clang/Format/Format.h
+++ b/include/clang/Format/Format.h
@@ -1495,6 +1495,17 @@ struct FormatStyle {
/// \endcode
bool SpaceBeforeAssignmentOperators;
+ /// If ``true``, a space will be inserted before a C++11 braced list
+ /// used to initialize an object (after the preceding identifier or type).
+ /// \code
+ /// true: false:
+ /// Foo foo { bar }; vs. Foo foo{ bar };
+ /// Foo {}; Foo{};
+ /// vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 };
+ /// new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 };
+ /// \endcode
+ bool SpaceBeforeCpp11BracedList;
+
/// If ``false``, spaces will be removed before constructor initializer
/// colon.
/// \code
@@ -1738,6 +1749,7 @@ struct FormatStyle {
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
+ SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&