[cfe-commits] r89533 - /cfe/trunk/test/Analysis/misc-ps-region-store.m

Ted Kremenek kremenek at apple.com
Fri Nov 20 18:17:47 PST 2009


Author: kremenek
Date: Fri Nov 20 20:17:47 2009
New Revision: 89533

URL: http://llvm.org/viewvc/llvm-project?rev=89533&view=rev
Log:
Add another test case to show the precision of RegionStore over
BasicStore.  In this example, BasicStore would lose information about
the pointer in path after '*path++', causing the analyzer to falsely
flag a null dereference.  This addresses <rdar://problem/7191542>.

Modified:
    cfe/trunk/test/Analysis/misc-ps-region-store.m

Modified: cfe/trunk/test/Analysis/misc-ps-region-store.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.m?rev=89533&r1=89532&r2=89533&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.m Fri Nov 20 20:17:47 2009
@@ -509,3 +509,26 @@
   *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
 }
 
+
+//===----------------------------------------------------------------------===//
+// Test that incrementing a non-null pointer results in a non-null pointer.
+// (<rdar://problem/7191542>)
+//===----------------------------------------------------------------------===//
+
+void test_increment_nonnull_rdar_7191542(const char *path) {
+  const char *alf = 0;
+  
+  for (;;) {
+    // When using basic-store, we get a null dereference here because we lose information
+    // about path after the pointer increment.
+    char c = *path++; // no-warning
+    if (c == 'a') {
+      alf = path;
+    }
+    
+    if (alf)
+      return;
+  }
+}
+
+





More information about the cfe-commits mailing list