Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-64614

clang-tidy tool reports warnings generated by gcc

      A bit related to JENKINS-64612. The clang-tidy tool reports warnings generated by gcc.

      This is a bigger problem than it may seem. You could argue "well, just put them in different files for different tools to parse", but a common way to run clang-tidy is via cmake as 

      cmake -DCMAKE_CXX_CLANG_TIDY=clang-tidy .. && cmake --build .

      Meaning both the clang-tidy and gcc warnings are generated as a result of the same command being executed. This can't be separated (https://discourse.cmake.org/t/run-clang-tidy-only/2537), and has benefits over other ways of running clang-tidy (only check the files that have changed in incremental builds).

      In the same way JENKINS-64612 argues for only including warnings with a "-W" in them, here I would like to argue that the clang-tidy tool should filter-out the warnings with a "-W" in them.

      In fact, as of clang-tidy 11.0.0, the only categories clang-tidy reports are:

      abseil-*
      android-*
      boost-*
      bugprone-*
      cert-*
      clang-analyzer-*
      cppcoreguidelines-*
      darwin-*
      fuchsia-*
      google-*
      hicpp-*
      linuxkernel-*
      llvm-*
      llvmlibc-*
      misc-*
      modernize-*
      mpi-*
      objc-*
      openmp-*
      performance-*
      portability-*
      readability-*
      zircon-*

      (none of them starting with "-W").

       

          [JENKINS-64614] clang-tidy tool reports warnings generated by gcc

          Cristian added a comment - - edited

          FWIW I have started using a custom groovy parser. I'm using

          (.+):(\d+):(\d+): warning: (?! in call to)(.*) \[(?!-W)(.*)\]
          

          with this mapping script

          return builder.setFileName(matcher.group(1))
           .setLineStart(matcher.group(2))
           .setColumnStart(matcher.group(3))
           .setMessage(matcher.group(4))
           .setCategory(matcher.group(5))
           .buildOptional() 

          The "in call to" thing is there to handle

          file.cpp: In member function ‘void func(const string&)’:
          file.cpp:171:35: warning: passing ‘type_t’ chooses ‘int’ over ‘unsigned int’ [-Wsign-promo]
            171 |                     std::to_string(value) + ")");
                |                     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
          file.cpp:171:35: warning:   in call to ‘std::string std::__cxx11::to_string(int)’ [-Wsign-promo]
           

          I guess that's a bug, the second "warning:" probably should be a "note:", but...

           

          Edit: bad example, the problem comes from

          file.cpp:121:146: warning:   in call to 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' [-Wsign-promo]

          Which has "[" and "]" as part of the message.

          Cristian added a comment - - edited FWIW I have started using a custom groovy parser. I'm using (.+):(\d+):(\d+): warning: (?! in call to)(.*) \[(?!-W)(.*)\] with this mapping script return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setColumnStart(matcher.group(3)) .setMessage(matcher.group(4)) .setCategory(matcher.group(5)) .buildOptional()  The "in call to" thing is there to handle file.cpp: In member function ‘void func(const string&)’: file.cpp:171:35: warning: passing ‘type_t’ chooses ‘int’ over ‘unsigned int’ [-Wsign-promo] 171 | std::to_string(value) + ")"); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ file.cpp:171:35: warning: in call to ‘std::string std::__cxx11::to_string(int)’ [-Wsign-promo]   I guess that's a bug, the second "warning:" probably should be a "note:", but...   Edit: bad example, the problem comes from file.cpp:121:146: warning: in call to 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' [-Wsign-promo] Which has " [" and "] " as part of the message.

            Unassigned Unassigned
            reddwarf94 Cristian
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: