[cfe-commits] Review: fix failing test

Ben Laurie benl at google.com
Mon Feb 16 11:15:20 PST 2009


This fixes a currently failing test by using the
RangeConstraintManager. The two tests failing are:

int f9(unsigned len) {
  assert (len != 0);
  int *p = 0;
  unsigned i;

  for (i = 0; i < len; ++i)
   p = qux(i);

  return *p++; // no-warning
}

int f9b(unsigned len) {
  assert (len > 0);  // note use of '>'
  int *p = 0;
  unsigned i;

  for (i = 0; i < len; ++i)
   p = qux(i);

  return *p++; // no-warning
}

which produce:

Warnings seen but not expected:
  Line 139: Dereference of null pointer.
  Line 150: Dereference of null pointer.

Index: test/Analysis/null-deref-ps.c
===================================================================
--- test/Analysis/null-deref-ps.c       (revision 64627)
+++ test/Analysis/null-deref-ps.c       (working copy)
@@ -1,6 +1,6 @@
-// RUN: clang -analyze -std=gnu99 -checker-simple -verify %s &&
-// RUN: clang -analyze -std=gnu99 -checker-simple
-analyzer-store-region -analyzer-purge-dead=false -verify %s &&
-// RUN: clang -analyze -std=gnu99 -checker-cfref
-analyzer-store-region -verify %s
+// RUN: clang -analyze -analyzer-range-constraints -std=gnu99
-checker-simple -verify %s &&
+// RUN: clang -analyze -analyzer-range-constraints -std=gnu99
-checker-simple -analyzer-store-region -analyzer-purge-dead=false
-verify %s &&
+// RUN: clang -analyze -analyzer-range-constraints -std=gnu99
-checker-cfref -analyzer-store-region -verify %s

 #include<stdint.h>
 #include <assert.h>



More information about the cfe-commits mailing list