diff options
author | Devin Coughlin <dcoughlin@apple.com> | 2015-11-15 17:48:22 +0000 |
---|---|---|
committer | Devin Coughlin <dcoughlin@apple.com> | 2015-11-15 17:48:22 +0000 |
commit | 1d4058322dfa18210cfb51d9b53139bdbea7c242 (patch) | |
tree | 7e06df9be32fca95ffe9f0b9ee70fb9202633193 /clang/lib/Analysis/AnalysisDeclContext.cpp | |
parent | 121262604158e8ad2fd5958044024246b6d326bb (diff) | |
download | llvm-1d4058322dfa18210cfb51d9b53139bdbea7c242.zip llvm-1d4058322dfa18210cfb51d9b53139bdbea7c242.tar.gz llvm-1d4058322dfa18210cfb51d9b53139bdbea7c242.tar.bz2 |
[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
Diffstat (limited to 'clang/lib/Analysis/AnalysisDeclContext.cpp')
-rw-r--r-- | clang/lib/Analysis/AnalysisDeclContext.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index d7fb7e9..52c7f26 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/lib/Analysis/AnalysisDeclContext.cpp @@ -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; } |