[cfe-dev] [RFC][clang-tidy][clang-format] RequiresVersion configuration
Nathan James via cfe-dev
cfe-dev at lists.llvm.org
Mon Apr 13 03:59:55 PDT 2020
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).
The benefit here wouldn't be immediately noticed but down the line it
will resolve issues when people are using different versions of the
respective tools contributing to large projects.
The idea would be you can set the entire file to require a minimun
version or just a specific option/check.
For example say you want to use the new `IndentCaseBlocks` introduced
recently to clang-format but some developers aren't using trunk clang-
Putting that in the config file will cause an error when running clang-
tidy in earlier versions that don't understand.
Proposed ideas could be to have:
// Style 1
>RequireMinimumVersion: 11 //At top of .clang-format file
>[[RequireMinimumVersion: 11]IndentCaseBlocks: true
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
There is a similar use case for clang-tidy, say a check has been
updated to add a new option in there that you need setting for your
project, you likely will only want the check to run if you can set the
version, this could be enabled in a similar(ish) way
>Checks: '-*,[[RequireMinimunVersion: 11]]check-with-new-option-added-
This could also be used to disable checks based on version(if there was
a regression in a check)
>Checks: '-*,misc*,[[RequireMinimumVersion: 11]]-misc-check-with-
Likewise you could use a global option in the .clang-tidy file
Obviously the syntax of the clause is open to discussion and this will
cause issues with people using a version of aforementioned tools with
configuration files that support this new syntax, however hopefully it
will be a slow rollout of groups/companies using this syntax.
Handling of the clang-format configuration will likely need to be
implemented when parsing the yaml file. Handling of the clang-tidy
configuration will need to be handled when creating the GlobList.
Thank you for reading,
More information about the cfe-dev