]> granicus.if.org Git - clang/commitdiff
Add another test case to show the precision of RegionStore over
authorTed Kremenek <kremenek@apple.com>
Sat, 21 Nov 2009 02:17:47 +0000 (02:17 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 21 Nov 2009 02:17:47 +0000 (02:17 +0000)
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>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89533 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/misc-ps-region-store.m

index 23199b636146c0a60e9d5f86b3c6fce4d96a2735..fe45823fe402673f396eac4d75be9340e9621054 100644 (file)
@@ -509,3 +509,26 @@ void rdar7403269_b_pos() {
   *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;
+  }
+}
+
+