[cfe-dev] [llvm-dev] [RFC] Adding support for clang-format making further code modifying changes
Ben Boeckel via cfe-dev
cfe-dev at lists.llvm.org
Tue Aug 10 04:49:52 PDT 2021
On Tue, Aug 10, 2021 at 13:35:46 +0200, Manuel Klimek wrote:
> 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.
IIRC, Phab deals with "patches" that have infinite context, but that's
not the norm out there. Maybe that's where this assumption comes from?
Anyways, the main issue I've seen is that developers have versions X, Y,
and Z laying around locally depending on their distro or whatever. So
developers' machines "fight" with CI and each other over the preferred
setup. This is why I don't use any formatting-on-save features myself
with any tool: it's CI's job to enforce it, so why am I wasting my time
on pre-commit hooks that aren't even necessarily accurate? It also makes
teasing out my change with `git add -p` that much harder. So instead, I
just say "ignore formatting if you don't have the exact right version
laying around; CI will handle it". The tool we use can rewrite the
entire topic to ensure it is well-formatted at each step on demand. In
fact, we update `clang-format` versions using this mechanism: tell it to
use a new version, update the config as necessary, and then tell it to
format the entire tree using the new setup.
--Ben
More information about the cfe-dev
mailing list