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

Warnings NG reports warnings generated by clang-tidy as gcc warnings

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      From a quick look it looks like recent gcc warnings are formatted as: 

      <file>:<line>:<column>: warning: <message> [-W<warning_command>]

      while clang-tidy warnings are formatted as:

      <file>:<line>:<column>: warning: <message> [<clang-tidy check>]

      So gcc warnings can be differentiated by the "-W".

      My understanding of https://github.com/jenkinsci/analysis-model/blob/master/src/main/java/edu/hm/hafner/analysis/parser/Gcc4CompilerParser.java#L23 is that it accepts lines with anything after "warning: ". Looking in https://godbolt.org/ it looks like the "[-W<warning_command>]" was not added until gcc 4.6, which would explain this.

      So maybe there is a need for a new "gcc46+" "tool" in Warnings NG / parser in analysis-model?

      Additionally, looking in godbolt, I see clang has used the exact same 

      <file>:<line>:<column>: warning: <message> [-W<warning_command>]

      format since at least clang 3.0.0 (the oldest available version in godbolt). But

      • The clang tool also includes clang-tdy warnings
      • In my codebase (building for multiple toolchains, mostly gcc-based but also for Android/clang) the clang tool reports 58 warnings while the gcc4 tool reports 119 warnings
      • The parsers in analysis model are very different (one based on RegexpLineParser and the other on LookaheadParser) 

      Since I mix clang and gcc builds in my Jenkins jobs, and given that the gcc and clang formats seem to have been identical at least since 2011 (gcc 4.6.0 and clang 3.0 releases) it would be nice if I could use a single "modern gcc/clang" tool to detect the warnings of both.

        Attachments

          Activity

          Hide
          drulli Ulli Hafner added a comment -

          Yes, this makes sense to update these parsers (or to introduce new ones) that work better on the modified formats.

          Show
          drulli Ulli Hafner added a comment - Yes, this makes sense to update these parsers (or to introduce new ones) that work better on the modified formats.
          Hide
          reddwarf94 Cristian added a comment - - edited

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

          (.+):(\d+):(\d+): warning: (.*) \[-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()
          

          Not only it avoids the clang-tidy warnings, I have also found it avoids problems with https://github.com/jenkinsci/analysis-model/blob/d1b967a1fa8c365a82c7328648bc6f6039cd2b91/src/main/java/edu/hm/hafner/analysis/parser/Gcc4CompilerParser.java#L70 which has a tendency to incorrectly include extra lines with modern gcc versions.

          Show
          reddwarf94 Cristian added a comment - - edited FWIW I have started using a custom groovy parser. I'm using (.+):(\d+):(\d+): warning: (.*) \[-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() Not only it avoids the clang-tidy warnings, I have also found it avoids problems with https://github.com/jenkinsci/analysis-model/blob/d1b967a1fa8c365a82c7328648bc6f6039cd2b91/src/main/java/edu/hm/hafner/analysis/parser/Gcc4CompilerParser.java#L70 which has a tendency to incorrectly include extra lines with modern gcc versions.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            reddwarf94 Cristian
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: