[cfe-commits] r75844 - in /cfe/trunk: lib/Analysis/BasicStore.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Wed Jul 15 15:09:48 PDT 2009
Author: kremenek
Date: Wed Jul 15 17:09:25 2009
New Revision: 75844
URL: http://llvm.org/viewvc/llvm-project?rev=75844&view=rev
Log:
Fix <rdar://problem/7062158> by having BasicStoreManager model values for 'static' global variables.
Modified:
cfe/trunk/lib/Analysis/BasicStore.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=75844&r1=75843&r2=75844&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Wed Jul 15 17:09:25 2009
@@ -521,10 +521,6 @@
}
}
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;
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=75844&r1=75843&r2=75844&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Wed Jul 15 17:09:25 2009
@@ -388,3 +388,30 @@
}
}
+// 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
+}
+
More information about the cfe-commits
mailing list