Minor pass-sensitivity improvement:
if we know that 'len != 0' and know that 'i == 0' then we know that
'i < len' must evaluate to true and cannot evaluate to false
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56260 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c
index 06f67da..a6819cc 100644
--- a/test/Analysis/null-deref-ps.c
+++ b/test/Analysis/null-deref-ps.c
@@ -1,6 +1,7 @@
// RUN: clang -checker-simple -verify %s
#include<stdint.h>
+#include <assert.h>
void f1(int *p) {
if (p) *p = 1;
@@ -87,3 +88,15 @@
if (!q)
*q = 1; // no-warning
}
+
+int* qux();
+
+int f9(int len) {
+ assert (len != 0);
+ int *p = 0;
+
+ for (int i = 0; i < len; ++i)
+ p = foo(i);
+
+ return *p++; // no-warning
+}