-
-
Notifications
You must be signed in to change notification settings - Fork 670
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
Update to clang format 19 support #5015
Update to clang format 19 support #5015
Conversation
6533a96
to
a2f9cb4
Compare
FYI: Github actions is having issues: actions/runner#3611 Local macos builds occur properly (my main development environment). |
FYI: Github actions is having issues: actions/runner#3611 Local macos builds occur properly (my main development environment is macos). |
This is precursor work that enables the larger goal in #5013 |
The end goal is to have precommit manage the clang format version, and remove our code with build and manages the clang format version? |
@blowekamp Yes! The pre-commit version is much easier to manage and covers a wider range of platforms. Using pre-commit will remove much of the complicated cmake code. I made this PR as a stepping stone to decouple the pre-commit considerations from updating the clang-format version. |
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.
Thanks for doing this!
Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryErodeImageFilter.hxx
Show resolved
Hide resolved
Modules/Filtering/DisplacementField/include/itkInvertDisplacementFieldImageFilter.hxx
Outdated
Show resolved
Hide resolved
Step 1: Download pypi wheels from https://pypi.org/project/clang-format/#files for each of the platforms. Step 2: For each wheel: ```bash if [ $(uname) == "Darwin" ]; then xattr -d com.apple.quarantine ${downloaded_wheel_file} fi unzip ${downloaded_wheel_file} cd clang_format/data/bin tar -cf clang_format.tar clang-format ``` Step 3: Upload the clang_format.tar file to https://data.kitware.com/ Copy the sha512 for the uploaded tarball and change the has in Utilities/ClangFormat/DownloadClangFormat.cmake Step 4: Update the allowed version limits ```cmake set(CLANG_FORMAT_MIN_VERSION 19.1.4) # First acceptable version set(CLANG_FORMAT_MAX_VERSION 20.0) # First unacceptable version ```
update support scripts to support new clang-format version. Utilities/Hooks/pre-commit-style.bash Utilities/Maintenance/clang-format.bash
Update .clang-format and Example/.clang-format propogating current selection forward to the new version. ```bash cd ${ITK_SOURCE_DIR} clang-format --dump-config > /tmp/ITK_clang_format mv /tmp/ITK_clang_format .clang-format cd ${ITK_SOURCE_DIR}/Examples clang-format --dump-config > /tmp/ITK_Examples_clang_format mv /tmp/ITK_Examples_clang_format .clang-format ```
The newer version of clang-format has a more rigorous enforcement of the ITK style. Most changes include placing the return value of a function on it's own line, and moving single line function definitions to the ITK multi-line format (even in macros).
a2f9cb4
to
9bd6b75
Compare
@dzenanz @blowekamp I have addressed all the issues that you pointed out earlier. I found a setting that minimized the differences with clang version 8 with ~130 fewer changed files. I'd love to get this PR to make progress toward acceptance because it is a key roadblock for evaluating the next set of build improvements (aka pre-commit). |
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.
Thank you for moving to a much needed newer version of clang-formatting. It is good to separate the stye preferences from version changes as best we can. Additionally, separating the code formatting changes from the introduction of pre-commit usage is good. Thank you for moving this forwards.
ObjectType * operator->() const { return m_Pointer; } | ||
ObjectType * | ||
operator->() const | ||
{ | ||
return m_Pointer; | ||
} |
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.
Interestingly, here it goes the other way (compared to the case of the m_LastPipelineMTime = 0;
statement). I like having the return m_Pointer;
statement on its own line. 👍
@hjmjohnson Thanks, really great! I'm very glad to see such a major clang-format upgrade! I'm now going to try your PR locally. Don't know if it's necessary to wait until it works on my Windows laptop... |
@hjmjohnson Dummy question: I just pulled the master branch and reran CMake. An attempt to commit locally tells me:
What should I do? I don't see the clang-format 19.1.4 executable on my disk. My "Bin\ITK\ClangFormat-prefix\src\ClangFormat" still has an old clang-format.exe |
Resolves: #4565
Update to newer version of clang-format.
The previous clang-format version 8 does not compile on arm64 mac. There is limited support for clang-format binaries before version 10.
This is a gateway toward greatly simplifying the support for pre-commit checking using the python pre-commit infrastructure. See: #5013
PR Checklist