summaryrefslogtreecommitdiffstats
path: root/clang/tools/CIndex/CXCursor.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-03-19 20:39:03 +0000
committerTed Kremenek <kremenek@apple.com>2010-03-19 20:39:03 +0000
commite184ac5a660c800d960c7a19935a64103ba276f0 (patch)
tree96da5ea0ec9def23455486941bff313af061b52b /clang/tools/CIndex/CXCursor.cpp
parentcf0843ed93d7b83c97e3e5b20ee06c638e138bb6 (diff)
downloadbcm5719-llvm-e184ac5a660c800d960c7a19935a64103ba276f0.tar.gz
bcm5719-llvm-e184ac5a660c800d960c7a19935a64103ba276f0.zip
Make the CIndex API more resilient to being used on invalid code.
llvm-svn: 98981
Diffstat (limited to 'clang/tools/CIndex/CXCursor.cpp')
-rw-r--r--clang/tools/CIndex/CXCursor.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/tools/CIndex/CXCursor.cpp b/clang/tools/CIndex/CXCursor.cpp
index 407f44c70a0..cbf9d7e6f91 100644
--- a/clang/tools/CIndex/CXCursor.cpp
+++ b/clang/tools/CIndex/CXCursor.cpp
@@ -266,7 +266,10 @@ cxcursor::getCursorObjCProtocolRef(CXCursor C) {
CXCursor cxcursor::MakeCursorObjCClassRef(ObjCInterfaceDecl *Class,
SourceLocation Loc,
ASTUnit *TU) {
- assert(Class && TU && "Invalid arguments!");
+ // 'Class' can be null for invalid code.
+ if (!Class)
+ return MakeCXCursorInvalid(CXCursor_InvalidCode);
+ assert(TU && "Invalid arguments!");
void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
CXCursor C = { CXCursor_ObjCClassRef, { Class, RawLoc, TU } };
return C;
OpenPOWER on IntegriCloud