New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-format] always use a line per constructor initialiser for longer lines #16962
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit worried that using such a new option could lead to a lot of churn on constructor formatting depending on the version of clang-format.
Either we accept that and go ahead or we don't use it. If someone has submitted a clang-formatted PR we should never request formatting changes because they used the wrong clang-format version imo.
Why not? We also require them to use other tools with at least a certain version. I don't see a difference to minimal required SDK version, for example. |
Linux distros are slow to add newer versions so it could make it a hassle to install the correct version. Is v9 available in any version of Ubuntu right now? One of the main values with clang-format imo is that it lowers the bar to contribute. If you use the tool your PR should pass formatting guidelines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The documentation mentioning
clang-format
has to be updated that at least version 9 is required. - The server running
git-clang-format
for the whole PR and per commit during a PR build has to be updated.
Looking at https://packages.ubuntu.com/search?suite=default§ion=all&arch=any&keywords=clang-format&searchon=names it appears that clang-format 9 isn't available in Ubuntu yet. If that's correct it's not feasible to require that they install or have it installed already unless we provide it in our apt repo. |
It's here: https://packages.ubuntu.com/search?suite=default§ion=all&arch=any&keywords=clang-format-9&searchon=names but only in eon |
Oh, I read the (devel) as it not being released yet, sorry about that 😄 |
You are right never the less. Many are on 18.04 LTS and will stay there until 20.04 |
If you run clang-format using the above I.e. can anyone using clang-format 8 check this? |
As 20.04 is out soon maybe this can be revisited soon. |
Ubuntu should be ok now:
@Rechi where and how would I update this on this on the server running git-clang-format for PRs? |
You are missing Ubuntu Xenial and also the correct package for checking versions is clang-format instead of clang-format-. |
cc5d024
to
e254231
Compare
Ok, then maybe this waits for kodi 20. I don't follow the mention of |
This seems to have got forgotten, and clearly isn't happening in v19 code, so bump to v20 and @phunkyfish please pursue it for that. |
Will do. Thanks @DaveTBlake |
f5a2f8d
to
8ce846c
Compare
05d98d4
to
be7fb43
Compare
Jenkins build this please |
execute_process(COMMAND clang-format --version ERROR_QUIET OUTPUT_VARIABLE CLANG_FORMAT_VERSION_OUTPUT) | ||
string(REGEX MATCH "([0-9]+)\\..*" CLANG_FORMAT_VERSION ${CLANG_FORMAT_VERSION_OUTPUT}) | ||
if(CLANG_FORMAT_VERSION VERSION_LESS_EQUAL "9.0.0") | ||
message(WARNING "clang-format must be at least version 9.0 and the version installed is ${CLANG_FORMAT_VERSION}") | ||
set(CLANG_FORMAT_FOUND OFF) | ||
endif() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can i suggest the following
#.rst:
# FindClangFormat
# ----------
# Finds clang-format
find_program(CLANG_FORMAT_EXECUTABLE clang-format)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ClangFormat REQUIRED_VARS CLANG_FORMAT_EXECUTABLE)
if(CLANGFORMAT_FOUND)
set(CLANGFORMAT_MINVERSION "9.0")
execute_process(COMMAND clang-format --version ERROR_QUIET OUTPUT_VARIABLE CLANG_FORMAT_VERSION_OUTPUT)
string(REGEX MATCH "([0-9]+)\\..*" CLANG_FORMAT_VERSION ${CLANG_FORMAT_VERSION_OUTPUT})
if(CLANG_FORMAT_VERSION VERSION_LESS_EQUAL ${CLANGFORMAT_MINVERSION})
message(WARNING "clang-format must be at least version ${CLANGFORMAT_MINVERSION}. The version found is ${CLANG_FORMAT_VERSION}")
set(CLANGFORMAT_FOUND OFF CACHE BOOL "" FORCE)
set(CLANG_FORMAT_EXECUTABLE "CLANG_FORMAT_EXECUTABLE-NOTFOUND" CACHE STRING "" FORCE)
endif()
endif()
mark_as_advanced(CLANG_FORMAT_EXECUTABLE)
We only do the version check if clang-format is found. We extract the version number to s single variable (for if/when it needs to be updated).
It also sets the cache variable for CLANGFORMAT_FOUND and CLANG_FORMAT_EXECUTABLE to false/notfound
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version hacking in the find module is wrong.
Use the correct CMake way for checking versions.
I dont really understand what you're asking for here @Rechi find_program calls do not have any understanding of versioning, and do not make version info available. What exactly is the "Correct Cmake way" for this? |
be7fb43
to
a5a0a5d
Compare
Read the documentation of find_package and FindPackageHandleStandardArgs and how those two commands interact. There is no need to touch the find module. There is also one dependency of Kodi with a minimum version requirement, where it is done correct. |
Which dependency? |
Description
Ensures for longer lines that this occurs:
But never this:
I.e. if a constructor lines is longer than
.clang-format
column limit then there will always be one initialiser per line.This change does not effect constructor lines short than the
.clang-format
column limit.Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of change
Checklist: