To use clang-tidy
on VoidLinux
, you should install clang-tools-extra
first:
# xbps-install -Suv clang-tools-extra
Take following code as an example:
# cat main.cpp
struct Base
{
virtual void do_thing() = 0;
int data;
};
struct Derived : Base
{
virtual void do_thing(int i) {}
};
int main()
{
}
Use clang-tidy
to check it:
# clang-tidy -checks=* *.cpp --
387 warnings generated.
/root/main.cpp:1:8: warning: constructor does not initialize these fields: data [cppcoreguidelines-pro-type-member-init]
struct Base
^
/root/main.cpp:4:6: warning: member variable 'data' has public visibility [misc-non-private-member-variables-in-classes]
int data;
^
Suppressed 384 warnings (384 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.