summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-12-03 00:46:16 +0000
committerTed Kremenek <kremenek@apple.com>2009-12-03 00:46:16 +0000
commitf66b72094a9d537a2ec15e6c4d2871b8f58c9aea (patch)
treea25b1c7ac14456971f76b1d307cc4e79c0087c58 /clang/test/Analysis
parent1ed59c63e3ad386ad4b2dca16153ad9e8f4dfa51 (diff)
downloadbcm5719-llvm-f66b72094a9d537a2ec15e6c4d2871b8f58c9aea.tar.gz
bcm5719-llvm-f66b72094a9d537a2ec15e6c4d2871b8f58c9aea.zip
Add a heuristic to the dead stores checker to prune dead stores for variables annotated with '__block'. This is overly conservative, but now the analyzer doesn't report dead stores for variables that can be updated by a block call.
llvm-svn: 90364
Diffstat (limited to 'clang/test/Analysis')
-rw-r--r--clang/test/Analysis/dead-stores.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/Analysis/dead-stores.c b/clang/test/Analysis/dead-stores.c
index ae5e3e36735..7cf8c31cd22 100644
--- a/clang/test/Analysis/dead-stores.c
+++ b/clang/test/Analysis/dead-stores.c
@@ -406,3 +406,24 @@ int f24_D(int y) {
return x;
}
+// This example shows that writing to a variable captured by a block means that it might
+// not be dead.
+int f25(int y) {
+ __block int x = (y > 2);
+ __block int z = 0;
+ void (^foo)() = ^{ z = x + y; };
+ x = 4; // no-warning
+ foo();
+ return z;
+}
+
+// This test is mostly the same as 'f25', but shows that the heuristic of pruning out dead
+// stores for variables that are just marked '__block' is overly conservative.
+int f25_b(int y) {
+ // FIXME: we should eventually report a dead store here.
+ __block int x = (y > 2);
+ __block int z = 0;
+ x = 4; // no-warning
+ return z;
+}
+
OpenPOWER on IntegriCloud