aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/malloc.c
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-05-01 21:10:26 +0000
committerAnna Zaks <ganna@apple.com>2012-05-01 21:10:26 +0000
commite2241cbb0455a60ba27d6c4b9d601ffef3ed103f (patch)
tree47272326c9e21833382e29d15cc9b1ba8331762c /test/Analysis/malloc.c
parent4e31b4d6cf25029aa280d691e9023359c0ef4204 (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155944 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/malloc.c')
-rw-r--r--test/Analysis/malloc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c
index 32c6171f8c..1fc874349e 100644
--- a/test/Analysis/malloc.c
+++ b/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.