[clang] [clang-format] extend clang-format directive with options to prevent formatting for one line (PR #118566)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 1 21:05:37 PST 2025


owenca wrote:

> > If we were to add // clang-format off-next-line, would "next line" mean the next physical or logical/unwrapped line?
> 
> I would expect it to apply only to the physical line, similar to how other formatters work. However, the main concern doesn’t seem to be about its behavior but rather about extending clang-format directive with new options at all.

This is an essential detail missing from the description of the proposed option for us to accept a new option and review the patch.

> From my perspective, these options are just additional ways to control formatting and give users more flexibility. These options aren’t intended to eliminate `clang-format` usage, and based on user feedback on the issue, it seems there are cases in which these options are useful. For [instance](https://github.com/athomps/lammps/blob/ceb9466172398e9a20cb510528b4b17f719c7cf2/src/set.h#L15-L17),
> 
> ```c++
> // clang-format off
> CommandStyle(set,Set);
> // clang-format on
> ```
> 
> vs
> 
> ```c++
> CommandStyle(set,Set); // clang-format off-line
> ```

For simplicity and clarify, I might accept a lone comment above the (physical) line to be skipped by clang-format, but not a trailing comment.

> If these options introduce significant complexity that could lead to regressions without improving the development experience, I believe the discussion should be wrapped up, and both the PR and issue should be closed. Otherwise, it would be helpful to continue the discussion in the issue to gather more insights into why users need these changes. Does that make sense?

I’m fine with continuing the discussion in the GitHub issue, but I’m still with @mydeveloperday on this one.

https://github.com/llvm/llvm-project/pull/118566


More information about the cfe-commits mailing list