This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] scan-build: Fix silencing multiple core checkers.
ClosedPublic

Authored by NoQ on Jul 17 2020, 7:51 PM.

Details

Summary

It was only silencing one checker because -analyzer-config flags can only carry one value at a time.

The silencing mechanism is still not working correctly in presence of conflicting flags, i.e. scan-build -disable-checker core.foo -enable-checker core.foo leaves core.foo silenced whereas scan-build -disable-checker unix.foo -enable-checker unix.foo leaves unix.foo enabled. I'd prefer to promote silencing to a frontend flag in order to fix that but that'd be more work that's fairly orthogonal and i'm currently looking for a quick fix.

Diff Detail

Event Timeline

NoQ created this revision.Jul 17 2020, 7:51 PM
Charusso accepted this revision.EditedJul 17 2020, 11:35 PM

I do not get why my solution -analyzer-config silence-checkers=core.NullDereference -analyzer-config silence-checkers=core.DivideZero was insufficient, whereas -analyzer-config silence-checkers=core.NullDereference;core.DivideZero is working. One funny thing to note here: LLDB cannot parse "a;b", so that it stops to parse the compiler flags at ;... It is mostly LLDB's fault, but that is why I wanted to avoid the character ;. If I remember right I have picked ; over ,, because the Clang's flag-parser cannot parse ,, but may , is working now. Could you try that and overwrite these silly behaviors, please?

This scan-build testing script is super repetitive to use, but it is great we could test these in place. Cool stuff!

This revision is now accepted and ready to land.Jul 17 2020, 11:35 PM
Szelethus accepted this revision.Jul 18 2020, 6:27 AM

I do not get why my solution -analyzer-config silence-checkers=core.NullDereference -analyzer-config silence-checkers=core.DivideZero was insufficient, whereas -analyzer-config silence-checkers=core.NullDereference;core.DivideZero is working.

Because analyzer configs only hold the last value to be friendly towards scripts (just like most other configs/flags in clang).

If I remember right I have picked ; over ,, because the Clang's flag-parser cannot parse ,, but may , is working now.

The problem is that it fishes for multiple analyzer configs: -analyzer-config option1=value1 -analyzer-config option2=value2 == -analyzer-config option1=value1,option2=value2.

I'd prefer to promote silencing to a frontend flag in order to fix that but that'd be more work that's fairly orthogonal and i'm currently looking for a quick fix.

I think the functionality to silence warnings should be there, not the actual flag. Ideally, disabling a checker should achieve what silencing is currently doing now.

NoQ added a comment.Jul 18 2020, 9:21 AM

I do not get why my solution -analyzer-config silence-checkers=core.NullDereference -analyzer-config silence-checkers=core.DivideZero was insufficient, whereas -analyzer-config silence-checkers=core.NullDereference;core.DivideZero is working.

Because analyzer configs only hold the last value to be friendly towards scripts (just like most other configs/flags in clang).

Yup, that's because AnalyzerOptions is a map. It cannot (and was never expected to) hold more than one value per key.

Even if there was a list data type in -analyzer-config that would have been appended rather than replaced upon getting specified multiple times, in our case such list would still need to interact with other frontend flags in a non-trivial way (i.e., the result has to be different depending on how it's placed in the command with respect to -analyzer-checker).

I think the functionality to silence warnings should be there, not the actual flag. Ideally, disabling a checker should achieve what silencing is currently doing now.

Hmm, yeah, that might actually be a better option.

NoQ closed this revision.Jul 18 2020, 10:39 AM

Forgot the phabricator link T_T
Committed in rG0b2a9222463.