[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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user