diff options
author | Anna Zaks <ganna@apple.com> | 2012-05-01 21:10:26 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-05-01 21:10:26 +0000 |
commit | b35437a85e39964bb05f5f4cbc47f8349a0bdc1a (patch) | |
tree | 7bf5a893cf9b6668c7e923c99f794c232491347f /clang/test/Analysis/malloc.c | |
parent | a01ff786ed48ebc310615caa7ad6ea6d216f0552 (diff) | |
download | bcm5719-llvm-b35437a85e39964bb05f5f4cbc47f8349a0bdc1a.tar.gz bcm5719-llvm-b35437a85e39964bb05f5f4cbc47f8349a0bdc1a.zip |
[analyzer] Construct a SymExpr even when the constraint solver cannot
reason about the expression.
This essentially keeps more history about how symbolic values were
constructed. As an optimization, previous to this commit, we only kept
the history if one of the symbols was tainted, but it's valuable keep
the history around for other purposes as well: it allows us to avoid
constructing conjured symbols.
Specifically, 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);
This change brings 2% slowdown on sqlite. Fixes radar://11329382.
llvm-svn: 155944
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 32c6171f8c4..1fc874349e6 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 +} + // ---------------------------------------------------------------------------- // Below are the known false positives. |