This is an archive of the discontinued LLVM Phabricator instance.

[Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.
ClosedPublic

Authored by xazax.hun on Jul 22 2015, 3:09 PM.

Details

Summary

For most of the implicit null pointer dereferences (when a pointer is dereferenced and the static analyzer can not prove that the pointer is non null, and can not prove that the pointer is null either) the DereferenceChecker will emit an event. However in some cases (e.g. binding such pointers to references in function parameters) no event will be emitted. This patch addresses this problem by extending NonNullParamChecker to emit an event in such cases. Future checkers (listening to these events) will profit from this change. For example I am working on a checker for nullability qualifiers that depend on this patch.

Diff Detail

Repository
rL LLVM

Event Timeline

xazax.hun updated this revision to Diff 30409.Jul 22 2015, 3:09 PM
xazax.hun retitled this revision from to [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events..
xazax.hun updated this object.
xazax.hun added a subscriber: cfe-commits.
zaks.anna requested changes to this revision.Aug 17 2015, 12:13 PM
zaks.anna edited edge metadata.

I believe we saw a regression in diagnostics with this modification. Gabor, do you recall what it was?

This revision now requires changes to proceed.Aug 17 2015, 12:13 PM

The problem here is that, this checker can emit a warning for two cases:
1, Null was bound to a reference which should be reported as a dereference
2, Null was passed to parameter that should be non-null (marked by the attribute, not the qualifier) which should be reported appropriately

Right now exactly the same event will be triggered for both cases, so the checkers that process this event has no information whether it is a dereference or a value passed to a nonnull parameter, so it can not provide appropriate diagnostic for both cases.

One possibility would be to have two separate events, the other is to have an argument to an event that determines its origin. Probably it would be better to have two separate events, since it might be confusing to have dereference in the name of the event in the second case.

What do you think?

xazax.hun updated this revision to Diff 32854.Aug 21 2015, 12:35 PM
xazax.hun edited edge metadata.

Only send implicit dereference events, when the null pointer was bound to a reference.

Please, commit this after committing the nullability checker so that this could have tests. Two tests need to be added:

  1. the reference case
  2. the attribute nonnull case

Also, I'd suggest adding a field to ImplicitNullDerefEvent instead of creating a new event.

xazax.hun updated this revision to Diff 33335.Aug 27 2015, 10:12 AM
xazax.hun edited edge metadata.
  • Updated to latest trunk.
  • Added a new field to the event with documentation.
  • Rebased the patch on the top of nullability checker.
  • Added covered cases to the nullability checker tests.
zaks.anna accepted this revision.Aug 27 2015, 11:43 AM
zaks.anna edited edge metadata.

Thanks!

This revision is now accepted and ready to land.Aug 27 2015, 11:43 AM
This revision was automatically updated to reflect the committed changes.