This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Don't pretend that unknown block calls have one null parameter.
ClosedPublic

Authored by NoQ on Dec 13 2018, 2:04 PM.

Details

Summary

CallEvent::parameters() returns an ArrayRef<ParmVarDecl *> and usually either delegates all the work to the underlying Decl or return an empty array if the underlying Decl is unavailable (eg., calling a symbolic function pointer). Returning an empty array is usually done with a convenient ArrayRef(llvm::NoneType) constructor: return None;. Returning an {} would have the same effect, and i don't have any preferences here.

At the same time, return nullptr; means a completely different thing: it produces an ArrayRef to a literal array of 1 element, and this element is equal to nullptr. This corresponds to the other common pattern: when something accepts an ArrayRef, it also automatically accepts a single element and transparently turns it into an array of 1 element, which is often convenient.

The BlockCall kind of CallEvent was incorrectly returning nullptr. This, well, wasn't quite expected by the newly added OSObject support in RetainCountChecker.

Fix BlockCall to return an empty parameter array when a symbolic block is called.

Diff Detail

Event Timeline

NoQ created this revision.Dec 13 2018, 2:04 PM
This revision was not accepted when it landed; it landed in state Needs Review.Dec 14 2018, 6:16 PM
This revision was automatically updated to reflect the committed changes.

Looks good to me!