From d671e605e4d22270300406268d483eb95558f543 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sun, 11 Aug 2019 17:48:36 +0000 Subject: [clang-format] Expand AllowShortBlocksOnASingleLine for WebKit See PR40840 Differential Revision: https://reviews.llvm.org/D66059 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368539 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Format/Format.h | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'include/clang/Format') diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h index 657ec4e3e5..7a6688bbdb 100644 --- a/include/clang/Format/Format.h +++ b/include/clang/Format/Format.h @@ -216,10 +216,37 @@ struct FormatStyle { /// \endcode bool AllowAllParametersOfDeclarationOnNextLine; - /// Allows contracting simple braced statements to a single line. - /// - /// E.g., this allows ``if (a) { return; }`` to be put on a single line. - bool AllowShortBlocksOnASingleLine; + /// Different styles for merging short blocks containing at most one + /// statement. + enum ShortBlockStyle { + /// Never merge blocks into a single line. + /// \code + /// while (true) { + /// } + /// while (true) { + /// continue; + /// } + /// \endcode + SBS_Never, + /// Only merge empty blocks. + /// \code + /// while (true) {} + /// while (true) { + /// continue; + /// } + /// \endcode + SBS_Empty, + /// Always merge short blocks into a single line. + /// \code + /// while (true) {} + /// while (true) { continue; } + /// \endcode + SBS_Always, + }; + + /// Dependent on the value, ``while (true) { continue; }`` can be put on a + /// single line. + ShortBlockStyle AllowShortBlocksOnASingleLine; /// If ``true``, short case labels will be contracted to a single line. /// \code -- cgit v1.2.1