This is an archive of the discontinued LLVM Phabricator instance.

[scan-build-py] Set of small fixes
ClosedPublic

Authored by xazax.hun on Nov 25 2019, 1:02 PM.

Details

Summary

This patch fix some small errors in scan-build-py, including:

  • When invoking clang with -### and parsing error add -fno-color-diagnostics to the invocation to avoid problems parsing potential errors. This might be sub-optimal for users expecting to see the results in the command line and expecting to have colors. If we really want this to work I can either make the regex more forgiving or try to restore the -fcolor-diagnosticsflag to its original state after the -### invocation.
  • If a file was missing from a compilation database the whole analysis was stopped due to an unhandled exception.
  • Fix two typos: analyzis -> analysis

Diff Detail

Event Timeline

xazax.hun created this revision.Nov 25 2019, 1:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 25 2019, 1:02 PM

Sorry, there was a brain hiccup on my side. We just do not generate HTMLs for every translation units (which is the case for plists).

phosek accepted this revision.Nov 26 2019, 3:07 PM

LGTM

clang/tools/scan-build-py/libscanbuild/clang.py
47

Alternative would be to set TERM=dumb environment variable which disables color support as well, but this also works.

This revision is now accepted and ready to land.Nov 26 2019, 3:07 PM
xazax.hun marked an inline comment as done.Nov 27 2019, 10:36 AM
xazax.hun added inline comments.
clang/tools/scan-build-py/libscanbuild/clang.py
47

Thanks! I'd love to have another solution, but it looks like the command line takes precedence over the environment variables and if -fcolor-diagnostics is specified in the command line it will always turn the colors on.

So after investigating the effects of this patch, the result is the following:

Verbose mode (-v) that also prints findings to the command line will no longer be colored after the patch. If we do not want this regression there are two easy ways around it:

  1. Make the parsing of error more forgiving
  2. Make two -### invocation, one for parsing the potential error and the other for actually getting the arguments.

Any preferences?

NoQ accepted this revision.Dec 4 2019, 1:09 PM

So after investigating the effects of this patch, the result is the following:

Verbose mode (-v) that also prints findings to the command line will no longer be colored after the patch.

These warning printouts are fairly useless anyway, users still need to read the html reports, so I don't care all that much. Thanks for cleaning this up!

This revision was automatically updated to reflect the committed changes.