Added `.clang-tidy` config as discussed in
[RFC](https://discourse.llvm.org/t/rfc-create-hardened-clang-tidy-config-for-clang-tidy-directory/87247).
Added `bugprone`, `readability`, `modernize`, `performance` checks that
didn't create many warnings.
Fixed minor warnings to make `/clang-tidy` directory complaint with
`clang-tidy-20`.
Disabled checks will be enabled in future PRs after fixing their
warnings.
Before, C++ member functions in the format of ``Class instance;
instance.memberfn();`` were unable to be matched.
This PR adds support for this type of call, and it is matched in exactly
the same format as other functions (eg. ``::Class::memberfn`` qualified
name).
Adds the check option `bugprone-unsafe-functions.CustomFunctions` to be
able to match user-defined functions as part of the checker.
Adds the option `bugprone-unsafe-functions.ReportDefaultFunctions` to
disable reporting the default set of functions as well.
The functions names are matched using the same mechanism as the
`matchesAnyListedName` tidy matcher, documented in
`unsafe-functions.rst`.
As discussed in [D91000](http://reviews.llvm.org/D91000) with @dyung, the
PlayStation-specific targets are using some custom standard library for
which the current written tests are not appropriate. Even though the
test code defines the `__STDC_LIB_EXT1__` and `__STDC_WANT_LIB_EXT1__`
macros and expected *Annex K.* support, the actual Clang
parser/preprocessor will report these macros as not existing, and thus
fail the tests.
The check reports the **non**-Annex K. functions as suggestions, such as
`fgets()` instead of `gets_s()` to replace `gets()`, so some safe
library suggestions are still there.
This patch is primarily done to unblock the relevant buildbot
[`llvm-clang-x86_64-sie-ubuntu-fast`](http://lab.llvm.org/buildbot/#/builders/139).
This commit partially reverts ed740e741ec22f9aaea09bfc0b87d0801a7c492f,
as the changes to the "caching logic" was not fixing anything.
There is a supposedly platform-specific crash related to not recognising
the availability of *Annex K.* properly? This patch is an attempt for
fixing this by moving the reset logic for the cache to a different
place.
It's really a coin-flip at this point whether this is really a fix...
Checks for unsafe functions, mostly those listed in the
SEI CERT C Coding Standard Recommendation `MSC24-C` and Rule `MSC33-C`.
For the listed functions, an alternative, more secure replacement is
suggested, if such is available. The checker heavily relies on the
functions from "Annex K" (Bounds-checking interfaces) from C11, but
there are several other recommendations not directly from Annex K.
Differential Revision: http://reviews.llvm.org/D91000
Reviewed-By: aaron.ballman, dkrupp, steakhal, whisperity
Co-Authored-By: Tamás Koller <koller.tamas1996@gmail.com>
Co-Authored-By: Balázs Benics <balazs.benics@sigmatechnology.se>
Co-Authored-By: Whisperity <whisperity@gmail.com>