Fix '<rdar://problem/8214263> MakeCXCursor null dereference when body of block is invalid' by checking that the body of a BlockDecl is null before constructing a CXCursor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109097 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 47c6d3c..0a3d54b 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -520,7 +520,10 @@
if (Visit(B->getSignatureAsWritten()->getTypeLoc()))
return true;
- return Visit(MakeCXCursor(B->getBody(), StmtParent, TU));
+ if (Stmt *Body = B->getBody())
+ return Visit(MakeCXCursor(Body, StmtParent, TU));
+
+ return false;
}
bool CursorVisitor::VisitDeclContext(DeclContext *DC) {