[analyzer] Fix StdLibraryFunctionsChecker NotNull Constraint Check
authorVince Bridgers <vince.a.bridgers@gmail.com>
Sun, 29 Mar 2020 12:48:26 +0000 (07:48 -0500)
committereinvbri <vince.a.bridgers@ericsson.com>
Mon, 30 Mar 2020 19:13:08 +0000 (14:13 -0500)
commitdefd95ef45171252ee8491729d3f3c863bbfe530
treefe16ead7613bed5ac6790422624364509f0593a7
parent3c371491a2d5023060391ff54b924bf1c7a0c41f
[analyzer] Fix StdLibraryFunctionsChecker NotNull Constraint Check

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.

Reviewers: martong, NoQ

Subscribers: xazax.hun, szepet, rnkovacs, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, Charusso, ASDenysPetrov, baloghadamsoftware, dkrupp, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77012
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions.c