Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
BasedOnStyle: LLVM
LineEnding: LF
ColumnLimit: 80
ReflowComments: true
ReflowCommentsNoStar: true
13 changes: 13 additions & 0 deletions clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -4250,6 +4250,19 @@ struct FormatStyle {
/// \version 3.8
ReflowCommentsStyle ReflowComments;

/// If reflow comments is enabled, dont include * in the formatted block comment.
/// \code
/// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
/// // information
/// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
/// information */
/// /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
/// information and a misaligned second line */
/// \endcode

/// \version 22
bool ReflowCommentsNoStar;

/// Remove optional braces of control statements (``if``, ``else``, ``for``,
/// and ``while``) in C++ according to the LLVM coding style.
/// \warning
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Format/BreakableToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ BreakableBlockComment::BreakableBlockComment(
}

Decoration = "* ";
if (Style.ReflowCommentsNoStar)
Decoration = "";
if (Lines.size() == 1 && !FirstInLine) {
// Comments for which FirstInLine is false can start on arbitrary column,
// and available horizontal space can be too small to align consecutive
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("RawStringFormats", Style.RawStringFormats);
IO.mapOptional("ReferenceAlignment", Style.ReferenceAlignment);
IO.mapOptional("ReflowComments", Style.ReflowComments);
IO.mapOptional("ReflowCommentsNoStar", Style.ReflowCommentsNoStar);
IO.mapOptional("RemoveBracesLLVM", Style.RemoveBracesLLVM);
IO.mapOptional("RemoveEmptyLinesInUnwrappedLines",
Style.RemoveEmptyLinesInUnwrappedLines);
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Format/ReflowCommentsNoStar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// RUN: clang-format -style="{ColumnLimit: 80, ReflowComments: true, ReflowCommentsNoStar: true}" %S/ReflowCommentsNoStarInput.cpp > %t
// RUN: diff %t %S/ReflowCommentsNoStarExpected.cpp
4 changes: 4 additions & 0 deletions clang/test/Format/ReflowCommentsNoStarExpected.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* 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 */

void func() {}
3 changes: 3 additions & 0 deletions clang/test/Format/ReflowCommentsNoStarInput.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* 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 */

void func() {}
Loading