================
@@ -1033,6 +1034,28 @@ void WhitespaceManager::alignTrailingComments() {
Newlines = 0;
}
}
+ // Break trailing comment alignment at non-trailing block comments on
+ // their own line, or at scope-closing tokens (} or )).
+ if (!C.IsTrailingComment && C.NewlinesBefore > 0 &&
+ (C.Tok->is(tok::comment) || C.Tok->is(tok::r_brace) ||
+ C.Tok->is(tok::r_paren))) {
+ bool HasTrailingCommentOnLine = false;
+ for (int J = I + 1; J < Size && Changes[J].NewlinesBefore == 0; ++J) {
+ if (Changes[J].IsTrailingComment) {
+ HasTrailingCommentOnLine = true;
+ break;
+ }
+ }
+ if (!HasTrailingCommentOnLine) {
+ alignTrailingComments(StartOfSequence, I, MinColumn);
+ MinColumn = 0;
+ MaxColumn = INT_MAX;
+ StartOfSequence = I + 1;
+ Newlines = 0;
+ } else {
+ BreakAfterTrailingComment = true;
+ }
+ }
----------------
owenca wrote:
```suggestion
if (NewLineThreshold > 1 && C.Tok->is(BK_Block)) {
alignTrailingComments(StartOfSequence, I, MinColumn);
MinColumn = 0;
MaxColumn = INT_MAX;
StartOfSequence = I + 1;
Newlines = 0;
continue;
}
```
https://github.com/llvm/llvm-project/pull/208324
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits