[analyzer] Only attempt to get the value of locations of known type
Fixes https://bugs.llvm.org/show_bug.cgi?id=36474 In general, getSVal API should be changed so that it does not crash on some non-obvious conditions. It should either be updated to require a type, or to return Optional<SVal>. Differential Revision: https://reviews.llvm.org/D43801 llvm-svn: 326233
This commit is contained in:
parent
fc0d02cbbf
commit
53c1c10beb
|
@ -73,9 +73,9 @@ void NonnullGlobalConstantsChecker::checkLocation(SVal location, bool isLoad,
|
|||
return;
|
||||
|
||||
ProgramStateRef State = C.getState();
|
||||
SVal V = State->getSVal(location.castAs<Loc>());
|
||||
|
||||
if (isGlobalConstString(location)) {
|
||||
SVal V = State->getSVal(location.castAs<Loc>());
|
||||
Optional<DefinedOrUnknownSVal> Constr = V.getAs<DefinedOrUnknownSVal>();
|
||||
|
||||
if (Constr) {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// RUN: %clang_analyze_cc1 -analyzer-checker=core %s
|
||||
a;
|
||||
b(void **c) { // no-crash
|
||||
*c = a;
|
||||
int *d;
|
||||
b(&d);
|
||||
*d;
|
||||
}
|
Loading…
Reference in New Issue