-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-format] Add BreakAfterOpenBracket* and BreakBeforeCloseBracket* #108332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
b49aef4
47a3749
26b3dec
e4a19cd
7d3d56d
327bec8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,57 +197,29 @@ the configuration (without a prefix: ``Auto``). | |
|
|
||
| .. _AlignAfterOpenBracket: | ||
|
|
||
| **AlignAfterOpenBracket** (``BracketAlignmentStyle``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>` | ||
| **AlignAfterOpenBracket** (``Boolean``) :versionbadge:`clang-format 3.8` :ref:`¶ <AlignAfterOpenBracket>` | ||
| If ``true``, horizontally aligns arguments after an open bracket. | ||
|
|
||
| This applies to round brackets (parentheses), angle brackets and square | ||
| brackets. | ||
|
|
||
| Possible values: | ||
|
|
||
| * ``BAS_Align`` (in configuration: ``Align``) | ||
| Align parameters on the open bracket, e.g.: | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| someLongFunction(argument1, | ||
| argument2); | ||
|
|
||
| * ``BAS_DontAlign`` (in configuration: ``DontAlign``) | ||
| Don't align, instead use ``ContinuationIndentWidth``, e.g.: | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| someLongFunction(argument1, | ||
| argument2); | ||
|
|
||
| * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``) | ||
| Always break after an open bracket, if the parameters don't fit | ||
| on a single line, e.g.: | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| someLongFunction( | ||
| argument1, argument2); | ||
|
|
||
| * ``BAS_BlockIndent`` (in configuration: ``BlockIndent``) | ||
| Always break after an open bracket, if the parameters don't fit | ||
| on a single line. Closing brackets will be placed on a new line. | ||
| E.g.: | ||
|
|
||
| .. code-block:: c++ | ||
| .. code-block:: c++ | ||
|
|
||
| someLongFunction( | ||
| argument1, argument2 | ||
| ) | ||
| true: vs. false | ||
| someLongFunction(argument1, someLongFunction(argument1, | ||
| argument2); argument2); | ||
|
|
||
|
|
||
| .. note:: | ||
|
|
||
| This currently only applies to braced initializer lists (when | ||
| ``Cpp11BracedListStyle`` is not ``Block``) and parentheses. | ||
| .. note:: | ||
|
|
||
| As of clang-format 22 this option is a bool with the previous | ||
| option of ``Align`` replaced with ``true``, ``DontAlign`` replaced | ||
| with ``false``, and the options of ``AlwaysBreak`` and ``BlockIndent`` | ||
| replaced with ``true`` and with setting of new style options using | ||
| ``BreakAfterOpenBracketBracedList``, ``BreakAfterOpenBracketFunction``, | ||
| ``BreakAfterOpenBracketIf``, ``BreakBeforeCloseBracketBracedList``, | ||
| ``BreakBeforeCloseBracketFunction``, and ``BreakBeforeCloseBracketIf``. | ||
|
|
||
| This applies to round brackets (parentheses), angle brackets and square | ||
| brackets. | ||
|
|
||
| .. _AlignArrayOfStructures: | ||
|
|
||
|
|
@@ -2746,6 +2718,67 @@ the configuration (without a prefix: ``Auto``). | |
| @Mock | ||
| DataLoad loader; | ||
|
|
||
| .. _BreakAfterOpenBracketBracedList: | ||
|
|
||
| **BreakAfterOpenBracketBracedList** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketBracedList>` | ||
| Force break after the left bracket of a braced initializer list (when | ||
| ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column | ||
| limit. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| vector<int> x { vs. vector<int> x {1, | ||
| 1, 2, 3} 2, 3} | ||
|
|
||
| .. _BreakAfterOpenBracketFunction: | ||
|
|
||
| **BreakAfterOpenBracketFunction** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketFunction>` | ||
| Force break after the left parenthesis of a function (declaration, | ||
| definition, call) when the parameters exceed the column limit. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| foo ( vs. foo (a, | ||
| a , b) b) | ||
|
|
||
| .. _BreakAfterOpenBracketIf: | ||
|
|
||
| **BreakAfterOpenBracketIf** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketIf>` | ||
| Force break after the left parenthesis of an if control statement | ||
| when the expression exceeds the column limit. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| if constexpr ( vs. if constexpr (a || | ||
| a || b) b) | ||
|
|
||
| .. _BreakAfterOpenBracketLoop: | ||
|
|
||
| **BreakAfterOpenBracketLoop** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketLoop>` | ||
| Force break after the left parenthesis of a loop control statement | ||
| when the expression exceeds the column limit. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| while ( vs. while (a && | ||
|
||
| a && b) { b) { | ||
|
|
||
| .. _BreakAfterOpenBracketSwitch: | ||
|
|
||
| **BreakAfterOpenBracketSwitch** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakAfterOpenBracketSwitch>` | ||
| Force break after the left parenthesis of a switch control statement | ||
| when the expression exceeds the column limit. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| switch ( vs. switch (a + | ||
| a + b) { b) { | ||
|
|
||
| .. _BreakAfterReturnType: | ||
|
|
||
| **BreakAfterReturnType** (``ReturnTypeBreakingStyle``) :versionbadge:`clang-format 19` :ref:`¶ <BreakAfterReturnType>` | ||
|
|
@@ -3383,6 +3416,79 @@ the configuration (without a prefix: ``Auto``). | |
|
|
||
|
|
||
|
|
||
| .. _BreakBeforeCloseBracketBracedList: | ||
|
|
||
| **BreakBeforeCloseBracketBracedList** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketBracedList>` | ||
| Force break before the right bracket of a braced initializer list (when | ||
| ``Cpp11BracedListStyle`` is ``true``) when the list exceeds the column | ||
| limit. The break before the right bracket is only made if there is a | ||
| break after the opening bracket. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| vector<int> x { vs. vector<int> x { | ||
| 1, 2, 3 1, 2, 3} | ||
| } | ||
|
|
||
| .. _BreakBeforeCloseBracketFunction: | ||
|
|
||
| **BreakBeforeCloseBracketFunction** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketFunction>` | ||
| Force break before the right parenthesis of a function (declaration, | ||
| definition, call) when the parameters exceed the column limit. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| foo ( vs. foo ( | ||
| a , b a , b) | ||
| ) | ||
|
|
||
| .. _BreakBeforeCloseBracketIf: | ||
|
|
||
| **BreakBeforeCloseBracketIf** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketIf>` | ||
| Force break before the right parenthesis of an if control statement | ||
| when the expression exceeds the column limit. The break before the | ||
| closing parenthesis is only made if there is a break after the opening | ||
| parenthesis. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| if constexpr ( vs. if constexpr ( | ||
| a || b a || b ) | ||
| ) | ||
|
|
||
| .. _BreakBeforeCloseBracketLoop: | ||
|
|
||
| **BreakBeforeCloseBracketLoop** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketLoop>` | ||
| Force break before the right parenthesis of a loop control statement | ||
| when the expression exceeds the column limit. The break before the | ||
| closing parenthesis is only made if there is a break after the opening | ||
| parenthesis. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| while ( vs. while ( | ||
| a && b a && b) { | ||
| ) { | ||
|
|
||
| .. _BreakBeforeCloseBracketSwitch: | ||
|
|
||
| **BreakBeforeCloseBracketSwitch** (``Boolean``) :versionbadge:`clang-format 22` :ref:`¶ <BreakBeforeCloseBracketSwitch>` | ||
| Force break before the right parenthesis of a switch control statement | ||
| when the expression exceeds the column limit. The break before the | ||
| closing parenthesis is only made if there is a break after the opening | ||
| parenthesis. | ||
|
|
||
| .. code-block:: c++ | ||
|
|
||
| true: false: | ||
| switch ( vs. switch ( | ||
| a + b a + b) { | ||
| ) { | ||
|
|
||
| .. _BreakBeforeConceptDeclarations: | ||
|
|
||
| **BreakBeforeConceptDeclarations** (``BreakBeforeConceptDeclarationsStyle``) :versionbadge:`clang-format 12` :ref:`¶ <BreakBeforeConceptDeclarations>` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the true case correct here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
BreakBeforeCloseBracketXXXXwill only work if there is a break after the opening bracket. This is a holdover from howAlwaysBreakandBlockIndentalignment options work.