This is an archive of the discontinued LLVM Phabricator instance.

Re-analyze functions as top-level
Needs ReviewPublic

Authored by chrisbazley on Jan 27 2023, 9:06 AM.

Details

Reviewers
NoQ
Summary

If a function with a _Nullable parameter has at least
one caller, the checker behaves as though no other
parameter value is possible. This is because the static
analyzer doesn't re-analyse functions as top level
(with the exception of C++ copy and move operators, and
ObjC methods).

Fixed by modifying shouldSkipFunction to return false.

After this change, Clang-tidy even emits different
warnings for the same line of code, if appropriate:
"Nullable pointer is dereferenced" for a (simulated)
top-level call and "Dereference of null pointer"
for a call to the same function with a known null value.

Diff Detail

Event Timeline

chrisbazley created this revision.Jan 27 2023, 9:06 AM
Herald added a project: Restricted Project. · View Herald Transcript
chrisbazley requested review of this revision.Jan 27 2023, 9:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2023, 9:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This change is admittedly a hack. It might be better to check the function parameter types, or maybe the list of exceptions in this function is now so long that it no longer serves any purpose.