This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix StdLibraryFunctionsChecker NotNull Constraint Check
ClosedPublic

Authored by vabridgers on Mar 29 2020, 6:01 AM.

Details

Summary

This check was causing a crash in a test case where the 0th argument was
uninitialized ('Assertion `T::isKind(*this)' at line SVals.h:104). This
was happening since the argument was actually undefined, but the castAs
assumes the value is DefinedOrUnknownSVal.

The fix appears to be simply to check for an undefined value and skip
the check allowing the uninitalized value checker to detect the error.

I included a test case that I verified to produce the negative case
prior to the fix, and passes with the fix.

Diff Detail

Event Timeline

vabridgers created this revision.Mar 29 2020, 6:01 AM
NoQ accepted this revision.Mar 29 2020, 7:31 AM
NoQ added a reviewer: Szelethus.

Thanks!

@Szelethus can we make this checker depend on undefined value checker (probably CallAndMessage) so that uninitialized arguments were handled first? In fact, can we make a silent assumption that everything depends on core? If so we could eliminate all checks for undefined values in PreStmt and PreCall.

This revision is now accepted and ready to land.Mar 29 2020, 7:31 AM

fix pre-merge lint checks

fix pre-merge lint checks

Ka-Ka added a subscriber: Ka-Ka.Mar 30 2020, 1:43 AM
martong accepted this revision.Mar 30 2020, 2:39 AM

LGTM and thanks!

In D77012#1948550, @NoQ wrote:

Thanks!

@Szelethus can we make this checker depend on undefined value checker (probably CallAndMessage) so that uninitialized arguments were handled first? In fact, can we make a silent assumption that everything depends on core? If so we could eliminate all checks for undefined values in PreStmt and PreCall.

+1, we should really do that.

In D77012#1948550, @NoQ wrote:

@Szelethus can we make this checker depend on undefined value checker (probably CallAndMessage) so that uninitialized arguments were handled first?

I'll drop some pointers to previous discussions: D67336#1928925, D69662#1891124. I took a look, the evaluation order indeed depends on the order of registration, and the order of registration can be controlled with checker dependencies.

In fact, can we make a silent assumption that everything depends on core? If so we could eliminate all checks for undefined values in PreStmt and PreCall.

I wouldn't be comfortable doing that before we can separate the modeling portions from the diagnostics.

[cfe-dev] [analyzer][RFC] Our stance on checker dependencies and disabling core checkers: http://lists.llvm.org/pipermail/cfe-dev/2019-August/063070.html

Szelethus accepted this revision.Mar 30 2020, 7:19 AM

Oh, yea, LGTM! Thanks!

This revision was automatically updated to reflect the committed changes.