[analyzer][StdLibraryFunctionsChecker] Remove strcasecmp
authorGabor Marton <gabor.marton@ericsson.com>
Mon, 7 Sep 2020 14:56:36 +0000 (16:56 +0200)
committerGabor Marton <gabor.marton@ericsson.com>
Thu, 10 Sep 2020 10:29:39 +0000 (12:29 +0200)
commitb7586afc4dcddd1abc70724585c3eb3857e27f43
treed9cd9e1f421a59ab96ad0a4309ca4db973d7ae40
parent1b9884df8d2d855879a8231c7a432ec8b291d8fa
[analyzer][StdLibraryFunctionsChecker] Remove strcasecmp

There are 2 reasons to remove strcasecmp and strncasecmp.
1) They are also modeled in CStringChecker and the related argumentum
   contraints are checked there.
2) The argument constraints are checked in CStringChecker::evalCall.
   This is fundamentally flawed, they should be checked in checkPreCall.
   Even if we set up CStringChecker as a weak dependency for
   StdLibraryFunctionsChecker then the latter reports the warning always.
   Besides, CStringChecker fails to discover the constraint violation
   before the call, so, its evalCall returns with `true` and then
   StdCLibraryFunctions also tries to evaluate, this causes an assertion
   in CheckerManager.

Either we fix CStringChecker to handle the call prerequisites in
checkPreCall, or we must not evaluate any pure functions in
StdCLibraryFunctions that are also handled in CStringChecker.
We do the latter in this patch.

Differential Revision: https://reviews.llvm.org/D87239
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions-POSIX.c
clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c [new file with mode: 0644]