-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Making use of static analysis to find bugs and UB #11839
Comments
I would appreciate having clang-tidy run on nix. If it the meson integration would work for us, we should use it. That target should likely go in it's own derivation. |
Should this be a one-per-library derivation or can we lint the whole codebase at once? @Ericson2314 |
@xokdvium I am fine either way re granularity; assume this is pretty fast right? |
Regarding the runtime. On my machine with
I guess the runtime would be very sensitive to the enabled checks. For the basic barebones config, which gives too many false-positives, but is an ok baseline: Checks:
- -*
- performance-*
- bugprone-*
- clang-analyzer-* Running the
I wouldn't call that pretty fast. But this shouldn't be run very often, since for CI we are primarily interested in diffs. It should be pretty easy to reuse the clang-tidy-diff.py for checking only the affected files. That would require going around the Meson integration and wrapping |
It's probably better to start having this once for the whole code base. The per library derivation would probably introduce quite a bit of complexity that we maybe want to avoid for the first iteration. But also your |
Is your feature request related to a problem? Please describe.
C++ is an inherently complex language and has countless footguns. Currently there are no safeguards against this and bug lifetime is very long. This makes even tiny refactoring hard because even a tiny change can lead to run-time errors or memory corruption. A lot of errors are left undiscovered for a long time or are missed during review.
Some examples:
StringSource
#11813fs::create_directory
out ofassert
#11718 - bugprone/assert-side-effect.htmlC++ compilers aren't very helpful most of the time, and even for diagnosable errors current compiler flags don't include enough warnings.
Describe the solution you'd like
Include
clang-tidy
runs and more compiler warnings in the build process and CI. Ideallyclang-tidy
would be run for every change.Meson has native
clang-tidy
integration since 0.52 and has been extended in 1.3 to enable automatic fixes via theclang-tidy-fix
target.We can start by bumping the
warning_level
in Meson and enabling the bare minimum checks for easily diagnosable issues likeclang-analyzer-*
and somebugprone-*
checks.There are some potential downsides like:
Describe alternatives you've considered
clang-tidy
out-of-tree.Additional context
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: