aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/AnalysisDeclContext.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-11-14 19:36:08 +0000
committerTed Kremenek <kremenek@apple.com>2011-11-14 19:36:08 +0000
commitccf1bfde160c03c677ba530c9dcb77365a9c2d7b (patch)
tree0a0249f4ad9dbf22ba732bb99af7c57f615a63a6 /lib/Analysis/AnalysisDeclContext.cpp
parentbf97947c4c467e72b97f8623f84c9bccb03e9448 (diff)
[analyzer] teach AnalysisDeclContext::getSelfDecl() about blocks that capture the 'self' variable of the enclosing ObjC method decl. Fixes <rdar://problem/10380300>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144556 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AnalysisDeclContext.cpp')
-rw-r--r--lib/Analysis/AnalysisDeclContext.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Analysis/AnalysisDeclContext.cpp b/lib/Analysis/AnalysisDeclContext.cpp
index 680f2c4050..546cf98f68 100644
--- a/lib/Analysis/AnalysisDeclContext.cpp
+++ b/lib/Analysis/AnalysisDeclContext.cpp
@@ -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;
}