diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-01-25 00:40:30 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-01-25 00:40:30 +0000 |
commit | 2def7eb3ca88354e31919ce71a81069bc65a4fc1 (patch) | |
tree | dd0ed98cf9197539e4f6df386585b7e6a7ae9f39 /clang/tools/CIndex/CXCursor.cpp | |
parent | 3e555fd85fcd591484a7e6afb35470c5223c3c37 (diff) | |
download | bcm5719-llvm-2def7eb3ca88354e31919ce71a81069bc65a4fc1.tar.gz bcm5719-llvm-2def7eb3ca88354e31919ce71a81069bc65a4fc1.zip |
CIndex: Don't crash when visitor passes null child statements, and sprinkle some
asserts in cursor construction functions to make this more obvious.
Doug, please check. c-index-test would previously crash on this code:
--
for(;;) {}
--
Do we need a custom visit of the for statement to cover the variable
declarations?
llvm-svn: 94391
Diffstat (limited to 'clang/tools/CIndex/CXCursor.cpp')
-rw-r--r-- | clang/tools/CIndex/CXCursor.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/tools/CIndex/CXCursor.cpp b/clang/tools/CIndex/CXCursor.cpp index 63d9bc9f2e9..64ff4939469 100644 --- a/clang/tools/CIndex/CXCursor.cpp +++ b/clang/tools/CIndex/CXCursor.cpp @@ -29,6 +29,7 @@ CXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K) { } static CXCursorKind GetCursorKind(Decl *D) { + assert(D && "Invalid arguments!"); switch (D->getKind()) { case Decl::Enum: return CXCursor_EnumDecl; case Decl::EnumConstant: return CXCursor_EnumConstantDecl; @@ -72,11 +73,13 @@ static CXCursorKind GetCursorKind(Decl *D) { } CXCursor cxcursor::MakeCXCursor(Decl *D, ASTUnit *TU) { + assert(D && TU && "Invalid arguments!"); CXCursor C = { GetCursorKind(D), { D, 0, TU } }; return C; } CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, ASTUnit *TU) { + assert(S && TU && "Invalid arguments!"); CXCursorKind K = CXCursor_NotImplemented; switch (S->getStmtClass()) { @@ -214,6 +217,7 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, ASTUnit *TU) { CXCursor cxcursor::MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, SourceLocation Loc, ASTUnit *TU) { + assert(Super && TU && "Invalid arguments!"); void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); CXCursor C = { CXCursor_ObjCSuperClassRef, { Super, RawLoc, TU } }; return C; @@ -230,6 +234,7 @@ cxcursor::getCursorObjCSuperClassRef(CXCursor C) { CXCursor cxcursor::MakeCursorObjCProtocolRef(ObjCProtocolDecl *Super, SourceLocation Loc, ASTUnit *TU) { + assert(Super && TU && "Invalid arguments!"); void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); CXCursor C = { CXCursor_ObjCProtocolRef, { Super, RawLoc, TU } }; return C; @@ -246,6 +251,7 @@ cxcursor::getCursorObjCProtocolRef(CXCursor C) { CXCursor cxcursor::MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc, ASTUnit *TU) { + assert(Class && TU && "Invalid arguments!"); void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); CXCursor C = { CXCursor_ObjCClassRef, { Class, RawLoc, TU } }; return C; @@ -261,6 +267,7 @@ cxcursor::getCursorObjCClassRef(CXCursor C) { CXCursor cxcursor::MakeCursorTypeRef(TypeDecl *Type, SourceLocation Loc, ASTUnit *TU) { + assert(Type && TU && "Invalid arguments!"); void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); CXCursor C = { CXCursor_TypeRef, { Type, RawLoc, TU } }; return C; |