aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/idempotent-operations.c
diff options
context:
space:
mode:
authorTom Care <tom.care@uqconnect.edu.au>2010-08-25 22:37:26 +0000
committerTom Care <tom.care@uqconnect.edu.au>2010-08-25 22:37:26 +0000
commit967fea6cd9ae60ea31d27d440967990d2c705729 (patch)
tree60d20c9e93acad9d02a784a008c02a00b9d12a35 /test/Analysis/idempotent-operations.c
parent141a4d43114dcc52653e192df6c4ec43c6f8dfec (diff)
Improved the handling of blocks and block variables in PseudoConstantAnalysis
- Removed the assumption that __block vars are all non-constant - Simplified some repetitive code in RunAnalysis - Added block walking support - Code/comments cleanup - Separated out test for block pseudoconstants git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/idempotent-operations.c')
-rw-r--r--test/Analysis/idempotent-operations.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/test/Analysis/idempotent-operations.c b/test/Analysis/idempotent-operations.c
index a730d03127..09df6dece0 100644
--- a/test/Analysis/idempotent-operations.c
+++ b/test/Analysis/idempotent-operations.c
@@ -112,18 +112,34 @@ unsigned false4() {
int c = 42;
test(height * c); // no-warning
- // Pseudo-constant (blockvar)
- __block int a = 0;
- int b = 10;
- a *= b; // no-warning
- test(a);
-
// Pseudo-constant (never changes after decl)
int width = height;
return width * 10; // no-warning
}
+// Block pseudoconstants
+void false4a() {
+ // Pseudo-constant
+ __block int a = 1;
+ int b = 10;
+ __block int c = 0;
+ b *= a; // no-warning
+
+ ^{
+ // Psuedoconstant block var
+ test(b * c); // no-warning
+
+ // Non-pseudoconstant block var
+ int d = 0;
+ test(b * d); // expected-warning{{The right operand to '*' is always 0}}
+ d = 5;
+ test(d);
+ }();
+
+ test(a + b);
+}
+
// Static vars are common false positives
int false5() {
static int test = 0;