diff options
author | Adrian Prantl <aprantl@apple.com> | 2016-04-18 23:48:16 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2016-04-18 23:48:16 +0000 |
commit | 2526fca8d891dad669e3a425b84d30bc7aaeb234 (patch) | |
tree | a32bc14b1328346ef49e810790bb799fb4d7e4a0 /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 6dd330504b237046886ea569708a2ab687d44a2c (diff) | |
download | bcm5719-llvm-2526fca8d891dad669e3a425b84d30bc7aaeb234.tar.gz bcm5719-llvm-2526fca8d891dad669e3a425b84d30bc7aaeb234.zip |
[ObjC++] Fix crash when emitting debug info for a block member capturing this.
rdar://problem/23871824
llvm-svn: 266698
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index ae95dd8ed66..0c61496162a 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3262,9 +3262,14 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, // If we have a null capture, this must be the C++ 'this' capture. if (!capture) { - const CXXMethodDecl *method = - cast<CXXMethodDecl>(blockDecl->getNonClosureContext()); - QualType type = method->getThisType(C); + QualType type; + if (auto *Method = + cast_or_null<CXXMethodDecl>(blockDecl->getNonClosureContext())) + type = Method->getThisType(C); + else if (auto *RDecl = dyn_cast<CXXRecordDecl>(blockDecl->getParent())) + type = QualType(RDecl->getTypeForDecl(), 0); + else + llvm_unreachable("unexpected block declcontext"); fields.push_back(createFieldType("this", type, 0, loc, AS_public, offsetInBits, tunit, tunit)); |