summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/tools/libclang/CIndex.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 80fc7551d7f..0aba04a48c6 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -494,14 +494,25 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
if (clang_isDeclaration(Cursor.kind)) {
Decl *D = getCursorDecl(Cursor);
- assert(D && "Invalid declaration cursor");
+ if (!D)
+ return false;
+
return VisitAttributes(D) || Visit(D);
}
- if (clang_isStatement(Cursor.kind))
- return Visit(getCursorStmt(Cursor));
- if (clang_isExpression(Cursor.kind))
- return Visit(getCursorExpr(Cursor));
+ if (clang_isStatement(Cursor.kind)) {
+ if (Stmt *S = getCursorStmt(Cursor))
+ return Visit(S);
+
+ return false;
+ }
+
+ if (clang_isExpression(Cursor.kind)) {
+ if (Expr *E = getCursorExpr(Cursor))
+ return Visit(E);
+
+ return false;
+ }
if (clang_isTranslationUnit(Cursor.kind)) {
CXTranslationUnit tu = getCursorTU(Cursor);
OpenPOWER on IntegriCloud