diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-12-22 00:46:32 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-12-22 00:46:32 +0000 |
commit | 280cf1451b4f02093e47ce956a0688407aa595b9 (patch) | |
tree | 0fc66979a7c80fde7cd577d10e2285136cc3b08c | |
parent | dedb362adc4b0f51a0f30399791360017bbacd59 (diff) |
Fix regression in LiveVariables when reasoning about variables captured by blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147116 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/LiveVariables.cpp | 9 | ||||
-rw-r--r-- | test/Analysis/dead-stores.m | 14 |
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index ff6607d51a..89cf9f8bbb 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -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); diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m index 4ed71c4e8b..d67703feb3 100644 --- a/test/Analysis/dead-stores.m +++ b/test/Analysis/dead-stores.m @@ -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; }(); +} |