From: Ted Kremenek Date: Sat, 6 Feb 2010 04:04:46 +0000 (+0000) Subject: Also teach RegionStore::RetrieveVar() to handle 'static' pointers that are implicitly... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81861abe9cd1669ca46e13866f77f7ece8c4c85f;p=clang Also teach RegionStore::RetrieveVar() to handle 'static' pointers that are implicitly initialized to NULL. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95479 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index 2e212db3e6..36022d5737 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -1407,7 +1407,9 @@ SVal RegionStoreManager::RetrieveVar(Store store, const VarRegion *R) { if (T->isIntegerType()) return ValMgr.makeIntVal(0, T); - + if (T->isPointerType()) + return ValMgr.makeNull(); + return UnknownVal(); } diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index c1b3d9788b..20eed9cb3d 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -908,3 +908,10 @@ void rdar7582031_test_static_init_zero() { int *p = 0; *p = 0xDEADBEEF; } +void rdar7582031_test_static_init_zero_b() { + static void* x; + if (x == 0) + return; + int *p = 0; + *p = 0xDEADBEEF; +}