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
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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits