summaryrefslogtreecommitdiffstats
path: root/clang/docs/ClangFormatStyleOptions.rst
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Allow optimizer to break template declaration.Francois Ferrand2018-05-161-7/+45
| | | | | | | | | | | | | | | | | | | Summary: Introduce `PenaltyBreakTemplateDeclaration` to control the penalty, and change `AlwaysBreakTemplateDeclarations` to an enum with 3 modes: * `No` for regular, penalty based, wrapping of template declaration * `MultiLine` for always wrapping before multi-line declarations (e.g. same as legacy behavior when `AlwaysBreakTemplateDeclarations=false`) * `Yes` for always wrapping (e.g. same as legacy behavior when `AlwaysBreakTemplateDeclarations=true`) Reviewers: krasimir, djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42684 llvm-svn: 332436
* [clang-format] Fix documentation for SpaceAfterCStyleCast optionKrasimir Georgiev2018-03-061-2/+50
| | | | | | | | | | | | | | | | Patch contributed by @EricMarti! Summary: I noticed that the example for SpaceAfterCStyleCast does not match its description. I fixed the example after testing it out. Reviewers: rsmith, krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43731 llvm-svn: 326781
* [clang-format] Add SpaceBeforeColon optionFrancois Ferrand2018-03-011-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: When disabled, this option allows removing the space before colon, making it act more like the semi-colon. When enabled (default), the current behavior is not affected. This mostly affects C++11 loop, initializer list, inheritance list and container literals: class Foo: Bar {} Foo::Foo(): a(a) {} for (auto i: myList) {} f({a: 1, b: 2, c: 3}); Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: xvallspl, teemperor, karies, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32525 llvm-svn: 326426
* Fix typos of occurred and occurrenceMalcolm Parsons2018-01-241-1/+1
| | | | llvm-svn: 323316
* [clang-format] Adds a canonical delimiter to raw string formattingKrasimir Georgiev2018-01-191-0/+4
| | | | | | | | | | | | | | | | Summary: This patch adds canonical delimiter support to the raw string formatting. This allows matching delimiters to be updated to the canonical one. Reviewers: bkramer Reviewed By: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42187 llvm-svn: 322956
* [clang-format] adds enclosing function detection to raw string formattingKrasimir Georgiev2018-01-171-21/+36
| | | | | | | | | | | | | | Summary: This patch adds enclosing function detection to raw string formatting. Reviewers: bkramer Reviewed By: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42167 llvm-svn: 322678
* [clang-format] Add option to group multiple #include blocks when sorting ↵Krasimir Georgiev2017-11-271-0/+39
| | | | | | | | | | | | | | | | | | | | includes Summary: This patch allows grouping multiple #include blocks together and sort all includes as one big block. Additionally, sorted includes can be regrouped after sorting based on configured categories. Contributed by @KrzysztofKapusta! Reviewers: krasimir Reviewed By: krasimir Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D40288 llvm-svn: 319024
* Indent code blocks so they are actually treated as suchStephan Bergmann2017-11-171-9/+9
| | | | llvm-svn: 318530
* [clang-format] Keep Sphinx happy after r317794Krasimir Georgiev2017-11-091-5/+6
| | | | llvm-svn: 317799
* [clang-format] Sort using declarations by splitting on '::'Krasimir Georgiev2017-11-091-7/+30
| | | | | | | | | | | | | | Summary: This patch improves using declarations sorting. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39786 llvm-svn: 317794
* Split the AlignTrailingComments on several lines. The comments were applied ↵Sylvestre Ledru2017-10-121-3/+7
| | | | | | to the right columns llvm-svn: 315568
* [clang-format] New flag - BraceWrapping.AfterExternBlockKrasimir Georgiev2017-09-151-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Bug: https://bugs.llvm.org/show_bug.cgi?id=34016 - **"extern C part"** **Problem:** Due to the lack of "brace wrapping extern" flag, clang format does parse the block after **extern** keyword moving the opening bracket to the header line always! **Patch description:** A new style added, new configuration flag - **BraceWrapping.AfterExternBlock** that allows us to decide whether we want a break before brace or not. Reviewers: djasper, krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37845 Contributed by @PriMee! llvm-svn: 313354
* [clang-format] Fix documentation for AllowAllParametersOfDeclarationOnNextLineDaniel Jasper2017-09-071-5/+12
| | | | | | | | | | | | The current description of AllowAllParametersOfDeclarationOnNextLine in the Clang-Format Style Options guide suggests that it is possible to format function declaration, which fits in a single line (what is not supported in current clang-format version). Also the example was not reproducible and mades no sense. Patch by Lucja Mazur, thank you! llvm-svn: 312721
* Add an usage example of BreakBeforeBracesSylvestre Ledru2017-09-071-0/+9
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37531 llvm-svn: 312717
* Refresh the clang format options doc with the recent changesSylvestre Ledru2017-09-071-13/+41
| | | | | | | | | | | | | | | | Summary: Looks like we are out of sync between the doc and the code. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D37558 llvm-svn: 312716
* clang-format: Add preprocessor directive indentationKrasimir Georgiev2017-08-301-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is an implementation for [bug 17362](https://bugs.llvm.org/attachment.cgi?bugid=17362) which adds support for indenting preprocessor statements inside if/ifdef/endif. This takes previous work from fmauch (https://github.com/fmauch/clang/tree/preprocessor_indent) and makes it into a full feature. The context of this patch is that I'm a VMware intern, and I implemented this because VMware needs the feature. As such, some decisions were made based on what VMware wants, and I would appreciate suggestions on expanding this if necessary to use-cases other people may want. This adds a new enum config option, `IndentPPDirectives`. Values are: * `PPDIS_None` (in config: `None`): ``` #if FOO #if BAR #include <foo> #endif #endif ``` * `PPDIS_AfterHash` (in config: `AfterHash`): ``` #if FOO # if BAR # include <foo> # endif #endif ``` This is meant to work whether spaces or tabs are used for indentation. Preprocessor indentation is independent of indentation for non-preprocessor lines. Preprocessor indentation also attempts to ignore include guards with the checks: 1. Include guards cover the entire file 2. Include guards don't have `#else` 3. Include guards begin with ``` #ifndef <var> #define <var> ``` This patch allows `UnwrappedLineParser::PPBranchLevel` to be decremented to -1 (the initial value is -1) so the variable can be used for indent tracking. Defects: * This patch does not handle the case where there's code between the `#ifndef` and `#define` but all other conditions hold. This is because when the #define line is parsed, `UnwrappedLineParser::Lines` doesn't hold the previous code line yet, so we can't detect it. This is out of the scope of this patch. * This patch does not handle cases where legitimate lines may be outside an include guard. Examples are `#pragma once` and `#pragma GCC diagnostic`, or anything else that does not change the meaning of the file if it's included multiple times. * This does not detect when there is a single non-preprocessor line in front of an include-guard-like structure where other conditions hold because `ScopedLineState` hides the line. * Preprocessor indentation throws off `TokenAnnotator::setCommentLineLevels` so the indentation of comments immediately before indented preprocessor lines is toggled on each run. Fixing this issue appears to be a major change and too much complexity for this patch. Contributed by @euhlmann! Reviewers: djasper, klimek, krasimir Reviewed By: djasper, krasimir Subscribers: krasimir, mzeren-vmw, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D35955 llvm-svn: 312125
* [clang-format] Add a SortUsingDeclaration option and enable it by defaultKrasimir Georgiev2017-06-231-0/+9
| | | | | | | | | | | | | | | | Summary: This patch adds a `SortUsingDeclaration` style option and enables it for llvm style. Reviewers: klimek Reviewed By: klimek Subscribers: klimek Differential Revision: https://reviews.llvm.org/D34453 llvm-svn: 306094
* [clang-format] Update dump_format_style.py to indent nested fieldsKrasimir Georgiev2017-06-231-102/+102
| | | | | | | | | | | | | | | | | | Summary: This updates the format options documentation script to indent the documentation of nested fields. The previous format caused some problems, as when a bulleted list ends with a multiline comment. See the buildbot failure http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/10020/steps/docs-clang-html/logs/stdio Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34552 llvm-svn: 306093
* [clang-format] Update style documentation, NFCKrasimir Georgiev2017-06-231-13/+96
| | | | | | | | | | | | Summary: Style documentation is generated automatically by `docs/tools/dump_format_style.py`. This hasn't been ran for a while. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D34457 llvm-svn: 306089
* Correct documentation about the AfterClass clang-format optionEric Fiselier2017-06-151-5/+5
| | | | llvm-svn: 305450
* Fix a mistake in the clang format documentation (BreakBeforeTernaryOperators)Sylvestre Ledru2017-06-061-1/+1
| | | | | | Patch sent through github by Jason Hsu llvm-svn: 304776
* [clang-format] Convert AlignEscapedNewlinesLeft to an enum, addingDaniel Jasper2017-05-081-15/+37
| | | | | | | | | | | | | | | | | | | | DontAlign This converts the clang-format option AlignEscapedNewlinesLeft from a boolean to an enum, named AlignEscapedNewlines, with options Left (prev. true), Right (prev. false), and a new option DontAlign. When set to DontAlign, the backslashes are placed just after the last token in each line: #define EXAMPLE \ do { \ int x = aaaaa; \ int b; \ int dddddddddd; \ } while (0) Patch by jtbandes. Thank you! llvm-svn: 302428
* Add more examples to clang-format configurationSylvestre Ledru2017-04-111-3/+66
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: Eugene.Zelenko, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D31408 llvm-svn: 299919
* clang-format: Support formatting utf-8 character literals in C++11+ mode.Nico Weber2017-04-051-1/+2
| | | | | | | | | | | | | | | | | | | clang-format <<END auto c1 = u8'a'; auto c2 = u'a'; END Before: auto c1 = u8 'a'; auto c2 = u'a'; Now: auto c1 = u8'a'; auto c2 = u'a'; Patch from Denis Gladkikh <llvm@denis.gladkikh.email>! llvm-svn: 299574
* Fix some sphinx -Werror'sJonathan Roelofs2017-03-201-3/+3
| | | | | | ... mostly having to do with code blocks which the syntax highlighter chokes on llvm-svn: 298275
* Add more examples to clang-format configurationSylvestre Ledru2017-03-201-2/+228
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D30990 llvm-svn: 298245
* [clang-format] Add more examples and fix a bug in the py generation scriptSylvestre Ledru2017-03-131-0/+291
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D30860 llvm-svn: 297623
* [clang-format] Add option to break before inheritance separation operator in ↵Andi-Bogdan Postelnicu2017-03-101-0/+4
| | | | | | | | class declaration. Differential Revision: https://reviews.llvm.org/D30487 llvm-svn: 297467
* Remove a useless subsitution in doxygen2rst which was incorrectly replacing ↵Sylvestre Ledru2017-03-091-5/+5
| | | | | | | | | | | | | | | | * by \* Summary: For example, "int\* a;" is displayed instead of "int* a;" Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30740 llvm-svn: 297363
* Add more examples to clang-format configurationSylvestre Ledru2017-03-081-1/+104
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D30734 llvm-svn: 297275
* Add examples to clang-format configurationSylvestre Ledru2017-03-061-0/+93
| | | | | | | | | | | | Reviewers: klimek, djasper Reviewed By: djasper Subscribers: krasimir, kimgr, cfe-commits Differential Revision: https://reviews.llvm.org/D30532 llvm-svn: 297025
* [clang-format] Add a new flag FixNamespaceComments to FormatStyleKrasimir Georgiev2017-03-011-1/+14
| | | | | | | | | | | | | | | | Summary: This patch enables namespace end comments under a new flag FixNamespaceComments, which is enabled for the LLVM and Google styles. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D30405 llvm-svn: 296632
* clang-format: Add SpaceAfterTemplateSylvestre Ledru2016-08-091-0/+3
| | | | | | | | | | | | | | | | Summary: This is required for compliance with the Mozilla style guide. This is a rebase+minor change of Birunthan Mohanathas's patch Reviewers: djasper Subscribers: klimek, cfe-commits, opilarium Differential Revision: https://reviews.llvm.org/D23317 llvm-svn: 278121
* clang-format: Make include sorting's main include detection configurable.Daniel Jasper2016-03-211-0/+29
| | | | | | | | | | This patch adds a regular expression to configure suffixes of an included file to check whether it is the "main" include of the current file. Previously, clang-format has allowed arbitrary suffixes on the formatted file, which is still the case when no IncludeMainRegex is specified. llvm-svn: 263943
* Workaround doxygen bug https://bugzilla.gnome.org/show_bug.cgi?id=506243Alexander Kornienko2016-02-271-1/+1
| | | | llvm-svn: 262138
* Fix a typo. NFCAlexander Kornienko2016-02-231-1/+1
| | | | llvm-svn: 261646
* Clean up clang-format options documentation. NFCAlexander Kornienko2016-02-231-37/+85
| | | | | | | Use uniform style for inline code blocks, specify language for YAML code blocks, various formatting fixes etc. llvm-svn: 261645
* Update clang-format options docs.Alexander Kornienko2016-02-231-5/+26
| | | | llvm-svn: 261643
* Fix some typos in the clang docSylvestre Ledru2016-02-141-1/+1
| | | | llvm-svn: 260856
* Support AlwaysBreakAfterReturnTypeZachary Turner2015-12-181-2/+21
| | | | | | | | | | | This changes the behavior of AlwaysBreakAfterDeclarationReturnType so that it supports breaking after declarations, definitions, or both. Differential Revision: http://reviews.llvm.org/D10370 Reviewed By: Daniel Jasper llvm-svn: 256046
* clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.Daniel Jasper2015-10-271-4/+28
| | | | | | | | | | | | | | | | | | | | Summary: If this option is set, clang-format will always insert a line wrap, e.g. before the first parameter of a function call unless all parameters fit on the same line. This obviates the need to make a decision on the alignment itself. Use this style for Google's JavaScript style and add some minor tweaks to correctly handle nested blocks etc. with it. Don't use this option for for/while loops. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14104 llvm-svn: 251405
* clang-format: Hopefully fix code blocks in docs.Daniel Jasper2015-10-071-0/+6
| | | | | | Otherwise I will have to install sphinx ;).. llvm-svn: 249542
* clang-format: Add empty line before code-blocks in Docs.Daniel Jasper2015-10-061-0/+6
| | | | llvm-svn: 249394
* clang-format: Make IncludeCategories configurable in .clang-format file.Daniel Jasper2015-10-061-14/+35
| | | | | | | | | This was made much easier by introducing an IncludeCategory struct to replace the previously used std::pair. Also, cleaned up documentation and added examples. llvm-svn: 249392
* clang-format: Small doc fix.Daniel Jasper2015-10-051-3/+3
| | | | llvm-svn: 249312
* clang-format: Remove sentence in option cost threshold that weakens theDaniel Jasper2015-10-051-2/+0
| | | | | | | statement. Specifically, we don't want people that have already written a patch to just write a style guide for their 1-person project. llvm-svn: 249290
* clang-format: Document threshold for adding new options.Daniel Jasper2015-10-051-0/+22
| | | | llvm-svn: 249289
* clang-format: Add a new brace style "custom" as well as flags toDaniel Jasper2015-09-291-0/+38
| | | | | | | | | | | | | | | control the individual braces. The existing choices for brace wrapping are now merely presets for the different flags that get expanded upon calling the reformat function. All presets have been chose to keep the existing formatting, so there shouldn't be any difference in formatting behavior. Also change the dump_format_style.py to properly document the nested structs that are used to keep these flags discoverable among all the configuration flags. llvm-svn: 248802
* Add WebKit brace style configuration option.Roman Kashitsyn2015-08-101-1/+3
| | | | | | | | | | | | | | | | | | Summary: Add brace style `BS_WebKit` as described on https://www.webkit.org/coding/coding-style.html: * Function definitions: place each brace on its own line. * Other braces: place the open brace on the line preceding the code block; place the close brace on its own line. Set brace style used in `getWebKitStyle()` to the newly added `BS_WebKit`. Reviewers: djasper, klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D11837 llvm-svn: 244446
* clang-format: Add Mozilla brace breaking styleBirunthan Mohanathas2015-07-121-0/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D10883 llvm-svn: 241986
OpenPOWER on IntegriCloud