Skip to content

Commit 49b5691

Browse files
committed
added a style for reflow comments to not add a star when splitting blocked comments.
1 parent d4c41b7 commit 49b5691

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

.clang-format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
BasedOnStyle: LLVM
22
LineEnding: LF
3+
ColumnLimit: 80
4+
ReflowComments: true
5+
ReflowCommentsNoStar: true

clang/include/clang/Format/Format.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,6 +4240,19 @@ struct FormatStyle {
42404240
/// \version 3.8
42414241
ReflowCommentsStyle ReflowComments;
42424242

4243+
/// If reflow comments is enabled, dont include * in the formatted block comment.
4244+
/// \code
4245+
/// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
4246+
/// // information
4247+
/// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
4248+
/// information */
4249+
/// /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
4250+
/// information and a misaligned second line */
4251+
/// \endcode
4252+
4253+
/// \version 22
4254+
bool ReflowCommentsNoStar;
4255+
42434256
/// Remove optional braces of control statements (``if``, ``else``, ``for``,
42444257
/// and ``while``) in C++ according to the LLVM coding style.
42454258
/// \warning

clang/lib/Format/BreakableToken.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ BreakableBlockComment::BreakableBlockComment(
506506
}
507507

508508
Decoration = "* ";
509+
if (Style.ReflowCommentsNoStar)
510+
Decoration = "";
509511
if (Lines.size() == 1 && !FirstInLine) {
510512
// Comments for which FirstInLine is false can start on arbitrary column,
511513
// and available horizontal space can be too small to align consecutive

clang/lib/Format/Format.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,7 @@ template <> struct MappingTraits<FormatStyle> {
12751275
IO.mapOptional("RawStringFormats", Style.RawStringFormats);
12761276
IO.mapOptional("ReferenceAlignment", Style.ReferenceAlignment);
12771277
IO.mapOptional("ReflowComments", Style.ReflowComments);
1278+
IO.mapOptional("ReflowCommentsNoStar", Style.ReflowCommentsNoStar);
12781279
IO.mapOptional("RemoveBracesLLVM", Style.RemoveBracesLLVM);
12791280
IO.mapOptional("RemoveEmptyLinesInUnwrappedLines",
12801281
Style.RemoveEmptyLinesInUnwrappedLines);

test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* erfdfdfdfdfdfd fd fdfd fd fd fd fd fd fd fd fd fd fd fd fd fd fdf df df df df df df df df df df df fd f */
2+
void func()
3+
{
4+
}

0 commit comments

Comments
 (0)