Different Clang-Tidy results on Linux vs Windows

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Different Clang-Tidy results on Linux vs Windows

David Blaikie via cfe-dev
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


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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Different Clang-Tidy results on Linux vs Windows

David Blaikie via cfe-dev

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

Am 16.01.19 um 19:13 schrieb Hugo lindström via cfe-dev:
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


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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Different Clang-Tidy results on Linux vs Windows

David Blaikie via cfe-dev
@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=''"

On Thu, Jan 17, 2019 at 8:46 PM Jonas Toth via cfe-dev <[hidden email]> wrote:

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

Am 16.01.19 um 19:13 schrieb Hugo lindström via cfe-dev:
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


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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev