diff options
author | Anna Zaks <ganna@apple.com> | 2012-05-03 02:13:56 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-05-03 02:13:56 +0000 |
commit | 1655aee1e3572a2fee6914e172a13dd0beadf1a3 (patch) | |
tree | e8a4708e356e864cbdd069ad343be8612c01a143 /clang/test/Analysis/malloc.c | |
parent | f0e9ca86044d3e674ec7c3a335fea93eb5625c0a (diff) | |
download | bcm5719-llvm-1655aee1e3572a2fee6914e172a13dd0beadf1a3.tar.gz bcm5719-llvm-1655aee1e3572a2fee6914e172a13dd0beadf1a3.zip |
[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
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r-- | clang/test/Analysis/malloc.c | 7 |
1 files changed, 7 insertions, 0 deletions
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); |