summaryrefslogtreecommitdiff
path: root/docs/ClangFormatStyleOptions.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/ClangFormatStyleOptions.rst')
-rw-r--r--docs/ClangFormatStyleOptions.rst300
1 files changed, 196 insertions, 104 deletions
diff --git a/docs/ClangFormatStyleOptions.rst b/docs/ClangFormatStyleOptions.rst
index fb014241809cc..6133ca9900c97 100644
--- a/docs/ClangFormatStyleOptions.rst
+++ b/docs/ClangFormatStyleOptions.rst
@@ -309,12 +309,28 @@ the configuration (without a prefix: ``Auto``).
* ``SFS_None`` (in configuration: ``None``)
Never merge functions into a single line.
+ * ``SFS_InlineOnly`` (in configuration: ``InlineOnly``)
+ Only merge functions defined inside a class. Same as "inline",
+ except it does not implies "empty": i.e. top level empty functions
+ are not merged either.
+
+ .. code-block:: c++
+
+ class Foo {
+ void f() { foo(); }
+ };
+ void f() {
+ foo();
+ }
+ void f() {
+ }
+
* ``SFS_Empty`` (in configuration: ``Empty``)
Only merge empty functions.
.. code-block:: c++
- void f() { bar(); }
+ void f() {}
void f2() {
bar2();
}
@@ -327,6 +343,10 @@ the configuration (without a prefix: ``Auto``).
class Foo {
void f() { foo(); }
};
+ void f() {
+ foo();
+ }
+ void f() {}
* ``SFS_All`` (in configuration: ``All``)
Merge all functions fitting on a single line.
@@ -518,147 +538,159 @@ the configuration (without a prefix: ``Auto``).
* ``bool AfterClass`` Wrap class definitions.
- .. code-block:: c++
+ .. code-block:: c++
- true:
- class foo
- {};
+ true:
+ class foo {};
- false:
- class foo {};
+ false:
+ class foo
+ {};
* ``bool AfterControlStatement`` Wrap control statements (``if``/``for``/``while``/``switch``/..).
- .. code-block:: c++
+ .. code-block:: c++
- true:
- if (foo())
- {
- } else
- {}
- for (int i = 0; i < 10; ++i)
- {}
+ true:
+ if (foo())
+ {
+ } else
+ {}
+ for (int i = 0; i < 10; ++i)
+ {}
- false:
- if (foo()) {
- } else {
- }
- for (int i = 0; i < 10; ++i) {
- }
+ false:
+ if (foo()) {
+ } else {
+ }
+ for (int i = 0; i < 10; ++i) {
+ }
* ``bool AfterEnum`` Wrap enum definitions.
- .. code-block:: c++
+ .. code-block:: c++
- true:
- enum X : int
- {
- B
- };
+ true:
+ enum X : int
+ {
+ B
+ };
- false:
- enum X : int { B };
+ false:
+ enum X : int { B };
* ``bool AfterFunction`` Wrap function definitions.
- .. code-block:: c++
+ .. code-block:: c++
- true:
- void foo()
- {
- bar();
- bar2();
- }
+ true:
+ void foo()
+ {
+ bar();
+ bar2();
+ }
- false:
- void foo() {
- bar();
- bar2();
- }
+ false:
+ void foo() {
+ bar();
+ bar2();
+ }
* ``bool AfterNamespace`` Wrap namespace definitions.
- .. code-block:: c++
+ .. code-block:: c++
- true:
- namespace
- {
- int foo();
- int bar();
- }
+ true:
+ namespace
+ {
+ int foo();
+ int bar();
+ }
- false:
- namespace {
- int foo();
- int bar();
- }
+ false:
+ namespace {
+ int foo();
+ int bar();
+ }
* ``bool AfterObjCDeclaration`` Wrap ObjC definitions (``@autoreleasepool``, interfaces, ..).
* ``bool AfterStruct`` Wrap struct definitions.
- .. code-block:: c++
+ .. code-block:: c++
- true:
- struct foo
- {
- int x;
- };
+ true:
+ struct foo
+ {
+ int x;
+ };
- false:
- struct foo {
- int x;
- };
+ false:
+ struct foo {
+ int x;
+ };
* ``bool AfterUnion`` Wrap union definitions.
- .. code-block:: c++
+ .. code-block:: c++
- true:
- union foo
- {
- int x;
- }
+ true:
+ union foo
+ {
+ int x;
+ }
- false:
- union foo {
- int x;
- }
+ false:
+ union foo {
+ int x;
+ }
* ``bool BeforeCatch`` Wrap before ``catch``.
- .. code-block:: c++
+ .. code-block:: c++
- true:
- try {
- foo();
- }
- catch () {
- }
+ true:
+ try {
+ foo();
+ }
+ catch () {
+ }
- false:
- try {
- foo();
- } catch () {
- }
+ false:
+ try {
+ foo();
+ } catch () {
+ }
* ``bool BeforeElse`` Wrap before ``else``.
- .. code-block:: c++
+ .. code-block:: c++
- true:
- if (foo()) {
- }
- else {
- }
+ true:
+ if (foo()) {
+ }
+ else {
+ }
- false:
- if (foo()) {
- } else {
- }
+ false:
+ if (foo()) {
+ } else {
+ }
* ``bool IndentBraces`` Indent the wrapped braces themselves.
+ * ``bool SplitEmptyFunctionBody`` If ``false``, empty function body can be put on a single line.
+ This option is used only if the opening brace of the function has
+ already been wrapped, i.e. the `AfterFunction` brace wrapping mode is
+ set, and the function could/should not be put on a single line (as per
+ `AllowShortFunctionsOnASingleLine` and constructor formatting options).
+
+ .. code-block:: c++
+
+ int f() vs. inf f()
+ {} {
+ }
+
**BreakAfterJavaFieldAnnotations** (``bool``)
Break after each annotation on a field in Java files.
@@ -899,17 +931,40 @@ the configuration (without a prefix: ``Auto``).
firstValue :
SecondValueVeryVeryVeryVeryLong;
-**BreakConstructorInitializersBeforeComma** (``bool``)
- Always break constructor initializers before commas and align
- the commas with the colon.
+**BreakConstructorInitializers** (``BreakConstructorInitializersStyle``)
+ The constructor initializers style to use.
+
+ Possible values:
+
+ * ``BCIS_BeforeColon`` (in configuration: ``BeforeColon``)
+ Break constructor initializers before the colon and after the commas.
+
+ .. code-block:: c++
+
+ Constructor()
+ : initializer1(),
+ initializer2()
+
+ * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
+ Break constructor initializers before the colon and commas, and align
+ the commas with the colon.
+
+ .. code-block:: c++
+
+ Constructor()
+ : initializer1()
+ , initializer2()
+
+ * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
+ Break constructor initializers after the colon and commas.
+
+ .. code-block:: c++
+
+ Constructor() :
+ initializer1(),
+ initializer2()
- .. code-block:: c++
- true: false:
- SomeClass::Constructor() vs. SomeClass::Constructor() : a(a),
- : a(a) b(b),
- , b(b) c(c) {}
- , c(c) {}
**BreakStringLiterals** (``bool``)
Allow breaking string literals when formatting.
@@ -931,6 +986,31 @@ the configuration (without a prefix: ``Auto``).
// Will leave the following line unaffected
#include <vector> // FOOBAR pragma: keep
+**CompactNamespaces** (``bool``)
+ If ``true``, consecutive namespace declarations will be on the same
+ line. If ``false``, each namespace is declared on a new line.
+
+ .. code-block:: c++
+
+ true:
+ namespace Foo { namespace Bar {
+ }}
+
+ false:
+ namespace Foo {
+ namespace Bar {
+ }
+ }
+
+ If it does not fit on a single line, the overflowing namespaces get
+ wrapped:
+
+ .. code-block:: c++
+
+ namespace Foo { namespace Bar {
+ namespace Extra {
+ }}}
+
**ConstructorInitializerAllOnOneLineOrOnePerLine** (``bool``)
If the constructor initializers don't fit on a line, put each
initializer on its own line.
@@ -1321,6 +1401,9 @@ the configuration (without a prefix: ``Auto``).
Add a space in front of an Objective-C protocol list, i.e. use
``Foo <Protocol>`` instead of ``Foo<Protocol>``.
+**PenaltyBreakAssignment** (``unsigned``)
+ The penalty for breaking around an assignment operator.
+
**PenaltyBreakBeforeFirstCallParameter** (``unsigned``)
The penalty for breaking a function call after ``call(``.
@@ -1392,6 +1475,15 @@ the configuration (without a prefix: ``Auto``).
#include "b.h" vs. #include "a.h"
#include "a.h" #include "b.h"
+**SortUsingDeclarations** (``bool``)
+ If ``true``, clang-format will sort using declarations.
+
+ .. code-block:: c++
+
+ false: true:
+ using std::cout; vs. using std::cin;
+ using std::cin; using std::cout;
+
**SpaceAfterCStyleCast** (``bool``)
If ``true``, a space is inserted after C style casts.