Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 149 additions & 43 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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>`
Expand Down Expand Up @@ -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>`
Expand Down
8 changes: 8 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,14 @@ clang-format
literals.
- Add ``Leave`` suboption to ``IndentPPDirectives``.
- Add ``AllowBreakBeforeQtProperty`` option.
- Add ``BreakAfterOpenBracketBracedList'', ``BreakAfterOpenBracketFunction'',
``BreakAfterOpenBracketIf``, ``BreakAfterOpenBracketLoop``,
``BreakAfterOpenBracketSwitch``, ``BreakBeforeCloseBracketBracedList'',
``BreakBeforeCloseBracketFunction``, ``BreakBeforeCloseBracketIf``,
``BreakBeforeCloseBracketLoop``, ``BreakBeforeCloseBracketSwitch`` options.
- Deprecate ``AlwaysBreak`` and ``BlockIndent`` suboptions from the
``AlignAfterOpenBracket`` option, and make ``AlignAfterOpenBracket`` a
``bool`` type.

libclang
--------
Expand Down
Loading