[cfe-dev] [RFC][clang-tidy][clang-format] RequiresVersion configuration

Ben Boeckel via cfe-dev cfe-dev at lists.llvm.org
Tue Apr 14 05:53:35 PDT 2020


On Mon, Apr 13, 2020 at 11:59:55 +0100, Nathan James via cfe-dev wrote:
> I'm asking if people think the idea of having a requires version clause
> in .clang-format and .clang-tidy configuration files would be a good
> idea, akin to cmake_minimum_required(VERSION 3.4.3).

Does this mean that if I say "min clang-format of 9.0", 10.0 will use
9.0-like defaults for settings that did not exist in 9.0? While this
might be nice to catch use of older-than-supported clang-format
versions, detecting new ones and making them not change opinion on whole
swaths of code at the same time would be great.

As it is, we have clang-format enforced in one location where we can pin
the version in use (and we can use it to push the expected formatting
back so that folks don't have to track down version x.y on every
development machine). It's the only way we've found that is scalable
with enforced formatting (personally, I find CI that just says "your
code looks dumb, here's a diff" and can't just apply that diff for me to
be very unhelpful).

> The 2 different styles handle different cases. If not having the
> `IndentCaseBlocks` option will break your formatting, you may not want
> to format at all, in which case use `Style 1`. If however you don't
> mind not having the format option, then use `Style 2` and when parsing
> the options it will just ignore options that fail the minimum version
> check.

I want to not have to track `master` though and know what new option
defaults break my code though. But, I know that's a high ask given how
much work we do in CMake to have that property :) .

Thanks,

--Ben


More information about the cfe-dev mailing list