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 | c177d9faf5ddca16e3962f884f754c6ae4594ed4 (patch) | |
| tree | c96adcb89e66f95b6fa4e8e5125f85f2ceb7f9b8 | |
| parent | a0124055b1be0fa6adce15859c4bb0c2d598bcf7 (diff) | |
| download | bcm5719-llvm-c177d9faf5ddca16e3962f884f754c6ae4594ed4.tar.gz bcm5719-llvm-c177d9faf5ddca16e3962f884f754c6ae4594ed4.zip | |
Fix regression in LiveVariables when reasoning about variables captured by blocks.
llvm-svn: 147116
| -rw-r--r-- | clang/lib/Analysis/LiveVariables.cpp | 9 | ||||
| -rw-r--r-- | clang/test/Analysis/dead-stores.m | 14 |
2 files changed, 17 insertions, 6 deletions
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp index ff6607d51aa..89cf9f8bbb6 100644 --- a/clang/lib/Analysis/LiveVariables.cpp +++ b/clang/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/clang/test/Analysis/dead-stores.m b/clang/test/Analysis/dead-stores.m index 4ed71c4e8bf..d67703feb39 100644 --- a/clang/test/Analysis/dead-stores.m +++ b/clang/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; }(); +} |

