[analyzer] Wrong type cast occurs during pointer dereferencing after type punning
authorDenys Petrov <dpetrov@accesssoftek.com>
Mon, 26 Apr 2021 16:17:56 +0000 (19:17 +0300)
committerDenys Petrov <dpetrov@accesssoftek.com>
Wed, 28 Apr 2021 22:03:38 +0000 (01:03 +0300)
commitb30521c28a4dc1b94d793385e4144ede5822b2c1
tree4f8167e80e0caf00ec5a1a7794476a195bcda935
parent1886aad9d03b95c35260d6d8013d746bd39dc94a
[analyzer] Wrong type cast occurs during pointer dereferencing after type punning

Summary: During pointer dereferencing CastRetrievedVal uses wrong type from the Store after type punning. Namely, the pointer casts to another type and then assigns with a value of one more another type. It produces NonLoc value when Loc is expected.

Differential Revision: https://reviews.llvm.org/D89055

Fixes:
https://bugs.llvm.org/show_bug.cgi?id=37503
https://bugs.llvm.org/show_bug.cgi?id=49007
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/test/Analysis/casts.c
clang/test/Analysis/string.c