[analyzer] Handle calling ObjC super method from inside C++ lambda.

When calling a ObjC method on super from inside a C++ lambda, look at the
captures to find "self". This mirrors how the analyzer handles calling super in
an ObjC block and fixes an assertion failure.

rdar://problem/23550077

llvm-svn: 253176
This commit is contained in:
Devin Coughlin
2015-11-15 17:48:22 +00:00
parent 1212626041
commit 1d4058322d
2 changed files with 63 additions and 0 deletions

View File

@@ -148,6 +148,23 @@ const ImplicitParamDecl *AnalysisDeclContext::getSelfDecl() const {
}
}
auto *CXXMethod = dyn_cast<CXXMethodDecl>(D);
if (!CXXMethod)
return nullptr;
const CXXRecordDecl *parent = CXXMethod->getParent();
if (!parent->isLambda())
return nullptr;
for (const LambdaCapture &LC : parent->captures()) {
if (!LC.capturesVariable())
continue;
VarDecl *VD = LC.getCapturedVar();
if (VD->getName() == "self")
return dyn_cast<ImplicitParamDecl>(VD);
}
return nullptr;
}