summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-15 03:13:30 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-15 03:13:30 +0000
commitc4deb923166ca8e63a9943f1e5b304404709e92a (patch)
treec0c1cb2d53275ac0883ffb484095f604499e3e23 /clang/test/Analysis
parent02d6467291e88927afbd9152b71b69c26ca69c59 (diff)
downloadbcm5719-llvm-c4deb923166ca8e63a9943f1e5b304404709e92a.tar.gz
bcm5719-llvm-c4deb923166ca8e63a9943f1e5b304404709e92a.zip
Disallow the use of UnknownVal as the index for ElementRegions. UnknownVals can be used as
the index when the value evaluation isn't powerful enough. By creating ElementRegions with UnknownVals as the index, this gives the false impression that they are the same element, when they really aren't. This becomes really problematic when deriving symbols from these regions (e.g., those representing the initial value of the index), since two different indices will get the same symbol for their binding. This fixes an issue with the idempotent operations checker that would cause two indices that are clearly not the same to make it appear as if they always had the same value. Fixes <rdar://problem/8431728>. llvm-svn: 113920
Diffstat (limited to 'clang/test/Analysis')
-rw-r--r--clang/test/Analysis/idempotent-operations.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/Analysis/idempotent-operations.c b/clang/test/Analysis/idempotent-operations.c
index d88bf49485e..c673f0062f0 100644
--- a/clang/test/Analysis/idempotent-operations.c
+++ b/clang/test/Analysis/idempotent-operations.c
@@ -194,3 +194,33 @@ void false8() {
a = (short)a; // no-warning
test(a);
}
+
+// This test case previously flagged a warning at 'b == c' because the
+// analyzer previously allowed 'UnknownVal' as the index for ElementRegions.
+typedef struct RDar8431728_F {
+ int RDar8431728_A;
+ unsigned char *RDar8431728_B;
+ int RDar8431728_E[6];
+} RDar8431728_D;
+static inline int RDar8431728_C(RDar8431728_D * s, int n,
+ unsigned char **RDar8431728_B_ptr) {
+ int xy, wrap, pred, a, b, c;
+
+ xy = s->RDar8431728_E[n];
+ wrap = s->RDar8431728_A;
+
+ a = s->RDar8431728_B[xy - 1];
+ b = s->RDar8431728_B[xy - 1 - wrap];
+ c = s->RDar8431728_B[xy - wrap];
+
+ if (b == c) { // no-warning
+ pred = a;
+ } else {
+ pred = c;
+ }
+
+ *RDar8431728_B_ptr = &s->RDar8431728_B[xy];
+
+ return pred;
+}
+
OpenPOWER on IntegriCloud