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

via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 02:15:18 PST 2024


mydeveloperday wrote:

> > I struggle with changes that encourage people to not be fully clang-formatted, I would prefer to ask why we need this feature, can we have some examples of where this would be used?
> 
> This makes it so only one line isn't formatted instead of the current solution which is 2 lines unformatted. Additionally, if you start writing code in between the unformatted region you inherit the unformatted scope. Being able to disable the formatter for only a single line means the formatter will be disabled for the shortest amount of code possible.

I understand what is can be used for, I'm asking why its needed? I don't understand why people are needing to unformat just one line, what is broken?

The implementation IMHO just complicates the code (I much prefer the isClangFormatOn() function than the parseXXXX()) 

I don't even deny it might be a nice to have, my concern is why do we continue to appease the people who don't want to use clang-format warts and all. I would prefer we put the effort into fixing the formatting issues which mean people are having to use this rather than marking hundreds of lines as // clang-format off.

Rather than complicating the code with a myriad of rules that effectively give half a dozen ways of doing the same thing. To me the current // clang-format off/on is enough, for everything else log an issue, or better still submit a pull request.


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


More information about the cfe-commits mailing list