diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-15 22:09:25 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-15 22:09:25 +0000 |
commit | fde2efe96e00c5d03e7caaf0c1e67d7b011d9d0c (patch) | |
tree | 98ea76b946ff582d9031c3df6c15980572c13dd8 | |
parent | b3b73642bfb4417d6312725ad6cc8d73ae143aca (diff) |
Fix <rdar://problem/7062158> by having BasicStoreManager model values for 'static' global variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75844 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/BasicStore.cpp | 4 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 27 |
2 files changed, 27 insertions, 4 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index f1f051f244..7aa63c1c63 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -521,10 +521,6 @@ Store BasicStoreManager::getInitialStore() { } } else if (VarDecl* VD = dyn_cast<VarDecl>(ND)) { - // Punt on static variables for now. - if (VD->getStorageClass() == VarDecl::Static) - continue; - // Only handle simple types that we can symbolicate. if (!SymbolManager::canSymbolicate(VD->getType())) continue; diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 93bb1f347c..958576f455 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -388,3 +388,30 @@ void test_trivial_symbolic_comparison(int *x) { } } +// Test for: +// <rdar://problem/7062158> false positive null dereference due to +// BasicStoreManager not tracking *static* globals +// +// This just tests the proper tracking of symbolic values for globals (both +// static and non-static). +// +static int* x_rdar_7062158; +void rdar_7062158() { + int *current = x_rdar_7062158; + if (current == x_rdar_7062158) + return; + + int *p = 0; + *p = 0xDEADBEEF; // no-warning +} + +int* x_rdar_7062158_2; +void rdar_7062158_2() { + int *current = x_rdar_7062158_2; + if (current == x_rdar_7062158_2) + return; + + int *p = 0; + *p = 0xDEADBEEF; // no-warning +} + |