summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-04-14 21:41:34 +0000
committerDouglas Gregor <dgregor@apple.com>2011-04-14 21:41:34 +0000
commit7df212600083983b9dea7b070b018bdc4c7fb213 (patch)
tree0af1408a8de82bdf3bfc67ee7836321573c53ef3 /clang
parent92651ec37497dbc222790846cb756488dccd7852 (diff)
downloadbcm5719-llvm-7df212600083983b9dea7b070b018bdc4c7fb213.tar.gz
bcm5719-llvm-7df212600083983b9dea7b070b018bdc4c7fb213.zip
Harden Clang's cursor visitation logic against NULL declaration,
statement, and expression pointers. While these shouldn't happen, it's better to be safe in libclang. llvm-svn: 129539
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