]> granicus.if.org Git - clang/commitdiff
Fix regression in LiveVariables when reasoning about variables captured by blocks.
authorTed Kremenek <kremenek@apple.com>
Thu, 22 Dec 2011 00:46:32 +0000 (00:46 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 22 Dec 2011 00:46:32 +0000 (00:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147116 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LiveVariables.cpp
test/Analysis/dead-stores.m

index ff6607d51aa94469bb3f2104a869900f5cd642bf..89cf9f8bbb622f867acf1e5870bbf0b2706bced7 100644 (file)
@@ -354,11 +354,10 @@ void TransferFunctions::VisitBinaryOperator(BinaryOperator *B) {
 }
 
 void TransferFunctions::VisitBlockExpr(BlockExpr *BE) {
-  AnalysisDeclContext::referenced_decls_iterator I, E;
-  llvm::tie(I, E) =
-    LV.analysisContext.getReferencedBlockVars(BE->getBlockDecl());
-  for ( ; I != E ; ++I) {
-    const VarDecl *VD = *I;
+  const BlockDecl *BD = BE->getBlockDecl();
+  for (BlockDecl::capture_const_iterator it = BD->capture_begin(),
+       ei = BD->capture_end(); it != ei; ++it) {
+    const VarDecl *VD = it->getVariable();
     if (isAlwaysAlive(VD))
       continue;
     val.liveDecls = LV.DSetFact.add(val.liveDecls, VD);
index 4ed71c4e8bfa72129b72ee6d1017fe5995eaaa3c..d67703feb39aeb7e444510f103fddce066c53c18 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify %s
 
 typedef signed char BOOL;
 typedef unsigned int NSUInteger;
@@ -76,3 +76,15 @@ void foo_rdar8527823();
 }
 @end
 
+// Don't flag dead stores when a variable is captured in a block used
+// by a property access.
+@interface RDar10591355
+@property (assign) int x;
+@end
+
+RDar10591355 *rdar10591355_aux();
+
+void rdar10591355() {
+  RDar10591355 *p = rdar10591355_aux();
+  ^{ (void) p.x; }();
+}