1 1.1 joerg ========================== 2 1.1 joerg Clang-Format Style Options 3 1.1 joerg ========================== 4 1.1 joerg 5 1.1 joerg :doc:`ClangFormatStyleOptions` describes configurable formatting style options 6 1.1 joerg supported by :doc:`LibFormat` and :doc:`ClangFormat`. 7 1.1 joerg 8 1.1 joerg When using :program:`clang-format` command line utility or 9 1.1 joerg ``clang::format::reformat(...)`` functions from code, one can either use one of 10 1.1 joerg the predefined styles (LLVM, Google, Chromium, Mozilla, WebKit, Microsoft) or 11 1.1 joerg create a custom style by configuring specific style options. 12 1.1 joerg 13 1.1 joerg 14 1.1 joerg Configuring Style with clang-format 15 1.1 joerg =================================== 16 1.1 joerg 17 1.1 joerg :program:`clang-format` supports two ways to provide custom style options: 18 1.1 joerg directly specify style configuration in the ``-style=`` command line option or 19 1.1 joerg use ``-style=file`` and put style configuration in the ``.clang-format`` or 20 1.1 joerg ``_clang-format`` file in the project directory. 21 1.1 joerg 22 1.1 joerg When using ``-style=file``, :program:`clang-format` for each input file will 23 1.1 joerg try to find the ``.clang-format`` file located in the closest parent directory 24 1.1 joerg of the input file. When the standard input is used, the search is started from 25 1.1 joerg the current directory. 26 1.1 joerg 27 1.1 joerg The ``.clang-format`` file uses YAML format: 28 1.1 joerg 29 1.1 joerg .. code-block:: yaml 30 1.1 joerg 31 1.1 joerg key1: value1 32 1.1 joerg key2: value2 33 1.1 joerg # A comment. 34 1.1 joerg ... 35 1.1 joerg 36 1.1 joerg The configuration file can consist of several sections each having different 37 1.1 joerg ``Language:`` parameter denoting the programming language this section of the 38 1.1 joerg configuration is targeted at. See the description of the **Language** option 39 1.1 joerg below for the list of supported languages. The first section may have no 40 1.1.1.2 joerg language set, it will set the default style options for all languages. 41 1.1 joerg Configuration sections for specific language will override options set in the 42 1.1 joerg default section. 43 1.1 joerg 44 1.1 joerg When :program:`clang-format` formats a file, it auto-detects the language using 45 1.1 joerg the file name. When formatting standard input or a file that doesn't have the 46 1.1 joerg extension corresponding to its language, ``-assume-filename=`` option can be 47 1.1 joerg used to override the file name :program:`clang-format` uses to detect the 48 1.1 joerg language. 49 1.1 joerg 50 1.1 joerg An example of a configuration file for multiple languages: 51 1.1 joerg 52 1.1 joerg .. code-block:: yaml 53 1.1 joerg 54 1.1 joerg --- 55 1.1 joerg # We'll use defaults from the LLVM style, but with 4 columns indentation. 56 1.1 joerg BasedOnStyle: LLVM 57 1.1 joerg IndentWidth: 4 58 1.1 joerg --- 59 1.1 joerg Language: Cpp 60 1.1 joerg # Force pointers to the type for C++. 61 1.1 joerg DerivePointerAlignment: false 62 1.1 joerg PointerAlignment: Left 63 1.1 joerg --- 64 1.1 joerg Language: JavaScript 65 1.1 joerg # Use 100 columns for JS. 66 1.1 joerg ColumnLimit: 100 67 1.1 joerg --- 68 1.1 joerg Language: Proto 69 1.1 joerg # Don't format .proto files. 70 1.1 joerg DisableFormat: true 71 1.1 joerg --- 72 1.1 joerg Language: CSharp 73 1.1 joerg # Use 100 columns for C#. 74 1.1 joerg ColumnLimit: 100 75 1.1 joerg ... 76 1.1 joerg 77 1.1 joerg An easy way to get a valid ``.clang-format`` file containing all configuration 78 1.1 joerg options of a certain predefined style is: 79 1.1 joerg 80 1.1 joerg .. code-block:: console 81 1.1 joerg 82 1.1 joerg clang-format -style=llvm -dump-config > .clang-format 83 1.1 joerg 84 1.1 joerg When specifying configuration in the ``-style=`` option, the same configuration 85 1.1 joerg is applied for all input files. The format of the configuration is: 86 1.1 joerg 87 1.1 joerg .. code-block:: console 88 1.1 joerg 89 1.1 joerg -style='{key1: value1, key2: value2, ...}' 90 1.1 joerg 91 1.1 joerg 92 1.1 joerg Disabling Formatting on a Piece of Code 93 1.1 joerg ======================================= 94 1.1 joerg 95 1.1 joerg Clang-format understands also special comments that switch formatting in a 96 1.1 joerg delimited range. The code between a comment ``// clang-format off`` or 97 1.1 joerg ``/* clang-format off */`` up to a comment ``// clang-format on`` or 98 1.1 joerg ``/* clang-format on */`` will not be formatted. The comments themselves 99 1.1 joerg will be formatted (aligned) normally. 100 1.1 joerg 101 1.1 joerg .. code-block:: c++ 102 1.1 joerg 103 1.1 joerg int formatted_code; 104 1.1 joerg // clang-format off 105 1.1 joerg void unformatted_code ; 106 1.1 joerg // clang-format on 107 1.1 joerg void formatted_code_again; 108 1.1 joerg 109 1.1 joerg 110 1.1 joerg Configuring Style in Code 111 1.1 joerg ========================= 112 1.1 joerg 113 1.1 joerg When using ``clang::format::reformat(...)`` functions, the format is specified 114 1.1 joerg by supplying the `clang::format::FormatStyle 115 1.1 joerg <https://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html>`_ 116 1.1 joerg structure. 117 1.1 joerg 118 1.1 joerg 119 1.1 joerg Configurable Format Style Options 120 1.1 joerg ================================= 121 1.1 joerg 122 1.1 joerg This section lists the supported style options. Value type is specified for 123 1.1 joerg each option. For enumeration types possible values are specified both as a C++ 124 1.1 joerg enumeration member (with a prefix, e.g. ``LS_Auto``), and as a value usable in 125 1.1 joerg the configuration (without a prefix: ``Auto``). 126 1.1 joerg 127 1.1 joerg 128 1.1 joerg **BasedOnStyle** (``string``) 129 1.1 joerg The style used for all options not specifically set in the configuration. 130 1.1 joerg 131 1.1 joerg This option is supported only in the :program:`clang-format` configuration 132 1.1 joerg (both within ``-style='{...}'`` and the ``.clang-format`` file). 133 1.1 joerg 134 1.1 joerg Possible values: 135 1.1 joerg 136 1.1 joerg * ``LLVM`` 137 1.1 joerg A style complying with the `LLVM coding standards 138 1.1 joerg <https://llvm.org/docs/CodingStandards.html>`_ 139 1.1 joerg * ``Google`` 140 1.1 joerg A style complying with `Google's C++ style guide 141 1.1 joerg <https://google.github.io/styleguide/cppguide.html>`_ 142 1.1 joerg * ``Chromium`` 143 1.1 joerg A style complying with `Chromium's style guide 144 1.1 joerg <https://chromium.googlesource.com/chromium/src/+/master/styleguide/styleguide.md>`_ 145 1.1 joerg * ``Mozilla`` 146 1.1 joerg A style complying with `Mozilla's style guide 147 1.1 joerg <https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style>`_ 148 1.1 joerg * ``WebKit`` 149 1.1 joerg A style complying with `WebKit's style guide 150 1.1 joerg <https://www.webkit.org/coding/coding-style.html>`_ 151 1.1 joerg * ``Microsoft`` 152 1.1 joerg A style complying with `Microsoft's style guide 153 1.1 joerg <https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017>`_ 154 1.1.1.2 joerg * ``GNU`` 155 1.1.1.2 joerg A style complying with the `GNU coding standards 156 1.1.1.2 joerg <https://www.gnu.org/prep/standards/standards.html>`_ 157 1.1.1.2 joerg * ``InheritParentConfig`` 158 1.1.1.2 joerg Not a real style, but allows to use the ``.clang-format`` file from the 159 1.1.1.2 joerg parent directory (or its parent if there is none). If there is no parent 160 1.1.1.2 joerg file found it falls back to the ``fallback`` style, and applies the changes 161 1.1.1.2 joerg to that. 162 1.1.1.2 joerg 163 1.1.1.2 joerg With this option you can overwrite some parts of your main style for your 164 1.1.1.2 joerg subdirectories. This is also possible through the command line, e.g.: 165 1.1.1.2 joerg ``--style={BasedOnStyle: InheritParentConfig, ColumnLimit: 20}`` 166 1.1 joerg 167 1.1 joerg .. START_FORMAT_STYLE_OPTIONS 168 1.1 joerg 169 1.1 joerg **AccessModifierOffset** (``int``) 170 1.1 joerg The extra indent or outdent of access modifiers, e.g. ``public:``. 171 1.1 joerg 172 1.1 joerg **AlignAfterOpenBracket** (``BracketAlignmentStyle``) 173 1.1 joerg If ``true``, horizontally aligns arguments after an open bracket. 174 1.1 joerg 175 1.1 joerg This applies to round brackets (parentheses), angle brackets and square 176 1.1 joerg brackets. 177 1.1 joerg 178 1.1 joerg Possible values: 179 1.1 joerg 180 1.1 joerg * ``BAS_Align`` (in configuration: ``Align``) 181 1.1 joerg Align parameters on the open bracket, e.g.: 182 1.1 joerg 183 1.1 joerg .. code-block:: c++ 184 1.1 joerg 185 1.1 joerg someLongFunction(argument1, 186 1.1 joerg argument2); 187 1.1 joerg 188 1.1 joerg * ``BAS_DontAlign`` (in configuration: ``DontAlign``) 189 1.1 joerg Don't align, instead use ``ContinuationIndentWidth``, e.g.: 190 1.1 joerg 191 1.1 joerg .. code-block:: c++ 192 1.1 joerg 193 1.1 joerg someLongFunction(argument1, 194 1.1 joerg argument2); 195 1.1 joerg 196 1.1 joerg * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``) 197 1.1 joerg Always break after an open bracket, if the parameters don't fit 198 1.1 joerg on a single line, e.g.: 199 1.1 joerg 200 1.1 joerg .. code-block:: c++ 201 1.1 joerg 202 1.1 joerg someLongFunction( 203 1.1 joerg argument1, argument2); 204 1.1 joerg 205 1.1 joerg 206 1.1 joerg 207 1.1.1.2 joerg **AlignConsecutiveAssignments** (``AlignConsecutiveStyle``) 208 1.1.1.2 joerg Style of aligning consecutive assignments. 209 1.1 joerg 210 1.1.1.2 joerg ``Consecutive`` will result in formattings like: 211 1.1 joerg 212 1.1 joerg .. code-block:: c++ 213 1.1 joerg 214 1.1.1.2 joerg int a = 1; 215 1.1.1.2 joerg int somelongname = 2; 216 1.1.1.2 joerg double c = 3; 217 1.1 joerg 218 1.1.1.2 joerg Possible values: 219 1.1.1.2 joerg 220 1.1.1.2 joerg * ``ACS_None`` (in configuration: ``None``) 221 1.1.1.2 joerg Do not align assignments on consecutive lines. 222 1.1.1.2 joerg 223 1.1.1.2 joerg * ``ACS_Consecutive`` (in configuration: ``Consecutive``) 224 1.1.1.2 joerg Align assignments on consecutive lines. This will result in 225 1.1.1.2 joerg formattings like: 226 1.1.1.2 joerg 227 1.1.1.2 joerg .. code-block:: c++ 228 1.1.1.2 joerg 229 1.1.1.2 joerg int a = 1; 230 1.1.1.2 joerg int somelongname = 2; 231 1.1.1.2 joerg double c = 3; 232 1.1.1.2 joerg 233 1.1.1.2 joerg int d = 3; 234 1.1.1.2 joerg /* A comment. */ 235 1.1.1.2 joerg double e = 4; 236 1.1.1.2 joerg 237 1.1.1.2 joerg * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``) 238 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over empty lines, e.g. 239 1.1.1.2 joerg 240 1.1.1.2 joerg .. code-block:: c++ 241 1.1.1.2 joerg 242 1.1.1.2 joerg int a = 1; 243 1.1.1.2 joerg int somelongname = 2; 244 1.1.1.2 joerg double c = 3; 245 1.1.1.2 joerg 246 1.1.1.2 joerg int d = 3; 247 1.1.1.2 joerg /* A comment. */ 248 1.1.1.2 joerg double e = 4; 249 1.1.1.2 joerg 250 1.1.1.2 joerg * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``) 251 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over lines only containing 252 1.1.1.2 joerg comments, e.g. 253 1.1.1.2 joerg 254 1.1.1.2 joerg .. code-block:: c++ 255 1.1.1.2 joerg 256 1.1.1.2 joerg int a = 1; 257 1.1.1.2 joerg int somelongname = 2; 258 1.1.1.2 joerg double c = 3; 259 1.1.1.2 joerg 260 1.1.1.2 joerg int d = 3; 261 1.1.1.2 joerg /* A comment. */ 262 1.1.1.2 joerg double e = 4; 263 1.1.1.2 joerg 264 1.1.1.2 joerg * ``ACS_AcrossEmptyLinesAndComments`` 265 1.1.1.2 joerg (in configuration: ``AcrossEmptyLinesAndComments``) 266 1.1.1.2 joerg 267 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over lines only containing 268 1.1.1.2 joerg comments and empty lines, e.g. 269 1.1.1.2 joerg 270 1.1.1.2 joerg .. code-block:: c++ 271 1.1.1.2 joerg 272 1.1.1.2 joerg int a = 1; 273 1.1.1.2 joerg int somelongname = 2; 274 1.1.1.2 joerg double c = 3; 275 1.1 joerg 276 1.1.1.2 joerg int d = 3; 277 1.1.1.2 joerg /* A comment. */ 278 1.1.1.2 joerg double e = 4; 279 1.1.1.2 joerg 280 1.1.1.2 joerg **AlignConsecutiveBitFields** (``AlignConsecutiveStyle``) 281 1.1.1.2 joerg Style of aligning consecutive bit field. 282 1.1.1.2 joerg 283 1.1.1.2 joerg ``Consecutive`` will align the bitfield separators of consecutive lines. 284 1.1.1.2 joerg This will result in formattings like: 285 1.1.1.2 joerg 286 1.1.1.2 joerg .. code-block:: c++ 287 1.1.1.2 joerg 288 1.1.1.2 joerg int aaaa : 1; 289 1.1.1.2 joerg int b : 12; 290 1.1.1.2 joerg int ccc : 8; 291 1.1.1.2 joerg 292 1.1.1.2 joerg Possible values: 293 1.1.1.2 joerg 294 1.1.1.2 joerg * ``ACS_None`` (in configuration: ``None``) 295 1.1.1.2 joerg Do not align bit fields on consecutive lines. 296 1.1.1.2 joerg 297 1.1.1.2 joerg * ``ACS_Consecutive`` (in configuration: ``Consecutive``) 298 1.1.1.2 joerg Align bit fields on consecutive lines. This will result in 299 1.1.1.2 joerg formattings like: 300 1.1.1.2 joerg 301 1.1.1.2 joerg .. code-block:: c++ 302 1.1.1.2 joerg 303 1.1.1.2 joerg int aaaa : 1; 304 1.1.1.2 joerg int b : 12; 305 1.1.1.2 joerg int ccc : 8; 306 1.1.1.2 joerg 307 1.1.1.2 joerg int d : 2; 308 1.1.1.2 joerg /* A comment. */ 309 1.1.1.2 joerg int ee : 3; 310 1.1.1.2 joerg 311 1.1.1.2 joerg * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``) 312 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over empty lines, e.g. 313 1.1.1.2 joerg 314 1.1.1.2 joerg .. code-block:: c++ 315 1.1.1.2 joerg 316 1.1.1.2 joerg int aaaa : 1; 317 1.1.1.2 joerg int b : 12; 318 1.1.1.2 joerg int ccc : 8; 319 1.1.1.2 joerg 320 1.1.1.2 joerg int d : 2; 321 1.1.1.2 joerg /* A comment. */ 322 1.1.1.2 joerg int ee : 3; 323 1.1.1.2 joerg 324 1.1.1.2 joerg * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``) 325 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over lines only containing 326 1.1.1.2 joerg comments, e.g. 327 1.1.1.2 joerg 328 1.1.1.2 joerg .. code-block:: c++ 329 1.1.1.2 joerg 330 1.1.1.2 joerg int aaaa : 1; 331 1.1.1.2 joerg int b : 12; 332 1.1.1.2 joerg int ccc : 8; 333 1.1.1.2 joerg 334 1.1.1.2 joerg int d : 2; 335 1.1.1.2 joerg /* A comment. */ 336 1.1.1.2 joerg int ee : 3; 337 1.1.1.2 joerg 338 1.1.1.2 joerg * ``ACS_AcrossEmptyLinesAndComments`` 339 1.1.1.2 joerg (in configuration: ``AcrossEmptyLinesAndComments``) 340 1.1.1.2 joerg 341 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over lines only containing 342 1.1.1.2 joerg comments and empty lines, e.g. 343 1.1.1.2 joerg 344 1.1.1.2 joerg .. code-block:: c++ 345 1.1.1.2 joerg 346 1.1.1.2 joerg int aaaa : 1; 347 1.1.1.2 joerg int b : 12; 348 1.1.1.2 joerg int ccc : 8; 349 1.1.1.2 joerg 350 1.1.1.2 joerg int d : 2; 351 1.1.1.2 joerg /* A comment. */ 352 1.1.1.2 joerg int ee : 3; 353 1.1.1.2 joerg 354 1.1.1.2 joerg **AlignConsecutiveDeclarations** (``AlignConsecutiveStyle``) 355 1.1.1.2 joerg Style of aligning consecutive declarations. 356 1.1.1.2 joerg 357 1.1.1.2 joerg ``Consecutive`` will align the declaration names of consecutive lines. 358 1.1.1.2 joerg This will result in formattings like: 359 1.1 joerg 360 1.1 joerg .. code-block:: c++ 361 1.1 joerg 362 1.1 joerg int aaaa = 12; 363 1.1 joerg float b = 23; 364 1.1.1.2 joerg std::string ccc; 365 1.1.1.2 joerg 366 1.1.1.2 joerg Possible values: 367 1.1.1.2 joerg 368 1.1.1.2 joerg * ``ACS_None`` (in configuration: ``None``) 369 1.1.1.2 joerg Do not align bit declarations on consecutive lines. 370 1.1.1.2 joerg 371 1.1.1.2 joerg * ``ACS_Consecutive`` (in configuration: ``Consecutive``) 372 1.1.1.2 joerg Align declarations on consecutive lines. This will result in 373 1.1.1.2 joerg formattings like: 374 1.1.1.2 joerg 375 1.1.1.2 joerg .. code-block:: c++ 376 1.1.1.2 joerg 377 1.1.1.2 joerg int aaaa = 12; 378 1.1.1.2 joerg float b = 23; 379 1.1.1.2 joerg std::string ccc; 380 1.1.1.2 joerg 381 1.1.1.2 joerg int a = 42; 382 1.1.1.2 joerg /* A comment. */ 383 1.1.1.2 joerg bool c = false; 384 1.1.1.2 joerg 385 1.1.1.2 joerg * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``) 386 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over empty lines, e.g. 387 1.1.1.2 joerg 388 1.1.1.2 joerg .. code-block:: c++ 389 1.1 joerg 390 1.1.1.2 joerg int aaaa = 12; 391 1.1.1.2 joerg float b = 23; 392 1.1.1.2 joerg std::string ccc; 393 1.1 joerg 394 1.1.1.2 joerg int a = 42; 395 1.1.1.2 joerg /* A comment. */ 396 1.1.1.2 joerg bool c = false; 397 1.1.1.2 joerg 398 1.1.1.2 joerg * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``) 399 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over lines only containing 400 1.1.1.2 joerg comments, e.g. 401 1.1.1.2 joerg 402 1.1.1.2 joerg .. code-block:: c++ 403 1.1.1.2 joerg 404 1.1.1.2 joerg int aaaa = 12; 405 1.1.1.2 joerg float b = 23; 406 1.1.1.2 joerg std::string ccc; 407 1.1.1.2 joerg 408 1.1.1.2 joerg int a = 42; 409 1.1.1.2 joerg /* A comment. */ 410 1.1.1.2 joerg bool c = false; 411 1.1.1.2 joerg 412 1.1.1.2 joerg * ``ACS_AcrossEmptyLinesAndComments`` 413 1.1.1.2 joerg (in configuration: ``AcrossEmptyLinesAndComments``) 414 1.1.1.2 joerg 415 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over lines only containing 416 1.1.1.2 joerg comments and empty lines, e.g. 417 1.1.1.2 joerg 418 1.1.1.2 joerg .. code-block:: c++ 419 1.1.1.2 joerg 420 1.1.1.2 joerg int aaaa = 12; 421 1.1.1.2 joerg float b = 23; 422 1.1.1.2 joerg std::string ccc; 423 1.1.1.2 joerg 424 1.1.1.2 joerg int a = 42; 425 1.1.1.2 joerg /* A comment. */ 426 1.1.1.2 joerg bool c = false; 427 1.1.1.2 joerg 428 1.1.1.2 joerg **AlignConsecutiveMacros** (``AlignConsecutiveStyle``) 429 1.1.1.2 joerg Style of aligning consecutive macro definitions. 430 1.1.1.2 joerg 431 1.1.1.2 joerg ``Consecutive`` will result in formattings like: 432 1.1 joerg 433 1.1 joerg .. code-block:: c++ 434 1.1 joerg 435 1.1 joerg #define SHORT_NAME 42 436 1.1 joerg #define LONGER_NAME 0x007f 437 1.1 joerg #define EVEN_LONGER_NAME (2) 438 1.1 joerg #define foo(x) (x * x) 439 1.1 joerg #define bar(y, z) (y + z) 440 1.1 joerg 441 1.1.1.2 joerg Possible values: 442 1.1.1.2 joerg 443 1.1.1.2 joerg * ``ACS_None`` (in configuration: ``None``) 444 1.1.1.2 joerg Do not align macro definitions on consecutive lines. 445 1.1.1.2 joerg 446 1.1.1.2 joerg * ``ACS_Consecutive`` (in configuration: ``Consecutive``) 447 1.1.1.2 joerg Align macro definitions on consecutive lines. This will result in 448 1.1.1.2 joerg formattings like: 449 1.1.1.2 joerg 450 1.1.1.2 joerg .. code-block:: c++ 451 1.1.1.2 joerg 452 1.1.1.2 joerg #define SHORT_NAME 42 453 1.1.1.2 joerg #define LONGER_NAME 0x007f 454 1.1.1.2 joerg #define EVEN_LONGER_NAME (2) 455 1.1.1.2 joerg 456 1.1.1.2 joerg #define foo(x) (x * x) 457 1.1.1.2 joerg /* some comment */ 458 1.1.1.2 joerg #define bar(y, z) (y + z) 459 1.1.1.2 joerg 460 1.1.1.2 joerg * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``) 461 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over empty lines, e.g. 462 1.1.1.2 joerg 463 1.1.1.2 joerg .. code-block:: c++ 464 1.1.1.2 joerg 465 1.1.1.2 joerg #define SHORT_NAME 42 466 1.1.1.2 joerg #define LONGER_NAME 0x007f 467 1.1.1.2 joerg #define EVEN_LONGER_NAME (2) 468 1.1.1.2 joerg 469 1.1.1.2 joerg #define foo(x) (x * x) 470 1.1.1.2 joerg /* some comment */ 471 1.1.1.2 joerg #define bar(y, z) (y + z) 472 1.1.1.2 joerg 473 1.1.1.2 joerg * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``) 474 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over lines only containing 475 1.1.1.2 joerg comments, e.g. 476 1.1.1.2 joerg 477 1.1.1.2 joerg .. code-block:: c++ 478 1.1.1.2 joerg 479 1.1.1.2 joerg #define SHORT_NAME 42 480 1.1.1.2 joerg #define LONGER_NAME 0x007f 481 1.1.1.2 joerg #define EVEN_LONGER_NAME (2) 482 1.1.1.2 joerg 483 1.1.1.2 joerg #define foo(x) (x * x) 484 1.1.1.2 joerg /* some comment */ 485 1.1.1.2 joerg #define bar(y, z) (y + z) 486 1.1.1.2 joerg 487 1.1.1.2 joerg * ``ACS_AcrossEmptyLinesAndComments`` 488 1.1.1.2 joerg (in configuration: ``AcrossEmptyLinesAndComments``) 489 1.1.1.2 joerg 490 1.1.1.2 joerg Same as ACS_Consecutive, but also spans over lines only containing 491 1.1.1.2 joerg comments and empty lines, e.g. 492 1.1.1.2 joerg 493 1.1.1.2 joerg .. code-block:: c++ 494 1.1.1.2 joerg 495 1.1.1.2 joerg #define SHORT_NAME 42 496 1.1.1.2 joerg #define LONGER_NAME 0x007f 497 1.1.1.2 joerg #define EVEN_LONGER_NAME (2) 498 1.1.1.2 joerg 499 1.1.1.2 joerg #define foo(x) (x * x) 500 1.1.1.2 joerg /* some comment */ 501 1.1.1.2 joerg #define bar(y, z) (y + z) 502 1.1.1.2 joerg 503 1.1 joerg **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) 504 1.1 joerg Options for aligning backslashes in escaped newlines. 505 1.1 joerg 506 1.1 joerg Possible values: 507 1.1 joerg 508 1.1 joerg * ``ENAS_DontAlign`` (in configuration: ``DontAlign``) 509 1.1 joerg Don't align escaped newlines. 510 1.1 joerg 511 1.1 joerg .. code-block:: c++ 512 1.1 joerg 513 1.1 joerg #define A \ 514 1.1 joerg int aaaa; \ 515 1.1 joerg int b; \ 516 1.1 joerg int dddddddddd; 517 1.1 joerg 518 1.1 joerg * ``ENAS_Left`` (in configuration: ``Left``) 519 1.1 joerg Align escaped newlines as far left as possible. 520 1.1 joerg 521 1.1 joerg .. code-block:: c++ 522 1.1 joerg 523 1.1 joerg true: 524 1.1 joerg #define A \ 525 1.1 joerg int aaaa; \ 526 1.1 joerg int b; \ 527 1.1 joerg int dddddddddd; 528 1.1 joerg 529 1.1 joerg false: 530 1.1 joerg 531 1.1 joerg * ``ENAS_Right`` (in configuration: ``Right``) 532 1.1 joerg Align escaped newlines in the right-most column. 533 1.1 joerg 534 1.1 joerg .. code-block:: c++ 535 1.1 joerg 536 1.1 joerg #define A \ 537 1.1 joerg int aaaa; \ 538 1.1 joerg int b; \ 539 1.1 joerg int dddddddddd; 540 1.1 joerg 541 1.1 joerg 542 1.1 joerg 543 1.1.1.2 joerg **AlignOperands** (``OperandAlignmentStyle``) 544 1.1 joerg If ``true``, horizontally align operands of binary and ternary 545 1.1 joerg expressions. 546 1.1 joerg 547 1.1.1.2 joerg Possible values: 548 1.1.1.2 joerg 549 1.1.1.2 joerg * ``OAS_DontAlign`` (in configuration: ``DontAlign``) 550 1.1.1.2 joerg Do not align operands of binary and ternary expressions. 551 1.1.1.2 joerg The wrapped lines are indented ``ContinuationIndentWidth`` spaces from 552 1.1.1.2 joerg the start of the line. 553 1.1.1.2 joerg 554 1.1.1.2 joerg * ``OAS_Align`` (in configuration: ``Align``) 555 1.1.1.2 joerg Horizontally align operands of binary and ternary expressions. 556 1.1.1.2 joerg 557 1.1.1.2 joerg Specifically, this aligns operands of a single expression that needs 558 1.1.1.2 joerg to be split over multiple lines, e.g.: 559 1.1.1.2 joerg 560 1.1.1.2 joerg .. code-block:: c++ 561 1.1.1.2 joerg 562 1.1.1.2 joerg int aaa = bbbbbbbbbbbbbbb + 563 1.1.1.2 joerg ccccccccccccccc; 564 1.1.1.2 joerg 565 1.1.1.2 joerg When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is 566 1.1.1.2 joerg aligned with the operand on the first line. 567 1.1.1.2 joerg 568 1.1.1.2 joerg .. code-block:: c++ 569 1.1.1.2 joerg 570 1.1.1.2 joerg int aaa = bbbbbbbbbbbbbbb 571 1.1.1.2 joerg + ccccccccccccccc; 572 1.1.1.2 joerg 573 1.1.1.2 joerg * ``OAS_AlignAfterOperator`` (in configuration: ``AlignAfterOperator``) 574 1.1.1.2 joerg Horizontally align operands of binary and ternary expressions. 575 1.1.1.2 joerg 576 1.1.1.2 joerg This is similar to ``AO_Align``, except when 577 1.1.1.2 joerg ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so 578 1.1.1.2 joerg that the wrapped operand is aligned with the operand on the first line. 579 1.1.1.2 joerg 580 1.1.1.2 joerg .. code-block:: c++ 581 1.1.1.2 joerg 582 1.1.1.2 joerg int aaa = bbbbbbbbbbbbbbb 583 1.1.1.2 joerg + ccccccccccccccc; 584 1.1 joerg 585 1.1 joerg 586 1.1 joerg 587 1.1 joerg **AlignTrailingComments** (``bool``) 588 1.1 joerg If ``true``, aligns trailing comments. 589 1.1 joerg 590 1.1 joerg .. code-block:: c++ 591 1.1 joerg 592 1.1 joerg true: false: 593 1.1 joerg int a; // My comment a vs. int a; // My comment a 594 1.1 joerg int b = 2; // comment b int b = 2; // comment about b 595 1.1 joerg 596 1.1 joerg **AllowAllArgumentsOnNextLine** (``bool``) 597 1.1 joerg If a function call or braced initializer list doesn't fit on a 598 1.1 joerg line, allow putting all arguments onto the next line, even if 599 1.1 joerg ``BinPackArguments`` is ``false``. 600 1.1 joerg 601 1.1 joerg .. code-block:: c++ 602 1.1 joerg 603 1.1 joerg true: 604 1.1 joerg callFunction( 605 1.1 joerg a, b, c, d); 606 1.1 joerg 607 1.1 joerg false: 608 1.1 joerg callFunction(a, 609 1.1 joerg b, 610 1.1 joerg c, 611 1.1 joerg d); 612 1.1 joerg 613 1.1 joerg **AllowAllConstructorInitializersOnNextLine** (``bool``) 614 1.1 joerg If a constructor definition with a member initializer list doesn't 615 1.1 joerg fit on a single line, allow putting all member initializers onto the next 616 1.1 joerg line, if ```ConstructorInitializerAllOnOneLineOrOnePerLine``` is true. 617 1.1 joerg Note that this parameter has no effect if 618 1.1 joerg ```ConstructorInitializerAllOnOneLineOrOnePerLine``` is false. 619 1.1 joerg 620 1.1 joerg .. code-block:: c++ 621 1.1 joerg 622 1.1 joerg true: 623 1.1 joerg MyClass::MyClass() : 624 1.1 joerg member0(0), member1(2) {} 625 1.1 joerg 626 1.1 joerg false: 627 1.1 joerg MyClass::MyClass() : 628 1.1 joerg member0(0), 629 1.1 joerg member1(2) {} 630 1.1 joerg 631 1.1 joerg **AllowAllParametersOfDeclarationOnNextLine** (``bool``) 632 1.1 joerg If the function declaration doesn't fit on a line, 633 1.1 joerg allow putting all parameters of a function declaration onto 634 1.1 joerg the next line even if ``BinPackParameters`` is ``false``. 635 1.1 joerg 636 1.1 joerg .. code-block:: c++ 637 1.1 joerg 638 1.1 joerg true: 639 1.1 joerg void myFunction( 640 1.1 joerg int a, int b, int c, int d, int e); 641 1.1 joerg 642 1.1 joerg false: 643 1.1 joerg void myFunction(int a, 644 1.1 joerg int b, 645 1.1 joerg int c, 646 1.1 joerg int d, 647 1.1 joerg int e); 648 1.1 joerg 649 1.1 joerg **AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) 650 1.1 joerg Dependent on the value, ``while (true) { continue; }`` can be put on a 651 1.1 joerg single line. 652 1.1 joerg 653 1.1 joerg Possible values: 654 1.1 joerg 655 1.1 joerg * ``SBS_Never`` (in configuration: ``Never``) 656 1.1 joerg Never merge blocks into a single line. 657 1.1 joerg 658 1.1 joerg .. code-block:: c++ 659 1.1 joerg 660 1.1 joerg while (true) { 661 1.1 joerg } 662 1.1 joerg while (true) { 663 1.1 joerg continue; 664 1.1 joerg } 665 1.1 joerg 666 1.1 joerg * ``SBS_Empty`` (in configuration: ``Empty``) 667 1.1 joerg Only merge empty blocks. 668 1.1 joerg 669 1.1 joerg .. code-block:: c++ 670 1.1 joerg 671 1.1 joerg while (true) {} 672 1.1 joerg while (true) { 673 1.1 joerg continue; 674 1.1 joerg } 675 1.1 joerg 676 1.1 joerg * ``SBS_Always`` (in configuration: ``Always``) 677 1.1 joerg Always merge short blocks into a single line. 678 1.1 joerg 679 1.1 joerg .. code-block:: c++ 680 1.1 joerg 681 1.1 joerg while (true) {} 682 1.1 joerg while (true) { continue; } 683 1.1 joerg 684 1.1 joerg 685 1.1 joerg 686 1.1 joerg **AllowShortCaseLabelsOnASingleLine** (``bool``) 687 1.1 joerg If ``true``, short case labels will be contracted to a single line. 688 1.1 joerg 689 1.1 joerg .. code-block:: c++ 690 1.1 joerg 691 1.1 joerg true: false: 692 1.1 joerg switch (a) { vs. switch (a) { 693 1.1 joerg case 1: x = 1; break; case 1: 694 1.1 joerg case 2: return; x = 1; 695 1.1 joerg } break; 696 1.1 joerg case 2: 697 1.1 joerg return; 698 1.1 joerg } 699 1.1 joerg 700 1.1.1.2 joerg **AllowShortEnumsOnASingleLine** (``bool``) 701 1.1.1.2 joerg Allow short enums on a single line. 702 1.1.1.2 joerg 703 1.1.1.2 joerg .. code-block:: c++ 704 1.1.1.2 joerg 705 1.1.1.2 joerg true: 706 1.1.1.2 joerg enum { A, B } myEnum; 707 1.1.1.2 joerg 708 1.1.1.2 joerg false: 709 1.1.1.2 joerg enum 710 1.1.1.2 joerg { 711 1.1.1.2 joerg A, 712 1.1.1.2 joerg B 713 1.1.1.2 joerg } myEnum; 714 1.1.1.2 joerg 715 1.1 joerg **AllowShortFunctionsOnASingleLine** (``ShortFunctionStyle``) 716 1.1 joerg Dependent on the value, ``int f() { return 0; }`` can be put on a 717 1.1 joerg single line. 718 1.1 joerg 719 1.1 joerg Possible values: 720 1.1 joerg 721 1.1 joerg * ``SFS_None`` (in configuration: ``None``) 722 1.1 joerg Never merge functions into a single line. 723 1.1 joerg 724 1.1 joerg * ``SFS_InlineOnly`` (in configuration: ``InlineOnly``) 725 1.1 joerg Only merge functions defined inside a class. Same as "inline", 726 1.1 joerg except it does not implies "empty": i.e. top level empty functions 727 1.1 joerg are not merged either. 728 1.1 joerg 729 1.1 joerg .. code-block:: c++ 730 1.1 joerg 731 1.1 joerg class Foo { 732 1.1 joerg void f() { foo(); } 733 1.1 joerg }; 734 1.1 joerg void f() { 735 1.1 joerg foo(); 736 1.1 joerg } 737 1.1 joerg void f() { 738 1.1 joerg } 739 1.1 joerg 740 1.1 joerg * ``SFS_Empty`` (in configuration: ``Empty``) 741 1.1 joerg Only merge empty functions. 742 1.1 joerg 743 1.1 joerg .. code-block:: c++ 744 1.1 joerg 745 1.1 joerg void f() {} 746 1.1 joerg void f2() { 747 1.1 joerg bar2(); 748 1.1 joerg } 749 1.1 joerg 750 1.1 joerg * ``SFS_Inline`` (in configuration: ``Inline``) 751 1.1 joerg Only merge functions defined inside a class. Implies "empty". 752 1.1 joerg 753 1.1 joerg .. code-block:: c++ 754 1.1 joerg 755 1.1 joerg class Foo { 756 1.1 joerg void f() { foo(); } 757 1.1 joerg }; 758 1.1 joerg void f() { 759 1.1 joerg foo(); 760 1.1 joerg } 761 1.1 joerg void f() {} 762 1.1 joerg 763 1.1 joerg * ``SFS_All`` (in configuration: ``All``) 764 1.1 joerg Merge all functions fitting on a single line. 765 1.1 joerg 766 1.1 joerg .. code-block:: c++ 767 1.1 joerg 768 1.1 joerg class Foo { 769 1.1 joerg void f() { foo(); } 770 1.1 joerg }; 771 1.1 joerg void f() { bar(); } 772 1.1 joerg 773 1.1 joerg 774 1.1 joerg 775 1.1 joerg **AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``) 776 1.1 joerg If ``true``, ``if (a) return;`` can be put on a single line. 777 1.1 joerg 778 1.1 joerg Possible values: 779 1.1 joerg 780 1.1 joerg * ``SIS_Never`` (in configuration: ``Never``) 781 1.1 joerg Never put short ifs on the same line. 782 1.1 joerg 783 1.1 joerg .. code-block:: c++ 784 1.1 joerg 785 1.1 joerg if (a) 786 1.1 joerg return ; 787 1.1 joerg else { 788 1.1 joerg return; 789 1.1 joerg } 790 1.1 joerg 791 1.1 joerg * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``) 792 1.1 joerg Without else put short ifs on the same line only if 793 1.1 joerg the else is not a compound statement. 794 1.1 joerg 795 1.1 joerg .. code-block:: c++ 796 1.1 joerg 797 1.1 joerg if (a) return; 798 1.1 joerg else 799 1.1 joerg return; 800 1.1 joerg 801 1.1 joerg * ``SIS_Always`` (in configuration: ``Always``) 802 1.1 joerg Always put short ifs on the same line if 803 1.1 joerg the else is not a compound statement or not. 804 1.1 joerg 805 1.1 joerg .. code-block:: c++ 806 1.1 joerg 807 1.1 joerg if (a) return; 808 1.1 joerg else { 809 1.1 joerg return; 810 1.1 joerg } 811 1.1 joerg 812 1.1 joerg 813 1.1 joerg 814 1.1 joerg **AllowShortLambdasOnASingleLine** (``ShortLambdaStyle``) 815 1.1 joerg Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a 816 1.1 joerg single line. 817 1.1 joerg 818 1.1 joerg Possible values: 819 1.1 joerg 820 1.1 joerg * ``SLS_None`` (in configuration: ``None``) 821 1.1 joerg Never merge lambdas into a single line. 822 1.1 joerg 823 1.1 joerg * ``SLS_Empty`` (in configuration: ``Empty``) 824 1.1 joerg Only merge empty lambdas. 825 1.1 joerg 826 1.1 joerg .. code-block:: c++ 827 1.1 joerg 828 1.1 joerg auto lambda = [](int a) {} 829 1.1 joerg auto lambda2 = [](int a) { 830 1.1 joerg return a; 831 1.1 joerg }; 832 1.1 joerg 833 1.1 joerg * ``SLS_Inline`` (in configuration: ``Inline``) 834 1.1 joerg Merge lambda into a single line if argument of a function. 835 1.1 joerg 836 1.1 joerg .. code-block:: c++ 837 1.1 joerg 838 1.1 joerg auto lambda = [](int a) { 839 1.1 joerg return a; 840 1.1 joerg }; 841 1.1 joerg sort(a.begin(), a.end(), ()[] { return x < y; }) 842 1.1 joerg 843 1.1 joerg * ``SLS_All`` (in configuration: ``All``) 844 1.1 joerg Merge all lambdas fitting on a single line. 845 1.1 joerg 846 1.1 joerg .. code-block:: c++ 847 1.1 joerg 848 1.1 joerg auto lambda = [](int a) {} 849 1.1 joerg auto lambda2 = [](int a) { return a; }; 850 1.1 joerg 851 1.1 joerg 852 1.1 joerg 853 1.1 joerg **AllowShortLoopsOnASingleLine** (``bool``) 854 1.1 joerg If ``true``, ``while (true) continue;`` can be put on a single 855 1.1 joerg line. 856 1.1 joerg 857 1.1 joerg **AlwaysBreakAfterDefinitionReturnType** (``DefinitionReturnTypeBreakingStyle``) 858 1.1 joerg The function definition return type breaking style to use. This 859 1.1 joerg option is **deprecated** and is retained for backwards compatibility. 860 1.1 joerg 861 1.1 joerg Possible values: 862 1.1 joerg 863 1.1 joerg * ``DRTBS_None`` (in configuration: ``None``) 864 1.1 joerg Break after return type automatically. 865 1.1 joerg ``PenaltyReturnTypeOnItsOwnLine`` is taken into account. 866 1.1 joerg 867 1.1 joerg * ``DRTBS_All`` (in configuration: ``All``) 868 1.1 joerg Always break after the return type. 869 1.1 joerg 870 1.1 joerg * ``DRTBS_TopLevel`` (in configuration: ``TopLevel``) 871 1.1 joerg Always break after the return types of top-level functions. 872 1.1 joerg 873 1.1 joerg 874 1.1 joerg 875 1.1 joerg **AlwaysBreakAfterReturnType** (``ReturnTypeBreakingStyle``) 876 1.1 joerg The function declaration return type breaking style to use. 877 1.1 joerg 878 1.1 joerg Possible values: 879 1.1 joerg 880 1.1 joerg * ``RTBS_None`` (in configuration: ``None``) 881 1.1 joerg Break after return type automatically. 882 1.1 joerg ``PenaltyReturnTypeOnItsOwnLine`` is taken into account. 883 1.1 joerg 884 1.1 joerg .. code-block:: c++ 885 1.1 joerg 886 1.1 joerg class A { 887 1.1 joerg int f() { return 0; }; 888 1.1 joerg }; 889 1.1 joerg int f(); 890 1.1 joerg int f() { return 1; } 891 1.1 joerg 892 1.1 joerg * ``RTBS_All`` (in configuration: ``All``) 893 1.1 joerg Always break after the return type. 894 1.1 joerg 895 1.1 joerg .. code-block:: c++ 896 1.1 joerg 897 1.1 joerg class A { 898 1.1 joerg int 899 1.1 joerg f() { 900 1.1 joerg return 0; 901 1.1 joerg }; 902 1.1 joerg }; 903 1.1 joerg int 904 1.1 joerg f(); 905 1.1 joerg int 906 1.1 joerg f() { 907 1.1 joerg return 1; 908 1.1 joerg } 909 1.1 joerg 910 1.1 joerg * ``RTBS_TopLevel`` (in configuration: ``TopLevel``) 911 1.1 joerg Always break after the return types of top-level functions. 912 1.1 joerg 913 1.1 joerg .. code-block:: c++ 914 1.1 joerg 915 1.1 joerg class A { 916 1.1 joerg int f() { return 0; }; 917 1.1 joerg }; 918 1.1 joerg int 919 1.1 joerg f(); 920 1.1 joerg int 921 1.1 joerg f() { 922 1.1 joerg return 1; 923 1.1 joerg } 924 1.1 joerg 925 1.1 joerg * ``RTBS_AllDefinitions`` (in configuration: ``AllDefinitions``) 926 1.1 joerg Always break after the return type of function definitions. 927 1.1 joerg 928 1.1 joerg .. code-block:: c++ 929 1.1 joerg 930 1.1 joerg class A { 931 1.1 joerg int 932 1.1 joerg f() { 933 1.1 joerg return 0; 934 1.1 joerg }; 935 1.1 joerg }; 936 1.1 joerg int f(); 937 1.1 joerg int 938 1.1 joerg f() { 939 1.1 joerg return 1; 940 1.1 joerg } 941 1.1 joerg 942 1.1 joerg * ``RTBS_TopLevelDefinitions`` (in configuration: ``TopLevelDefinitions``) 943 1.1 joerg Always break after the return type of top-level definitions. 944 1.1 joerg 945 1.1 joerg .. code-block:: c++ 946 1.1 joerg 947 1.1 joerg class A { 948 1.1 joerg int f() { return 0; }; 949 1.1 joerg }; 950 1.1 joerg int f(); 951 1.1 joerg int 952 1.1 joerg f() { 953 1.1 joerg return 1; 954 1.1 joerg } 955 1.1 joerg 956 1.1 joerg 957 1.1 joerg 958 1.1 joerg **AlwaysBreakBeforeMultilineStrings** (``bool``) 959 1.1 joerg If ``true``, always break before multiline string literals. 960 1.1 joerg 961 1.1 joerg This flag is mean to make cases where there are multiple multiline strings 962 1.1 joerg in a file look more consistent. Thus, it will only take effect if wrapping 963 1.1 joerg the string at that point leads to it being indented 964 1.1 joerg ``ContinuationIndentWidth`` spaces from the start of the line. 965 1.1 joerg 966 1.1 joerg .. code-block:: c++ 967 1.1 joerg 968 1.1 joerg true: false: 969 1.1 joerg aaaa = vs. aaaa = "bbbb" 970 1.1 joerg "bbbb" "cccc"; 971 1.1 joerg "cccc"; 972 1.1 joerg 973 1.1 joerg **AlwaysBreakTemplateDeclarations** (``BreakTemplateDeclarationsStyle``) 974 1.1 joerg The template declaration breaking style to use. 975 1.1 joerg 976 1.1 joerg Possible values: 977 1.1 joerg 978 1.1 joerg * ``BTDS_No`` (in configuration: ``No``) 979 1.1 joerg Do not force break before declaration. 980 1.1 joerg ``PenaltyBreakTemplateDeclaration`` is taken into account. 981 1.1 joerg 982 1.1 joerg .. code-block:: c++ 983 1.1 joerg 984 1.1 joerg template <typename T> T foo() { 985 1.1 joerg } 986 1.1 joerg template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa, 987 1.1 joerg int bbbbbbbbbbbbbbbbbbbbb) { 988 1.1 joerg } 989 1.1 joerg 990 1.1 joerg * ``BTDS_MultiLine`` (in configuration: ``MultiLine``) 991 1.1 joerg Force break after template declaration only when the following 992 1.1 joerg declaration spans multiple lines. 993 1.1 joerg 994 1.1 joerg .. code-block:: c++ 995 1.1 joerg 996 1.1 joerg template <typename T> T foo() { 997 1.1 joerg } 998 1.1 joerg template <typename T> 999 1.1 joerg T foo(int aaaaaaaaaaaaaaaaaaaaa, 1000 1.1 joerg int bbbbbbbbbbbbbbbbbbbbb) { 1001 1.1 joerg } 1002 1.1 joerg 1003 1.1 joerg * ``BTDS_Yes`` (in configuration: ``Yes``) 1004 1.1 joerg Always break after template declaration. 1005 1.1 joerg 1006 1.1 joerg .. code-block:: c++ 1007 1.1 joerg 1008 1.1 joerg template <typename T> 1009 1.1 joerg T foo() { 1010 1.1 joerg } 1011 1.1 joerg template <typename T> 1012 1.1 joerg T foo(int aaaaaaaaaaaaaaaaaaaaa, 1013 1.1 joerg int bbbbbbbbbbbbbbbbbbbbb) { 1014 1.1 joerg } 1015 1.1 joerg 1016 1.1 joerg 1017 1.1 joerg 1018 1.1.1.2 joerg **AttributeMacros** (``std::vector<std::string>``) 1019 1.1.1.2 joerg A vector of strings that should be interpreted as attributes/qualifiers 1020 1.1.1.2 joerg instead of identifiers. This can be useful for language extensions or 1021 1.1.1.2 joerg static analyzer annotations. 1022 1.1.1.2 joerg 1023 1.1.1.2 joerg For example: 1024 1.1.1.2 joerg 1025 1.1.1.2 joerg .. code-block:: c++ 1026 1.1.1.2 joerg 1027 1.1.1.2 joerg x = (char *__capability)&y; 1028 1.1.1.2 joerg int function(void) __ununsed; 1029 1.1.1.2 joerg void only_writes_to_buffer(char *__output buffer); 1030 1.1.1.2 joerg 1031 1.1.1.2 joerg In the .clang-format configuration file, this can be configured like: 1032 1.1.1.2 joerg 1033 1.1.1.2 joerg .. code-block:: yaml 1034 1.1.1.2 joerg 1035 1.1.1.2 joerg AttributeMacros: ['__capability', '__output', '__ununsed'] 1036 1.1.1.2 joerg 1037 1.1 joerg **BinPackArguments** (``bool``) 1038 1.1 joerg If ``false``, a function call's arguments will either be all on the 1039 1.1 joerg same line or will have one line each. 1040 1.1 joerg 1041 1.1 joerg .. code-block:: c++ 1042 1.1 joerg 1043 1.1 joerg true: 1044 1.1 joerg void f() { 1045 1.1 joerg f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, 1046 1.1 joerg aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); 1047 1.1 joerg } 1048 1.1 joerg 1049 1.1 joerg false: 1050 1.1 joerg void f() { 1051 1.1 joerg f(aaaaaaaaaaaaaaaaaaaa, 1052 1.1 joerg aaaaaaaaaaaaaaaaaaaa, 1053 1.1 joerg aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); 1054 1.1 joerg } 1055 1.1 joerg 1056 1.1 joerg **BinPackParameters** (``bool``) 1057 1.1 joerg If ``false``, a function declaration's or function definition's 1058 1.1 joerg parameters will either all be on the same line or will have one line each. 1059 1.1 joerg 1060 1.1 joerg .. code-block:: c++ 1061 1.1 joerg 1062 1.1 joerg true: 1063 1.1 joerg void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa, 1064 1.1 joerg int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} 1065 1.1 joerg 1066 1.1 joerg false: 1067 1.1 joerg void f(int aaaaaaaaaaaaaaaaaaaa, 1068 1.1 joerg int aaaaaaaaaaaaaaaaaaaa, 1069 1.1 joerg int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} 1070 1.1 joerg 1071 1.1.1.2 joerg **BitFieldColonSpacing** (``BitFieldColonSpacingStyle``) 1072 1.1.1.2 joerg The BitFieldColonSpacingStyle to use for bitfields. 1073 1.1.1.2 joerg 1074 1.1.1.2 joerg Possible values: 1075 1.1.1.2 joerg 1076 1.1.1.2 joerg * ``BFCS_Both`` (in configuration: ``Both``) 1077 1.1.1.2 joerg Add one space on each side of the ``:`` 1078 1.1.1.2 joerg 1079 1.1.1.2 joerg .. code-block:: c++ 1080 1.1.1.2 joerg 1081 1.1.1.2 joerg unsigned bf : 2; 1082 1.1.1.2 joerg 1083 1.1.1.2 joerg * ``BFCS_None`` (in configuration: ``None``) 1084 1.1.1.2 joerg Add no space around the ``:`` (except when needed for 1085 1.1.1.2 joerg ``AlignConsecutiveBitFields``). 1086 1.1.1.2 joerg 1087 1.1.1.2 joerg .. code-block:: c++ 1088 1.1.1.2 joerg 1089 1.1.1.2 joerg unsigned bf:2; 1090 1.1.1.2 joerg 1091 1.1.1.2 joerg * ``BFCS_Before`` (in configuration: ``Before``) 1092 1.1.1.2 joerg Add space before the ``:`` only 1093 1.1.1.2 joerg 1094 1.1.1.2 joerg .. code-block:: c++ 1095 1.1.1.2 joerg 1096 1.1.1.2 joerg unsigned bf :2; 1097 1.1.1.2 joerg 1098 1.1.1.2 joerg * ``BFCS_After`` (in configuration: ``After``) 1099 1.1.1.2 joerg Add space after the ``:`` only (space may be added before if 1100 1.1.1.2 joerg needed for ``AlignConsecutiveBitFields``). 1101 1.1.1.2 joerg 1102 1.1.1.2 joerg .. code-block:: c++ 1103 1.1.1.2 joerg 1104 1.1.1.2 joerg unsigned bf: 2; 1105 1.1.1.2 joerg 1106 1.1.1.2 joerg 1107 1.1.1.2 joerg 1108 1.1 joerg **BraceWrapping** (``BraceWrappingFlags``) 1109 1.1 joerg Control of individual brace wrapping cases. 1110 1.1 joerg 1111 1.1 joerg If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how 1112 1.1 joerg each individual brace case should be handled. Otherwise, this is ignored. 1113 1.1 joerg 1114 1.1 joerg .. code-block:: yaml 1115 1.1 joerg 1116 1.1 joerg # Example of usage: 1117 1.1 joerg BreakBeforeBraces: Custom 1118 1.1 joerg BraceWrapping: 1119 1.1 joerg AfterEnum: true 1120 1.1 joerg AfterStruct: false 1121 1.1 joerg SplitEmptyFunction: false 1122 1.1 joerg 1123 1.1 joerg Nested configuration flags: 1124 1.1 joerg 1125 1.1 joerg 1126 1.1 joerg * ``bool AfterCaseLabel`` Wrap case labels. 1127 1.1 joerg 1128 1.1 joerg .. code-block:: c++ 1129 1.1 joerg 1130 1.1 joerg false: true: 1131 1.1 joerg switch (foo) { vs. switch (foo) { 1132 1.1 joerg case 1: { case 1: 1133 1.1 joerg bar(); { 1134 1.1 joerg break; bar(); 1135 1.1 joerg } break; 1136 1.1 joerg default: { } 1137 1.1 joerg plop(); default: 1138 1.1 joerg } { 1139 1.1 joerg } plop(); 1140 1.1 joerg } 1141 1.1 joerg } 1142 1.1 joerg 1143 1.1 joerg * ``bool AfterClass`` Wrap class definitions. 1144 1.1 joerg 1145 1.1 joerg .. code-block:: c++ 1146 1.1 joerg 1147 1.1 joerg true: 1148 1.1 joerg class foo {}; 1149 1.1 joerg 1150 1.1 joerg false: 1151 1.1 joerg class foo 1152 1.1 joerg {}; 1153 1.1 joerg 1154 1.1 joerg * ``BraceWrappingAfterControlStatementStyle AfterControlStatement`` 1155 1.1 joerg Wrap control statements (``if``/``for``/``while``/``switch``/..). 1156 1.1 joerg 1157 1.1 joerg Possible values: 1158 1.1 joerg 1159 1.1 joerg * ``BWACS_Never`` (in configuration: ``Never``) 1160 1.1 joerg Never wrap braces after a control statement. 1161 1.1 joerg 1162 1.1 joerg .. code-block:: c++ 1163 1.1 joerg 1164 1.1 joerg if (foo()) { 1165 1.1 joerg } else { 1166 1.1 joerg } 1167 1.1 joerg for (int i = 0; i < 10; ++i) { 1168 1.1 joerg } 1169 1.1 joerg 1170 1.1 joerg * ``BWACS_MultiLine`` (in configuration: ``MultiLine``) 1171 1.1 joerg Only wrap braces after a multi-line control statement. 1172 1.1 joerg 1173 1.1 joerg .. code-block:: c++ 1174 1.1 joerg 1175 1.1 joerg if (foo && bar && 1176 1.1 joerg baz) 1177 1.1 joerg { 1178 1.1 joerg quux(); 1179 1.1 joerg } 1180 1.1 joerg while (foo || bar) { 1181 1.1 joerg } 1182 1.1 joerg 1183 1.1 joerg * ``BWACS_Always`` (in configuration: ``Always``) 1184 1.1 joerg Always wrap braces after a control statement. 1185 1.1 joerg 1186 1.1 joerg .. code-block:: c++ 1187 1.1 joerg 1188 1.1 joerg if (foo()) 1189 1.1 joerg { 1190 1.1 joerg } else 1191 1.1 joerg {} 1192 1.1 joerg for (int i = 0; i < 10; ++i) 1193 1.1 joerg {} 1194 1.1 joerg 1195 1.1.1.2 joerg 1196 1.1 joerg * ``bool AfterEnum`` Wrap enum definitions. 1197 1.1 joerg 1198 1.1 joerg .. code-block:: c++ 1199 1.1 joerg 1200 1.1 joerg true: 1201 1.1 joerg enum X : int 1202 1.1 joerg { 1203 1.1 joerg B 1204 1.1 joerg }; 1205 1.1 joerg 1206 1.1 joerg false: 1207 1.1 joerg enum X : int { B }; 1208 1.1 joerg 1209 1.1 joerg * ``bool AfterFunction`` Wrap function definitions. 1210 1.1 joerg 1211 1.1 joerg .. code-block:: c++ 1212 1.1 joerg 1213 1.1 joerg true: 1214 1.1 joerg void foo() 1215 1.1 joerg { 1216 1.1 joerg bar(); 1217 1.1 joerg bar2(); 1218 1.1 joerg } 1219 1.1 joerg 1220 1.1 joerg false: 1221 1.1 joerg void foo() { 1222 1.1 joerg bar(); 1223 1.1 joerg bar2(); 1224 1.1 joerg } 1225 1.1 joerg 1226 1.1 joerg * ``bool AfterNamespace`` Wrap namespace definitions. 1227 1.1 joerg 1228 1.1 joerg .. code-block:: c++ 1229 1.1 joerg 1230 1.1 joerg true: 1231 1.1 joerg namespace 1232 1.1 joerg { 1233 1.1 joerg int foo(); 1234 1.1 joerg int bar(); 1235 1.1 joerg } 1236 1.1 joerg 1237 1.1 joerg false: 1238 1.1 joerg namespace { 1239 1.1 joerg int foo(); 1240 1.1 joerg int bar(); 1241 1.1 joerg } 1242 1.1 joerg 1243 1.1 joerg * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (interfaces, implementations...). 1244 1.1 joerg @autoreleasepool and @synchronized blocks are wrapped 1245 1.1 joerg according to `AfterControlStatement` flag. 1246 1.1 joerg 1247 1.1 joerg * ``bool AfterStruct`` Wrap struct definitions. 1248 1.1 joerg 1249 1.1 joerg .. code-block:: c++ 1250 1.1 joerg 1251 1.1 joerg true: 1252 1.1 joerg struct foo 1253 1.1 joerg { 1254 1.1 joerg int x; 1255 1.1 joerg }; 1256 1.1 joerg 1257 1.1 joerg false: 1258 1.1 joerg struct foo { 1259 1.1 joerg int x; 1260 1.1 joerg }; 1261 1.1 joerg 1262 1.1 joerg * ``bool AfterUnion`` Wrap union definitions. 1263 1.1 joerg 1264 1.1 joerg .. code-block:: c++ 1265 1.1 joerg 1266 1.1 joerg true: 1267 1.1 joerg union foo 1268 1.1 joerg { 1269 1.1 joerg int x; 1270 1.1 joerg } 1271 1.1 joerg 1272 1.1 joerg false: 1273 1.1 joerg union foo { 1274 1.1 joerg int x; 1275 1.1 joerg } 1276 1.1 joerg 1277 1.1 joerg * ``bool AfterExternBlock`` Wrap extern blocks. 1278 1.1 joerg 1279 1.1 joerg .. code-block:: c++ 1280 1.1 joerg 1281 1.1 joerg true: 1282 1.1 joerg extern "C" 1283 1.1 joerg { 1284 1.1 joerg int foo(); 1285 1.1 joerg } 1286 1.1 joerg 1287 1.1 joerg false: 1288 1.1 joerg extern "C" { 1289 1.1 joerg int foo(); 1290 1.1 joerg } 1291 1.1 joerg 1292 1.1 joerg * ``bool BeforeCatch`` Wrap before ``catch``. 1293 1.1 joerg 1294 1.1 joerg .. code-block:: c++ 1295 1.1 joerg 1296 1.1 joerg true: 1297 1.1 joerg try { 1298 1.1 joerg foo(); 1299 1.1 joerg } 1300 1.1 joerg catch () { 1301 1.1 joerg } 1302 1.1 joerg 1303 1.1 joerg false: 1304 1.1 joerg try { 1305 1.1 joerg foo(); 1306 1.1 joerg } catch () { 1307 1.1 joerg } 1308 1.1 joerg 1309 1.1 joerg * ``bool BeforeElse`` Wrap before ``else``. 1310 1.1 joerg 1311 1.1 joerg .. code-block:: c++ 1312 1.1 joerg 1313 1.1 joerg true: 1314 1.1 joerg if (foo()) { 1315 1.1 joerg } 1316 1.1 joerg else { 1317 1.1 joerg } 1318 1.1 joerg 1319 1.1 joerg false: 1320 1.1 joerg if (foo()) { 1321 1.1 joerg } else { 1322 1.1 joerg } 1323 1.1 joerg 1324 1.1.1.2 joerg * ``bool BeforeLambdaBody`` Wrap lambda block. 1325 1.1.1.2 joerg 1326 1.1.1.2 joerg .. code-block:: c++ 1327 1.1.1.2 joerg 1328 1.1.1.2 joerg true: 1329 1.1.1.2 joerg connect( 1330 1.1.1.2 joerg []() 1331 1.1.1.2 joerg { 1332 1.1.1.2 joerg foo(); 1333 1.1.1.2 joerg bar(); 1334 1.1.1.2 joerg }); 1335 1.1.1.2 joerg 1336 1.1.1.2 joerg false: 1337 1.1.1.2 joerg connect([]() { 1338 1.1.1.2 joerg foo(); 1339 1.1.1.2 joerg bar(); 1340 1.1.1.2 joerg }); 1341 1.1.1.2 joerg 1342 1.1.1.2 joerg * ``bool BeforeWhile`` Wrap before ``while``. 1343 1.1.1.2 joerg 1344 1.1.1.2 joerg .. code-block:: c++ 1345 1.1.1.2 joerg 1346 1.1.1.2 joerg true: 1347 1.1.1.2 joerg do { 1348 1.1.1.2 joerg foo(); 1349 1.1.1.2 joerg } 1350 1.1.1.2 joerg while (1); 1351 1.1.1.2 joerg 1352 1.1.1.2 joerg false: 1353 1.1.1.2 joerg do { 1354 1.1.1.2 joerg foo(); 1355 1.1.1.2 joerg } while (1); 1356 1.1.1.2 joerg 1357 1.1 joerg * ``bool IndentBraces`` Indent the wrapped braces themselves. 1358 1.1 joerg 1359 1.1 joerg * ``bool SplitEmptyFunction`` If ``false``, empty function body can be put on a single line. 1360 1.1 joerg This option is used only if the opening brace of the function has 1361 1.1 joerg already been wrapped, i.e. the `AfterFunction` brace wrapping mode is 1362 1.1 joerg set, and the function could/should not be put on a single line (as per 1363 1.1 joerg `AllowShortFunctionsOnASingleLine` and constructor formatting options). 1364 1.1 joerg 1365 1.1 joerg .. code-block:: c++ 1366 1.1 joerg 1367 1.1.1.2 joerg int f() vs. int f() 1368 1.1 joerg {} { 1369 1.1 joerg } 1370 1.1 joerg 1371 1.1 joerg * ``bool SplitEmptyRecord`` If ``false``, empty record (e.g. class, struct or union) body 1372 1.1 joerg can be put on a single line. This option is used only if the opening 1373 1.1 joerg brace of the record has already been wrapped, i.e. the `AfterClass` 1374 1.1 joerg (for classes) brace wrapping mode is set. 1375 1.1 joerg 1376 1.1 joerg .. code-block:: c++ 1377 1.1 joerg 1378 1.1 joerg class Foo vs. class Foo 1379 1.1 joerg {} { 1380 1.1 joerg } 1381 1.1 joerg 1382 1.1 joerg * ``bool SplitEmptyNamespace`` If ``false``, empty namespace body can be put on a single line. 1383 1.1 joerg This option is used only if the opening brace of the namespace has 1384 1.1 joerg already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is 1385 1.1 joerg set. 1386 1.1 joerg 1387 1.1 joerg .. code-block:: c++ 1388 1.1 joerg 1389 1.1 joerg namespace Foo vs. namespace Foo 1390 1.1 joerg {} { 1391 1.1 joerg } 1392 1.1 joerg 1393 1.1 joerg 1394 1.1 joerg **BreakAfterJavaFieldAnnotations** (``bool``) 1395 1.1 joerg Break after each annotation on a field in Java files. 1396 1.1 joerg 1397 1.1 joerg .. code-block:: java 1398 1.1 joerg 1399 1.1 joerg true: false: 1400 1.1 joerg @Partial vs. @Partial @Mock DataLoad loader; 1401 1.1 joerg @Mock 1402 1.1 joerg DataLoad loader; 1403 1.1 joerg 1404 1.1 joerg **BreakBeforeBinaryOperators** (``BinaryOperatorStyle``) 1405 1.1 joerg The way to wrap binary operators. 1406 1.1 joerg 1407 1.1 joerg Possible values: 1408 1.1 joerg 1409 1.1 joerg * ``BOS_None`` (in configuration: ``None``) 1410 1.1 joerg Break after operators. 1411 1.1 joerg 1412 1.1 joerg .. code-block:: c++ 1413 1.1 joerg 1414 1.1 joerg LooooooooooongType loooooooooooooooooooooongVariable = 1415 1.1 joerg someLooooooooooooooooongFunction(); 1416 1.1 joerg 1417 1.1 joerg bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + 1418 1.1 joerg aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == 1419 1.1 joerg aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && 1420 1.1 joerg aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > 1421 1.1 joerg ccccccccccccccccccccccccccccccccccccccccc; 1422 1.1 joerg 1423 1.1 joerg * ``BOS_NonAssignment`` (in configuration: ``NonAssignment``) 1424 1.1 joerg Break before operators that aren't assignments. 1425 1.1 joerg 1426 1.1 joerg .. code-block:: c++ 1427 1.1 joerg 1428 1.1 joerg LooooooooooongType loooooooooooooooooooooongVariable = 1429 1.1 joerg someLooooooooooooooooongFunction(); 1430 1.1 joerg 1431 1.1 joerg bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1432 1.1 joerg + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1433 1.1 joerg == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1434 1.1 joerg && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1435 1.1 joerg > ccccccccccccccccccccccccccccccccccccccccc; 1436 1.1 joerg 1437 1.1 joerg * ``BOS_All`` (in configuration: ``All``) 1438 1.1 joerg Break before operators. 1439 1.1 joerg 1440 1.1 joerg .. code-block:: c++ 1441 1.1 joerg 1442 1.1 joerg LooooooooooongType loooooooooooooooooooooongVariable 1443 1.1 joerg = someLooooooooooooooooongFunction(); 1444 1.1 joerg 1445 1.1 joerg bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1446 1.1 joerg + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1447 1.1 joerg == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1448 1.1 joerg && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1449 1.1 joerg > ccccccccccccccccccccccccccccccccccccccccc; 1450 1.1 joerg 1451 1.1 joerg 1452 1.1 joerg 1453 1.1 joerg **BreakBeforeBraces** (``BraceBreakingStyle``) 1454 1.1 joerg The brace breaking style to use. 1455 1.1 joerg 1456 1.1 joerg Possible values: 1457 1.1 joerg 1458 1.1 joerg * ``BS_Attach`` (in configuration: ``Attach``) 1459 1.1 joerg Always attach braces to surrounding context. 1460 1.1 joerg 1461 1.1 joerg .. code-block:: c++ 1462 1.1 joerg 1463 1.1.1.2 joerg namespace N { 1464 1.1.1.2 joerg enum E { 1465 1.1.1.2 joerg E1, 1466 1.1.1.2 joerg E2, 1467 1.1.1.2 joerg }; 1468 1.1.1.2 joerg 1469 1.1.1.2 joerg class C { 1470 1.1.1.2 joerg public: 1471 1.1.1.2 joerg C(); 1472 1.1.1.2 joerg }; 1473 1.1.1.2 joerg 1474 1.1.1.2 joerg bool baz(int i) { 1475 1.1.1.2 joerg try { 1476 1.1.1.2 joerg do { 1477 1.1.1.2 joerg switch (i) { 1478 1.1.1.2 joerg case 1: { 1479 1.1.1.2 joerg foobar(); 1480 1.1.1.2 joerg break; 1481 1.1.1.2 joerg } 1482 1.1.1.2 joerg default: { 1483 1.1.1.2 joerg break; 1484 1.1.1.2 joerg } 1485 1.1.1.2 joerg } 1486 1.1.1.2 joerg } while (--i); 1487 1.1.1.2 joerg return true; 1488 1.1.1.2 joerg } catch (...) { 1489 1.1.1.2 joerg handleError(); 1490 1.1.1.2 joerg return false; 1491 1.1.1.2 joerg } 1492 1.1 joerg } 1493 1.1.1.2 joerg 1494 1.1.1.2 joerg void foo(bool b) { 1495 1.1.1.2 joerg if (b) { 1496 1.1.1.2 joerg baz(2); 1497 1.1.1.2 joerg } else { 1498 1.1.1.2 joerg baz(5); 1499 1.1.1.2 joerg } 1500 1.1 joerg } 1501 1.1.1.2 joerg 1502 1.1.1.2 joerg void bar() { foo(true); } 1503 1.1.1.2 joerg } // namespace N 1504 1.1 joerg 1505 1.1 joerg * ``BS_Linux`` (in configuration: ``Linux``) 1506 1.1 joerg Like ``Attach``, but break before braces on function, namespace and 1507 1.1 joerg class definitions. 1508 1.1 joerg 1509 1.1 joerg .. code-block:: c++ 1510 1.1 joerg 1511 1.1.1.2 joerg namespace N 1512 1.1 joerg { 1513 1.1.1.2 joerg enum E { 1514 1.1.1.2 joerg E1, 1515 1.1.1.2 joerg E2, 1516 1.1 joerg }; 1517 1.1.1.2 joerg 1518 1.1.1.2 joerg class C 1519 1.1.1.2 joerg { 1520 1.1.1.2 joerg public: 1521 1.1.1.2 joerg C(); 1522 1.1.1.2 joerg }; 1523 1.1.1.2 joerg 1524 1.1.1.2 joerg bool baz(int i) 1525 1.1.1.2 joerg { 1526 1.1.1.2 joerg try { 1527 1.1.1.2 joerg do { 1528 1.1.1.2 joerg switch (i) { 1529 1.1.1.2 joerg case 1: { 1530 1.1.1.2 joerg foobar(); 1531 1.1.1.2 joerg break; 1532 1.1.1.2 joerg } 1533 1.1.1.2 joerg default: { 1534 1.1.1.2 joerg break; 1535 1.1.1.2 joerg } 1536 1.1.1.2 joerg } 1537 1.1.1.2 joerg } while (--i); 1538 1.1.1.2 joerg return true; 1539 1.1.1.2 joerg } catch (...) { 1540 1.1.1.2 joerg handleError(); 1541 1.1.1.2 joerg return false; 1542 1.1.1.2 joerg } 1543 1.1.1.2 joerg } 1544 1.1.1.2 joerg 1545 1.1.1.2 joerg void foo(bool b) 1546 1.1.1.2 joerg { 1547 1.1.1.2 joerg if (b) { 1548 1.1.1.2 joerg baz(2); 1549 1.1.1.2 joerg } else { 1550 1.1.1.2 joerg baz(5); 1551 1.1.1.2 joerg } 1552 1.1 joerg } 1553 1.1.1.2 joerg 1554 1.1.1.2 joerg void bar() { foo(true); } 1555 1.1.1.2 joerg } // namespace N 1556 1.1 joerg 1557 1.1 joerg * ``BS_Mozilla`` (in configuration: ``Mozilla``) 1558 1.1 joerg Like ``Attach``, but break before braces on enum, function, and record 1559 1.1 joerg definitions. 1560 1.1 joerg 1561 1.1 joerg .. code-block:: c++ 1562 1.1 joerg 1563 1.1.1.2 joerg namespace N { 1564 1.1.1.2 joerg enum E 1565 1.1 joerg { 1566 1.1.1.2 joerg E1, 1567 1.1.1.2 joerg E2, 1568 1.1 joerg }; 1569 1.1.1.2 joerg 1570 1.1.1.2 joerg class C 1571 1.1.1.2 joerg { 1572 1.1.1.2 joerg public: 1573 1.1.1.2 joerg C(); 1574 1.1.1.2 joerg }; 1575 1.1.1.2 joerg 1576 1.1.1.2 joerg bool baz(int i) 1577 1.1.1.2 joerg { 1578 1.1.1.2 joerg try { 1579 1.1.1.2 joerg do { 1580 1.1.1.2 joerg switch (i) { 1581 1.1.1.2 joerg case 1: { 1582 1.1.1.2 joerg foobar(); 1583 1.1.1.2 joerg break; 1584 1.1.1.2 joerg } 1585 1.1.1.2 joerg default: { 1586 1.1.1.2 joerg break; 1587 1.1.1.2 joerg } 1588 1.1.1.2 joerg } 1589 1.1.1.2 joerg } while (--i); 1590 1.1.1.2 joerg return true; 1591 1.1.1.2 joerg } catch (...) { 1592 1.1.1.2 joerg handleError(); 1593 1.1.1.2 joerg return false; 1594 1.1.1.2 joerg } 1595 1.1 joerg } 1596 1.1.1.2 joerg 1597 1.1.1.2 joerg void foo(bool b) 1598 1.1.1.2 joerg { 1599 1.1.1.2 joerg if (b) { 1600 1.1.1.2 joerg baz(2); 1601 1.1.1.2 joerg } else { 1602 1.1.1.2 joerg baz(5); 1603 1.1.1.2 joerg } 1604 1.1.1.2 joerg } 1605 1.1.1.2 joerg 1606 1.1.1.2 joerg void bar() { foo(true); } 1607 1.1.1.2 joerg } // namespace N 1608 1.1 joerg 1609 1.1 joerg * ``BS_Stroustrup`` (in configuration: ``Stroustrup``) 1610 1.1 joerg Like ``Attach``, but break before function definitions, ``catch``, and 1611 1.1 joerg ``else``. 1612 1.1 joerg 1613 1.1 joerg .. code-block:: c++ 1614 1.1 joerg 1615 1.1.1.2 joerg namespace N { 1616 1.1.1.2 joerg enum E { 1617 1.1.1.2 joerg E1, 1618 1.1.1.2 joerg E2, 1619 1.1 joerg }; 1620 1.1.1.2 joerg 1621 1.1.1.2 joerg class C { 1622 1.1.1.2 joerg public: 1623 1.1.1.2 joerg C(); 1624 1.1.1.2 joerg }; 1625 1.1.1.2 joerg 1626 1.1.1.2 joerg bool baz(int i) 1627 1.1.1.2 joerg { 1628 1.1.1.2 joerg try { 1629 1.1.1.2 joerg do { 1630 1.1.1.2 joerg switch (i) { 1631 1.1.1.2 joerg case 1: { 1632 1.1.1.2 joerg foobar(); 1633 1.1.1.2 joerg break; 1634 1.1.1.2 joerg } 1635 1.1.1.2 joerg default: { 1636 1.1.1.2 joerg break; 1637 1.1.1.2 joerg } 1638 1.1.1.2 joerg } 1639 1.1.1.2 joerg } while (--i); 1640 1.1.1.2 joerg return true; 1641 1.1.1.2 joerg } 1642 1.1.1.2 joerg catch (...) { 1643 1.1.1.2 joerg handleError(); 1644 1.1.1.2 joerg return false; 1645 1.1.1.2 joerg } 1646 1.1 joerg } 1647 1.1.1.2 joerg 1648 1.1.1.2 joerg void foo(bool b) 1649 1.1.1.2 joerg { 1650 1.1.1.2 joerg if (b) { 1651 1.1.1.2 joerg baz(2); 1652 1.1.1.2 joerg } 1653 1.1.1.2 joerg else { 1654 1.1.1.2 joerg baz(5); 1655 1.1.1.2 joerg } 1656 1.1 joerg } 1657 1.1.1.2 joerg 1658 1.1.1.2 joerg void bar() { foo(true); } 1659 1.1.1.2 joerg } // namespace N 1660 1.1 joerg 1661 1.1 joerg * ``BS_Allman`` (in configuration: ``Allman``) 1662 1.1 joerg Always break before braces. 1663 1.1 joerg 1664 1.1 joerg .. code-block:: c++ 1665 1.1 joerg 1666 1.1.1.2 joerg namespace N 1667 1.1 joerg { 1668 1.1.1.2 joerg enum E 1669 1.1 joerg { 1670 1.1.1.2 joerg E1, 1671 1.1.1.2 joerg E2, 1672 1.1.1.2 joerg }; 1673 1.1.1.2 joerg 1674 1.1.1.2 joerg class C 1675 1.1 joerg { 1676 1.1.1.2 joerg public: 1677 1.1.1.2 joerg C(); 1678 1.1 joerg }; 1679 1.1.1.2 joerg 1680 1.1.1.2 joerg bool baz(int i) 1681 1.1 joerg { 1682 1.1.1.2 joerg try 1683 1.1.1.2 joerg { 1684 1.1.1.2 joerg do 1685 1.1.1.2 joerg { 1686 1.1.1.2 joerg switch (i) 1687 1.1.1.2 joerg { 1688 1.1.1.2 joerg case 1: 1689 1.1.1.2 joerg { 1690 1.1.1.2 joerg foobar(); 1691 1.1.1.2 joerg break; 1692 1.1.1.2 joerg } 1693 1.1.1.2 joerg default: 1694 1.1.1.2 joerg { 1695 1.1.1.2 joerg break; 1696 1.1.1.2 joerg } 1697 1.1.1.2 joerg } 1698 1.1.1.2 joerg } while (--i); 1699 1.1.1.2 joerg return true; 1700 1.1.1.2 joerg } 1701 1.1.1.2 joerg catch (...) 1702 1.1.1.2 joerg { 1703 1.1.1.2 joerg handleError(); 1704 1.1.1.2 joerg return false; 1705 1.1.1.2 joerg } 1706 1.1 joerg } 1707 1.1.1.2 joerg 1708 1.1.1.2 joerg void foo(bool b) 1709 1.1 joerg { 1710 1.1.1.2 joerg if (b) 1711 1.1.1.2 joerg { 1712 1.1.1.2 joerg baz(2); 1713 1.1.1.2 joerg } 1714 1.1.1.2 joerg else 1715 1.1.1.2 joerg { 1716 1.1.1.2 joerg baz(5); 1717 1.1.1.2 joerg } 1718 1.1 joerg } 1719 1.1.1.2 joerg 1720 1.1.1.2 joerg void bar() { foo(true); } 1721 1.1.1.2 joerg } // namespace N 1722 1.1 joerg 1723 1.1 joerg * ``BS_Whitesmiths`` (in configuration: ``Whitesmiths``) 1724 1.1 joerg Like ``Allman`` but always indent braces and line up code with braces. 1725 1.1 joerg 1726 1.1 joerg .. code-block:: c++ 1727 1.1 joerg 1728 1.1.1.2 joerg namespace N 1729 1.1 joerg { 1730 1.1.1.2 joerg enum E 1731 1.1 joerg { 1732 1.1.1.2 joerg E1, 1733 1.1.1.2 joerg E2, 1734 1.1.1.2 joerg }; 1735 1.1.1.2 joerg 1736 1.1.1.2 joerg class C 1737 1.1 joerg { 1738 1.1.1.2 joerg public: 1739 1.1.1.2 joerg C(); 1740 1.1 joerg }; 1741 1.1.1.2 joerg 1742 1.1.1.2 joerg bool baz(int i) 1743 1.1 joerg { 1744 1.1.1.2 joerg try 1745 1.1.1.2 joerg { 1746 1.1.1.2 joerg do 1747 1.1.1.2 joerg { 1748 1.1.1.2 joerg switch (i) 1749 1.1.1.2 joerg { 1750 1.1.1.2 joerg case 1: 1751 1.1.1.2 joerg { 1752 1.1.1.2 joerg foobar(); 1753 1.1.1.2 joerg break; 1754 1.1.1.2 joerg } 1755 1.1.1.2 joerg default: 1756 1.1.1.2 joerg { 1757 1.1.1.2 joerg break; 1758 1.1.1.2 joerg } 1759 1.1.1.2 joerg } 1760 1.1.1.2 joerg } while (--i); 1761 1.1.1.2 joerg return true; 1762 1.1.1.2 joerg } 1763 1.1.1.2 joerg catch (...) 1764 1.1.1.2 joerg { 1765 1.1.1.2 joerg handleError(); 1766 1.1.1.2 joerg return false; 1767 1.1.1.2 joerg } 1768 1.1 joerg } 1769 1.1.1.2 joerg 1770 1.1.1.2 joerg void foo(bool b) 1771 1.1 joerg { 1772 1.1.1.2 joerg if (b) 1773 1.1.1.2 joerg { 1774 1.1.1.2 joerg baz(2); 1775 1.1.1.2 joerg } 1776 1.1.1.2 joerg else 1777 1.1.1.2 joerg { 1778 1.1.1.2 joerg baz(5); 1779 1.1.1.2 joerg } 1780 1.1 joerg } 1781 1.1.1.2 joerg 1782 1.1.1.2 joerg void bar() { foo(true); } 1783 1.1.1.2 joerg } // namespace N 1784 1.1 joerg 1785 1.1 joerg * ``BS_GNU`` (in configuration: ``GNU``) 1786 1.1 joerg Always break before braces and add an extra level of indentation to 1787 1.1 joerg braces of control statements, not to those of class, function 1788 1.1 joerg or other definitions. 1789 1.1 joerg 1790 1.1 joerg .. code-block:: c++ 1791 1.1.1.2 joerg 1792 1.1.1.2 joerg namespace N 1793 1.1 joerg { 1794 1.1.1.2 joerg enum E 1795 1.1.1.2 joerg { 1796 1.1.1.2 joerg E1, 1797 1.1.1.2 joerg E2, 1798 1.1.1.2 joerg }; 1799 1.1.1.2 joerg 1800 1.1.1.2 joerg class C 1801 1.1.1.2 joerg { 1802 1.1.1.2 joerg public: 1803 1.1.1.2 joerg C(); 1804 1.1 joerg }; 1805 1.1 joerg 1806 1.1.1.2 joerg bool baz(int i) 1807 1.1.1.2 joerg { 1808 1.1.1.2 joerg try 1809 1.1.1.2 joerg { 1810 1.1.1.2 joerg do 1811 1.1.1.2 joerg { 1812 1.1.1.2 joerg switch (i) 1813 1.1.1.2 joerg { 1814 1.1.1.2 joerg case 1: 1815 1.1.1.2 joerg { 1816 1.1.1.2 joerg foobar(); 1817 1.1.1.2 joerg break; 1818 1.1.1.2 joerg } 1819 1.1.1.2 joerg default: 1820 1.1.1.2 joerg { 1821 1.1.1.2 joerg break; 1822 1.1.1.2 joerg } 1823 1.1.1.2 joerg } 1824 1.1.1.2 joerg } 1825 1.1.1.2 joerg while (--i); 1826 1.1.1.2 joerg return true; 1827 1.1.1.2 joerg } 1828 1.1.1.2 joerg catch (...) 1829 1.1.1.2 joerg { 1830 1.1.1.2 joerg handleError(); 1831 1.1.1.2 joerg return false; 1832 1.1.1.2 joerg } 1833 1.1.1.2 joerg } 1834 1.1.1.2 joerg 1835 1.1.1.2 joerg void foo(bool b) 1836 1.1.1.2 joerg { 1837 1.1.1.2 joerg if (b) 1838 1.1.1.2 joerg { 1839 1.1.1.2 joerg baz(2); 1840 1.1.1.2 joerg } 1841 1.1.1.2 joerg else 1842 1.1.1.2 joerg { 1843 1.1.1.2 joerg baz(5); 1844 1.1.1.2 joerg } 1845 1.1.1.2 joerg } 1846 1.1.1.2 joerg 1847 1.1.1.2 joerg void bar() { foo(true); } 1848 1.1.1.2 joerg } // namespace N 1849 1.1.1.2 joerg 1850 1.1 joerg * ``BS_WebKit`` (in configuration: ``WebKit``) 1851 1.1 joerg Like ``Attach``, but break before functions. 1852 1.1 joerg 1853 1.1 joerg .. code-block:: c++ 1854 1.1 joerg 1855 1.1.1.2 joerg namespace N { 1856 1.1.1.2 joerg enum E { 1857 1.1.1.2 joerg E1, 1858 1.1.1.2 joerg E2, 1859 1.1 joerg }; 1860 1.1.1.2 joerg 1861 1.1.1.2 joerg class C { 1862 1.1.1.2 joerg public: 1863 1.1.1.2 joerg C(); 1864 1.1.1.2 joerg }; 1865 1.1.1.2 joerg 1866 1.1.1.2 joerg bool baz(int i) 1867 1.1.1.2 joerg { 1868 1.1.1.2 joerg try { 1869 1.1.1.2 joerg do { 1870 1.1.1.2 joerg switch (i) { 1871 1.1.1.2 joerg case 1: { 1872 1.1.1.2 joerg foobar(); 1873 1.1.1.2 joerg break; 1874 1.1.1.2 joerg } 1875 1.1.1.2 joerg default: { 1876 1.1.1.2 joerg break; 1877 1.1.1.2 joerg } 1878 1.1.1.2 joerg } 1879 1.1.1.2 joerg } while (--i); 1880 1.1.1.2 joerg return true; 1881 1.1.1.2 joerg } catch (...) { 1882 1.1.1.2 joerg handleError(); 1883 1.1.1.2 joerg return false; 1884 1.1.1.2 joerg } 1885 1.1.1.2 joerg } 1886 1.1.1.2 joerg 1887 1.1.1.2 joerg void foo(bool b) 1888 1.1.1.2 joerg { 1889 1.1.1.2 joerg if (b) { 1890 1.1.1.2 joerg baz(2); 1891 1.1.1.2 joerg } else { 1892 1.1.1.2 joerg baz(5); 1893 1.1.1.2 joerg } 1894 1.1 joerg } 1895 1.1.1.2 joerg 1896 1.1.1.2 joerg void bar() { foo(true); } 1897 1.1.1.2 joerg } // namespace N 1898 1.1 joerg 1899 1.1 joerg * ``BS_Custom`` (in configuration: ``Custom``) 1900 1.1 joerg Configure each individual brace in `BraceWrapping`. 1901 1.1 joerg 1902 1.1 joerg 1903 1.1 joerg 1904 1.1.1.2 joerg **BreakBeforeConceptDeclarations** (``bool``) 1905 1.1.1.2 joerg If ``true``, concept will be placed on a new line. 1906 1.1.1.2 joerg 1907 1.1.1.2 joerg .. code-block:: c++ 1908 1.1.1.2 joerg 1909 1.1.1.2 joerg true: 1910 1.1.1.2 joerg template<typename T> 1911 1.1.1.2 joerg concept ... 1912 1.1.1.2 joerg 1913 1.1.1.2 joerg false: 1914 1.1.1.2 joerg template<typename T> concept ... 1915 1.1.1.2 joerg 1916 1.1 joerg **BreakBeforeTernaryOperators** (``bool``) 1917 1.1 joerg If ``true``, ternary operators will be placed after line breaks. 1918 1.1 joerg 1919 1.1 joerg .. code-block:: c++ 1920 1.1 joerg 1921 1.1 joerg true: 1922 1.1 joerg veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription 1923 1.1 joerg ? firstValue 1924 1.1 joerg : SecondValueVeryVeryVeryVeryLong; 1925 1.1 joerg 1926 1.1 joerg false: 1927 1.1 joerg veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ? 1928 1.1 joerg firstValue : 1929 1.1 joerg SecondValueVeryVeryVeryVeryLong; 1930 1.1 joerg 1931 1.1 joerg **BreakConstructorInitializers** (``BreakConstructorInitializersStyle``) 1932 1.1 joerg The constructor initializers style to use. 1933 1.1 joerg 1934 1.1 joerg Possible values: 1935 1.1 joerg 1936 1.1 joerg * ``BCIS_BeforeColon`` (in configuration: ``BeforeColon``) 1937 1.1 joerg Break constructor initializers before the colon and after the commas. 1938 1.1 joerg 1939 1.1 joerg .. code-block:: c++ 1940 1.1 joerg 1941 1.1 joerg Constructor() 1942 1.1 joerg : initializer1(), 1943 1.1 joerg initializer2() 1944 1.1 joerg 1945 1.1 joerg * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``) 1946 1.1 joerg Break constructor initializers before the colon and commas, and align 1947 1.1 joerg the commas with the colon. 1948 1.1 joerg 1949 1.1 joerg .. code-block:: c++ 1950 1.1 joerg 1951 1.1 joerg Constructor() 1952 1.1 joerg : initializer1() 1953 1.1 joerg , initializer2() 1954 1.1 joerg 1955 1.1 joerg * ``BCIS_AfterColon`` (in configuration: ``AfterColon``) 1956 1.1 joerg Break constructor initializers after the colon and commas. 1957 1.1 joerg 1958 1.1 joerg .. code-block:: c++ 1959 1.1 joerg 1960 1.1 joerg Constructor() : 1961 1.1 joerg initializer1(), 1962 1.1 joerg initializer2() 1963 1.1 joerg 1964 1.1 joerg 1965 1.1 joerg 1966 1.1 joerg **BreakInheritanceList** (``BreakInheritanceListStyle``) 1967 1.1 joerg The inheritance list style to use. 1968 1.1 joerg 1969 1.1 joerg Possible values: 1970 1.1 joerg 1971 1.1 joerg * ``BILS_BeforeColon`` (in configuration: ``BeforeColon``) 1972 1.1 joerg Break inheritance list before the colon and after the commas. 1973 1.1 joerg 1974 1.1 joerg .. code-block:: c++ 1975 1.1 joerg 1976 1.1 joerg class Foo 1977 1.1 joerg : Base1, 1978 1.1 joerg Base2 1979 1.1 joerg {}; 1980 1.1 joerg 1981 1.1 joerg * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``) 1982 1.1 joerg Break inheritance list before the colon and commas, and align 1983 1.1 joerg the commas with the colon. 1984 1.1 joerg 1985 1.1 joerg .. code-block:: c++ 1986 1.1 joerg 1987 1.1 joerg class Foo 1988 1.1 joerg : Base1 1989 1.1 joerg , Base2 1990 1.1 joerg {}; 1991 1.1 joerg 1992 1.1 joerg * ``BILS_AfterColon`` (in configuration: ``AfterColon``) 1993 1.1 joerg Break inheritance list after the colon and commas. 1994 1.1 joerg 1995 1.1 joerg .. code-block:: c++ 1996 1.1 joerg 1997 1.1 joerg class Foo : 1998 1.1 joerg Base1, 1999 1.1 joerg Base2 2000 1.1 joerg {}; 2001 1.1 joerg 2002 1.1 joerg 2003 1.1 joerg 2004 1.1 joerg **BreakStringLiterals** (``bool``) 2005 1.1 joerg Allow breaking string literals when formatting. 2006 1.1 joerg 2007 1.1 joerg .. code-block:: c++ 2008 1.1 joerg 2009 1.1 joerg true: 2010 1.1 joerg const char* x = "veryVeryVeryVeryVeryVe" 2011 1.1 joerg "ryVeryVeryVeryVeryVery" 2012 1.1 joerg "VeryLongString"; 2013 1.1 joerg 2014 1.1 joerg false: 2015 1.1 joerg const char* x = 2016 1.1 joerg "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString"; 2017 1.1 joerg 2018 1.1 joerg **ColumnLimit** (``unsigned``) 2019 1.1 joerg The column limit. 2020 1.1 joerg 2021 1.1 joerg A column limit of ``0`` means that there is no column limit. In this case, 2022 1.1 joerg clang-format will respect the input's line breaking decisions within 2023 1.1 joerg statements unless they contradict other rules. 2024 1.1 joerg 2025 1.1 joerg **CommentPragmas** (``std::string``) 2026 1.1 joerg A regular expression that describes comments with special meaning, 2027 1.1 joerg which should not be split into lines or otherwise changed. 2028 1.1 joerg 2029 1.1 joerg .. code-block:: c++ 2030 1.1 joerg 2031 1.1 joerg // CommentPragmas: '^ FOOBAR pragma:' 2032 1.1 joerg // Will leave the following line unaffected 2033 1.1 joerg #include <vector> // FOOBAR pragma: keep 2034 1.1 joerg 2035 1.1 joerg **CompactNamespaces** (``bool``) 2036 1.1 joerg If ``true``, consecutive namespace declarations will be on the same 2037 1.1 joerg line. If ``false``, each namespace is declared on a new line. 2038 1.1 joerg 2039 1.1 joerg .. code-block:: c++ 2040 1.1 joerg 2041 1.1 joerg true: 2042 1.1 joerg namespace Foo { namespace Bar { 2043 1.1 joerg }} 2044 1.1 joerg 2045 1.1 joerg false: 2046 1.1 joerg namespace Foo { 2047 1.1 joerg namespace Bar { 2048 1.1 joerg } 2049 1.1 joerg } 2050 1.1 joerg 2051 1.1 joerg If it does not fit on a single line, the overflowing namespaces get 2052 1.1 joerg wrapped: 2053 1.1 joerg 2054 1.1 joerg .. code-block:: c++ 2055 1.1 joerg 2056 1.1 joerg namespace Foo { namespace Bar { 2057 1.1 joerg namespace Extra { 2058 1.1 joerg }}} 2059 1.1 joerg 2060 1.1 joerg **ConstructorInitializerAllOnOneLineOrOnePerLine** (``bool``) 2061 1.1 joerg If the constructor initializers don't fit on a line, put each 2062 1.1 joerg initializer on its own line. 2063 1.1 joerg 2064 1.1 joerg .. code-block:: c++ 2065 1.1 joerg 2066 1.1 joerg true: 2067 1.1 joerg SomeClass::Constructor() 2068 1.1 joerg : aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa) { 2069 1.1 joerg return 0; 2070 1.1 joerg } 2071 1.1 joerg 2072 1.1 joerg false: 2073 1.1 joerg SomeClass::Constructor() 2074 1.1 joerg : aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaa), 2075 1.1 joerg aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa) { 2076 1.1 joerg return 0; 2077 1.1 joerg } 2078 1.1 joerg 2079 1.1 joerg **ConstructorInitializerIndentWidth** (``unsigned``) 2080 1.1 joerg The number of characters to use for indentation of constructor 2081 1.1 joerg initializer lists as well as inheritance lists. 2082 1.1 joerg 2083 1.1 joerg **ContinuationIndentWidth** (``unsigned``) 2084 1.1 joerg Indent width for line continuations. 2085 1.1 joerg 2086 1.1 joerg .. code-block:: c++ 2087 1.1 joerg 2088 1.1 joerg ContinuationIndentWidth: 2 2089 1.1 joerg 2090 1.1 joerg int i = // VeryVeryVeryVeryVeryLongComment 2091 1.1 joerg longFunction( // Again a long comment 2092 1.1 joerg arg); 2093 1.1 joerg 2094 1.1 joerg **Cpp11BracedListStyle** (``bool``) 2095 1.1 joerg If ``true``, format braced lists as best suited for C++11 braced 2096 1.1 joerg lists. 2097 1.1 joerg 2098 1.1 joerg Important differences: 2099 1.1 joerg - No spaces inside the braced list. 2100 1.1 joerg - No line break before the closing brace. 2101 1.1 joerg - Indentation with the continuation indent, not with the block indent. 2102 1.1 joerg 2103 1.1 joerg Fundamentally, C++11 braced lists are formatted exactly like function 2104 1.1 joerg calls would be formatted in their place. If the braced list follows a name 2105 1.1 joerg (e.g. a type or variable name), clang-format formats as if the ``{}`` were 2106 1.1 joerg the parentheses of a function call with that name. If there is no name, 2107 1.1 joerg a zero-length name is assumed. 2108 1.1 joerg 2109 1.1 joerg .. code-block:: c++ 2110 1.1 joerg 2111 1.1 joerg true: false: 2112 1.1 joerg vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 }; 2113 1.1 joerg vector<T> x{{}, {}, {}, {}}; vector<T> x{ {}, {}, {}, {} }; 2114 1.1 joerg f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]); 2115 1.1 joerg new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 }; 2116 1.1 joerg 2117 1.1.1.2 joerg **DeriveLineEnding** (``bool``) 2118 1.1.1.2 joerg Analyze the formatted file for the most used line ending (``\r\n`` 2119 1.1.1.2 joerg or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived. 2120 1.1.1.2 joerg 2121 1.1 joerg **DerivePointerAlignment** (``bool``) 2122 1.1 joerg If ``true``, analyze the formatted file for the most common 2123 1.1 joerg alignment of ``&`` and ``*``. 2124 1.1 joerg Pointer and reference alignment styles are going to be updated according 2125 1.1 joerg to the preferences found in the file. 2126 1.1 joerg ``PointerAlignment`` is then used only as fallback. 2127 1.1 joerg 2128 1.1 joerg **DisableFormat** (``bool``) 2129 1.1 joerg Disables formatting completely. 2130 1.1 joerg 2131 1.1.1.2 joerg **EmptyLineAfterAccessModifier** (``EmptyLineAfterAccessModifierStyle``) 2132 1.1.1.2 joerg Defines when to put an empty line after access modifiers. 2133 1.1.1.2 joerg ``EmptyLineBeforeAccessModifier`` configuration handles the number of 2134 1.1.1.2 joerg empty lines between two access modifiers. 2135 1.1.1.2 joerg 2136 1.1.1.2 joerg Possible values: 2137 1.1.1.2 joerg 2138 1.1.1.2 joerg * ``ELAAMS_Never`` (in configuration: ``Never``) 2139 1.1.1.2 joerg Remove all empty lines after access modifiers. 2140 1.1.1.2 joerg 2141 1.1.1.2 joerg .. code-block:: c++ 2142 1.1.1.2 joerg 2143 1.1.1.2 joerg struct foo { 2144 1.1.1.2 joerg private: 2145 1.1.1.2 joerg int i; 2146 1.1.1.2 joerg protected: 2147 1.1.1.2 joerg int j; 2148 1.1.1.2 joerg /* comment */ 2149 1.1.1.2 joerg public: 2150 1.1.1.2 joerg foo() {} 2151 1.1.1.2 joerg private: 2152 1.1.1.2 joerg protected: 2153 1.1.1.2 joerg }; 2154 1.1.1.2 joerg 2155 1.1.1.2 joerg * ``ELAAMS_Leave`` (in configuration: ``Leave``) 2156 1.1.1.2 joerg Keep existing empty lines after access modifiers. 2157 1.1.1.2 joerg MaxEmptyLinesToKeep is applied instead. 2158 1.1.1.2 joerg 2159 1.1.1.2 joerg * ``ELAAMS_Always`` (in configuration: ``Always``) 2160 1.1.1.2 joerg Always add empty line after access modifiers if there are none. 2161 1.1.1.2 joerg MaxEmptyLinesToKeep is applied also. 2162 1.1.1.2 joerg 2163 1.1.1.2 joerg .. code-block:: c++ 2164 1.1.1.2 joerg 2165 1.1.1.2 joerg struct foo { 2166 1.1.1.2 joerg private: 2167 1.1.1.2 joerg 2168 1.1.1.2 joerg int i; 2169 1.1.1.2 joerg protected: 2170 1.1.1.2 joerg 2171 1.1.1.2 joerg int j; 2172 1.1.1.2 joerg /* comment */ 2173 1.1.1.2 joerg public: 2174 1.1.1.2 joerg 2175 1.1.1.2 joerg foo() {} 2176 1.1.1.2 joerg private: 2177 1.1.1.2 joerg 2178 1.1.1.2 joerg protected: 2179 1.1.1.2 joerg }; 2180 1.1.1.2 joerg 2181 1.1.1.2 joerg **EmptyLineBeforeAccessModifier** (``EmptyLineBeforeAccessModifierStyle``) 2182 1.1.1.2 joerg Defines in which cases to put empty line before access modifiers. 2183 1.1.1.2 joerg 2184 1.1.1.2 joerg Possible values: 2185 1.1.1.2 joerg 2186 1.1.1.2 joerg * ``ELBAMS_Never`` (in configuration: ``Never``) 2187 1.1.1.2 joerg Remove all empty lines before access modifiers. 2188 1.1.1.2 joerg 2189 1.1.1.2 joerg .. code-block:: c++ 2190 1.1.1.2 joerg 2191 1.1.1.2 joerg struct foo { 2192 1.1.1.2 joerg private: 2193 1.1.1.2 joerg int i; 2194 1.1.1.2 joerg protected: 2195 1.1.1.2 joerg int j; 2196 1.1.1.2 joerg /* comment */ 2197 1.1.1.2 joerg public: 2198 1.1.1.2 joerg foo() {} 2199 1.1.1.2 joerg private: 2200 1.1.1.2 joerg protected: 2201 1.1.1.2 joerg }; 2202 1.1.1.2 joerg 2203 1.1.1.2 joerg * ``ELBAMS_Leave`` (in configuration: ``Leave``) 2204 1.1.1.2 joerg Keep existing empty lines before access modifiers. 2205 1.1.1.2 joerg 2206 1.1.1.2 joerg * ``ELBAMS_LogicalBlock`` (in configuration: ``LogicalBlock``) 2207 1.1.1.2 joerg Add empty line only when access modifier starts a new logical block. 2208 1.1.1.2 joerg Logical block is a group of one or more member fields or functions. 2209 1.1.1.2 joerg 2210 1.1.1.2 joerg .. code-block:: c++ 2211 1.1.1.2 joerg 2212 1.1.1.2 joerg struct foo { 2213 1.1.1.2 joerg private: 2214 1.1.1.2 joerg int i; 2215 1.1.1.2 joerg 2216 1.1.1.2 joerg protected: 2217 1.1.1.2 joerg int j; 2218 1.1.1.2 joerg /* comment */ 2219 1.1.1.2 joerg public: 2220 1.1.1.2 joerg foo() {} 2221 1.1.1.2 joerg 2222 1.1.1.2 joerg private: 2223 1.1.1.2 joerg protected: 2224 1.1.1.2 joerg }; 2225 1.1.1.2 joerg 2226 1.1.1.2 joerg * ``ELBAMS_Always`` (in configuration: ``Always``) 2227 1.1.1.2 joerg Always add empty line before access modifiers unless access modifier 2228 1.1.1.2 joerg is at the start of struct or class definition. 2229 1.1.1.2 joerg 2230 1.1.1.2 joerg .. code-block:: c++ 2231 1.1.1.2 joerg 2232 1.1.1.2 joerg struct foo { 2233 1.1.1.2 joerg private: 2234 1.1.1.2 joerg int i; 2235 1.1.1.2 joerg 2236 1.1.1.2 joerg protected: 2237 1.1.1.2 joerg int j; 2238 1.1.1.2 joerg /* comment */ 2239 1.1.1.2 joerg 2240 1.1.1.2 joerg public: 2241 1.1.1.2 joerg foo() {} 2242 1.1.1.2 joerg 2243 1.1.1.2 joerg private: 2244 1.1.1.2 joerg 2245 1.1.1.2 joerg protected: 2246 1.1.1.2 joerg }; 2247 1.1.1.2 joerg 2248 1.1 joerg **ExperimentalAutoDetectBinPacking** (``bool``) 2249 1.1 joerg If ``true``, clang-format detects whether function calls and 2250 1.1 joerg definitions are formatted with one parameter per line. 2251 1.1 joerg 2252 1.1 joerg Each call can be bin-packed, one-per-line or inconclusive. If it is 2253 1.1 joerg inconclusive, e.g. completely on one line, but a decision needs to be 2254 1.1 joerg made, clang-format analyzes whether there are other bin-packed cases in 2255 1.1 joerg the input file and act accordingly. 2256 1.1 joerg 2257 1.1 joerg NOTE: This is an experimental flag, that might go away or be renamed. Do 2258 1.1 joerg not use this in config files, etc. Use at your own risk. 2259 1.1 joerg 2260 1.1 joerg **FixNamespaceComments** (``bool``) 2261 1.1.1.2 joerg If ``true``, clang-format adds missing namespace end comments for 2262 1.1.1.2 joerg short namespaces and fixes invalid existing ones. Short ones are 2263 1.1.1.2 joerg controlled by "ShortNamespaceLines". 2264 1.1 joerg 2265 1.1 joerg .. code-block:: c++ 2266 1.1 joerg 2267 1.1 joerg true: false: 2268 1.1 joerg namespace a { vs. namespace a { 2269 1.1 joerg foo(); foo(); 2270 1.1.1.2 joerg bar(); bar(); 2271 1.1 joerg } // namespace a } 2272 1.1 joerg 2273 1.1 joerg **ForEachMacros** (``std::vector<std::string>``) 2274 1.1 joerg A vector of macros that should be interpreted as foreach loops 2275 1.1 joerg instead of as function calls. 2276 1.1 joerg 2277 1.1 joerg These are expected to be macros of the form: 2278 1.1 joerg 2279 1.1 joerg .. code-block:: c++ 2280 1.1 joerg 2281 1.1 joerg FOREACH(<variable-declaration>, ...) 2282 1.1 joerg <loop-body> 2283 1.1 joerg 2284 1.1 joerg In the .clang-format configuration file, this can be configured like: 2285 1.1 joerg 2286 1.1 joerg .. code-block:: yaml 2287 1.1 joerg 2288 1.1 joerg ForEachMacros: ['RANGES_FOR', 'FOREACH'] 2289 1.1 joerg 2290 1.1 joerg For example: BOOST_FOREACH. 2291 1.1 joerg 2292 1.1 joerg **IncludeBlocks** (``IncludeBlocksStyle``) 2293 1.1 joerg Dependent on the value, multiple ``#include`` blocks can be sorted 2294 1.1 joerg as one and divided based on category. 2295 1.1 joerg 2296 1.1 joerg Possible values: 2297 1.1 joerg 2298 1.1 joerg * ``IBS_Preserve`` (in configuration: ``Preserve``) 2299 1.1 joerg Sort each ``#include`` block separately. 2300 1.1 joerg 2301 1.1 joerg .. code-block:: c++ 2302 1.1 joerg 2303 1.1 joerg #include "b.h" into #include "b.h" 2304 1.1 joerg 2305 1.1 joerg #include <lib/main.h> #include "a.h" 2306 1.1 joerg #include "a.h" #include <lib/main.h> 2307 1.1 joerg 2308 1.1 joerg * ``IBS_Merge`` (in configuration: ``Merge``) 2309 1.1 joerg Merge multiple ``#include`` blocks together and sort as one. 2310 1.1 joerg 2311 1.1 joerg .. code-block:: c++ 2312 1.1 joerg 2313 1.1 joerg #include "b.h" into #include "a.h" 2314 1.1 joerg #include "b.h" 2315 1.1 joerg #include <lib/main.h> #include <lib/main.h> 2316 1.1 joerg #include "a.h" 2317 1.1 joerg 2318 1.1 joerg * ``IBS_Regroup`` (in configuration: ``Regroup``) 2319 1.1 joerg Merge multiple ``#include`` blocks together and sort as one. 2320 1.1 joerg Then split into groups based on category priority. See 2321 1.1 joerg ``IncludeCategories``. 2322 1.1 joerg 2323 1.1 joerg .. code-block:: c++ 2324 1.1 joerg 2325 1.1 joerg #include "b.h" into #include "a.h" 2326 1.1 joerg #include "b.h" 2327 1.1 joerg #include <lib/main.h> 2328 1.1 joerg #include "a.h" #include <lib/main.h> 2329 1.1 joerg 2330 1.1 joerg 2331 1.1 joerg 2332 1.1 joerg **IncludeCategories** (``std::vector<IncludeCategory>``) 2333 1.1 joerg Regular expressions denoting the different ``#include`` categories 2334 1.1 joerg used for ordering ``#includes``. 2335 1.1 joerg 2336 1.1 joerg `POSIX extended 2337 1.1 joerg <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html>`_ 2338 1.1 joerg regular expressions are supported. 2339 1.1 joerg 2340 1.1 joerg These regular expressions are matched against the filename of an include 2341 1.1 joerg (including the <> or "") in order. The value belonging to the first 2342 1.1 joerg matching regular expression is assigned and ``#includes`` are sorted first 2343 1.1 joerg according to increasing category number and then alphabetically within 2344 1.1 joerg each category. 2345 1.1 joerg 2346 1.1 joerg If none of the regular expressions match, INT_MAX is assigned as 2347 1.1 joerg category. The main header for a source file automatically gets category 0. 2348 1.1 joerg so that it is generally kept at the beginning of the ``#includes`` 2349 1.1 joerg (https://llvm.org/docs/CodingStandards.html#include-style). However, you 2350 1.1 joerg can also assign negative priorities if you have certain headers that 2351 1.1 joerg always need to be first. 2352 1.1 joerg 2353 1.1 joerg There is a third and optional field ``SortPriority`` which can used while 2354 1.1.1.2 joerg ``IncludeBlocks = IBS_Regroup`` to define the priority in which 2355 1.1.1.2 joerg ``#includes`` should be ordered. The value of ``Priority`` defines the 2356 1.1.1.2 joerg order of ``#include blocks`` and also allows the grouping of ``#includes`` 2357 1.1.1.2 joerg of different priority. ``SortPriority`` is set to the value of 2358 1.1.1.2 joerg ``Priority`` as default if it is not assigned. 2359 1.1.1.2 joerg 2360 1.1.1.2 joerg Each regular expression can be marked as case sensitive with the field 2361 1.1.1.2 joerg ``CaseSensitive``, per default it is not. 2362 1.1 joerg 2363 1.1 joerg To configure this in the .clang-format file, use: 2364 1.1 joerg 2365 1.1 joerg .. code-block:: yaml 2366 1.1 joerg 2367 1.1 joerg IncludeCategories: 2368 1.1 joerg - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 2369 1.1 joerg Priority: 2 2370 1.1 joerg SortPriority: 2 2371 1.1.1.2 joerg CaseSensitive: true 2372 1.1 joerg - Regex: '^(<|"(gtest|gmock|isl|json)/)' 2373 1.1 joerg Priority: 3 2374 1.1 joerg - Regex: '<[[:alnum:].]+>' 2375 1.1 joerg Priority: 4 2376 1.1 joerg - Regex: '.*' 2377 1.1 joerg Priority: 1 2378 1.1 joerg SortPriority: 0 2379 1.1 joerg 2380 1.1 joerg **IncludeIsMainRegex** (``std::string``) 2381 1.1 joerg Specify a regular expression of suffixes that are allowed in the 2382 1.1 joerg file-to-main-include mapping. 2383 1.1 joerg 2384 1.1 joerg When guessing whether a #include is the "main" include (to assign 2385 1.1 joerg category 0, see above), use this regex of allowed suffixes to the header 2386 1.1 joerg stem. A partial match is done, so that: 2387 1.1 joerg - "" means "arbitrary suffix" 2388 1.1 joerg - "$" means "no suffix" 2389 1.1 joerg 2390 1.1 joerg For example, if configured to "(_test)?$", then a header a.h would be seen 2391 1.1 joerg as the "main" include in both a.cc and a_test.cc. 2392 1.1 joerg 2393 1.1.1.2 joerg **IncludeIsMainSourceRegex** (``std::string``) 2394 1.1.1.2 joerg Specify a regular expression for files being formatted 2395 1.1.1.2 joerg that are allowed to be considered "main" in the 2396 1.1.1.2 joerg file-to-main-include mapping. 2397 1.1.1.2 joerg 2398 1.1.1.2 joerg By default, clang-format considers files as "main" only when they end 2399 1.1.1.2 joerg with: ``.c``, ``.cc``, ``.cpp``, ``.c++``, ``.cxx``, ``.m`` or ``.mm`` 2400 1.1.1.2 joerg extensions. 2401 1.1.1.2 joerg For these files a guessing of "main" include takes place 2402 1.1.1.2 joerg (to assign category 0, see above). This config option allows for 2403 1.1.1.2 joerg additional suffixes and extensions for files to be considered as "main". 2404 1.1.1.2 joerg 2405 1.1.1.2 joerg For example, if this option is configured to ``(Impl\.hpp)$``, 2406 1.1.1.2 joerg then a file ``ClassImpl.hpp`` is considered "main" (in addition to 2407 1.1.1.2 joerg ``Class.c``, ``Class.cc``, ``Class.cpp`` and so on) and "main 2408 1.1.1.2 joerg include file" logic will be executed (with *IncludeIsMainRegex* setting 2409 1.1.1.2 joerg also being respected in later phase). Without this option set, 2410 1.1.1.2 joerg ``ClassImpl.hpp`` would not have the main include file put on top 2411 1.1.1.2 joerg before any other include. 2412 1.1.1.2 joerg 2413 1.1.1.2 joerg **IndentAccessModifiers** (``bool``) 2414 1.1.1.2 joerg Specify whether access modifiers should have their own indentation level. 2415 1.1.1.2 joerg 2416 1.1.1.2 joerg When ``false``, access modifiers are indented (or outdented) relative to 2417 1.1.1.2 joerg the record members, respecting the ``AccessModifierOffset``. Record 2418 1.1.1.2 joerg members are indented one level below the record. 2419 1.1.1.2 joerg When ``true``, access modifiers get their own indentation level. As a 2420 1.1.1.2 joerg consequence, record members are always indented 2 levels below the record, 2421 1.1.1.2 joerg regardless of the access modifier presence. Value of the 2422 1.1.1.2 joerg ``AccessModifierOffset`` is ignored. 2423 1.1.1.2 joerg 2424 1.1.1.2 joerg .. code-block:: c++ 2425 1.1.1.2 joerg 2426 1.1.1.2 joerg false: true: 2427 1.1.1.2 joerg class C { vs. class C { 2428 1.1.1.2 joerg class D { class D { 2429 1.1.1.2 joerg void bar(); void bar(); 2430 1.1.1.2 joerg protected: protected: 2431 1.1.1.2 joerg D(); D(); 2432 1.1.1.2 joerg }; }; 2433 1.1.1.2 joerg public: public: 2434 1.1.1.2 joerg C(); C(); 2435 1.1.1.2 joerg }; }; 2436 1.1.1.2 joerg void foo() { void foo() { 2437 1.1.1.2 joerg return 1; return 1; 2438 1.1.1.2 joerg } } 2439 1.1.1.2 joerg 2440 1.1.1.2 joerg **IndentCaseBlocks** (``bool``) 2441 1.1.1.2 joerg Indent case label blocks one level from the case label. 2442 1.1.1.2 joerg 2443 1.1.1.2 joerg When ``false``, the block following the case label uses the same 2444 1.1.1.2 joerg indentation level as for the case label, treating the case label the same 2445 1.1.1.2 joerg as an if-statement. 2446 1.1.1.2 joerg When ``true``, the block gets indented as a scope block. 2447 1.1.1.2 joerg 2448 1.1.1.2 joerg .. code-block:: c++ 2449 1.1.1.2 joerg 2450 1.1.1.2 joerg false: true: 2451 1.1.1.2 joerg switch (fool) { vs. switch (fool) { 2452 1.1.1.2 joerg case 1: { case 1: 2453 1.1.1.2 joerg bar(); { 2454 1.1.1.2 joerg } break; bar(); 2455 1.1.1.2 joerg default: { } 2456 1.1.1.2 joerg plop(); break; 2457 1.1.1.2 joerg } default: 2458 1.1.1.2 joerg } { 2459 1.1.1.2 joerg plop(); 2460 1.1.1.2 joerg } 2461 1.1.1.2 joerg } 2462 1.1.1.2 joerg 2463 1.1 joerg **IndentCaseLabels** (``bool``) 2464 1.1 joerg Indent case labels one level from the switch statement. 2465 1.1 joerg 2466 1.1.1.2 joerg When ``false``, use the same indentation level as for the switch 2467 1.1.1.2 joerg statement. Switch statement body is always indented one level more than 2468 1.1.1.2 joerg case labels (except the first block following the case label, which 2469 1.1.1.2 joerg itself indents the code - unless IndentCaseBlocks is enabled). 2470 1.1 joerg 2471 1.1 joerg .. code-block:: c++ 2472 1.1 joerg 2473 1.1 joerg false: true: 2474 1.1 joerg switch (fool) { vs. switch (fool) { 2475 1.1 joerg case 1: case 1: 2476 1.1 joerg bar(); bar(); 2477 1.1 joerg break; break; 2478 1.1 joerg default: default: 2479 1.1 joerg plop(); plop(); 2480 1.1 joerg } } 2481 1.1 joerg 2482 1.1.1.2 joerg **IndentExternBlock** (``IndentExternBlockStyle``) 2483 1.1.1.2 joerg IndentExternBlockStyle is the type of indenting of extern blocks. 2484 1.1.1.2 joerg 2485 1.1.1.2 joerg Possible values: 2486 1.1.1.2 joerg 2487 1.1.1.2 joerg * ``IEBS_AfterExternBlock`` (in configuration: ``AfterExternBlock``) 2488 1.1.1.2 joerg Backwards compatible with AfterExternBlock's indenting. 2489 1.1.1.2 joerg 2490 1.1.1.2 joerg .. code-block:: c++ 2491 1.1.1.2 joerg 2492 1.1.1.2 joerg IndentExternBlock: AfterExternBlock 2493 1.1.1.2 joerg BraceWrapping.AfterExternBlock: true 2494 1.1.1.2 joerg extern "C" 2495 1.1.1.2 joerg { 2496 1.1.1.2 joerg void foo(); 2497 1.1.1.2 joerg } 2498 1.1.1.2 joerg 2499 1.1.1.2 joerg 2500 1.1.1.2 joerg .. code-block:: c++ 2501 1.1.1.2 joerg 2502 1.1.1.2 joerg IndentExternBlock: AfterExternBlock 2503 1.1.1.2 joerg BraceWrapping.AfterExternBlock: false 2504 1.1.1.2 joerg extern "C" { 2505 1.1.1.2 joerg void foo(); 2506 1.1.1.2 joerg } 2507 1.1.1.2 joerg 2508 1.1.1.2 joerg * ``IEBS_NoIndent`` (in configuration: ``NoIndent``) 2509 1.1.1.2 joerg Does not indent extern blocks. 2510 1.1.1.2 joerg 2511 1.1.1.2 joerg .. code-block:: c++ 2512 1.1.1.2 joerg 2513 1.1.1.2 joerg extern "C" { 2514 1.1.1.2 joerg void foo(); 2515 1.1.1.2 joerg } 2516 1.1.1.2 joerg 2517 1.1.1.2 joerg * ``IEBS_Indent`` (in configuration: ``Indent``) 2518 1.1.1.2 joerg Indents extern blocks. 2519 1.1.1.2 joerg 2520 1.1.1.2 joerg .. code-block:: c++ 2521 1.1.1.2 joerg 2522 1.1.1.2 joerg extern "C" { 2523 1.1.1.2 joerg void foo(); 2524 1.1.1.2 joerg } 2525 1.1.1.2 joerg 2526 1.1.1.2 joerg 2527 1.1.1.2 joerg 2528 1.1 joerg **IndentGotoLabels** (``bool``) 2529 1.1 joerg Indent goto labels. 2530 1.1 joerg 2531 1.1 joerg When ``false``, goto labels are flushed left. 2532 1.1 joerg 2533 1.1 joerg .. code-block:: c++ 2534 1.1 joerg 2535 1.1 joerg true: false: 2536 1.1 joerg int f() { vs. int f() { 2537 1.1 joerg if (foo()) { if (foo()) { 2538 1.1 joerg label1: label1: 2539 1.1 joerg bar(); bar(); 2540 1.1 joerg } } 2541 1.1 joerg label2: label2: 2542 1.1 joerg return 1; return 1; 2543 1.1 joerg } } 2544 1.1 joerg 2545 1.1 joerg **IndentPPDirectives** (``PPDirectiveIndentStyle``) 2546 1.1 joerg The preprocessor directive indenting style to use. 2547 1.1 joerg 2548 1.1 joerg Possible values: 2549 1.1 joerg 2550 1.1 joerg * ``PPDIS_None`` (in configuration: ``None``) 2551 1.1 joerg Does not indent any directives. 2552 1.1 joerg 2553 1.1 joerg .. code-block:: c++ 2554 1.1 joerg 2555 1.1 joerg #if FOO 2556 1.1 joerg #if BAR 2557 1.1 joerg #include <foo> 2558 1.1 joerg #endif 2559 1.1 joerg #endif 2560 1.1 joerg 2561 1.1 joerg * ``PPDIS_AfterHash`` (in configuration: ``AfterHash``) 2562 1.1 joerg Indents directives after the hash. 2563 1.1 joerg 2564 1.1 joerg .. code-block:: c++ 2565 1.1 joerg 2566 1.1 joerg #if FOO 2567 1.1 joerg # if BAR 2568 1.1 joerg # include <foo> 2569 1.1 joerg # endif 2570 1.1 joerg #endif 2571 1.1 joerg 2572 1.1 joerg * ``PPDIS_BeforeHash`` (in configuration: ``BeforeHash``) 2573 1.1 joerg Indents directives before the hash. 2574 1.1 joerg 2575 1.1 joerg .. code-block:: c++ 2576 1.1 joerg 2577 1.1 joerg #if FOO 2578 1.1 joerg #if BAR 2579 1.1 joerg #include <foo> 2580 1.1 joerg #endif 2581 1.1 joerg #endif 2582 1.1 joerg 2583 1.1 joerg 2584 1.1 joerg 2585 1.1.1.2 joerg **IndentRequires** (``bool``) 2586 1.1.1.2 joerg Indent the requires clause in a template 2587 1.1.1.2 joerg 2588 1.1.1.2 joerg .. code-block:: c++ 2589 1.1.1.2 joerg 2590 1.1.1.2 joerg true: 2591 1.1.1.2 joerg template <typename It> 2592 1.1.1.2 joerg requires Iterator<It> 2593 1.1.1.2 joerg void sort(It begin, It end) { 2594 1.1.1.2 joerg //.... 2595 1.1.1.2 joerg } 2596 1.1.1.2 joerg 2597 1.1.1.2 joerg false: 2598 1.1.1.2 joerg template <typename It> 2599 1.1.1.2 joerg requires Iterator<It> 2600 1.1.1.2 joerg void sort(It begin, It end) { 2601 1.1.1.2 joerg //.... 2602 1.1.1.2 joerg } 2603 1.1.1.2 joerg 2604 1.1 joerg **IndentWidth** (``unsigned``) 2605 1.1 joerg The number of columns to use for indentation. 2606 1.1 joerg 2607 1.1 joerg .. code-block:: c++ 2608 1.1 joerg 2609 1.1 joerg IndentWidth: 3 2610 1.1 joerg 2611 1.1 joerg void f() { 2612 1.1 joerg someFunction(); 2613 1.1 joerg if (true, false) { 2614 1.1 joerg f(); 2615 1.1 joerg } 2616 1.1 joerg } 2617 1.1 joerg 2618 1.1 joerg **IndentWrappedFunctionNames** (``bool``) 2619 1.1 joerg Indent if a function definition or declaration is wrapped after the 2620 1.1 joerg type. 2621 1.1 joerg 2622 1.1 joerg .. code-block:: c++ 2623 1.1 joerg 2624 1.1 joerg true: 2625 1.1 joerg LoooooooooooooooooooooooooooooooooooooooongReturnType 2626 1.1 joerg LoooooooooooooooooooooooooooooooongFunctionDeclaration(); 2627 1.1 joerg 2628 1.1 joerg false: 2629 1.1 joerg LoooooooooooooooooooooooooooooooooooooooongReturnType 2630 1.1 joerg LoooooooooooooooooooooooooooooooongFunctionDeclaration(); 2631 1.1 joerg 2632 1.1.1.2 joerg **InsertTrailingCommas** (``TrailingCommaStyle``) 2633 1.1.1.2 joerg If set to ``TCS_Wrapped`` will insert trailing commas in container 2634 1.1.1.2 joerg literals (arrays and objects) that wrap across multiple lines. 2635 1.1.1.2 joerg It is currently only available for JavaScript 2636 1.1.1.2 joerg and disabled by default ``TCS_None``. 2637 1.1.1.2 joerg ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments`` 2638 1.1.1.2 joerg as inserting the comma disables bin-packing. 2639 1.1.1.2 joerg 2640 1.1.1.2 joerg .. code-block:: c++ 2641 1.1.1.2 joerg 2642 1.1.1.2 joerg TSC_Wrapped: 2643 1.1.1.2 joerg const someArray = [ 2644 1.1.1.2 joerg aaaaaaaaaaaaaaaaaaaaaaaaaa, 2645 1.1.1.2 joerg aaaaaaaaaaaaaaaaaaaaaaaaaa, 2646 1.1.1.2 joerg aaaaaaaaaaaaaaaaaaaaaaaaaa, 2647 1.1.1.2 joerg // ^ inserted 2648 1.1.1.2 joerg ] 2649 1.1.1.2 joerg 2650 1.1.1.2 joerg Possible values: 2651 1.1.1.2 joerg 2652 1.1.1.2 joerg * ``TCS_None`` (in configuration: ``None``) 2653 1.1.1.2 joerg Do not insert trailing commas. 2654 1.1.1.2 joerg 2655 1.1.1.2 joerg * ``TCS_Wrapped`` (in configuration: ``Wrapped``) 2656 1.1.1.2 joerg Insert trailing commas in container literals that were wrapped over 2657 1.1.1.2 joerg multiple lines. Note that this is conceptually incompatible with 2658 1.1.1.2 joerg bin-packing, because the trailing comma is used as an indicator 2659 1.1.1.2 joerg that a container should be formatted one-per-line (i.e. not bin-packed). 2660 1.1.1.2 joerg So inserting a trailing comma counteracts bin-packing. 2661 1.1.1.2 joerg 2662 1.1.1.2 joerg 2663 1.1.1.2 joerg 2664 1.1 joerg **JavaImportGroups** (``std::vector<std::string>``) 2665 1.1 joerg A vector of prefixes ordered by the desired groups for Java imports. 2666 1.1 joerg 2667 1.1.1.2 joerg One group's prefix can be a subset of another - the longest prefix is 2668 1.1.1.2 joerg always matched. Within a group, the imports are ordered lexicographically. 2669 1.1.1.2 joerg Static imports are grouped separately and follow the same group rules. 2670 1.1.1.2 joerg By default, static imports are placed before non-static imports, 2671 1.1.1.2 joerg but this behavior is changed by another option, 2672 1.1.1.2 joerg ``SortJavaStaticImport``. 2673 1.1 joerg 2674 1.1 joerg In the .clang-format configuration file, this can be configured like 2675 1.1 joerg in the following yaml example. This will result in imports being 2676 1.1 joerg formatted as in the Java example below. 2677 1.1 joerg 2678 1.1 joerg .. code-block:: yaml 2679 1.1 joerg 2680 1.1 joerg JavaImportGroups: ['com.example', 'com', 'org'] 2681 1.1 joerg 2682 1.1 joerg 2683 1.1 joerg .. code-block:: java 2684 1.1 joerg 2685 1.1 joerg import static com.example.function1; 2686 1.1 joerg 2687 1.1 joerg import static com.test.function2; 2688 1.1 joerg 2689 1.1 joerg import static org.example.function3; 2690 1.1 joerg 2691 1.1 joerg import com.example.ClassA; 2692 1.1 joerg import com.example.Test; 2693 1.1 joerg import com.example.a.ClassB; 2694 1.1 joerg 2695 1.1 joerg import com.test.ClassC; 2696 1.1 joerg 2697 1.1 joerg import org.example.ClassD; 2698 1.1 joerg 2699 1.1 joerg **JavaScriptQuotes** (``JavaScriptQuoteStyle``) 2700 1.1 joerg The JavaScriptQuoteStyle to use for JavaScript strings. 2701 1.1 joerg 2702 1.1 joerg Possible values: 2703 1.1 joerg 2704 1.1 joerg * ``JSQS_Leave`` (in configuration: ``Leave``) 2705 1.1 joerg Leave string quotes as they are. 2706 1.1 joerg 2707 1.1 joerg .. code-block:: js 2708 1.1 joerg 2709 1.1 joerg string1 = "foo"; 2710 1.1 joerg string2 = 'bar'; 2711 1.1 joerg 2712 1.1 joerg * ``JSQS_Single`` (in configuration: ``Single``) 2713 1.1 joerg Always use single quotes. 2714 1.1 joerg 2715 1.1 joerg .. code-block:: js 2716 1.1 joerg 2717 1.1 joerg string1 = 'foo'; 2718 1.1 joerg string2 = 'bar'; 2719 1.1 joerg 2720 1.1 joerg * ``JSQS_Double`` (in configuration: ``Double``) 2721 1.1 joerg Always use double quotes. 2722 1.1 joerg 2723 1.1 joerg .. code-block:: js 2724 1.1 joerg 2725 1.1 joerg string1 = "foo"; 2726 1.1 joerg string2 = "bar"; 2727 1.1 joerg 2728 1.1 joerg 2729 1.1 joerg 2730 1.1 joerg **JavaScriptWrapImports** (``bool``) 2731 1.1 joerg Whether to wrap JavaScript import/export statements. 2732 1.1 joerg 2733 1.1 joerg .. code-block:: js 2734 1.1 joerg 2735 1.1 joerg true: 2736 1.1 joerg import { 2737 1.1 joerg VeryLongImportsAreAnnoying, 2738 1.1 joerg VeryLongImportsAreAnnoying, 2739 1.1 joerg VeryLongImportsAreAnnoying, 2740 1.1 joerg } from 'some/module.js' 2741 1.1 joerg 2742 1.1 joerg false: 2743 1.1 joerg import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js" 2744 1.1 joerg 2745 1.1 joerg **KeepEmptyLinesAtTheStartOfBlocks** (``bool``) 2746 1.1 joerg If true, the empty line at the start of blocks is kept. 2747 1.1 joerg 2748 1.1 joerg .. code-block:: c++ 2749 1.1 joerg 2750 1.1 joerg true: false: 2751 1.1 joerg if (foo) { vs. if (foo) { 2752 1.1 joerg bar(); 2753 1.1 joerg bar(); } 2754 1.1 joerg } 2755 1.1 joerg 2756 1.1 joerg **Language** (``LanguageKind``) 2757 1.1 joerg Language, this format style is targeted at. 2758 1.1 joerg 2759 1.1 joerg Possible values: 2760 1.1 joerg 2761 1.1 joerg * ``LK_None`` (in configuration: ``None``) 2762 1.1 joerg Do not use. 2763 1.1 joerg 2764 1.1 joerg * ``LK_Cpp`` (in configuration: ``Cpp``) 2765 1.1 joerg Should be used for C, C++. 2766 1.1 joerg 2767 1.1 joerg * ``LK_CSharp`` (in configuration: ``CSharp``) 2768 1.1 joerg Should be used for C#. 2769 1.1 joerg 2770 1.1 joerg * ``LK_Java`` (in configuration: ``Java``) 2771 1.1 joerg Should be used for Java. 2772 1.1 joerg 2773 1.1 joerg * ``LK_JavaScript`` (in configuration: ``JavaScript``) 2774 1.1 joerg Should be used for JavaScript. 2775 1.1 joerg 2776 1.1 joerg * ``LK_ObjC`` (in configuration: ``ObjC``) 2777 1.1 joerg Should be used for Objective-C, Objective-C++. 2778 1.1 joerg 2779 1.1 joerg * ``LK_Proto`` (in configuration: ``Proto``) 2780 1.1 joerg Should be used for Protocol Buffers 2781 1.1 joerg (https://developers.google.com/protocol-buffers/). 2782 1.1 joerg 2783 1.1 joerg * ``LK_TableGen`` (in configuration: ``TableGen``) 2784 1.1 joerg Should be used for TableGen code. 2785 1.1 joerg 2786 1.1 joerg * ``LK_TextProto`` (in configuration: ``TextProto``) 2787 1.1 joerg Should be used for Protocol Buffer messages in text format 2788 1.1 joerg (https://developers.google.com/protocol-buffers/). 2789 1.1 joerg 2790 1.1 joerg 2791 1.1 joerg 2792 1.1 joerg **MacroBlockBegin** (``std::string``) 2793 1.1 joerg A regular expression matching macros that start a block. 2794 1.1 joerg 2795 1.1 joerg .. code-block:: c++ 2796 1.1 joerg 2797 1.1 joerg # With: 2798 1.1 joerg MacroBlockBegin: "^NS_MAP_BEGIN|\ 2799 1.1 joerg NS_TABLE_HEAD$" 2800 1.1 joerg MacroBlockEnd: "^\ 2801 1.1 joerg NS_MAP_END|\ 2802 1.1 joerg NS_TABLE_.*_END$" 2803 1.1 joerg 2804 1.1 joerg NS_MAP_BEGIN 2805 1.1 joerg foo(); 2806 1.1 joerg NS_MAP_END 2807 1.1 joerg 2808 1.1 joerg NS_TABLE_HEAD 2809 1.1 joerg bar(); 2810 1.1 joerg NS_TABLE_FOO_END 2811 1.1 joerg 2812 1.1 joerg # Without: 2813 1.1 joerg NS_MAP_BEGIN 2814 1.1 joerg foo(); 2815 1.1 joerg NS_MAP_END 2816 1.1 joerg 2817 1.1 joerg NS_TABLE_HEAD 2818 1.1 joerg bar(); 2819 1.1 joerg NS_TABLE_FOO_END 2820 1.1 joerg 2821 1.1 joerg **MacroBlockEnd** (``std::string``) 2822 1.1 joerg A regular expression matching macros that end a block. 2823 1.1 joerg 2824 1.1 joerg **MaxEmptyLinesToKeep** (``unsigned``) 2825 1.1 joerg The maximum number of consecutive empty lines to keep. 2826 1.1 joerg 2827 1.1 joerg .. code-block:: c++ 2828 1.1 joerg 2829 1.1 joerg MaxEmptyLinesToKeep: 1 vs. MaxEmptyLinesToKeep: 0 2830 1.1 joerg int f() { int f() { 2831 1.1 joerg int = 1; int i = 1; 2832 1.1 joerg i = foo(); 2833 1.1 joerg i = foo(); return i; 2834 1.1 joerg } 2835 1.1 joerg return i; 2836 1.1 joerg } 2837 1.1 joerg 2838 1.1 joerg **NamespaceIndentation** (``NamespaceIndentationKind``) 2839 1.1 joerg The indentation used for namespaces. 2840 1.1 joerg 2841 1.1 joerg Possible values: 2842 1.1 joerg 2843 1.1 joerg * ``NI_None`` (in configuration: ``None``) 2844 1.1 joerg Don't indent in namespaces. 2845 1.1 joerg 2846 1.1 joerg .. code-block:: c++ 2847 1.1 joerg 2848 1.1 joerg namespace out { 2849 1.1 joerg int i; 2850 1.1 joerg namespace in { 2851 1.1 joerg int i; 2852 1.1 joerg } 2853 1.1 joerg } 2854 1.1 joerg 2855 1.1 joerg * ``NI_Inner`` (in configuration: ``Inner``) 2856 1.1 joerg Indent only in inner namespaces (nested in other namespaces). 2857 1.1 joerg 2858 1.1 joerg .. code-block:: c++ 2859 1.1 joerg 2860 1.1 joerg namespace out { 2861 1.1 joerg int i; 2862 1.1 joerg namespace in { 2863 1.1 joerg int i; 2864 1.1 joerg } 2865 1.1 joerg } 2866 1.1 joerg 2867 1.1 joerg * ``NI_All`` (in configuration: ``All``) 2868 1.1 joerg Indent in all namespaces. 2869 1.1 joerg 2870 1.1 joerg .. code-block:: c++ 2871 1.1 joerg 2872 1.1 joerg namespace out { 2873 1.1 joerg int i; 2874 1.1 joerg namespace in { 2875 1.1 joerg int i; 2876 1.1 joerg } 2877 1.1 joerg } 2878 1.1 joerg 2879 1.1 joerg 2880 1.1 joerg 2881 1.1 joerg **NamespaceMacros** (``std::vector<std::string>``) 2882 1.1 joerg A vector of macros which are used to open namespace blocks. 2883 1.1 joerg 2884 1.1 joerg These are expected to be macros of the form: 2885 1.1 joerg 2886 1.1 joerg .. code-block:: c++ 2887 1.1 joerg 2888 1.1 joerg NAMESPACE(<namespace-name>, ...) { 2889 1.1 joerg <namespace-content> 2890 1.1 joerg } 2891 1.1 joerg 2892 1.1 joerg For example: TESTSUITE 2893 1.1 joerg 2894 1.1 joerg **ObjCBinPackProtocolList** (``BinPackStyle``) 2895 1.1 joerg Controls bin-packing Objective-C protocol conformance list 2896 1.1 joerg items into as few lines as possible when they go over ``ColumnLimit``. 2897 1.1 joerg 2898 1.1 joerg If ``Auto`` (the default), delegates to the value in 2899 1.1 joerg ``BinPackParameters``. If that is ``true``, bin-packs Objective-C 2900 1.1 joerg protocol conformance list items into as few lines as possible 2901 1.1 joerg whenever they go over ``ColumnLimit``. 2902 1.1 joerg 2903 1.1 joerg If ``Always``, always bin-packs Objective-C protocol conformance 2904 1.1 joerg list items into as few lines as possible whenever they go over 2905 1.1 joerg ``ColumnLimit``. 2906 1.1 joerg 2907 1.1 joerg If ``Never``, lays out Objective-C protocol conformance list items 2908 1.1 joerg onto individual lines whenever they go over ``ColumnLimit``. 2909 1.1 joerg 2910 1.1 joerg 2911 1.1 joerg .. code-block:: objc 2912 1.1 joerg 2913 1.1 joerg Always (or Auto, if BinPackParameters=true): 2914 1.1 joerg @interface ccccccccccccc () < 2915 1.1 joerg ccccccccccccc, ccccccccccccc, 2916 1.1 joerg ccccccccccccc, ccccccccccccc> { 2917 1.1 joerg } 2918 1.1 joerg 2919 1.1 joerg Never (or Auto, if BinPackParameters=false): 2920 1.1 joerg @interface ddddddddddddd () < 2921 1.1 joerg ddddddddddddd, 2922 1.1 joerg ddddddddddddd, 2923 1.1 joerg ddddddddddddd, 2924 1.1 joerg ddddddddddddd> { 2925 1.1 joerg } 2926 1.1 joerg 2927 1.1 joerg Possible values: 2928 1.1 joerg 2929 1.1 joerg * ``BPS_Auto`` (in configuration: ``Auto``) 2930 1.1 joerg Automatically determine parameter bin-packing behavior. 2931 1.1 joerg 2932 1.1 joerg * ``BPS_Always`` (in configuration: ``Always``) 2933 1.1 joerg Always bin-pack parameters. 2934 1.1 joerg 2935 1.1 joerg * ``BPS_Never`` (in configuration: ``Never``) 2936 1.1 joerg Never bin-pack parameters. 2937 1.1 joerg 2938 1.1 joerg 2939 1.1 joerg 2940 1.1 joerg **ObjCBlockIndentWidth** (``unsigned``) 2941 1.1 joerg The number of characters to use for indentation of ObjC blocks. 2942 1.1 joerg 2943 1.1 joerg .. code-block:: objc 2944 1.1 joerg 2945 1.1 joerg ObjCBlockIndentWidth: 4 2946 1.1 joerg 2947 1.1 joerg [operation setCompletionBlock:^{ 2948 1.1 joerg [self onOperationDone]; 2949 1.1 joerg }]; 2950 1.1 joerg 2951 1.1.1.2 joerg **ObjCBreakBeforeNestedBlockParam** (``bool``) 2952 1.1.1.2 joerg Break parameters list into lines when there is nested block 2953 1.1.1.2 joerg parameters in a function call. 2954 1.1.1.2 joerg 2955 1.1.1.2 joerg .. code-block:: c++ 2956 1.1.1.2 joerg 2957 1.1.1.2 joerg false: 2958 1.1.1.2 joerg - (void)_aMethod 2959 1.1.1.2 joerg { 2960 1.1.1.2 joerg [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber 2961 1.1.1.2 joerg *u, NSNumber *v) { 2962 1.1.1.2 joerg u = c; 2963 1.1.1.2 joerg }] 2964 1.1.1.2 joerg } 2965 1.1.1.2 joerg true: 2966 1.1.1.2 joerg - (void)_aMethod 2967 1.1.1.2 joerg { 2968 1.1.1.2 joerg [self.test1 t:self 2969 1.1.1.2 joerg w:self 2970 1.1.1.2 joerg callback:^(typeof(self) self, NSNumber *u, NSNumber *v) { 2971 1.1.1.2 joerg u = c; 2972 1.1.1.2 joerg }] 2973 1.1.1.2 joerg } 2974 1.1.1.2 joerg 2975 1.1 joerg **ObjCSpaceAfterProperty** (``bool``) 2976 1.1 joerg Add a space after ``@property`` in Objective-C, i.e. use 2977 1.1 joerg ``@property (readonly)`` instead of ``@property(readonly)``. 2978 1.1 joerg 2979 1.1 joerg **ObjCSpaceBeforeProtocolList** (``bool``) 2980 1.1 joerg Add a space in front of an Objective-C protocol list, i.e. use 2981 1.1 joerg ``Foo <Protocol>`` instead of ``Foo<Protocol>``. 2982 1.1 joerg 2983 1.1 joerg **PenaltyBreakAssignment** (``unsigned``) 2984 1.1 joerg The penalty for breaking around an assignment operator. 2985 1.1 joerg 2986 1.1 joerg **PenaltyBreakBeforeFirstCallParameter** (``unsigned``) 2987 1.1 joerg The penalty for breaking a function call after ``call(``. 2988 1.1 joerg 2989 1.1 joerg **PenaltyBreakComment** (``unsigned``) 2990 1.1 joerg The penalty for each line break introduced inside a comment. 2991 1.1 joerg 2992 1.1 joerg **PenaltyBreakFirstLessLess** (``unsigned``) 2993 1.1 joerg The penalty for breaking before the first ``<<``. 2994 1.1 joerg 2995 1.1 joerg **PenaltyBreakString** (``unsigned``) 2996 1.1 joerg The penalty for each line break introduced inside a string literal. 2997 1.1 joerg 2998 1.1 joerg **PenaltyBreakTemplateDeclaration** (``unsigned``) 2999 1.1 joerg The penalty for breaking after template declaration. 3000 1.1 joerg 3001 1.1 joerg **PenaltyExcessCharacter** (``unsigned``) 3002 1.1 joerg The penalty for each character outside of the column limit. 3003 1.1 joerg 3004 1.1.1.2 joerg **PenaltyIndentedWhitespace** (``unsigned``) 3005 1.1.1.2 joerg Penalty for each character of whitespace indentation 3006 1.1.1.2 joerg (counted relative to leading non-whitespace column). 3007 1.1.1.2 joerg 3008 1.1 joerg **PenaltyReturnTypeOnItsOwnLine** (``unsigned``) 3009 1.1 joerg Penalty for putting the return type of a function onto its own 3010 1.1 joerg line. 3011 1.1 joerg 3012 1.1 joerg **PointerAlignment** (``PointerAlignmentStyle``) 3013 1.1 joerg Pointer and reference alignment style. 3014 1.1 joerg 3015 1.1 joerg Possible values: 3016 1.1 joerg 3017 1.1 joerg * ``PAS_Left`` (in configuration: ``Left``) 3018 1.1 joerg Align pointer to the left. 3019 1.1 joerg 3020 1.1 joerg .. code-block:: c++ 3021 1.1 joerg 3022 1.1 joerg int* a; 3023 1.1 joerg 3024 1.1 joerg * ``PAS_Right`` (in configuration: ``Right``) 3025 1.1 joerg Align pointer to the right. 3026 1.1 joerg 3027 1.1 joerg .. code-block:: c++ 3028 1.1 joerg 3029 1.1 joerg int *a; 3030 1.1 joerg 3031 1.1 joerg * ``PAS_Middle`` (in configuration: ``Middle``) 3032 1.1 joerg Align pointer in the middle. 3033 1.1 joerg 3034 1.1 joerg .. code-block:: c++ 3035 1.1 joerg 3036 1.1 joerg int * a; 3037 1.1 joerg 3038 1.1 joerg 3039 1.1 joerg 3040 1.1 joerg **RawStringFormats** (``std::vector<RawStringFormat>``) 3041 1.1 joerg Defines hints for detecting supported languages code blocks in raw 3042 1.1 joerg strings. 3043 1.1 joerg 3044 1.1 joerg A raw string with a matching delimiter or a matching enclosing function 3045 1.1 joerg name will be reformatted assuming the specified language based on the 3046 1.1 joerg style for that language defined in the .clang-format file. If no style has 3047 1.1 joerg been defined in the .clang-format file for the specific language, a 3048 1.1 joerg predefined style given by 'BasedOnStyle' is used. If 'BasedOnStyle' is not 3049 1.1 joerg found, the formatting is based on llvm style. A matching delimiter takes 3050 1.1 joerg precedence over a matching enclosing function name for determining the 3051 1.1 joerg language of the raw string contents. 3052 1.1 joerg 3053 1.1 joerg If a canonical delimiter is specified, occurrences of other delimiters for 3054 1.1 joerg the same language will be updated to the canonical if possible. 3055 1.1 joerg 3056 1.1 joerg There should be at most one specification per language and each delimiter 3057 1.1 joerg and enclosing function should not occur in multiple specifications. 3058 1.1 joerg 3059 1.1 joerg To configure this in the .clang-format file, use: 3060 1.1 joerg 3061 1.1 joerg .. code-block:: yaml 3062 1.1 joerg 3063 1.1 joerg RawStringFormats: 3064 1.1 joerg - Language: TextProto 3065 1.1 joerg Delimiters: 3066 1.1 joerg - 'pb' 3067 1.1 joerg - 'proto' 3068 1.1 joerg EnclosingFunctions: 3069 1.1 joerg - 'PARSE_TEXT_PROTO' 3070 1.1 joerg BasedOnStyle: google 3071 1.1 joerg - Language: Cpp 3072 1.1 joerg Delimiters: 3073 1.1 joerg - 'cc' 3074 1.1 joerg - 'cpp' 3075 1.1 joerg BasedOnStyle: llvm 3076 1.1 joerg CanonicalDelimiter: 'cc' 3077 1.1 joerg 3078 1.1 joerg **ReflowComments** (``bool``) 3079 1.1 joerg If ``true``, clang-format will attempt to re-flow comments. 3080 1.1 joerg 3081 1.1 joerg .. code-block:: c++ 3082 1.1 joerg 3083 1.1 joerg false: 3084 1.1 joerg // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information 3085 1.1 joerg /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */ 3086 1.1 joerg 3087 1.1 joerg true: 3088 1.1 joerg // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of 3089 1.1 joerg // information 3090 1.1 joerg /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of 3091 1.1 joerg * information */ 3092 1.1 joerg 3093 1.1.1.2 joerg **ShortNamespaceLines** (``unsigned``) 3094 1.1.1.2 joerg The maximal number of unwrapped lines that a short namespace spans. 3095 1.1.1.2 joerg Defaults to 1. 3096 1.1.1.2 joerg 3097 1.1.1.2 joerg This determines the maximum length of short namespaces by counting 3098 1.1.1.2 joerg unwrapped lines (i.e. containing neither opening nor closing 3099 1.1.1.2 joerg namespace brace) and makes "FixNamespaceComments" omit adding 3100 1.1.1.2 joerg end comments for those. 3101 1.1 joerg 3102 1.1 joerg .. code-block:: c++ 3103 1.1 joerg 3104 1.1.1.2 joerg ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0 3105 1.1.1.2 joerg namespace a { namespace a { 3106 1.1.1.2 joerg int foo; int foo; 3107 1.1.1.2 joerg } } // namespace a 3108 1.1.1.2 joerg 3109 1.1.1.2 joerg ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0 3110 1.1.1.2 joerg namespace b { namespace b { 3111 1.1.1.2 joerg int foo; int foo; 3112 1.1.1.2 joerg int bar; int bar; 3113 1.1.1.2 joerg } // namespace b } // namespace b 3114 1.1.1.2 joerg 3115 1.1.1.2 joerg **SortIncludes** (``SortIncludesOptions``) 3116 1.1.1.2 joerg Controls if and how clang-format will sort ``#includes``. 3117 1.1.1.2 joerg If ``Never``, includes are never sorted. 3118 1.1.1.2 joerg If ``CaseInsensitive``, includes are sorted in an ASCIIbetical or case 3119 1.1.1.2 joerg insensitive fashion. 3120 1.1.1.2 joerg If ``CaseSensitive``, includes are sorted in an alphabetical or case 3121 1.1.1.2 joerg sensitive fashion. 3122 1.1.1.2 joerg 3123 1.1.1.2 joerg Possible values: 3124 1.1.1.2 joerg 3125 1.1.1.2 joerg * ``SI_Never`` (in configuration: ``Never``) 3126 1.1.1.2 joerg Includes are never sorted. 3127 1.1.1.2 joerg 3128 1.1.1.2 joerg .. code-block:: c++ 3129 1.1.1.2 joerg 3130 1.1.1.2 joerg #include "B/A.h" 3131 1.1.1.2 joerg #include "A/B.h" 3132 1.1.1.2 joerg #include "a/b.h" 3133 1.1.1.2 joerg #include "A/b.h" 3134 1.1.1.2 joerg #include "B/a.h" 3135 1.1.1.2 joerg 3136 1.1.1.2 joerg * ``SI_CaseSensitive`` (in configuration: ``CaseSensitive``) 3137 1.1.1.2 joerg Includes are sorted in an ASCIIbetical or case sensitive fashion. 3138 1.1.1.2 joerg 3139 1.1.1.2 joerg .. code-block:: c++ 3140 1.1.1.2 joerg 3141 1.1.1.2 joerg #include "A/B.h" 3142 1.1.1.2 joerg #include "A/b.h" 3143 1.1.1.2 joerg #include "B/A.h" 3144 1.1.1.2 joerg #include "B/a.h" 3145 1.1.1.2 joerg #include "a/b.h" 3146 1.1.1.2 joerg 3147 1.1.1.2 joerg * ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``) 3148 1.1.1.2 joerg Includes are sorted in an alphabetical or case insensitive fashion. 3149 1.1.1.2 joerg 3150 1.1.1.2 joerg .. code-block:: c++ 3151 1.1.1.2 joerg 3152 1.1.1.2 joerg #include "A/B.h" 3153 1.1.1.2 joerg #include "A/b.h" 3154 1.1.1.2 joerg #include "a/b.h" 3155 1.1.1.2 joerg #include "B/A.h" 3156 1.1.1.2 joerg #include "B/a.h" 3157 1.1.1.2 joerg 3158 1.1.1.2 joerg 3159 1.1.1.2 joerg 3160 1.1.1.2 joerg **SortJavaStaticImport** (``SortJavaStaticImportOptions``) 3161 1.1.1.2 joerg When sorting Java imports, by default static imports are placed before 3162 1.1.1.2 joerg non-static imports. If ``JavaStaticImportAfterImport`` is ``After``, 3163 1.1.1.2 joerg static imports are placed after non-static imports. 3164 1.1.1.2 joerg 3165 1.1.1.2 joerg Possible values: 3166 1.1.1.2 joerg 3167 1.1.1.2 joerg * ``SJSIO_Before`` (in configuration: ``Before``) 3168 1.1.1.2 joerg Static imports are placed before non-static imports. 3169 1.1.1.2 joerg 3170 1.1.1.2 joerg .. code-block:: java 3171 1.1.1.2 joerg 3172 1.1.1.2 joerg import static org.example.function1; 3173 1.1.1.2 joerg 3174 1.1.1.2 joerg import org.example.ClassA; 3175 1.1.1.2 joerg 3176 1.1.1.2 joerg * ``SJSIO_After`` (in configuration: ``After``) 3177 1.1.1.2 joerg Static imports are placed after non-static imports. 3178 1.1.1.2 joerg 3179 1.1.1.2 joerg .. code-block:: java 3180 1.1.1.2 joerg 3181 1.1.1.2 joerg import org.example.ClassA; 3182 1.1.1.2 joerg 3183 1.1.1.2 joerg import static org.example.function1; 3184 1.1.1.2 joerg 3185 1.1.1.2 joerg 3186 1.1 joerg 3187 1.1 joerg **SortUsingDeclarations** (``bool``) 3188 1.1 joerg If ``true``, clang-format will sort using declarations. 3189 1.1 joerg 3190 1.1 joerg The order of using declarations is defined as follows: 3191 1.1 joerg Split the strings by "::" and discard any initial empty strings. The last 3192 1.1 joerg element of each list is a non-namespace name; all others are namespace 3193 1.1 joerg names. Sort the lists of names lexicographically, where the sort order of 3194 1.1 joerg individual names is that all non-namespace names come before all namespace 3195 1.1 joerg names, and within those groups, names are in case-insensitive 3196 1.1 joerg lexicographic order. 3197 1.1 joerg 3198 1.1 joerg .. code-block:: c++ 3199 1.1 joerg 3200 1.1 joerg false: true: 3201 1.1 joerg using std::cout; vs. using std::cin; 3202 1.1 joerg using std::cin; using std::cout; 3203 1.1 joerg 3204 1.1 joerg **SpaceAfterCStyleCast** (``bool``) 3205 1.1 joerg If ``true``, a space is inserted after C style casts. 3206 1.1 joerg 3207 1.1 joerg .. code-block:: c++ 3208 1.1 joerg 3209 1.1 joerg true: false: 3210 1.1 joerg (int) i; vs. (int)i; 3211 1.1 joerg 3212 1.1 joerg **SpaceAfterLogicalNot** (``bool``) 3213 1.1 joerg If ``true``, a space is inserted after the logical not operator (``!``). 3214 1.1 joerg 3215 1.1 joerg .. code-block:: c++ 3216 1.1 joerg 3217 1.1 joerg true: false: 3218 1.1 joerg ! someExpression(); vs. !someExpression(); 3219 1.1 joerg 3220 1.1 joerg **SpaceAfterTemplateKeyword** (``bool``) 3221 1.1 joerg If ``true``, a space will be inserted after the 'template' keyword. 3222 1.1 joerg 3223 1.1 joerg .. code-block:: c++ 3224 1.1 joerg 3225 1.1 joerg true: false: 3226 1.1 joerg template <int> void foo(); vs. template<int> void foo(); 3227 1.1 joerg 3228 1.1.1.2 joerg **SpaceAroundPointerQualifiers** (``SpaceAroundPointerQualifiersStyle``) 3229 1.1.1.2 joerg Defines in which cases to put a space before or after pointer qualifiers 3230 1.1.1.2 joerg 3231 1.1.1.2 joerg Possible values: 3232 1.1.1.2 joerg 3233 1.1.1.2 joerg * ``SAPQ_Default`` (in configuration: ``Default``) 3234 1.1.1.2 joerg Don't ensure spaces around pointer qualifiers and use PointerAlignment 3235 1.1.1.2 joerg instead. 3236 1.1.1.2 joerg 3237 1.1.1.2 joerg .. code-block:: c++ 3238 1.1.1.2 joerg 3239 1.1.1.2 joerg PointerAlignment: Left PointerAlignment: Right 3240 1.1.1.2 joerg void* const* x = NULL; vs. void *const *x = NULL; 3241 1.1.1.2 joerg 3242 1.1.1.2 joerg * ``SAPQ_Before`` (in configuration: ``Before``) 3243 1.1.1.2 joerg Ensure that there is a space before pointer qualifiers. 3244 1.1.1.2 joerg 3245 1.1.1.2 joerg .. code-block:: c++ 3246 1.1.1.2 joerg 3247 1.1.1.2 joerg PointerAlignment: Left PointerAlignment: Right 3248 1.1.1.2 joerg void* const* x = NULL; vs. void * const *x = NULL; 3249 1.1.1.2 joerg 3250 1.1.1.2 joerg * ``SAPQ_After`` (in configuration: ``After``) 3251 1.1.1.2 joerg Ensure that there is a space after pointer qualifiers. 3252 1.1.1.2 joerg 3253 1.1.1.2 joerg .. code-block:: c++ 3254 1.1.1.2 joerg 3255 1.1.1.2 joerg PointerAlignment: Left PointerAlignment: Right 3256 1.1.1.2 joerg void* const * x = NULL; vs. void *const *x = NULL; 3257 1.1.1.2 joerg 3258 1.1.1.2 joerg * ``SAPQ_Both`` (in configuration: ``Both``) 3259 1.1.1.2 joerg Ensure that there is a space both before and after pointer qualifiers. 3260 1.1.1.2 joerg 3261 1.1.1.2 joerg .. code-block:: c++ 3262 1.1.1.2 joerg 3263 1.1.1.2 joerg PointerAlignment: Left PointerAlignment: Right 3264 1.1.1.2 joerg void* const * x = NULL; vs. void * const *x = NULL; 3265 1.1.1.2 joerg 3266 1.1.1.2 joerg 3267 1.1.1.2 joerg 3268 1.1 joerg **SpaceBeforeAssignmentOperators** (``bool``) 3269 1.1 joerg If ``false``, spaces will be removed before assignment operators. 3270 1.1 joerg 3271 1.1 joerg .. code-block:: c++ 3272 1.1 joerg 3273 1.1 joerg true: false: 3274 1.1 joerg int a = 5; vs. int a= 5; 3275 1.1 joerg a += 42; a+= 42; 3276 1.1 joerg 3277 1.1.1.2 joerg **SpaceBeforeCaseColon** (``bool``) 3278 1.1.1.2 joerg If ``false``, spaces will be removed before case colon. 3279 1.1.1.2 joerg 3280 1.1.1.2 joerg .. code-block:: c++ 3281 1.1.1.2 joerg 3282 1.1.1.2 joerg true: false 3283 1.1.1.2 joerg switch (x) { vs. switch (x) { 3284 1.1.1.2 joerg case 1 : break; case 1: break; 3285 1.1.1.2 joerg } } 3286 1.1.1.2 joerg 3287 1.1 joerg **SpaceBeforeCpp11BracedList** (``bool``) 3288 1.1 joerg If ``true``, a space will be inserted before a C++11 braced list 3289 1.1 joerg used to initialize an object (after the preceding identifier or type). 3290 1.1 joerg 3291 1.1 joerg .. code-block:: c++ 3292 1.1 joerg 3293 1.1 joerg true: false: 3294 1.1 joerg Foo foo { bar }; vs. Foo foo{ bar }; 3295 1.1 joerg Foo {}; Foo{}; 3296 1.1 joerg vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 }; 3297 1.1 joerg new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 }; 3298 1.1 joerg 3299 1.1 joerg **SpaceBeforeCtorInitializerColon** (``bool``) 3300 1.1 joerg If ``false``, spaces will be removed before constructor initializer 3301 1.1 joerg colon. 3302 1.1 joerg 3303 1.1 joerg .. code-block:: c++ 3304 1.1 joerg 3305 1.1 joerg true: false: 3306 1.1 joerg Foo::Foo() : a(a) {} Foo::Foo(): a(a) {} 3307 1.1 joerg 3308 1.1 joerg **SpaceBeforeInheritanceColon** (``bool``) 3309 1.1 joerg If ``false``, spaces will be removed before inheritance colon. 3310 1.1 joerg 3311 1.1 joerg .. code-block:: c++ 3312 1.1 joerg 3313 1.1 joerg true: false: 3314 1.1 joerg class Foo : Bar {} vs. class Foo: Bar {} 3315 1.1 joerg 3316 1.1 joerg **SpaceBeforeParens** (``SpaceBeforeParensOptions``) 3317 1.1 joerg Defines in which cases to put a space before opening parentheses. 3318 1.1 joerg 3319 1.1 joerg Possible values: 3320 1.1 joerg 3321 1.1 joerg * ``SBPO_Never`` (in configuration: ``Never``) 3322 1.1 joerg Never put a space before opening parentheses. 3323 1.1 joerg 3324 1.1 joerg .. code-block:: c++ 3325 1.1 joerg 3326 1.1 joerg void f() { 3327 1.1 joerg if(true) { 3328 1.1 joerg f(); 3329 1.1 joerg } 3330 1.1 joerg } 3331 1.1 joerg 3332 1.1 joerg * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``) 3333 1.1 joerg Put a space before opening parentheses only after control statement 3334 1.1 joerg keywords (``for/if/while...``). 3335 1.1 joerg 3336 1.1 joerg .. code-block:: c++ 3337 1.1 joerg 3338 1.1 joerg void f() { 3339 1.1 joerg if (true) { 3340 1.1 joerg f(); 3341 1.1 joerg } 3342 1.1 joerg } 3343 1.1 joerg 3344 1.1.1.2 joerg * ``SBPO_ControlStatementsExceptForEachMacros`` (in configuration: ``ControlStatementsExceptForEachMacros``) 3345 1.1.1.2 joerg Same as ``SBPO_ControlStatements`` except this option doesn't apply to 3346 1.1.1.2 joerg ForEach macros. This is useful in projects where ForEach macros are 3347 1.1.1.2 joerg treated as function calls instead of control statements. 3348 1.1.1.2 joerg 3349 1.1.1.2 joerg .. code-block:: c++ 3350 1.1.1.2 joerg 3351 1.1.1.2 joerg void f() { 3352 1.1.1.2 joerg Q_FOREACH(...) { 3353 1.1.1.2 joerg f(); 3354 1.1.1.2 joerg } 3355 1.1.1.2 joerg } 3356 1.1.1.2 joerg 3357 1.1 joerg * ``SBPO_NonEmptyParentheses`` (in configuration: ``NonEmptyParentheses``) 3358 1.1 joerg Put a space before opening parentheses only if the parentheses are not 3359 1.1 joerg empty i.e. '()' 3360 1.1 joerg 3361 1.1 joerg .. code-block:: c++ 3362 1.1 joerg 3363 1.1 joerg void() { 3364 1.1 joerg if (true) { 3365 1.1 joerg f(); 3366 1.1 joerg g (x, y, z); 3367 1.1 joerg } 3368 1.1 joerg } 3369 1.1 joerg 3370 1.1 joerg * ``SBPO_Always`` (in configuration: ``Always``) 3371 1.1 joerg Always put a space before opening parentheses, except when it's 3372 1.1 joerg prohibited by the syntax rules (in function-like macro definitions) or 3373 1.1 joerg when determined by other style rules (after unary operators, opening 3374 1.1 joerg parentheses, etc.) 3375 1.1 joerg 3376 1.1 joerg .. code-block:: c++ 3377 1.1 joerg 3378 1.1 joerg void f () { 3379 1.1 joerg if (true) { 3380 1.1 joerg f (); 3381 1.1 joerg } 3382 1.1 joerg } 3383 1.1 joerg 3384 1.1 joerg 3385 1.1 joerg 3386 1.1 joerg **SpaceBeforeRangeBasedForLoopColon** (``bool``) 3387 1.1 joerg If ``false``, spaces will be removed before range-based for loop 3388 1.1 joerg colon. 3389 1.1 joerg 3390 1.1 joerg .. code-block:: c++ 3391 1.1 joerg 3392 1.1 joerg true: false: 3393 1.1 joerg for (auto v : values) {} vs. for(auto v: values) {} 3394 1.1 joerg 3395 1.1.1.2 joerg **SpaceBeforeSquareBrackets** (``bool``) 3396 1.1.1.2 joerg If ``true``, spaces will be before ``[``. 3397 1.1.1.2 joerg Lambdas will not be affected. Only the first ``[`` will get a space added. 3398 1.1.1.2 joerg 3399 1.1.1.2 joerg .. code-block:: c++ 3400 1.1.1.2 joerg 3401 1.1.1.2 joerg true: false: 3402 1.1.1.2 joerg int a [5]; vs. int a[5]; 3403 1.1.1.2 joerg int a [5][5]; vs. int a[5][5]; 3404 1.1.1.2 joerg 3405 1.1 joerg **SpaceInEmptyBlock** (``bool``) 3406 1.1 joerg If ``true``, spaces will be inserted into ``{}``. 3407 1.1 joerg 3408 1.1 joerg .. code-block:: c++ 3409 1.1 joerg 3410 1.1 joerg true: false: 3411 1.1 joerg void f() { } vs. void f() {} 3412 1.1 joerg while (true) { } while (true) {} 3413 1.1 joerg 3414 1.1 joerg **SpaceInEmptyParentheses** (``bool``) 3415 1.1 joerg If ``true``, spaces may be inserted into ``()``. 3416 1.1 joerg 3417 1.1 joerg .. code-block:: c++ 3418 1.1 joerg 3419 1.1 joerg true: false: 3420 1.1 joerg void f( ) { vs. void f() { 3421 1.1 joerg int x[] = {foo( ), bar( )}; int x[] = {foo(), bar()}; 3422 1.1 joerg if (true) { if (true) { 3423 1.1 joerg f( ); f(); 3424 1.1 joerg } } 3425 1.1 joerg } } 3426 1.1 joerg 3427 1.1 joerg **SpacesBeforeTrailingComments** (``unsigned``) 3428 1.1 joerg The number of spaces before trailing line comments 3429 1.1 joerg (``//`` - comments). 3430 1.1 joerg 3431 1.1 joerg This does not affect trailing block comments (``/*`` - comments) as 3432 1.1 joerg those commonly have different usage patterns and a number of special 3433 1.1 joerg cases. 3434 1.1 joerg 3435 1.1 joerg .. code-block:: c++ 3436 1.1 joerg 3437 1.1 joerg SpacesBeforeTrailingComments: 3 3438 1.1 joerg void f() { 3439 1.1 joerg if (true) { // foo1 3440 1.1 joerg f(); // bar 3441 1.1 joerg } // foo 3442 1.1 joerg } 3443 1.1 joerg 3444 1.1 joerg **SpacesInAngles** (``bool``) 3445 1.1 joerg If ``true``, spaces will be inserted after ``<`` and before ``>`` 3446 1.1 joerg in template argument lists. 3447 1.1 joerg 3448 1.1 joerg .. code-block:: c++ 3449 1.1 joerg 3450 1.1 joerg true: false: 3451 1.1 joerg static_cast< int >(arg); vs. static_cast<int>(arg); 3452 1.1 joerg std::function< void(int) > fct; std::function<void(int)> fct; 3453 1.1 joerg 3454 1.1 joerg **SpacesInCStyleCastParentheses** (``bool``) 3455 1.1 joerg If ``true``, spaces may be inserted into C style casts. 3456 1.1 joerg 3457 1.1 joerg .. code-block:: c++ 3458 1.1 joerg 3459 1.1 joerg true: false: 3460 1.1 joerg x = ( int32 )y vs. x = (int32)y 3461 1.1 joerg 3462 1.1.1.2 joerg **SpacesInConditionalStatement** (``bool``) 3463 1.1.1.2 joerg If ``true``, spaces will be inserted around if/for/switch/while 3464 1.1.1.2 joerg conditions. 3465 1.1.1.2 joerg 3466 1.1.1.2 joerg .. code-block:: c++ 3467 1.1.1.2 joerg 3468 1.1.1.2 joerg true: false: 3469 1.1.1.2 joerg if ( a ) { ... } vs. if (a) { ... } 3470 1.1.1.2 joerg while ( i < 5 ) { ... } while (i < 5) { ... } 3471 1.1.1.2 joerg 3472 1.1 joerg **SpacesInContainerLiterals** (``bool``) 3473 1.1 joerg If ``true``, spaces are inserted inside container literals (e.g. 3474 1.1 joerg ObjC and Javascript array and dict literals). 3475 1.1 joerg 3476 1.1 joerg .. code-block:: js 3477 1.1 joerg 3478 1.1 joerg true: false: 3479 1.1 joerg var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3]; 3480 1.1 joerg f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3}); 3481 1.1 joerg 3482 1.1.1.2 joerg **SpacesInLineCommentPrefix** (``SpacesInLineComment``) 3483 1.1.1.2 joerg How many spaces are allowed at the start of a line comment. To disable the 3484 1.1.1.2 joerg maximum set it to ``-1``, apart from that the maximum takes precedence 3485 1.1.1.2 joerg over the minimum. 3486 1.1.1.2 joerg Minimum = 1 Maximum = -1 3487 1.1.1.2 joerg // One space is forced 3488 1.1.1.2 joerg 3489 1.1.1.2 joerg // but more spaces are possible 3490 1.1.1.2 joerg 3491 1.1.1.2 joerg Minimum = 0 3492 1.1.1.2 joerg Maximum = 0 3493 1.1.1.2 joerg //Forces to start every comment directly after the slashes 3494 1.1.1.2 joerg 3495 1.1.1.2 joerg Note that in line comment sections the relative indent of the subsequent 3496 1.1.1.2 joerg lines is kept, that means the following: 3497 1.1.1.2 joerg 3498 1.1.1.2 joerg .. code-block:: c++ 3499 1.1.1.2 joerg 3500 1.1.1.2 joerg before: after: 3501 1.1.1.2 joerg Minimum: 1 3502 1.1.1.2 joerg //if (b) { // if (b) { 3503 1.1.1.2 joerg // return true; // return true; 3504 1.1.1.2 joerg //} // } 3505 1.1.1.2 joerg 3506 1.1.1.2 joerg Maximum: 0 3507 1.1.1.2 joerg /// List: ///List: 3508 1.1.1.2 joerg /// - Foo /// - Foo 3509 1.1.1.2 joerg /// - Bar /// - Bar 3510 1.1.1.2 joerg 3511 1.1.1.2 joerg Nested configuration flags: 3512 1.1.1.2 joerg 3513 1.1.1.2 joerg 3514 1.1.1.2 joerg * ``unsigned Minimum`` The minimum number of spaces at the start of the comment. 3515 1.1.1.2 joerg 3516 1.1.1.2 joerg * ``unsigned Maximum`` The maximum number of spaces at the start of the comment. 3517 1.1.1.2 joerg 3518 1.1.1.2 joerg 3519 1.1 joerg **SpacesInParentheses** (``bool``) 3520 1.1 joerg If ``true``, spaces will be inserted after ``(`` and before ``)``. 3521 1.1 joerg 3522 1.1 joerg .. code-block:: c++ 3523 1.1 joerg 3524 1.1 joerg true: false: 3525 1.1 joerg t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete; 3526 1.1 joerg 3527 1.1 joerg **SpacesInSquareBrackets** (``bool``) 3528 1.1 joerg If ``true``, spaces will be inserted after ``[`` and before ``]``. 3529 1.1.1.2 joerg Lambdas without arguments or unspecified size array declarations will not 3530 1.1.1.2 joerg be affected. 3531 1.1 joerg 3532 1.1 joerg .. code-block:: c++ 3533 1.1 joerg 3534 1.1 joerg true: false: 3535 1.1 joerg int a[ 5 ]; vs. int a[5]; 3536 1.1 joerg std::unique_ptr<int[]> foo() {} // Won't be affected 3537 1.1 joerg 3538 1.1 joerg **Standard** (``LanguageStandard``) 3539 1.1 joerg Parse and format C++ constructs compatible with this standard. 3540 1.1 joerg 3541 1.1 joerg .. code-block:: c++ 3542 1.1 joerg 3543 1.1 joerg c++03: latest: 3544 1.1 joerg vector<set<int> > x; vs. vector<set<int>> x; 3545 1.1 joerg 3546 1.1 joerg Possible values: 3547 1.1 joerg 3548 1.1 joerg * ``LS_Cpp03`` (in configuration: ``c++03``) 3549 1.1.1.2 joerg Parse and format as C++03. 3550 1.1.1.2 joerg ``Cpp03`` is a deprecated alias for ``c++03`` 3551 1.1 joerg 3552 1.1 joerg * ``LS_Cpp11`` (in configuration: ``c++11``) 3553 1.1.1.2 joerg Parse and format as C++11. 3554 1.1 joerg 3555 1.1 joerg * ``LS_Cpp14`` (in configuration: ``c++14``) 3556 1.1.1.2 joerg Parse and format as C++14. 3557 1.1 joerg 3558 1.1 joerg * ``LS_Cpp17`` (in configuration: ``c++17``) 3559 1.1.1.2 joerg Parse and format as C++17. 3560 1.1 joerg 3561 1.1 joerg * ``LS_Cpp20`` (in configuration: ``c++20``) 3562 1.1.1.2 joerg Parse and format as C++20. 3563 1.1 joerg 3564 1.1 joerg * ``LS_Latest`` (in configuration: ``Latest``) 3565 1.1 joerg Parse and format using the latest supported language version. 3566 1.1.1.2 joerg ``Cpp11`` is a deprecated alias for ``Latest`` 3567 1.1 joerg 3568 1.1 joerg * ``LS_Auto`` (in configuration: ``Auto``) 3569 1.1 joerg Automatic detection based on the input. 3570 1.1 joerg 3571 1.1 joerg 3572 1.1.1.2 joerg 3573 1.1.1.2 joerg **StatementAttributeLikeMacros** (``std::vector<std::string>``) 3574 1.1.1.2 joerg Macros which are ignored in front of a statement, as if they were an 3575 1.1.1.2 joerg attribute. So that they are not parsed as identifier, for example for Qts 3576 1.1.1.2 joerg emit. 3577 1.1.1.2 joerg 3578 1.1.1.2 joerg .. code-block:: c++ 3579 1.1.1.2 joerg 3580 1.1.1.2 joerg AlignConsecutiveDeclarations: true 3581 1.1.1.2 joerg StatementAttributeLikeMacros: [] 3582 1.1.1.2 joerg unsigned char data = 'x'; 3583 1.1.1.2 joerg emit signal(data); // This is parsed as variable declaration. 3584 1.1.1.2 joerg 3585 1.1.1.2 joerg AlignConsecutiveDeclarations: true 3586 1.1.1.2 joerg StatementAttributeLikeMacros: [emit] 3587 1.1.1.2 joerg unsigned char data = 'x'; 3588 1.1.1.2 joerg emit signal(data); // Now it's fine again. 3589 1.1 joerg 3590 1.1 joerg **StatementMacros** (``std::vector<std::string>``) 3591 1.1 joerg A vector of macros that should be interpreted as complete 3592 1.1 joerg statements. 3593 1.1 joerg 3594 1.1 joerg Typical macros are expressions, and require a semi-colon to be 3595 1.1 joerg added; sometimes this is not the case, and this allows to make 3596 1.1 joerg clang-format aware of such cases. 3597 1.1 joerg 3598 1.1 joerg For example: Q_UNUSED 3599 1.1 joerg 3600 1.1 joerg **TabWidth** (``unsigned``) 3601 1.1 joerg The number of columns used for tab stops. 3602 1.1 joerg 3603 1.1 joerg **TypenameMacros** (``std::vector<std::string>``) 3604 1.1 joerg A vector of macros that should be interpreted as type declarations 3605 1.1 joerg instead of as function calls. 3606 1.1 joerg 3607 1.1 joerg These are expected to be macros of the form: 3608 1.1 joerg 3609 1.1 joerg .. code-block:: c++ 3610 1.1 joerg 3611 1.1 joerg STACK_OF(...) 3612 1.1 joerg 3613 1.1 joerg In the .clang-format configuration file, this can be configured like: 3614 1.1 joerg 3615 1.1 joerg .. code-block:: yaml 3616 1.1 joerg 3617 1.1 joerg TypenameMacros: ['STACK_OF', 'LIST'] 3618 1.1 joerg 3619 1.1 joerg For example: OpenSSL STACK_OF, BSD LIST_ENTRY. 3620 1.1 joerg 3621 1.1.1.2 joerg **UseCRLF** (``bool``) 3622 1.1.1.2 joerg Use ``\r\n`` instead of ``\n`` for line breaks. 3623 1.1.1.2 joerg Also used as fallback if ``DeriveLineEnding`` is true. 3624 1.1.1.2 joerg 3625 1.1 joerg **UseTab** (``UseTabStyle``) 3626 1.1 joerg The way to use tab characters in the resulting file. 3627 1.1 joerg 3628 1.1 joerg Possible values: 3629 1.1 joerg 3630 1.1 joerg * ``UT_Never`` (in configuration: ``Never``) 3631 1.1 joerg Never use tab. 3632 1.1 joerg 3633 1.1 joerg * ``UT_ForIndentation`` (in configuration: ``ForIndentation``) 3634 1.1 joerg Use tabs only for indentation. 3635 1.1 joerg 3636 1.1 joerg * ``UT_ForContinuationAndIndentation`` (in configuration: ``ForContinuationAndIndentation``) 3637 1.1.1.2 joerg Fill all leading whitespace with tabs, and use spaces for alignment that 3638 1.1.1.2 joerg appears within a line (e.g. consecutive assignments and declarations). 3639 1.1.1.2 joerg 3640 1.1.1.2 joerg * ``UT_AlignWithSpaces`` (in configuration: ``AlignWithSpaces``) 3641 1.1.1.2 joerg Use tabs for line continuation and indentation, and spaces for 3642 1.1.1.2 joerg alignment. 3643 1.1 joerg 3644 1.1 joerg * ``UT_Always`` (in configuration: ``Always``) 3645 1.1 joerg Use tabs whenever we need to fill whitespace that spans at least from 3646 1.1 joerg one tab stop to the next one. 3647 1.1 joerg 3648 1.1 joerg 3649 1.1 joerg 3650 1.1.1.2 joerg **WhitespaceSensitiveMacros** (``std::vector<std::string>``) 3651 1.1.1.2 joerg A vector of macros which are whitespace-sensitive and should not 3652 1.1.1.2 joerg be touched. 3653 1.1.1.2 joerg 3654 1.1.1.2 joerg These are expected to be macros of the form: 3655 1.1.1.2 joerg 3656 1.1.1.2 joerg .. code-block:: c++ 3657 1.1.1.2 joerg 3658 1.1.1.2 joerg STRINGIZE(...) 3659 1.1.1.2 joerg 3660 1.1.1.2 joerg In the .clang-format configuration file, this can be configured like: 3661 1.1.1.2 joerg 3662 1.1.1.2 joerg .. code-block:: yaml 3663 1.1.1.2 joerg 3664 1.1.1.2 joerg WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE'] 3665 1.1.1.2 joerg 3666 1.1.1.2 joerg For example: BOOST_PP_STRINGIZE 3667 1.1.1.2 joerg 3668 1.1 joerg .. END_FORMAT_STYLE_OPTIONS 3669 1.1 joerg 3670 1.1 joerg Adding additional style options 3671 1.1 joerg =============================== 3672 1.1 joerg 3673 1.1 joerg Each additional style option adds costs to the clang-format project. Some of 3674 1.1 joerg these costs affect the clang-format development itself, as we need to make 3675 1.1 joerg sure that any given combination of options work and that new features don't 3676 1.1 joerg break any of the existing options in any way. There are also costs for end users 3677 1.1 joerg as options become less discoverable and people have to think about and make a 3678 1.1 joerg decision on options they don't really care about. 3679 1.1 joerg 3680 1.1 joerg The goal of the clang-format project is more on the side of supporting a 3681 1.1 joerg limited set of styles really well as opposed to supporting every single style 3682 1.1 joerg used by a codebase somewhere in the wild. Of course, we do want to support all 3683 1.1 joerg major projects and thus have established the following bar for adding style 3684 1.1 joerg options. Each new style option must .. 3685 1.1 joerg 3686 1.1 joerg * be used in a project of significant size (have dozens of contributors) 3687 1.1 joerg * have a publicly accessible style guide 3688 1.1 joerg * have a person willing to contribute and maintain patches 3689 1.1 joerg 3690 1.1 joerg Examples 3691 1.1 joerg ======== 3692 1.1 joerg 3693 1.1 joerg A style similar to the `Linux Kernel style 3694 1.1 joerg <https://www.kernel.org/doc/Documentation/CodingStyle>`_: 3695 1.1 joerg 3696 1.1 joerg .. code-block:: yaml 3697 1.1 joerg 3698 1.1 joerg BasedOnStyle: LLVM 3699 1.1 joerg IndentWidth: 8 3700 1.1 joerg UseTab: Always 3701 1.1 joerg BreakBeforeBraces: Linux 3702 1.1 joerg AllowShortIfStatementsOnASingleLine: false 3703 1.1 joerg IndentCaseLabels: false 3704 1.1 joerg 3705 1.1 joerg The result is (imagine that tabs are used for indentation here): 3706 1.1 joerg 3707 1.1 joerg .. code-block:: c++ 3708 1.1 joerg 3709 1.1 joerg void test() 3710 1.1 joerg { 3711 1.1 joerg switch (x) { 3712 1.1 joerg case 0: 3713 1.1 joerg case 1: 3714 1.1 joerg do_something(); 3715 1.1 joerg break; 3716 1.1 joerg case 2: 3717 1.1 joerg do_something_else(); 3718 1.1 joerg break; 3719 1.1 joerg default: 3720 1.1 joerg break; 3721 1.1 joerg } 3722 1.1 joerg if (condition) 3723 1.1 joerg do_something_completely_different(); 3724 1.1 joerg 3725 1.1 joerg if (x == y) { 3726 1.1 joerg q(); 3727 1.1 joerg } else if (x > y) { 3728 1.1 joerg w(); 3729 1.1 joerg } else { 3730 1.1 joerg r(); 3731 1.1 joerg } 3732 1.1 joerg } 3733 1.1 joerg 3734 1.1 joerg A style similar to the default Visual Studio formatting style: 3735 1.1 joerg 3736 1.1 joerg .. code-block:: yaml 3737 1.1 joerg 3738 1.1 joerg UseTab: Never 3739 1.1 joerg IndentWidth: 4 3740 1.1 joerg BreakBeforeBraces: Allman 3741 1.1 joerg AllowShortIfStatementsOnASingleLine: false 3742 1.1 joerg IndentCaseLabels: false 3743 1.1 joerg ColumnLimit: 0 3744 1.1 joerg 3745 1.1 joerg The result is: 3746 1.1 joerg 3747 1.1 joerg .. code-block:: c++ 3748 1.1 joerg 3749 1.1 joerg void test() 3750 1.1 joerg { 3751 1.1 joerg switch (suffix) 3752 1.1 joerg { 3753 1.1 joerg case 0: 3754 1.1 joerg case 1: 3755 1.1 joerg do_something(); 3756 1.1 joerg break; 3757 1.1 joerg case 2: 3758 1.1 joerg do_something_else(); 3759 1.1 joerg break; 3760 1.1 joerg default: 3761 1.1 joerg break; 3762 1.1 joerg } 3763 1.1 joerg if (condition) 3764 1.1.1.2 joerg do_something_completely_different(); 3765 1.1 joerg 3766 1.1 joerg if (x == y) 3767 1.1 joerg { 3768 1.1 joerg q(); 3769 1.1 joerg } 3770 1.1 joerg else if (x > y) 3771 1.1 joerg { 3772 1.1 joerg w(); 3773 1.1 joerg } 3774 1.1 joerg else 3775 1.1 joerg { 3776 1.1 joerg r(); 3777 1.1 joerg } 3778 1.1 joerg } 3779