[all-commits] [llvm/llvm-project] 5a0b4c: [clang-format] Preserve trailing NOLINTEND placeme...
Jiaqi He via All-commits
all-commits at lists.llvm.org
Sat Apr 18 03:05:51 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5a0b4c95de4b08d9c18667fc06f17253fc18f087
https://github.com/llvm/llvm-project/commit/5a0b4c95de4b08d9c18667fc06f17253fc18f087
Author: Jiaqi He <heturing at gmail.com>
Date: 2026-04-18 (Sat, 18 Apr 2026)
Changed paths:
M clang/lib/Format/DefinitionBlockSeparator.cpp
M clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
Log Message:
-----------
[clang-format] Preserve trailing NOLINTEND placement with SeparateDefinitionBlocks (#190741)
Fixes https://github.com/llvm/llvm-project/issues/189384.
When `SeparateDefinitionBlocks: Always` is enabled, clang-format may
separate a clearly trailing comment block by inserting an empty line
before it.
For example, it may format:
```c++
// NOLINTBEGIN
int x = 1;
int y = 2;
// NOLINTEND
void some_function() {}
```
as
```c++
// NOLINTBEGIN
int x = 1;
int y = 2;
// NOLINTEND
void some_function() {}
```
This is undesirable as the trailing comment is visually attached to the
preceding block rather than acting as a separator for the following
definition.
This change preserves comment blocks that are clearly trailing the
preceding block.
Also add a regression test.
---------
Co-authored-by: owenca <owenpiano at gmail.com>
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