[libclang] Indexing API: Fix issues, mostly C++ related.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145107 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp
index 777dea1..0970054 100644
--- a/tools/libclang/IndexDecl.cpp
+++ b/tools/libclang/IndexDecl.cpp
@@ -109,6 +109,9 @@
 
   bool VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
     const ObjCInterfaceDecl *Class = D->getClassInterface();
+    if (!Class)
+      return true;
+
     if (Class->isImplicitInterfaceDecl())
       IndexCtx.handleObjCInterface(Class);
 
@@ -128,7 +131,8 @@
   }
 
   bool VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
-    if (D->getCategoryDecl()->getLocation().isInvalid())
+    const ObjCCategoryDecl *Cat = D->getCategoryDecl();
+    if (!Cat)
       return true;
 
     IndexCtx.handleObjCCategoryImpl(D);