[clang] [clang-format] Propagate `LeadingEmptyLinesAffected` when joining lines (PR #146761)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 5 02:01:47 PDT 2025
================
@@ -986,7 +986,7 @@ class LineJoiner {
void join(AnnotatedLine &A, const AnnotatedLine &B) {
assert(!A.Last->Next);
assert(!B.First->Previous);
- if (B.Affected)
+ if (B.Affected || (B.LeadingEmptyLinesAffected && A.Last->Children.empty()))
----------------
owenca wrote:
Either dropping the condition with a comment, or adding an assertion would be fine by me. For example,
```cc
if (B.Affected || B.LeadingEmptyLinesAffected) {
assert(B.Affected || A.Last->Children.empty());
```
https://github.com/llvm/llvm-project/pull/146761
More information about the cfe-commits
mailing list