[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
Adheesh Wadkar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 26 15:08:54 PDT 2023
apwadkar created this revision.
Herald added a project: All.
apwadkar requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Added the DecorateReflowComments option to control whether '* ' are added
to the beginnings of continuation lines for block comments.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146926
Files:
clang/include/clang/Format/Format.h
clang/lib/Format/BreakableToken.cpp
clang/lib/Format/Format.cpp
Index: clang/lib/Format/Format.cpp
===================================================================
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -901,6 +901,7 @@
Style.ConstructorInitializerIndentWidth);
IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
IO.mapOptional("Cpp11BracedListStyle", Style.Cpp11BracedListStyle);
+ IO.mapOptional("DecorateReflowedComments", Style.DecorateReflowedComments);
IO.mapOptional("DerivePointerAlignment", Style.DerivePointerAlignment);
IO.mapOptional("DisableFormat", Style.DisableFormat);
IO.mapOptional("EmptyLineAfterAccessModifier",
Index: clang/lib/Format/BreakableToken.cpp
===================================================================
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -403,7 +403,7 @@
}
Decoration = "* ";
- if (Lines.size() == 1 && !FirstInLine) {
+ if ((Lines.size() == 1 && !FirstInLine) || !Style.DecorateReflowedComments) {
// Comments for which FirstInLine is false can start on arbitrary column,
// and available horizontal space can be too small to align consecutive
// lines with the first one.
Index: clang/include/clang/Format/Format.h
===================================================================
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2007,6 +2007,20 @@
/// \version 3.4
bool Cpp11BracedListStyle;
+ /// If ``true``, when a block comment is reflowed, add a ``* `` to the
+ /// beginning of the continuation line.
+ /// \code
+ /// false:
+ /// /* blah blah blah blah blah blah blah blah blah blah blah blah blah
+ /// blah blah blah blah blah blah blah blah */
+ ///
+ /// true:
+ /// /* blah blah blah blah blah blah blah blah blah blah blah blah blah
+ /// * blah blah blah blah blah blah blah blah */
+ /// \endcode
+ /// \version 17
+ bool DecorateReflowedComments;
+
/// This option is **deprecated**. See ``DeriveLF`` and ``DeriveCRLF`` of
/// ``LineEnding``.
/// \version 10
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146926.508443.patch
Type: text/x-patch
Size: 2125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230326/6cbb5e60/attachment.bin>
More information about the cfe-commits
mailing list