[cfe-dev] [llvm-dev] [RFC] Adding support for clang-format making further code modifying changes

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 10 04:35:46 PDT 2021

On Tue, Aug 10, 2021 at 1:32 PM Ben Boeckel <ben.boeckel at kitware.com> wrote:

> On Tue, Aug 10, 2021 at 13:13:09 +0200, Manuel Klimek via cfe-dev wrote:
> > clang-format is designed to run on changed lines, not to have all code be
> > compliant. You can use it for the latter, but I think it's a pretty
> > fundamental difference in development goals.
> The problem I've seen is that the opinion of code formatted with 3 lines
> of context can differ from 5 lines of context which can be still
> different again given the entire file. The only reliable way we've
> gotten it to work is to format the whole file every time. But we require
> well-formatted code via CI processes, so that's fine (if one can afford
> the "rewrite the world" every time the tool gets updated…hence why some
> projects are still on version 3.8(!), others 6, some even made it to 9).

The underlying design idea for clang-format is to give it the whole file as
*context*, but only *format* the changed lines.
clang-format supports that use case very well, and it can even be built
into presubmit checks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210810/876a3a61/attachment.html>

More information about the cfe-dev mailing list