-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add clang-tidy plugin to convert implicit conversions to explicit ones #4663
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
base: develop
Are you sure you want to change the base?
Conversation
9c4b4ab
to
d7ddfb1
Compare
I've made a small improvement to the check, improved the documentation and tried to placate the REUSE licence checks. I think that the Codacy check failures probably just need to be ignored somehow. We don't really want to modify LLVM's I'm afraid that I don't really understand the Windows failures. |
This pull request has been marked as stale because it has had no activity for 30 days. While we won’t close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions! |
Add a clang-tidy plugin containing one check to replace implicit conversions (as enabled by default with JSON_USE_IMPLICIT_CONVERSIONS) with explicit ones. This will make it easier for library users to switch away from using implicit conversions which should make it possible for the library to start disallowing them sooner. Being able to test the plugin in a similar way to how checks are tested within clang-tidy itself requires copying the check_clang_tidy.py script from the LLVM code itself. The check itself is virtually identical to the one proposed for inclusion in clang-tidy itself at llvm/llvm-project#126425 . Unfortunately it is necessary to add "C" to the languages for the project in CMakeLists.txt for find_package to work for LLVM. Signed-off-by: Mike Crowe <[email protected]>
The purpose of these tests is to ensure that anyone attempting to compile the clang-tidy plugin on the tested distributions will be able to and that the resulting plugin will work. Clang-tidy plugins were only introduced with Clang 16, so we can't test with any earlier versions than that. Signed-off-by: Mike Crowe <[email protected]>
Signed-off-by: Mike Crowe <[email protected]>
d7ddfb1
to
2403373
Compare
This pull request has been marked as stale because it has had no activity for 30 days. While we won’t close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions! |
Add a clang-tidy plugin containing one check to replace implicit conversions (as enabled by default with JSON_USE_IMPLICIT_CONVERSIONS) with explicit ones. This will make it easier for library users to switch away from using implicit conversions which should make it possible for the library to start disallowing them sooner.
The skeleton of the check was generated by the clang-tidy add_new_check.py script. It added headers indicating that the files were under the LLVM Apache-2.0-with-LLVM-exception licence. I've replaced these with the MIT licence to match the rest of the library but would be happy to change them back.
The check was written using LLVM's clang-format style. I can modify that if you'd prefer.
The check_clang_tidy.py script was copied in its entirety from the LLVM repository so it must keep its existing Apache-2.0-with-LLVM-exception licence.
The test file is written in the style of clang-tidy's own tests. This means that it cannot include system headers. We might be able to relax that for a plugin so that the actual single_include header could be used. That might make cross-platform CI harder though and I haven't looked into doing so.
I know very little about CMake or GitHub workflows. What I have implemented appears to work, but I don't know whether both work the way you would like. I have a Linux and Debian bias.
A reviewer of the original check asked about implicit conversions to
std::wstring
andstd::string_view
. I think that neither of those are possible. Is that true?make amalgamate
. N/A