Different Clang-Tidy results on Linux vs Windows

Greetings!

I’m using CMake and the CXX_CLANG_TIDY property to enable Clang-Tidy on Linux (GCC/Clang) and Windows (MSVC).

I use these lines to demo that I get different results on the platforms:

const TU8* comp_ptr = static_cast<const TU8*>(buf_ptr);

const TU8* t = NULL;

Using Ninja and MSVC on Windows, Clang-Tidy modernize only reports

C:\Zebra\llvm-demo\build-win\..\src\aligned_buffer.cc:7:18: warning: use nullptr [modernize-use-nullptr]
  const TU8* t = NULL;
                 ^~~~~
                 nullptr

Using Make and GCC on Linux, Clang-Tidy modernize reports

/tmp/workspace/llvm-demo/src/aligned_buffer.cc:6:9: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
  const TU8* comp_ptr = static_cast<const TU8*>(buf_ptr);
        ^~~~
        auto

Hey Hugo,

that is weird, but the default configurations could differ. modernize-use-auto has a feature that disables the replacements if the type (e.g. bool) is shorter/same length as auto.
Could you please check if that for some reason interfered?

Best, Jonas

@JonasToth I wonder if this could this be related to https://bugs.llvm.org/show_bug.cgi?id=38471

You know how bugs go, you see it once, you see it everywhere…

Perhaps the -checks=’’ has the effect here of changing the checks being used by default, Hugo what is the reason for supplying an empty -checks here?

Normally I’d recommend using a .clang-tidy file in the root of the project where you specify the checks you want (more specifically those you don’t want, so you get new ones when added)

"C:\Program Files\CMake\bin\cmake.exe" -E __run_co_compile --tidy="C:/Program Files/LLVM/bin/clang-tidy.exe;-enable-check-profile;-checks=''"