diff options
author | Francois Ferrand <thetypz@gmail.com> | 2018-03-01 10:09:13 +0000 |
---|---|---|
committer | Francois Ferrand <thetypz@gmail.com> | 2018-03-01 10:09:13 +0000 |
commit | 2818cfe4cbfcbceed9ed0aca79c91a958636691e (patch) | |
tree | c00e8cb9067b3d10d6725b842c5756940fdfeb98 /include/clang/Format | |
parent | e845f691846783e8e30d3131c8f8a08311c406e8 (diff) | |
download | clang-2818cfe4cbfcbceed9ed0aca79c91a958636691e.tar.gz |
[clang-format] Add SpaceBeforeColon option
Summary:
When disabled, this option allows removing the space before colon,
making it act more like the semi-colon. When enabled (default), the
current behavior is not affected.
This mostly affects C++11 loop, initializer list, inheritance list and
container literals:
class Foo: Bar {}
Foo::Foo(): a(a) {}
for (auto i: myList) {}
f({a: 1, b: 2, c: 3});
Reviewers: krasimir, djasper
Reviewed By: djasper
Subscribers: xvallspl, teemperor, karies, cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D32525
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Format')
-rw-r--r-- | include/clang/Format/Format.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h index 3060d9b944..6a508b0f71 100644 --- a/include/clang/Format/Format.h +++ b/include/clang/Format/Format.h @@ -1525,6 +1525,21 @@ struct FormatStyle { /// \endcode bool SpaceBeforeAssignmentOperators; + /// \brief If ``false``, spaces will be removed before constructor initializer + /// colon. + /// \code + /// true: false: + /// Foo::Foo() : a(a) {} Foo::Foo(): a(a) {} + /// \endcode + bool SpaceBeforeCtorInitializerColon; + + /// \brief If ``false``, spaces will be removed before inheritance colon. + /// \code + /// true: false: + /// class Foo : Bar {} vs. class Foo: Bar {} + /// \endcode + bool SpaceBeforeInheritanceColon; + /// \brief Different ways to put a space before opening parentheses. enum SpaceBeforeParensOptions { /// Never put a space before opening parentheses. @@ -1563,6 +1578,14 @@ struct FormatStyle { /// \brief Defines in which cases to put a space before opening parentheses. SpaceBeforeParensOptions SpaceBeforeParens; + /// \brief If ``false``, spaces will be removed before range-based for loop + /// colon. + /// \code + /// true: false: + /// for (auto v : values) {} vs. for(auto v: values) {} + /// \endcode + bool SpaceBeforeRangeBasedForLoopColon; + /// \brief If ``true``, spaces may be inserted into ``()``. /// \code /// true: false: @@ -1744,7 +1767,12 @@ struct FormatStyle { SpaceAfterCStyleCast == R.SpaceAfterCStyleCast && SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword && SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators && + SpaceBeforeCtorInitializerColon == + R.SpaceBeforeCtorInitializerColon && + SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon && SpaceBeforeParens == R.SpaceBeforeParens && + SpaceBeforeRangeBasedForLoopColon == + R.SpaceBeforeRangeBasedForLoopColon && SpaceInEmptyParentheses == R.SpaceInEmptyParentheses && SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments && SpacesInAngles == R.SpacesInAngles && |