[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
apwadkar added inline comments. Comment at: clang/lib/Format/BreakableToken.cpp:406 Decoration = "* "; - if (Lines.size() == 1 && !FirstInLine) { + if ((Lines.size() == 1 && !FirstInLine) || !Style.DecorateReflowedComments) { // Comments for which FirstInLine is false can start on arbitrary column, HazardyKnusperkeks wrote: > So if set to `false` it will never add the decoration. But when set to `true` > it still will not, if it's the first line. > > This is not what I'd expect reading the documentation. > > If you want to pursue this I think you should go for an enum with `Never`, > `Always`, and `` (what we currently have). > So if set to `false` it will never add the decoration. But when set to `true` > it still will not, if it's the first line. > > This is not what I'd expect reading the documentation. Yeah, I think that makes sense. That's what I was thinking while working on the unit tests, because I realized this was breaking the existing style. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146926/new/ https://reviews.llvm.org/D146926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
HazardyKnusperkeks added inline comments. Comment at: clang/lib/Format/BreakableToken.cpp:406 Decoration = "* "; - if (Lines.size() == 1 && !FirstInLine) { + if ((Lines.size() == 1 && !FirstInLine) || !Style.DecorateReflowedComments) { // Comments for which FirstInLine is false can start on arbitrary column, So if set to `false` it will never add the decoration. But when set to `true` it still will not, if it's the first line. This is not what I'd expect reading the documentation. If you want to pursue this I think you should go for an enum with `Never`, `Always`, and `` (what we currently have). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146926/new/ https://reviews.llvm.org/D146926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
MyDeveloperDay added inline comments. Comment at: clang/include/clang/Format/Format.h:2022 + /// \version 17 + bool DecorateReflowedComments; + you are not setting the default value for this so it could be uninitialized, you need to set that in the LLVMStyle section you need to ensure the == operator has been updated you should be adding a CHECK_PARSE_BOOL() unit test at a minimum but also some verifyFormat checks in clang/unittest/Format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146926/new/ https://reviews.llvm.org/D146926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
MyDeveloperDay added a comment. no you need to run clang/doc/tools/dump_format_style.py This will regnerate ClangFormatStyleOptions.rst from the Format.h change you have here, you then need to include that rst file in the review Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146926/new/ https://reviews.llvm.org/D146926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
apwadkar added a comment. Sorry about the premature review, this is my first commit, and I didn't realize it wouldn't create a draft first. - For rebuilding the docs, I assume I need to add `-DLLVM_BUILD_DOCS=true` to CMake and then run `ninja -C build`? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146926/new/ https://reviews.llvm.org/D146926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
MyDeveloperDay added a comment. You need to add unit tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146926/new/ https://reviews.llvm.org/D146926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
MyDeveloperDay added a comment. You need to regenerate the documentation after changing Format.h Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146926/new/ https://reviews.llvm.org/D146926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments
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