[PATCH] D103204: [Format] New BreakInheritanceList style AfterComma
Zhihao Yuan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 26 14:10:50 PDT 2021
lichray updated this revision to Diff 348092.
lichray added a comment.
Fix typo in docs.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103204/new/
https://reviews.llvm.org/D103204
Files:
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3639,6 +3639,9 @@
if (Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma &&
Right.is(TT_InheritanceComma))
return true;
+ if (Style.BreakInheritanceList == FormatStyle::BILS_AfterComma &&
+ Left.is(TT_InheritanceComma))
+ return true;
if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\""))
// Multiline raw string literals are special wrt. line breaks. The author
// has made a deliberate choice and might have aligned the contents of the
@@ -4058,12 +4061,18 @@
if (Right.is(TT_CtorInitializerComma) &&
Style.BreakConstructorInitializers == FormatStyle::BCIS_BeforeComma)
return true;
- if (Left.is(TT_InheritanceComma) &&
- Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma)
- return false;
- if (Right.is(TT_InheritanceComma) &&
- Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma)
- return true;
+ if (Left.is(TT_InheritanceComma)) {
+ if (Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma)
+ return false;
+ else if (Style.BreakInheritanceList == FormatStyle::BILS_AfterComma)
+ return true;
+ }
+ if (Right.is(TT_InheritanceComma)) {
+ if (Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma)
+ return true;
+ else if (Style.BreakInheritanceList == FormatStyle::BILS_AfterComma)
+ return false;
+ }
if ((Left.is(tok::greater) && Right.is(tok::greater)) ||
(Left.is(tok::less) && Right.is(tok::less)))
return false;
Index: clang/lib/Format/Format.cpp
===================================================================
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -240,6 +240,7 @@
IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon);
IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma);
IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon);
+ IO.enumCase(Value, "AfterComma", FormatStyle::BILS_AfterComma);
}
};
Index: clang/include/clang/Format/Format.h
===================================================================
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1829,7 +1829,14 @@
/// Base2
/// {};
/// \endcode
- BILS_AfterColon
+ BILS_AfterColon,
+ /// Break inheritance list only after the commas.
+ /// \code
+ /// class Foo : Base1,
+ /// Base2
+ /// {};
+ /// \endcode
+ BILS_AfterComma
};
/// The inheritance list style to use.
Index: clang/docs/ClangFormatStyleOptions.rst
===================================================================
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -1999,6 +1999,15 @@
Base2
{};
+ * ``BILS_AfterComma`` (in configuration: ``AfterComma``)
+ Break inheritance list only after the commas.
+
+ .. code-block:: c++
+
+ class Foo : Base1,
+ Base2
+ {};
+
**BreakStringLiterals** (``bool``)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103204.348092.patch
Type: text/x-patch
Size: 3230 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210526/49cccf60/attachment.bin>
More information about the cfe-commits
mailing list