clang-format improvements#1251
Conversation
1bd5793 to
5b3e9be
Compare
- Add a clang-format linter check to the PR pipeline - Apply clang-format to files where the linter initially failed - Remove `CommentPragmas` from `.clang-format` - Remove all `// clang-format off` and `// NO-FORMAT` as they are not needed - Remove a commented out `GSL_SUPPRESS`
|
I am not github pipeline expert. The clang-format.yml file is AI generated. I have no idea if it is OK or not. |
carsonRadtke
left a comment
There was a problem hiding this comment.
Thanks for making these changes! The only blocker is the third-party actions dependency - if you wouldn't mind changing that to a shell command, that'd be appreciated.
OK, I'll give it a try. |
Co-authored-by: Carson Radtke <nosrac925@gmail.com>
…"GSL_SUPPRESS(bounds .1)"
to prevent formatting of include/CMakeLists.txt
In a VS2026 developer command prompt I ran `clang-format -i include\gsl\* --assume-filename x.cpp`. This was necessary because VS GUI does not format files without an extension :(. Please note that `--assume-filename` is necessary here, otherwise the files will not be formatted. Surprisingly the behaviour for the formatter differs from the behaviour of `lang-format(-20) --dry-run --Werror include/gsl/*` where clang-format recognizes that the files is C++.
Consider adding |
| # Install the exact clang-format binary | ||
| - name: Install clang-format | ||
| run: | | ||
| sudo apt install clang-format-${{ env.CLANG_VERSION }} |
There was a problem hiding this comment.
I'd rather use the pre-installed version, but I'm not going to block the PR on it.
There was a problem hiding this comment.
The pre-installed version needs the WhitespaceSensitiveMacros change, clang-format-20 does not.
Regarding the burden on the authors: I think it might be a good idea to provide an apply-clang-format.bat and an apply-clang-format.sh. Of course the bat file would only work in the developer command prompt and could only use the clang-format version shipped with Visual Studio. What do you think about it? Shall I add those files to make formatting easier?
carsonRadtke
left a comment
There was a problem hiding this comment.
Thanks for the changes! LGTM
I'll merge it on Monday in case you want to address my non-blocking comments.
Here is a patch for .clang-format together with the changes it does to the files. I understand that it fixes the whitespace-in-suppress-attributes-problem, but I am not sure if this looks better. Which version do you prefer? Shall I apply the patch or leave it as it is? For example: |
CommentPragmasfrom.clang-format// clang-format offand// NO-FORMATas they are not neededGSL_SUPPRESS