diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-11-14 19:36:08 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-11-14 19:36:08 +0000 |
commit | b39fcfaa1996736dfefe5434dc1691880011d79e (patch) | |
tree | 0bc82e7b2a9439efc854ddd4e59cbd134ff1e256 /clang/lib/Analysis/AnalysisDeclContext.cpp | |
parent | 42d098e1b4d2aabe72fcba1406f89fd6a401d392 (diff) | |
download | llvm-b39fcfaa1996736dfefe5434dc1691880011d79e.zip llvm-b39fcfaa1996736dfefe5434dc1691880011d79e.tar.gz llvm-b39fcfaa1996736dfefe5434dc1691880011d79e.tar.bz2 |
[analyzer] teach AnalysisDeclContext::getSelfDecl() about blocks that capture the 'self' variable of the enclosing ObjC method decl. Fixes <rdar://problem/10380300>.
llvm-svn: 144556
Diffstat (limited to 'clang/lib/Analysis/AnalysisDeclContext.cpp')
-rw-r--r-- | clang/lib/Analysis/AnalysisDeclContext.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index 680f2c4..546cf98 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/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; } |