[llvm-dev] [cfe-dev] clang-tidy: identify "C++-code-specific-checks" and "C-Code-specific-checks"

Aaron Ballman via llvm-dev
Wed, 15 Sep 2021 11:13:25 -0000

On Wed, Sep 15, 2021 at 3:09 AM Oza, Hiral via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Greetings!
>
> We are using clang-tidy with single ‘config-file’ listing enabled
tidy-checks to run for both “C++-code” and “C-code”.
>
> We are looking for your inputs:
>
> From list of supported clang-tidy checks, how to identify
"C++-code-specific-checks" and which are
"C-Code-specific-checks"? Can this be checked programmatically?

There is not a way to identify them from the command line, but each
check has an `isLanguageVersionSupported()` function that checks for
valid language options that you can use to find this information via
manual inspection.

> Are “clang-analyzer-“ checks only applied to C++-code?

Not always, those come from the static analyzer (rather than
explicitly written as clang-tidy checks) and many of those apply to C
code as well as C++ code (for example, there are checks specific to
malloc/free behavior, checks for division by zero, etc).

> What happens internally if C++-code-check ran on C-code? Will it skip
parsing C-code?

If the check is designed to be C++-only, then it will be skipped for a
C translation unit.

~Aaron

>
>
>
> Thank you in advance for your valuable inputs.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev