[analyzer] teach AnalysisDeclContext::getSelfDecl() about blocks that capture the 'self' variable of the enclosing ObjC method decl. Fixes <rdar://problem/10380300>.

llvm-svn: 144556
This commit is contained in:
Ted Kremenek
2011-11-14 19:36:08 +00:00
parent 42d098e1b4
commit b39fcfaa19
2 changed files with 22 additions and 0 deletions

View File

@@ -95,6 +95,15 @@ Stmt *AnalysisDeclContext::getBody() const {
const ImplicitParamDecl *AnalysisDeclContext::getSelfDecl() const {
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
return MD->getSelfDecl();
if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
// See if 'self' was captured by the block.
for (BlockDecl::capture_const_iterator it = BD->capture_begin(),
et = BD->capture_end(); it != et; ++it) {
const VarDecl *VD = it->getVariable();
if (VD->getName() == "self")
return dyn_cast<ImplicitParamDecl>(VD);
}
}
return NULL;
}