summaryrefslogtreecommitdiff
path: root/docs/ClangFormatStyleOptions.rst
diff options
context:
space:
mode:
authorPaul Hoad <mydeveloperday@gmail.com>2019-03-13 08:07:46 +0000
committerPaul Hoad <mydeveloperday@gmail.com>2019-03-13 08:07:46 +0000
commit0ba0294ffd68b08a82fbcf6e132974363331e777 (patch)
tree2a04f0c4aea864f82902000711f88fd595ea2113 /docs/ClangFormatStyleOptions.rst
parent309f4aff2af55a8838c7cb790acd4293f3e3d49f (diff)
downloadclang-0ba0294ffd68b08a82fbcf6e132974363331e777.tar.gz
[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present
Summary: Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010 Code like: ``` if(true) var++; else { var--; } ``` is reformatted to be ``` if (true) var++; else { var--; } ``` Even when `AllowShortIfStatementsOnASingleLine` is true The following revision comes from a +1'd suggestion in the PR to support AllowShortIfElseStatementsOnASingleLine This suppresses the clause prevents the merging of the if when there is a compound else Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk Reviewed By: reuk Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D59087 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356029 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/ClangFormatStyleOptions.rst')
-rw-r--r--docs/ClangFormatStyleOptions.rst41
1 files changed, 39 insertions, 2 deletions
diff --git a/docs/ClangFormatStyleOptions.rst b/docs/ClangFormatStyleOptions.rst
index 582b9d938c..d4a56d3bb3 100644
--- a/docs/ClangFormatStyleOptions.rst
+++ b/docs/ClangFormatStyleOptions.rst
@@ -365,10 +365,47 @@ the configuration (without a prefix: ``Auto``).
};
void f() { bar(); }
+**AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``)
+ Dependent on the value, ``if (a) return 0;`` can be put on a
+ single line.
+
+ Possible values:
+
+ * ``SIS_Never`` (in configuration: ``Never``)
+ Do not allow short if functions.
+
+ .. code-block:: c++
+
+ if (a)
+ return;
+ else
+ return;
+
+ * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
+ Allow short if functions on the same line, as long as else
+ is not a compound statement.
+ .. code-block:: c++
+
+ if (a) return;
+ else
+ return;
+
+ if (a)
+ return;
+ else {
+ return;
+ }
-**AllowShortIfStatementsOnASingleLine** (``bool``)
- If ``true``, ``if (a) return;`` can be put on a single line.
+ * ``SIS_Always`` (in configuration: ``Always``)
+ Allow short if statements even if the else is a compound statement.
+
+ .. code-block:: c++
+
+ if (a) return;
+ else {
+ return;
+ }
**AllowShortLoopsOnASingleLine** (``bool``)
If ``true``, ``while (true) continue;`` can be put on a single