From 1655aee1e3572a2fee6914e172a13dd0beadf1a3 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Thu, 3 May 2012 02:13:56 +0000 Subject: [analyzer] Conjure a symbol to ensure we can identify pointer arithmetic We need to identify the value of ptr as ElementRegion (result of pointer arithmetic) in the following code. However, before this commit '(2-x)' evaluated to Unknown value, and as the result, 'p + (2-x)' evaluated to Unknown value as well. int *p = malloc(sizeof(int)); ptr = p + (2-x); llvm-svn: 156052 --- clang/test/Analysis/malloc.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/test/Analysis/malloc.c') diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index 27e34e9039c..9c09051c31b 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -776,6 +776,13 @@ int rdar11269741(struct rdar11269741_b_t o) return p->n.m; // expected-warning {{leak}} } +// Pointer arithmetic, returning an ElementRegion. +void *radar11329382(unsigned bl) { + void *ptr = malloc (16); + ptr = ptr + (2 - bl); + return ptr; // no warning +} + void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__)); int strcmp(const char *, const char *); char *a (void); -- cgit v1.2.1