diff options
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 1e4f5690ef24..5073f5105d05 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -1984,9 +1984,17 @@ ContinuationIndenter::createBreakableToken(const FormatToken &Current, } else if (Current.is(TT_LineComment) && (Current.Previous == nullptr || Current.Previous->isNot(TT_ImplicitStringLiteral))) { + bool RegularComments = [&]() { + for (const FormatToken *T = &Current; T && T->is(TT_LineComment); + T = T->Next) { + if (!(T->TokenText.startswith("//") || T->TokenText.startswith("#"))) + return false; + } + return true; + }(); if (!Style.ReflowComments || CommentPragmasRegex.match(Current.TokenText.substr(2)) || - switchesFormatting(Current)) + switchesFormatting(Current) || !RegularComments) return nullptr; return std::make_unique<BreakableLineCommentSection>( Current, StartColumn, /*InPPDirective=*/false, Encoding, Style); @@ -2195,11 +2203,10 @@ ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, // When breaking before a tab character, it may be moved by a few columns, // but will still be expanded to the next tab stop, so we don't save any // columns. - if (NewRemainingTokenColumns == RemainingTokenColumns) { + if (NewRemainingTokenColumns >= RemainingTokenColumns) { // FIXME: Do we need to adjust the penalty? break; } - assert(NewRemainingTokenColumns < RemainingTokenColumns); LLVM_DEBUG(llvm::dbgs() << " Breaking at: " << TailOffset + Split.first << ", " << Split.second << "\n"); |