[cfe-dev] Different Clang-Tidy results on Linux vs Windows

Hugo lindström via cfe-dev cfe-dev at lists.llvm.org
Wed Jan 16 10:13:34 PST 2019


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

/tmp/workspace/llvm-demo/src/aligned_buffer.cc:7:18: warning: use
nullptr [modernize-use-nullptr]
  const TU8* t = NULL;
                 ^~~~~
                 nullptr


Both platforms have clang-tidy-6.0 and CMake 3.13

Demo project: https://github.com/hugolm84/llvm-demo

Is this expected, or do I do something wrong? I thought the clang-tidy
binary would do the same checks on any platform it can run on?
Can the compiler flags have anything to do with this? I use

target_compile_options(${PROJECT_NAME}
>     PRIVATE
>         $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
>             $<$<CONFIG:Debug>:-O0 -Wall -Wextra>>
>         $<$<CXX_COMPILER_ID:MSVC>:
>             $<$<CONFIG:Debug>:/Od /W4 /Zi>>
> )



Thanks in advance!

Ps. This is my first post to the mailing list, please forgive me if the
format is off or if this is the wrong forum.

Best
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190116/ba97144e/attachment.html>


More information about the cfe-dev mailing list