7 Commits

Author SHA1 Message Date
Baranov Victor
d7a17540f8
[clang-tidy][NFC] add '.clang-tidy' config for clang-tidy project (#147793)
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.
2025-07-11 17:17:59 +03:00
Discookie
3262863805
[clang-tidy] Add C++ member function support to custom bugprone-unsafe-functions matches (#117165)
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).
2025-01-30 10:49:01 +00:00
Discookie
0b8866d15a
[clang-tidy] Add user-defined functions to bugprone-unsafe-functions check (#106350)
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`.
2024-09-26 12:52:13 +00:00
Piotr Zegar
d57cf05f94 [clang-tidy][NFC] Fix modernize-concat-nested-namespaces findings
Fix issues found by clang-tidy in clang-tidy source directory.
2023-08-27 08:52:10 +00:00
Whisperity
9225d08ccc [NFC][clang-tidy] Disable test for bugprone-unsafe-functions for PlayStation
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.
2023-02-02 16:35:08 +01:00
Whisperity
ed740e741e [clang-tidy] Attempt fixing wrong caching result in bugprone-unsafe-functions
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...
2023-02-02 15:24:40 +01:00
Gergely Fűtő
f27c8ac83e [clang-tidy] Add the bugprone-unsafe-functions check
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>
2023-02-02 14:11:42 +01:00