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
This commit is contained in:
Ted Kremenek 2011-12-22 00:46:32 +00:00
Родитель dedb362adc
Коммит 280cf1451b
2 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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; }();
}