[all-commits] [llvm/llvm-project] 878ce2: [clang-format] Propagate `LeadingEmptyLinesAffecte...

Eric Li via All-commits all-commits at lists.llvm.org
Sat Jul 5 14:07:21 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 878ce210e30f8ebcb4b73d834f91229a403e2376
      https://github.com/llvm/llvm-project/commit/878ce210e30f8ebcb4b73d834f91229a403e2376
  Author: Eric Li <li.zhe.hua at gmail.com>
  Date:   2025-07-05 (Sat, 05 Jul 2025)

  Changed paths:
    M clang/lib/Format/UnwrappedLineFormatter.cpp
    M clang/unittests/Format/FormatTestSelective.cpp

  Log Message:
  -----------
  [clang-format] Propagate `LeadingEmptyLinesAffected` when joining lines (#146761)

Before this commit, when `LineJoiner` joins a line with affected leading
whitespace, it would drop the knowledge of this entirely. However, when
the `AffectedRangeManager` is computing the affected lines, the leading
empty whitespace lines are potentially considered for non-first tokens
in the `AnnotatedLine`. This causes a discrepancy in behavior when an
`AnnotatedLine` is put together from joining multiple lines versus when
it is not.

We change `LineJoiner::join` to follow `AffectedRangeManager`'s logic,
considering the leading whitespace when determining `Affected` for a
token.


https://github.com/llvm/llvm-project/blob/a63f57262898588b576d66e5fd79c0aa64b35f2d/clang/lib/Format/AffectedRangeManager.cpp#L111-L130

Fixes #138942.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list