-
Notifications
You must be signed in to change notification settings - Fork 53
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
Use clang-tidy #561
Comments
After testing it a little, I have the impression it would be better to first activate all compiler warnings and work through those. Then one could go through all the clang-tidy options and see which ones really make sense here. For example in this code base, warning about "pointer arithmetic", e.g. when using The config I was testing so far:
|
I'm actually not so convinced of this anymore. While trying around with it, it did not seem to help more with the Spirit codebase than compiler warnings. |
Actually, due to the fact that clang-tidy can provide IDE support (e.g. via clangd, which has a vs code extension) and corresponding auto-fixes and refactorings, it would in fact be quite useful. An added benefit, complementary to clang-format (see issue #550), would be the ability to automatically check given style- and naming-convention, e.g.
Note, compile commands should be exported by default in order to provide a more automatic IDE integration. We could simply add |
clang-tidy is a useful tool for helping to keep a good code quality. I would suggest looking into the following option classes:
bugprone-
clang-analyzer-
cppcoreguidelines-
modernize-
openmp-
performance-
portability-
readability-
It can give warnings, but with
-fix
or--fix-errors
it can even automatically apply some corrections.The full list of options is here.
Notably, it also integrates well with IDEs (see here and e.g. this vs-code extension).
From a terminal,
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
when calling cmake (e.g. add it to the cmake.sh)-p=build
when calling clang-tidy, so it will know all include directories, defines etc.The text was updated successfully, but these errors were encountered: