Make the CIndex API more resilient to being used on invalid code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98981 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 7d1033d..ab6b9e1 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -743,7 +743,10 @@
 }
 
 ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const {
-  return getClassInterface()->FindCategoryDeclaration(getIdentifier());
+  // The class interface might be NULL if we are working with invalid code.
+  if (const ObjCInterfaceDecl *ID = getClassInterface())
+    return ID->FindCategoryDeclaration(getIdentifier());
+  return 0;
 }